CFG: add more CfgScopeRanges

This commit is contained in:
Arthur Baars
2020-11-25 16:50:55 +01:00
parent e181666a37
commit 30cb2cc3e0
3 changed files with 87 additions and 1 deletions

View File

@@ -7,14 +7,34 @@ private import internal.ControlFlowGraphImpl
private import internal.Splitting
private import internal.Completion
private class CfgScopeRange = @method or @block or @do_block;
private class CfgScopeRange =
@program or @begin_block or @end_block or @module or @class or @singleton_class or @method or
@singleton_method or @block or @do_block;
/** An AST node with an associated control-flow graph. */
class CfgScope extends AstNode, CfgScopeRange {
/** Gets the name of this scope. */
string getName() {
this instanceof Program and
result = "top-level"
or
this instanceof BeginBlock and
result = "BEGIN block"
or
this instanceof EndBlock and
result = "END block"
or
result = this.(Module).getName().toString()
or
result = this.(Class).getName().toString()
or
this instanceof SingletonClass and
result = "singleton class"
or
result = this.(Method).getName().toString()
or
result = this.(SingletonMethod).getName().toString()
or
this instanceof Block and
result = "block"
or

View File

@@ -246,6 +246,10 @@ private module Trees {
}
}
private class BeginBlockTree extends StandardPreOrderTree, BeginBlock {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
}
private class BinaryTree extends StandardPostOrderTree, Binary {
BinaryTree() { not this instanceof LogicalAndAstNode and not this instanceof LogicalOrAstNode }
@@ -272,6 +276,12 @@ private module Trees {
}
}
private class ClassTree extends StandardPreOrderTree, Class {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
override predicate isHidden() { any() }
}
private class DoTree extends StandardPreOrderTree, Do {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
@@ -290,6 +300,10 @@ private module Trees {
override predicate isHidden() { any() }
}
private class EndBlockTree extends StandardPreOrderTree, EndBlock {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
}
private class IdentifierTree extends LeafTree, Identifier { }
private class IfElsifTree extends PreOrderTree, IfElsifAstNode {
@@ -392,6 +406,12 @@ private module Trees {
}
}
private class ModuleTree extends StandardPreOrderTree, Module {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
override predicate isHidden() { any() }
}
private class NextTree extends StandardPostOrderTree, Next {
final override AstNode getChildNode(int i) { result = this.getChild() and i = 0 }
}
@@ -408,6 +428,12 @@ private module Trees {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
}
private class ProgramTree extends StandardPostOrderTree, Program {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
override predicate isHidden() { any() }
}
private class RedoTree extends StandardPostOrderTree, Redo {
final override AstNode getChildNode(int i) { result = this.getChild() and i = 0 }
}
@@ -416,6 +442,18 @@ private module Trees {
final override AstNode getChildNode(int i) { result = this.getChild() and i = 0 }
}
private class SingletonClassTree extends StandardPreOrderTree, SingletonClass {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
override predicate isHidden() { any() }
}
private class SingletonMethodTree extends StandardPreOrderTree, SingletonMethod {
final override AstNode getChildNode(int i) { result = this.getChild(i) }
override predicate isHidden() { any() }
}
private class StringTree extends LeafTree, String { }
private class ThenTree extends StandardPreOrderTree, Then {