mozilla-spidermonkey / jsparagus

Experimental JS parser-generator project.
Other
447 stars 20 forks source link

Create FunctionStencil in scope pass and emit lazy function (fixes #535) #540

Closed arai-a closed 4 years ago

arai-a commented 4 years ago

This modifies the scope pass to build FunctionStencil, for all functions. FunctionStencil built by this contains the following information, with tree structure:

Given that the scope pass is going to be merged to the first (parse) pass, this part also uses callback style for each position/node. So, even if AST parameter contains all information, it doesn't use the info until visiting the node. (for example, source location is partially initialized when entering a function, and remaining part is intialized when leaving the function)

Currently, the plan is to support all functions as lazy, so this builds lazy function stencil for all functions. (when we support non-lazy function, some calculation will become redundant)

Emitter is also modified to emit lazy function, but it's disabled, given closed over bindings isn't supported yet.