Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Reusable Analysis
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
Reusable Analysis
Commits
2aa86825
Commit
2aa86825
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
separate analysis and cfg a bit more
parent
7b25d235
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
reusablecfg/src/main/jastadd/Helpers.jrag
+8
-0
8 additions, 0 deletions
reusablecfg/src/main/jastadd/Helpers.jrag
reusablecfg/src/main/jastadd/VariableDeclarationScope.jrag
+15
-17
15 additions, 17 deletions
reusablecfg/src/main/jastadd/VariableDeclarationScope.jrag
with
23 additions
and
17 deletions
reusablecfg/src/main/jastadd/Helpers.jrag
0 → 100644
+
8
−
0
View file @
2aa86825
aspect Helpers {
syn boolean List.contains(ASTNode other) {
for (ASTNode node : this) {
if (node.equals(other)) return true;
}
return false;
}
}
This diff is collapsed.
Click to expand it.
reusablecfg/src/main/jastadd/VariableDeclarationScope.jrag
+
15
−
17
View file @
2aa86825
...
...
@@ -28,16 +28,15 @@ aspect VariableDeclarationScope {
syn boolean CfgNode.isDeclarationOf(Variable var) = false;
eq CfgBranch.isDeclarationOf(Variable var) =
branchD
eclaresVariable(var)
|| variableDeclaredInside
Statement
(var);
getHostStatement().d
eclaresVariable(var)
||
getHostStatement().
variableDeclaredInside(var);
syn boolean CfgBranch.variableDeclaredInsideStatement(Variable var) {
Stmt stmt = getHostStatement();
syn boolean Stmt.variableDeclaredInside(Variable var) {
ASTNode node = (ASTNode) var;
while (node !=
stmt
&& node != null) {
while (node !=
this
&& node != null) {
node = node.getParent();
}
return node ==
stmt
;
return node ==
this
;
}
/** The statement this expression is part of. */
...
...
@@ -45,16 +44,15 @@ aspect VariableDeclarationScope {
eq Stmt.getChild().hostStatement() = this;
eq Program.getChild().hostStatement() = null;
/** Test if the CFG node is tied to a statement that declares the variable. */
inh boolean CfgBranch.branchDeclaresVariable(Variable var);
eq EnhancedForStmt.branch().branchDeclaresVariable(Variable var) =
getVariableDecl() == var;
eq IfStmt.branch().branchDeclaresVariable(Variable var) = false;
eq ConditionalExpr.branch().branchDeclaresVariable(Variable var) = false;
eq ForStmt.branch().branchDeclaresVariable(Variable var) = false;
eq WhileStmt.branch().branchDeclaresVariable(Variable var) = false;
eq DoStmt.branch().branchDeclaresVariable(Variable var) = false;
eq SwitchStmt.branch().branchDeclaresVariable(Variable var) = false;
/** Test if a statement declares a variable */
syn boolean Stmt.declaresVariable(Variable var) = false;
eq VarDeclStmt.declaresVariable(Variable var) = getDeclaratorList().contains((ASTNode)var);
eq EnhancedForStmt.declaresVariable(Variable var) = getVariableDecl() == var;
eq Block.declaresVariable(Variable var) {
for (Stmt stmt : getStmtList()) {
if (stmt.declaresVariable(var)) return true;
}
return false;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment