@@ -734,15 +734,12 @@ module Trees {
734734 override ControlFlowTree getChildElement ( int i ) { result = this .getVariableAccess ( ) and i = 0 }
735735 }
736736
737- private class InClauseTree extends PostOrderTree , InClause {
737+ private class InClauseTree extends PreOrderTree , InClause {
738738 final override predicate propagatesAbnormal ( AstNode child ) {
739739 child = this .getPattern ( ) or
740- child = this .getCondition ( ) or
741- child = this .getBody ( )
740+ child = this .getCondition ( )
742741 }
743742
744- final override predicate first ( AstNode first ) { first ( this .getPattern ( ) , first ) }
745-
746743 private predicate lastCondition ( AstNode last , BooleanCompletion c , boolean flag ) {
747744 last ( this .getCondition ( ) , last , c ) and
748745 (
@@ -753,44 +750,51 @@ module Trees {
753750 }
754751
755752 final override predicate last ( AstNode last , Completion c ) {
756- super .last ( last , c )
757- or
758753 last ( this .getPattern ( ) , last , c ) and
759754 c .( MatchingCompletion ) .getValue ( ) = false
760755 or
761- exists ( BooleanCompletion bc , boolean flag |
762- bc .getValue ( ) = flag .booleanNot ( ) and
756+ exists ( BooleanCompletion bc , boolean flag , MatchingCompletion mc |
763757 lastCondition ( last , bc , flag ) and
764758 c =
765759 any ( NestedMatchingCompletion nmc |
766- nmc .getInnerCompletion ( ) = bc and nmc .getOuterCompletion ( ) . getValue ( ) = false
760+ nmc .getInnerCompletion ( ) = bc and nmc .getOuterCompletion ( ) = mc
767761 )
762+ |
763+ mc .getValue ( ) = false and
764+ bc .getValue ( ) = flag .booleanNot ( )
765+ or
766+ not exists ( this .getBody ( ) ) and
767+ mc .getValue ( ) = true and
768+ bc .getValue ( ) = flag
768769 )
770+ or
771+ last ( this .getBody ( ) , last , c )
772+ or
773+ not exists ( this .getBody ( ) ) and
774+ not exists ( this .getCondition ( ) ) and
775+ last ( this .getPattern ( ) , last , c )
769776 }
770777
771778 final override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
772- last ( this .getPattern ( ) , pred , c ) and
773- not c .( MatchingCompletion ) .getValue ( ) = false and
774- (
775- first ( this .getCondition ( ) , succ )
776- or
777- not exists ( this .getCondition ( ) ) and first ( this .getBody ( ) , succ )
779+ pred = this and
780+ first ( this .getPattern ( ) , succ ) and
781+ c instanceof SimpleCompletion
782+ or
783+ exists ( Expr next |
784+ last ( this .getPattern ( ) , pred , c ) and
785+ c .( MatchingCompletion ) .getValue ( ) = true and
786+ first ( next , succ )
787+ |
788+ next = this .getCondition ( )
778789 or
779- not exists ( this .getCondition ( ) ) and not exists ( this .getBody ( ) ) and succ = this
790+ not exists ( this .getCondition ( ) ) and next = this .getBody ( )
780791 )
781792 or
782793 exists ( boolean flag |
783794 lastCondition ( pred , c , flag ) and
784- c .( BooleanCompletion ) .getValue ( ) = flag
785- |
795+ c .( BooleanCompletion ) .getValue ( ) = flag and
786796 first ( this .getBody ( ) , succ )
787- or
788- not exists ( this .getBody ( ) ) and succ = this
789797 )
790- or
791- last ( this .getBody ( ) , pred , c ) and
792- succ = this and
793- c instanceof NormalCompletion
794798 }
795799 }
796800
0 commit comments