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

make attribute hostStatement() a relation

parent 735b53ed
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ CfgMethodCall : CfgNode;
/** A conditional branch in the CFG. */
CfgBranch : CfgNode;
rel CfgBranch.hostStatement -> Stmt;
/** A branch in the CFG caused by potential thrown exceptions. */
CfgException : CfgNode;
......
......@@ -440,7 +440,11 @@ aspect SimpleCFG {
eq Dot.getLeft().follow() = getRight().entry();
/** The branch node for this conditional expression. */
syn nta CfgBranch ConditionalExpr.branch() = new CfgBranch();
syn nta CfgBranch ConditionalExpr.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(hostStatement());
return branch;
}
/**
* The then-end node is a marker node marking the end of a then-branch in a conditional
......@@ -467,7 +471,11 @@ aspect SimpleCFG {
smallSet(getTrueExpr().entry(), getFalseExpr().entry());
/** The branch node for this statement. */
syn nta CfgBranch IfStmt.branch() = new CfgBranch();
syn nta CfgBranch IfStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
/** The then-end node is a marker node marking the end of a then-branch in an if statement. */
syn nta CfgMarker IfStmt.thenEndMarker() = new CfgMarker();
......@@ -491,7 +499,11 @@ aspect SimpleCFG {
: smallSet(getThen().entry(), follow());
/** The branch node for this statement. */
syn nta CfgBranch ForStmt.branch() = new CfgBranch();
syn nta CfgBranch ForStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
/** The CFG end marker for this loop. */
syn nta CfgMarker ForStmt.loopEndMarker() = new CfgMarker();
......@@ -536,7 +548,11 @@ aspect SimpleCFG {
}
/** The branch node for this statement. */
syn nta CfgBranch EnhancedForStmt.branch() = new CfgBranch();
syn nta CfgBranch EnhancedForStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
/** The CFG end marker for this loop. */
syn nta CfgMarker EnhancedForStmt.loopEndMarker() = new CfgMarker();
......@@ -555,7 +571,11 @@ aspect SimpleCFG {
eq EnhancedForStmt.loopEndMarker().succ() = Collections.singleton(entry());
/** The branch node for this statement. */
syn nta CfgBranch WhileStmt.branch() = new CfgBranch();
syn nta CfgBranch WhileStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
/** The CFG end marker for this loop. */
syn nta CfgMarker WhileStmt.loopEndMarker() = new CfgMarker();
......@@ -581,7 +601,11 @@ aspect SimpleCFG {
}
/** The branch node for this statement. */
syn nta CfgBranch DoStmt.branch() = new CfgBranch();
syn nta CfgBranch DoStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
/** The CFG entry marker for this loop. */
syn nta CfgMarker DoStmt.doEntryMarker() = new CfgMarker();
......@@ -607,7 +631,11 @@ aspect SimpleCFG {
}
}
syn nta CfgBranch SwitchStmt.branch() = new CfgBranch();
syn nta CfgBranch SwitchStmt.branch() {
CfgBranch branch = new CfgBranch();
branch.setHostStatement(this);
return branch;
}
eq SwitchStmt.entry() = getExpr().entry();
......
......@@ -32,7 +32,7 @@ aspect VariableDeclarationScope {
|| variableDeclaredInsideStatement(var);
syn boolean CfgBranch.variableDeclaredInsideStatement(Variable var) {
Stmt stmt = hostStatement();
Stmt stmt = getHostStatement();
ASTNode node = (ASTNode) var;
while (node != stmt && node != null) {
node = node.getParent();
......@@ -40,22 +40,11 @@ aspect VariableDeclarationScope {
return node == stmt;
}
/** The statement this branch represents. */
inh Stmt CfgBranch.hostStatement();
/** The statement this expression is part of. */
inh Stmt Expr.hostStatement();
eq Stmt.getChild().hostStatement() = this;
eq Program.getChild().hostStatement() = null;
eq IfStmt.branch().hostStatement() = this;
eq ConditionalExpr.branch().hostStatement() = hostStatement();
eq ForStmt.branch().hostStatement() = this;
eq WhileStmt.branch().hostStatement() = this;
eq DoStmt.branch().hostStatement() = this;
eq EnhancedForStmt.branch().hostStatement() = this;
eq SwitchStmt.branch().hostStatement() = this;
/** Test if the CFG node is tied to a statement that declares the variable. */
inh boolean CfgBranch.branchDeclaresVariable(Variable var);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment