Skip to content
Snippets Groups Projects
Commit 1c56c33e authored by Johannes Mey's avatar Johannes Mey
Browse files

rename ScopeTree to RootScope, this fixes #1

parent b96ebc28
No related branches found
No related tags found
No related merge requests found
ScopeTree : Scope; RootScope : Scope;
abstract Element; abstract Element;
Declaration:Element ::= <Name:String>; Declaration:Element ::= <Name:String>;
Scope:Element ::= Element*; Scope:Element ::= Element*;
......
aspect Shadowing { aspect Shadowing {
coll Set<AbstractFinding> ScopeTree.variableShadowings() [new HashSet<>()] with add root ScopeTree; coll Set<AbstractFinding> RootScope.variableShadowings() [new HashSet<>()] with add root RootScope;
Declaration contributes new VariableShadowFinding(shadowed(), this) when isShadowing() to ScopeTree.variableShadowings(); Declaration contributes new VariableShadowFinding(shadowed(), this) when isShadowing() to RootScope.variableShadowings();
Declaration contributes new MultipleDeclarationFinding(this) when isShadowingInSameScope() to ScopeTree.variableShadowings(); Declaration contributes new MultipleDeclarationFinding(this) when isShadowingInSameScope() to RootScope.variableShadowings();
syn Declaration Declaration.shadowed()= shadowed(asDeclaration()); syn Declaration Declaration.shadowed()= shadowed(asDeclaration());
...@@ -25,7 +25,7 @@ aspect Shadowing { ...@@ -25,7 +25,7 @@ aspect Shadowing {
} }
} }
} }
return (this instanceof ScopeTree) ? null : shadowed(shadower); return (this instanceof RootScope) ? null : shadowed(shadower);
} }
inh Declaration Declaration.shadowedInSameScope(); inh Declaration Declaration.shadowedInSameScope();
...@@ -43,7 +43,7 @@ aspect Shadowing { ...@@ -43,7 +43,7 @@ aspect Shadowing {
syn boolean Declaration.isShadowingInSameScope() = shadowedInSameScope() != null; syn boolean Declaration.isShadowingInSameScope() = shadowedInSameScope() != null;
syn boolean Scope.isSuperScopeOf(Scope subScope) = (this==subScope) || isSuperScopeInh(subScope); syn boolean Scope.isSuperScopeOf(Scope subScope) = (this==subScope) || isSuperScopeInh(subScope);
eq ScopeTree.isSuperScopeOf(Scope subScope) = this==subScope; eq RootScope.isSuperScopeOf(Scope subScope) = this==subScope;
inh boolean Scope.isSuperScopeInh(Scope subScope); inh boolean Scope.isSuperScopeInh(Scope subScope);
eq Scope.getElement().isSuperScopeInh(Scope subScope) = isSuperScopeOf(subScope); eq Scope.getElement().isSuperScopeInh(Scope subScope) = isSuperScopeOf(subScope);
......
aspect ProgramToScopeTree { aspect ProgramToScopeTree {
/** a relational nta collection attribute to compute the scope tree */ /** a relational nta collection attribute to compute the scope tree */
syn lazy ScopeTree Program.scopeTree() { syn lazy RootScope Program.scopeTree() {
ScopeTree tree = asScopeTree(); RootScope tree = asRootScope();
// add all classes // add all classes
for (CompilationUnit cu : getCompilationUnitList()) { for (CompilationUnit cu : getCompilationUnitList()) {
...@@ -73,8 +73,8 @@ aspect ProgramToScopeTree { ...@@ -73,8 +73,8 @@ aspect ProgramToScopeTree {
*/ */
aspect ScopeTreeConstructors { aspect ScopeTreeConstructors {
syn lazy ScopeTree Program.asScopeTree() { syn lazy RootScope Program.asRootScope() {
ScopeTree tree = new ScopeTree(); RootScope tree = new RootScope();
tree.setProgram(this); tree.setProgram(this);
return tree; return tree;
} }
......
// glue relation for the Java-based variable shadowing analysis // glue relation for the Java-based variable shadowing analysis
rel ScopeTree.Program -> Program; rel RootScope.Program -> Program;
abstract JavaScope : Scope; abstract JavaScope : Scope;
abstract TypeDeclScope : JavaScope; abstract TypeDeclScope : JavaScope;
......
...@@ -76,7 +76,7 @@ public class ScopeAnalysis extends Frontend { ...@@ -76,7 +76,7 @@ public class ScopeAnalysis extends Frontend {
// measure the time (without parsing) from here // measure the time (without parsing) from here
long startGenerationTime = System.nanoTime(); long startGenerationTime = System.nanoTime();
ScopeTree scopeTree = program.scopeTree(); RootScope scopeTree = program.scopeTree();
DrAST_root_node = scopeTree; DrAST_root_node = scopeTree;
long startAnalysisTime = System.nanoTime(); long startAnalysisTime = System.nanoTime();
...@@ -118,7 +118,7 @@ public class ScopeAnalysis extends Frontend { ...@@ -118,7 +118,7 @@ public class ScopeAnalysis extends Frontend {
program = readProgram(files); program = readProgram(files);
ScopeTree scopeTree = program.scopeTree(); RootScope scopeTree = program.scopeTree();
if (tree) { if (tree) {
scopeTree.printAST(); scopeTree.printAST();
......
aspect ModelicaToScopeTree { aspect ModelicaToScopeTree {
/** a relational nta attribute to compute the scope tree */ /** a relational nta attribute to compute the scope tree */
syn lazy ScopeTree SourceRoot.scopeTree() { syn lazy RootScope SourceRoot.scopeTree() {
ScopeTree tree = (ScopeTree) scope(); RootScope tree = (RootScope) scope();
// add all top-level classes // add all top-level classes
for (SrcClassDecl classDecl : topLevelClasses()) { for (SrcClassDecl classDecl : topLevelClasses()) {
...@@ -53,8 +53,8 @@ aspect ModelicaToScopeTree { ...@@ -53,8 +53,8 @@ aspect ModelicaToScopeTree {
*/ */
aspect ScopeTreeConstructors { aspect ScopeTreeConstructors {
syn lazy ScopeTree SourceRoot.asScope() { syn lazy RootScope SourceRoot.asScope() {
ScopeTree tree = new ScopeTree(); RootScope tree = new RootScope();
tree.setSourceRoot(this); tree.setSourceRoot(this);
return tree; return tree;
} }
......
// glue relation for the Java-based variable shadowing analysis // glue relation for the Java-based variable shadowing analysis
rel ScopeTree.SourceRoot -> SourceRoot; rel RootScope.SourceRoot -> SourceRoot;
// scopes // scopes
......
...@@ -65,7 +65,7 @@ public class ScopeAnalysis { ...@@ -65,7 +65,7 @@ public class ScopeAnalysis {
// measure the time (without parsing) from here // measure the time (without parsing) from here
long startGenerationTime = System.nanoTime(); long startGenerationTime = System.nanoTime();
ScopeTree scopeTree = sourceRoot.scopeTree(); RootScope scopeTree = sourceRoot.scopeTree();
long startAnalysisTime = System.nanoTime(); long startAnalysisTime = System.nanoTime();
...@@ -109,7 +109,7 @@ public class ScopeAnalysis { ...@@ -109,7 +109,7 @@ public class ScopeAnalysis {
sourceRoot = readProgram(files); sourceRoot = readProgram(files);
ScopeTree scopeTree = sourceRoot.scopeTree(); RootScope scopeTree = sourceRoot.scopeTree();
if (tree) { if (tree) {
scopeTree.printAST(); scopeTree.printAST();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment