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