Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor AST inlining and use Variable objects #80

Merged
merged 9 commits into from
Dec 26, 2016

Conversation

smarr
Copy link
Owner

@smarr smarr commented Dec 26, 2016

The goal of this change is to make the AST inlining more maintainable and
less complex. Furthermore, we want the Variable objects to encode more
information for debugging purposes.

Currently, AST inlining is essentially encoded in the inliners,
which operate on demand and add variable slots lazily.

With this rewrite, AST splitting and inlining is done based on the
tree of scopes. Thus, the correct construction of frame slots and
variable objects is localized in one place. And, it is done eagerly
based on upfront knowledge, so that bugs hopefully aren’t hidden,
which they were by the on-demand approach.

Thus, first, we construct the MethodScope tree now, keep all relevant info about variables there, and adapt it when inlining/splitting first, before making a pass over the AST. The pass over the AST uses a visitor that just looks up the new info in the scope tree.

  • populate lexical scopes eagerly with embedded info
    needed for the inlining at parse time, because we need the info directly
    once the parsing of the embedded scope is completed.
  • variables are now equal if they refer to the same lexical entity
  • when correcting ASTs after inlining/splitting, lookup variables in
    scope tree
  • make sure scope tree updates embedded methods, need to be split, and
    inlined methods/blocks need to be removed

The goal of this change is to make the AST inlining more maintainable and
less complex. Furthermore, we want the Variable objects to encode more
information for debugging purposes.

Currently, AST inlining is essentially encoded in the inliners,
which operate on demand and add variable slots lazily.

With this rewrite, AST splitting and inlining is done based on the
tree of scopes. Thus, the correct construction of frame slots and
variable objects in localized in one place. And, it is done eagerly
based on upfront knowledge, so that bugs hopefully aren’t hidden,
which they were by the on-demand approach.

- moved visitor into inlining package
- populate lexical scopes eagerly with embedded info
  needed for the inlining at parse time, because we need the info directly
  once the parsing of the embedded scope is completed.
- variables are now equal if they refer to the same lexical entity
- when correcting ASTs after inlining/splitting, lookup variables in
  scope tree
- make sure scope tree updates embedded methods, need to be split, and
  inlined methods/blocks need to be removed

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Not sure what the purpose here was but this seems just to be incorrect. How could we allow these non-failing incorrect additions? Addition should only be done on declaration.

Unclear, are there any bugs going to be popping up because of this?

Signed-off-by: Stefan Marr <git@stefan-marr.de>
- initializer setVars needs to happen after primary factory method
  arguments were added
- make sure method is set after splitting scope

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Does not have a real purpose anymore.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
This test is outdated, because it isn’t used by VS code debugger. Should adapt Kompos to use the new infrastructure, too.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr added the enhancement Improves the implementation with something noteworthy label Dec 26, 2016
@smarr smarr self-assigned this Dec 26, 2016
@coveralls
Copy link

Coverage Status

Coverage remained the same at 77.616% when pulling fa9f257 on inlining-and-var-handling into 4395919 on master.

- minimize duplicated code
  - use helpers to update variables
  - refactor code to handle adaptation and spliting in Method

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr force-pushed the inlining-and-var-handling branch from fa9f257 to b71ca3e Compare December 26, 2016 11:58
@smarr smarr merged commit 2dd90ae into master Dec 26, 2016
@smarr smarr deleted the inlining-and-var-handling branch December 26, 2016 11:59
@coveralls
Copy link

Coverage Status

Coverage remained the same at 77.616% when pulling b71ca3e on inlining-and-var-handling into 4395919 on master.

smarr added a commit that referenced this pull request Jan 18, 2017
Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr added this to the v0.2.0 milestone Mar 6, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Improves the implementation with something noteworthy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants