@@ -200,8 +200,7 @@ class TypeReprTree extends LeafTree instanceof TypeRepr { }
200
200
/**
201
201
* Provides `ControlFlowTree`s for expressions.
202
202
*
203
- * Since expressions construct values, they are modeled in post-order, except for
204
- * `LetExpr`s.
203
+ * Since expressions construct values, they are modeled in post-order.
205
204
*/
206
205
module ExprTrees {
207
206
class ArrayExprTree extends StandardPostOrderTree , ArrayExpr {
@@ -341,21 +340,15 @@ module ExprTrees {
341
340
child = [ super .getCondition ( ) , super .getABranch ( ) ]
342
341
}
343
342
344
- private ConditionalCompletion conditionCompletion ( Completion c ) {
345
- if super .getCondition ( ) instanceof LetExpr
346
- then result = c .( MatchCompletion )
347
- else result = c .( BooleanCompletion )
348
- }
349
-
350
343
override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
351
344
// Edges from the condition to the branches
352
345
last ( super .getCondition ( ) , pred , c ) and
353
346
(
354
- first ( super .getThen ( ) , succ ) and this . conditionCompletion ( c ) .succeeded ( )
347
+ first ( super .getThen ( ) , succ ) and c . ( ConditionalCompletion ) .succeeded ( )
355
348
or
356
- first ( super .getElse ( ) , succ ) and this . conditionCompletion ( c ) .failed ( )
349
+ first ( super .getElse ( ) , succ ) and c . ( ConditionalCompletion ) .failed ( )
357
350
or
358
- not super .hasElse ( ) and succ = this and this . conditionCompletion ( c ) .failed ( )
351
+ not super .hasElse ( ) and succ = this and c . ( ConditionalCompletion ) .failed ( )
359
352
)
360
353
or
361
354
// An edge from the then branch to the last node
@@ -401,10 +394,7 @@ module ExprTrees {
401
394
}
402
395
}
403
396
404
- // `LetExpr` is a pre-order tree such that the pattern itself ends up
405
- // dominating successors in the graph in the same way that patterns do in
406
- // `match` expressions.
407
- class LetExprTree extends StandardPreOrderTree , LetExpr {
397
+ class LetExprTree extends StandardPostOrderTree , LetExpr {
408
398
override AstNode getChildNode ( int i ) {
409
399
i = 0 and
410
400
result = this .getScrutinee ( )
@@ -456,21 +446,15 @@ module ExprTrees {
456
446
457
447
override predicate first ( AstNode node ) { first ( super .getCondition ( ) , node ) }
458
448
459
- private ConditionalCompletion conditionCompletion ( Completion c ) {
460
- if super .getCondition ( ) instanceof LetExpr
461
- then result = c .( MatchCompletion )
462
- else result = c .( BooleanCompletion )
463
- }
464
-
465
449
override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
466
450
super .succ ( pred , succ , c )
467
451
or
468
452
last ( super .getCondition ( ) , pred , c ) and
469
- this . conditionCompletion ( c ) .succeeded ( ) and
453
+ c . ( ConditionalCompletion ) .succeeded ( ) and
470
454
first ( this .getLoopBody ( ) , succ )
471
455
or
472
456
last ( super .getCondition ( ) , pred , c ) and
473
- this . conditionCompletion ( c ) .failed ( ) and
457
+ c . ( ConditionalCompletion ) .failed ( ) and
474
458
succ = this
475
459
}
476
460
}
0 commit comments