-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Until now, we kept mixin and method scopes separately, which does not directly represent the lexical structure and can cause confusion. With this change, scope is managed as a single chain outwards, with methods and mixins on the same chain. This change applies to LexicalScope classes as well as to the Builder classes. - add ScopeBuilder superclass for MixinBuilder and MethodBuilder - correctly determine whether scopes are immutable also for methods - added Local.isMutable() - InliningVisitor, handle case that there are no variables Signed-off-by: Stefan Marr <[email protected]>
- Loading branch information
Showing
11 changed files
with
359 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package som.compiler; | ||
|
||
import som.compiler.Variable.Internal; | ||
import som.compiler.Variable.Local; | ||
import som.interpreter.LexicalScope; | ||
import som.vmobjects.SSymbol; | ||
|
||
|
||
/** | ||
* The super class of {@link MixinBuilder} and {@link MethodBuilder}. | ||
* It manages scope information; | ||
*/ | ||
public abstract class ScopeBuilder<LS extends LexicalScope> { | ||
protected final ScopeBuilder<? extends LexicalScope> outer; | ||
|
||
protected final LS scope; | ||
|
||
protected ScopeBuilder(final ScopeBuilder<?> outer, final LexicalScope outerScope) { | ||
this.outer = outer; | ||
this.scope = createScope(outerScope); | ||
} | ||
|
||
public final ScopeBuilder<?> getOuter() { | ||
return outer; | ||
} | ||
|
||
public LS getScope() { | ||
return scope; | ||
} | ||
|
||
protected abstract LS createScope(LexicalScope outer); | ||
|
||
public abstract MixinBuilder getMixin(); | ||
|
||
public abstract MethodBuilder getMethod(); | ||
|
||
protected abstract int getContextLevel(SSymbol varName); | ||
|
||
protected abstract Local getLocal(SSymbol varName); | ||
|
||
protected abstract Variable getVariable(SSymbol varName); | ||
|
||
protected abstract boolean hasArgument(SSymbol varName); | ||
|
||
public abstract Internal getFrameOnStackMarkerVar(); | ||
|
||
protected abstract boolean isImmutable(); | ||
|
||
public abstract String getName(); | ||
} |
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.