Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement block scoped variable declarations #173

Merged
merged 3 commits into from
Oct 22, 2019
Merged

Implement block scoped variable declarations #173

merged 3 commits into from
Oct 22, 2019

Commits on Oct 20, 2019

  1. 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
    barskern committed Oct 20, 2019
    Configuration menu
    Copy the full SHA
    826d094 View commit details
    Browse the repository at this point in the history
  2. 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.
    barskern committed Oct 20, 2019
    Configuration menu
    Copy the full SHA
    efe5796 View commit details
    Browse the repository at this point in the history
  3. 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.
    barskern committed Oct 20, 2019
    Configuration menu
    Copy the full SHA
    0021a15 View commit details
    Browse the repository at this point in the history