@@ -378,35 +378,18 @@ module Trees {
378
378
override ControlFlowTree getChildElement ( int i ) { result = this .getArgument ( i ) }
379
379
}
380
380
381
- private class CaseTree extends PreOrderTree , CaseExpr , ASTInternal:: TCaseExpr {
381
+ private class CaseTree extends PostOrderTree , CaseExpr , ASTInternal:: TCaseExpr {
382
382
final override predicate propagatesAbnormal ( AstNode child ) {
383
383
child = this .getValue ( ) or child = this .getABranch ( )
384
384
}
385
385
386
- final override predicate last ( AstNode last , Completion c ) {
387
- last ( this .getValue ( ) , last , c ) and not exists ( this .getABranch ( ) )
388
- or
389
- last ( this .getABranch ( ) .( WhenExpr ) .getBody ( ) , last , c )
386
+ final override predicate first ( AstNode first ) {
387
+ first ( this .getValue ( ) , first )
390
388
or
391
- exists ( int i , ControlFlowTree lastBranch |
392
- lastBranch = this .getBranch ( i ) and
393
- not exists ( this .getBranch ( i + 1 ) ) and
394
- last ( lastBranch , last , c )
395
- )
389
+ not exists ( this .getValue ( ) ) and first ( this .getBranch ( 0 ) , first )
396
390
}
397
391
398
392
final override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
399
- exists ( AstNode next |
400
- pred = this and
401
- first ( next , succ ) and
402
- c instanceof SimpleCompletion
403
- |
404
- next = this .getValue ( )
405
- or
406
- not exists ( this .getValue ( ) ) and
407
- next = this .getBranch ( 0 )
408
- )
409
- or
410
393
last ( this .getValue ( ) , pred , c ) and
411
394
first ( this .getBranch ( 0 ) , succ ) and
412
395
c instanceof SimpleCompletion
@@ -416,17 +399,31 @@ module Trees {
416
399
first ( this .getBranch ( i + 1 ) , succ ) and
417
400
c .( ConditionalCompletion ) .getValue ( ) = false
418
401
)
402
+ or
403
+ succ = this and
404
+ (
405
+ last ( this .getValue ( ) , pred , c ) and not exists ( this .getABranch ( ) )
406
+ or
407
+ last ( this .getABranch ( ) .( WhenExpr ) .getBody ( ) , pred , c )
408
+ or
409
+ exists ( int i , ControlFlowTree lastBranch |
410
+ lastBranch = this .getBranch ( i ) and
411
+ not exists ( this .getBranch ( i + 1 ) ) and
412
+ last ( lastBranch , pred , c )
413
+ )
414
+ )
419
415
}
420
416
}
421
417
422
- private class CaseMatchTree extends PreOrderTree , CaseExpr , ASTInternal:: TCaseMatch {
418
+ private class CaseMatchTree extends PostOrderTree , CaseExpr , ASTInternal:: TCaseMatch {
423
419
final override predicate propagatesAbnormal ( AstNode child ) {
424
420
child = this .getValue ( ) or child = this .getABranch ( )
425
421
}
426
422
423
+ final override predicate first ( AstNode first ) { first ( this .getValue ( ) , first ) }
424
+
427
425
final override predicate last ( AstNode last , Completion c ) {
428
- last ( this .getABranch ( ) , last , c ) and
429
- not c .( MatchingCompletion ) .getValue ( ) = false
426
+ super .last ( last , c )
430
427
or
431
428
not exists ( this .getElseBranch ( ) ) and
432
429
exists ( MatchingCompletion lc , Expr lastBranch |
@@ -439,10 +436,6 @@ module Trees {
439
436
}
440
437
441
438
final override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
442
- pred = this and
443
- first ( this .getValue ( ) , succ ) and
444
- c instanceof SimpleCompletion
445
- or
446
439
last ( this .getValue ( ) , pred , c ) and
447
440
first ( this .getBranch ( 0 ) , succ ) and
448
441
c instanceof SimpleCompletion
@@ -452,6 +445,15 @@ module Trees {
452
445
first ( this .getBranch ( i + 1 ) , succ ) and
453
446
c .( MatchingCompletion ) .getValue ( ) = false
454
447
)
448
+ or
449
+ succ = this and
450
+ (
451
+ last ( this .getABranch ( ) , pred , c ) and
452
+ not c .( MatchingCompletion ) .getValue ( ) = false
453
+ or
454
+ last ( this .getElseBranch ( ) , pred , c ) and
455
+ c instanceof NormalCompletion
456
+ )
455
457
}
456
458
}
457
459
0 commit comments