-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement block scoped variable declarations (#173)
* Implement block scoped variable declarations `const` and `let` are now scoped to the block, while `var` is scoped to the surronding function (or global). Another bigger change is that all tests have been changed to use `var` instead of `let` or `const`. This is because every time `forward` is called with some new Javascript to evaluate, we parse it as a block, hence variables can only persist across calls to `forward` if they are defined using `var`. I assume it is intentional to parse each call as a separate block, because a block is the only `ExprDef` which can contain multiple statements. Closes #39 * Prefer environment parent over environment_stack Instead of iterating over the `environment_stack` we rather use `get_outer_environment` as it will be a better fit when asyncronous functions are implemented. * Ensure variable from outer scope is assigned Variables that are defined outside a block should be changeable within the scope. Just because variable is undefined does not mean it is not initialized.
- Loading branch information
1 parent
0dca535
commit ffcc9ad
Showing
8 changed files
with
259 additions
and
121 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
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.