-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vm): Reimplement FunctionDeclarationInstantiation as part of fun…
…ction compilation FunctionDeclarationInstantiation is an abstract operation in the spec which runs at the start of a function call and sets up the parameters, lexical environments and variables for the function. Until now, we implemented it as a Rust function called before the function body was executed. Since this operation is not implemented using bytecode, and it binds the function arguments, it couldn't support complex bindings (such as default values or object/array bindings) without reimplementing them. This patch therefore instead implements this operation as bytecode instructions emitted before the function body. That way the binding of arguments can be compiled into a regular array binding pattern. Doing this requires some way to pass the arguments into the VM, and have them stored in its state until they are evaluated. We do this by having `Vm::execute` take an optional arguments slice, which it stores on the iterator stack. For generators, currently FunctionDeclarationInstantiation happens when the generator function is called, and this patch moves it to when the generator object is first resumed, which is correct. However, this means that the arguments must be stored until that first time the generator is resumed. To do this, the `Option<Vm>` field in `GeneratorState::Suspended` is made into an enum which can store either a `Vm` or a boxed slice of arguments.
- Loading branch information
1 parent
f9aeadf
commit b94dc2e
Showing
13 changed files
with
713 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.