@@ -100,24 +100,29 @@ private class EndBlockScope extends CfgScopeImpl, EndBlock {
100100 }
101101}
102102
103- private class BodyStmtCallableScope extends CfgScopeImpl , AstInternal:: TBodyStmt , Callable {
104- final override predicate entry ( AstNode first ) { this .( Trees:: BodyStmtTree ) .firstInner ( first ) }
105-
106- final override predicate exit ( AstNode last , Completion c ) {
107- this .( Trees:: BodyStmtTree ) .lastInner ( last , c )
108- }
109- }
110-
111- private class BraceBlockScope extends CfgScopeImpl , BraceBlock {
103+ // private class BodyStmtCallableScope extends CfgScopeImpl, AstInternal::TBodyStmt, Callable {
104+ // final override predicate entry(AstNode first) { this.(Trees::BodyStmtTree).firstInner(first) }
105+ // final override predicate exit(AstNode last, Completion c) {
106+ // this.(Trees::BodyStmtTree).lastInner(last, c)
107+ // }
108+ // }
109+ private class CallableScope extends CfgScopeImpl , Callable {
110+ // private class BraceBlockScope extends CfgScopeImpl, BraceBlock {
112111 final override predicate entry ( AstNode first ) {
113- first ( this .( Trees:: BraceBlockTree ) .getBodyChild ( 0 , _) , first )
112+ // first(this.(Trees::BraceBlockTree).getBodyChild(0, _), first)
113+ // first(this.getBody().(Trees::BodyStmtTree).getBodyChild(0, _), first)
114+ // this.getBody().(Trees::BodyStmtTree).first(first)
115+ first ( this .( Trees:: CallableTree ) .getBodyChild ( 0 ) , first )
114116 }
115117
116118 final override predicate exit ( AstNode last , Completion c ) {
117- last ( this .( Trees:: BraceBlockTree ) .getLastBodyChild ( ) , last , c )
118- or
119- last ( this .( Trees:: BraceBlockTree ) .getBodyChild ( _, _) , last , c ) and
120- not c instanceof NormalCompletion
119+ this .getBody ( ) .( Trees:: BodyStmtTree ) .last ( last , c )
120+ // // last(this.(Trees::BraceBlockTree).getLastBodyChild(), last, c)
121+ // last(this.getBody().(Trees::BodyStmtTree).getLastBodyChild(), last, c)
122+ // or
123+ // // last(this.(Trees::BraceBlockTree).getBodyChild(_, _), last, c) and
124+ // last(this.getBody().(Trees::BodyStmtTree).getBodyChild(_, _), last, c) and
125+ // not c instanceof NormalCompletion
121126 }
122127}
123128
@@ -159,10 +164,8 @@ module Trees {
159164 }
160165
161166 private class BeginTree extends BodyStmtTree instanceof BeginExpr {
162- final override predicate first ( AstNode first ) { this .firstInner ( first ) }
163-
164- final override predicate last ( AstNode last , Completion c ) { this .lastInner ( last , c ) }
165-
167+ // final override predicate first(AstNode first) { this.firstInner(first) }
168+ // final override predicate last(AstNode last, Completion c) { this.lastInner(last, c) }
166169 final override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
167170 }
168171
@@ -196,16 +199,17 @@ module Trees {
196199 private class BlockParameterTree extends NonDefaultValueParameterTree instanceof BlockParameter {
197200 }
198201
199- abstract class BodyStmtTree extends StmtSequenceTree instanceof BodyStmt {
202+ // abstract
203+ class BodyStmtTree extends StmtSequenceTree instanceof BodyStmt {
200204 /** Gets a rescue clause in this block. */
201205 final RescueClause getARescue ( ) { result = super .getRescue ( _) }
202206
203207 /** Gets the `ensure` clause in this block, if any. */
204208 final StmtSequence getEnsure ( ) { result = super .getEnsure ( ) }
205209
206- override predicate first ( AstNode first ) { first = this }
207-
208- predicate firstInner ( AstNode first ) {
210+ override predicate first ( AstNode first ) {
211+ // { first = this }
212+ // predicate firstInner(AstNode first)
209213 first ( this .getBodyChild ( 0 , _) , first )
210214 or
211215 not exists ( this .getBodyChild ( _, _) ) and
@@ -217,7 +221,8 @@ module Trees {
217221 )
218222 }
219223
220- predicate lastInner ( AstNode last , Completion c ) {
224+ // predicate lastInner(AstNode last, Completion c)
225+ override predicate last ( AstNode last , Completion c ) {
221226 exists ( boolean ensurable | last = this .getAnEnsurePredecessor ( c , ensurable ) |
222227 not super .hasEnsure ( )
223228 or
@@ -387,27 +392,49 @@ module Trees {
387392
388393 private class BooleanLiteralTree extends LeafTree instanceof BooleanLiteral { }
389394
390- class BraceBlockTree extends StmtSequenceTree instanceof BraceBlock {
395+ // class BraceBlockTree extends StmtSequenceTree instanceof BraceBlock {
396+ class BraceBlockTree extends CallableTree instanceof BraceBlock {
397+ // final override predicate propagatesAbnormal(AstNode child) { none() }
398+ final override AstNode getBodyChild ( int i ) {
399+ result = super .getParameter ( i )
400+ or
401+ result = super .getLocalVariable ( i - super .getNumberOfParameters ( ) )
402+ or
403+ result = super .getBody ( ) and
404+ i = super .getNumberOfParameters ( ) + count ( super .getALocalVariable ( ) )
405+ // result =
406+ // StmtSequenceTree.super
407+ // .getBodyChild(i - super.getNumberOfParameters() - count(super.getALocalVariable()),
408+ // rescuable)
409+ }
410+ // override predicate first(AstNode first) { first = this }
411+ // override predicate succ(AstNode pred, AstNode succ, Completion c) {
412+ // // Normal left-to-right evaluation in the body
413+ // exists(int i |
414+ // last(this.getBodyChild(i, _), pred, c) and
415+ // first(this.getBodyChild(i + 1, _), succ) and
416+ // c instanceof NormalCompletion
417+ // )
418+ // }
419+ }
420+
421+ class CallableTree extends PostOrderTree instanceof Callable {
391422 final override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
392423
393- final override AstNode getBodyChild ( int i , boolean rescuable ) {
394- result = super .getParameter ( i ) and rescuable = false
395- or
396- result = super .getLocalVariable ( i - super .getNumberOfParameters ( ) ) and rescuable = false
397- or
398- result =
399- StmtSequenceTree .super
400- .getBodyChild ( i - super .getNumberOfParameters ( ) - count ( super .getALocalVariable ( ) ) ,
401- rescuable )
402- }
403-
404424 override predicate first ( AstNode first ) { first = this }
405425
426+ abstract AstNode getBodyChild ( int i ) ;
427+
428+ // final AstNode getLastBodyChild() {
429+ // exists(int i |
430+ // result = this.getBodyChild(i) and
431+ // not exists(this.getBodyChild(i + 1))
432+ // )
433+ // }
406434 override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
407- // Normal left-to-right evaluation in the body
408435 exists ( int i |
409- last ( this .getBodyChild ( i , _ ) , pred , c ) and
410- first ( this .getBodyChild ( i + 1 , _ ) , succ ) and
436+ last ( this .getBodyChild ( i ) , pred , c ) and
437+ first ( this .getBodyChild ( i + 1 ) , succ ) and
411438 c instanceof NormalCompletion
412439 )
413440 }
@@ -1016,20 +1043,22 @@ module Trees {
10161043 final override predicate succ ( AstNode pred , AstNode succ , Completion c ) { none ( ) }
10171044 }
10181045
1019- private class DoBlockTree extends BodyStmtTree instanceof DoBlock {
1046+ // private class DoBlockTree extends BodyStmtTree instanceof DoBlock {
1047+ private class DoBlockTree extends CallableTree instanceof DoBlock {
10201048 /** Gets the `i`th child in the body of this block. */
1021- final override AstNode getBodyChild ( int i , boolean rescuable ) {
1022- result = super .getParameter ( i ) and rescuable = false
1049+ final override AstNode getBodyChild ( int i ) {
1050+ result = super .getParameter ( i )
10231051 or
1024- result = super .getLocalVariable ( i - super .getNumberOfParameters ( ) ) and rescuable = false
1052+ result = super .getLocalVariable ( i - super .getNumberOfParameters ( ) )
10251053 or
1026- result =
1027- BodyStmtTree .super
1028- .getBodyChild ( i - super .getNumberOfParameters ( ) - count ( super .getALocalVariable ( ) ) ,
1029- rescuable )
1054+ result = super .getBody ( ) and
1055+ i = super .getNumberOfParameters ( ) + count ( super .getALocalVariable ( ) )
1056+ // result =
1057+ // BodyStmtTree.super
1058+ // .getBodyChild(i - super.getNumberOfParameters() - count(super.getALocalVariable()),
1059+ // rescuable)
10301060 }
1031-
1032- override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
1061+ // override predicate propagatesAbnormal(AstNode child) { none() }
10331062 }
10341063
10351064 private class EmptyStatementTree extends LeafTree instanceof EmptyStmt { }
@@ -1073,14 +1102,13 @@ module Trees {
10731102 final override AstNode getAccessNode ( ) { result = super .getDefiningAccess ( ) }
10741103 }
10751104
1076- private class LambdaTree extends BodyStmtTree instanceof Lambda {
1077- final override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
1078-
1105+ private class LambdaTree extends CallableTree instanceof Lambda {
10791106 /** Gets the `i`th child in the body of this block. */
1080- final override AstNode getBodyChild ( int i , boolean rescuable ) {
1081- result = super .getParameter ( i ) and rescuable = false
1107+ final override AstNode getBodyChild ( int i ) {
1108+ result = super .getParameter ( i )
10821109 or
1083- result = BodyStmtTree .super .getBodyChild ( i - super .getNumberOfParameters ( ) , rescuable )
1110+ result = super .getBody ( ) and i = super .getNumberOfParameters ( )
1111+ // result = BodyStmtTree.super.getBodyChild(i - super.getNumberOfParameters(), rescuable)
10841112 }
10851113 }
10861114
@@ -1151,14 +1179,13 @@ module Trees {
11511179 private class MethodNameTree extends LeafTree instanceof MethodName , AstInternal:: TTokenMethodName
11521180 { }
11531181
1154- private class MethodTree extends BodyStmtTree instanceof Method {
1155- final override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
1156-
1182+ private class MethodTree extends CallableTree instanceof Method {
11571183 /** Gets the `i`th child in the body of this block. */
1158- final override AstNode getBodyChild ( int i , boolean rescuable ) {
1159- result = super .getParameter ( i ) and rescuable = false
1184+ final override AstNode getBodyChild ( int i ) {
1185+ result = super .getParameter ( i )
11601186 or
1161- result = BodyStmtTree .super .getBodyChild ( i - super .getNumberOfParameters ( ) , rescuable )
1187+ result = super .getBody ( ) and i = super .getNumberOfParameters ( )
1188+ // result = BodyStmtTree.super.getBodyChild(i - super.getNumberOfParameters(), rescuable)
11621189 }
11631190 }
11641191
@@ -1183,12 +1210,12 @@ module Trees {
11831210 BodyStmtTree .super .succ ( pred , succ , c )
11841211 or
11851212 pred = this and
1186- this . firstInner ( succ ) and
1213+ super . first ( succ ) and
11871214 c instanceof SimpleCompletion
11881215 }
11891216
11901217 final override predicate last ( AstNode last , Completion c ) {
1191- this . lastInner ( last , c )
1218+ super . last ( last , c )
11921219 or
11931220 not exists ( this .getAChild ( _) ) and
11941221 last = this and
@@ -1328,7 +1355,7 @@ module Trees {
13281355
13291356 private class SingletonClassTree extends BodyStmtTree instanceof SingletonClass {
13301357 final override predicate first ( AstNode first ) {
1331- this . firstInner ( first )
1358+ super . first ( first )
13321359 or
13331360 not exists ( this .getAChild ( _) ) and
13341361 first = this
@@ -1338,7 +1365,7 @@ module Trees {
13381365 BodyStmtTree .super .succ ( pred , succ , c )
13391366 or
13401367 succ = this and
1341- this . lastInner ( pred , c )
1368+ super . last ( pred , c )
13421369 }
13431370
13441371 /** Gets the `i`th child in the body of this block. */
@@ -1351,20 +1378,19 @@ module Trees {
13511378 }
13521379 }
13531380
1354- private class SingletonMethodTree extends BodyStmtTree instanceof SingletonMethod {
1355- final override predicate propagatesAbnormal ( AstNode child ) { none ( ) }
1356-
1381+ private class SingletonMethodTree extends CallableTree instanceof SingletonMethod {
13571382 /** Gets the `i`th child in the body of this block. */
1358- final override AstNode getBodyChild ( int i , boolean rescuable ) {
1359- result = super .getParameter ( i ) and rescuable = false
1383+ final override AstNode getBodyChild ( int i ) {
1384+ result = super .getParameter ( i )
13601385 or
1361- result = BodyStmtTree .super .getBodyChild ( i - super .getNumberOfParameters ( ) , rescuable )
1386+ result = super .getBody ( ) and i = super .getNumberOfParameters ( )
1387+ // result = BodyStmtTree.super.getBodyChild(i - super.getNumberOfParameters(), rescuable)
13621388 }
13631389
13641390 override predicate first ( AstNode first ) { first ( super .getObject ( ) , first ) }
13651391
13661392 override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
1367- BodyStmtTree .super .succ ( pred , succ , c )
1393+ CallableTree .super .succ ( pred , succ , c )
13681394 or
13691395 last ( super .getObject ( ) , pred , c ) and
13701396 succ = this and
@@ -1443,10 +1469,8 @@ module Trees {
14431469 or
14441470 result = BodyStmtTree .super .getBodyChild ( i - count ( super .getABeginBlock ( ) ) , rescuable )
14451471 }
1446-
1447- final override predicate first ( AstNode first ) { super .firstInner ( first ) }
1448-
1449- final override predicate last ( AstNode last , Completion c ) { super .lastInner ( last , c ) }
1472+ // final override predicate first(AstNode first) { super.firstInner(first) }
1473+ // final override predicate last(AstNode last, Completion c) { super.lastInner(last, c) }
14501474 }
14511475
14521476 private class UndefStmtTree extends StandardPreOrderTree instanceof UndefStmt {
0 commit comments