mozilla-spidermonkey / jsparagus

Experimental JS parser-generator project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Annex B.3.3

arai-a opened this issue · comments

https://tc39.es/ecma262/#sec-block-level-function-declarations-web-legacy-compatibility-semantics

To achieve this:

  • when visiting a function inside a block
    • mark the as possibly-annex
  • when leaving a scope
    • propagate the list of possibly-annex functions to enclosing scope
      • currently, at this point, the function is converted into an element of LexicalScopeData.base.bindings
      • the list should contain:
        • ScopeIndex for the scope
        • the index of the function in BaseScopeData.bindings
        • FunctionStencilIndex for the function
        • map from SourceAtomSetIndex to function
      • => HashMap<SourceAtomSetIndex, Vec<(ScopeIndex, usize, FunctionStencilIndex)>> ?
  • when leaving a scope that can conflict with var
    • if there's any conflicting declarations, remove the function from the list of possibly-annex functions
  • when leaving a var scope
    • makr all possibly-annex functions annex
      • this needs modification to elements in LexicalScopeData.base.bindings
      • also, modify FunctionStencil for those functions, to mark annex
      • append the function to GlobalScopeData.functions

At the same time, it would be better to stop using AssociatedDataKey, but use FunctionStencilIndex instead, to identify functions.

wait, I guess I was using "hoisted" in wrong meaning here