mirror of
https://github.com/github/codeql.git
synced 2026-02-19 16:33:40 +01:00
Make ModuleDeclarationTree post-order
This commit is contained in:
@@ -603,7 +603,7 @@ module Trees {
|
||||
private class CharacterTree extends LeafTree, CharacterLiteral { }
|
||||
|
||||
private class ClassDeclarationTree extends BodyStmtPostOrderTree, ClassDeclaration {
|
||||
override predicate first(AstNode first) {
|
||||
final override predicate first(AstNode first) {
|
||||
this.firstInner(first)
|
||||
or
|
||||
not exists(this.getAChild(_)) and
|
||||
@@ -952,12 +952,26 @@ module Trees {
|
||||
}
|
||||
}
|
||||
|
||||
private class ModuleDeclarationTree extends BodyStmtPreOrderTree, ModuleDeclaration {
|
||||
private class ModuleDeclarationTree extends BodyStmtPostOrderTree, ModuleDeclaration {
|
||||
final override predicate first(AstNode first) {
|
||||
this.firstInner(first)
|
||||
or
|
||||
not exists(this.getAChild(_)) and
|
||||
first = this
|
||||
}
|
||||
|
||||
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
|
||||
BodyStmtPostOrderTree.super.succ(pred, succ, c)
|
||||
or
|
||||
succ = this and
|
||||
this.lastInner(pred, c)
|
||||
}
|
||||
|
||||
/** Gets the `i`th child in the body of this block. */
|
||||
final override AstNode getBodyChild(int i, boolean rescuable) {
|
||||
result = this.getScopeExpr() and i = 0 and rescuable = false
|
||||
or
|
||||
result = BodyStmtPreOrderTree.super.getBodyChild(i - count(this.getScopeExpr()), rescuable)
|
||||
result = BodyStmtPostOrderTree.super.getBodyChild(i - count(this.getScopeExpr()), rescuable)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1389,7 +1389,7 @@ cfg.rb:
|
||||
#-----| -> ... = ...
|
||||
|
||||
# 120| ... = ...
|
||||
#-----| -> M
|
||||
#-----| -> nothing
|
||||
|
||||
# 120| swap
|
||||
#-----| -> -> { ... }
|
||||
@@ -1424,7 +1424,7 @@ cfg.rb:
|
||||
#-----| -> [...]
|
||||
|
||||
# 122| M
|
||||
#-----| -> nothing
|
||||
#-----| -> EmptyClass
|
||||
|
||||
# 123| ... = ...
|
||||
#-----| -> some
|
||||
@@ -1529,7 +1529,7 @@ cfg.rb:
|
||||
#-----| -> #{...}
|
||||
|
||||
# 130| ... = ...
|
||||
#-----| -> EmptyClass
|
||||
#-----| -> M
|
||||
|
||||
# 130| Constant
|
||||
#-----| -> 5
|
||||
|
||||
Reference in New Issue
Block a user