Make ClassDeclarationTree post-order

This commit is contained in:
Nick Rolfe
2021-05-06 15:36:25 +01:00
parent a0084b7732
commit d623f47ba0
2 changed files with 25 additions and 11 deletions

View File

@@ -602,7 +602,21 @@ module Trees {
private class CharacterTree extends LeafTree, CharacterLiteral { }
private class ClassDeclarationTree extends BodyStmtPreOrderTree, ClassDeclaration {
private class ClassDeclarationTree extends BodyStmtPostOrderTree, ClassDeclaration {
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