@@ -842,9 +842,7 @@ class TranslatedCatchAnyHandler extends TranslatedHandler {
842
842
}
843
843
}
844
844
845
- class TranslatedIfStmt extends TranslatedStmt , ConditionContext {
846
- override IfStmt stmt ;
847
-
845
+ abstract class TranslatedIfLikeStmt extends TranslatedStmt , ConditionContext {
848
846
override Instruction getFirstInstruction ( EdgeKind kind ) {
849
847
if this .hasInitialization ( )
850
848
then result = this .getInitialization ( ) .getFirstInstruction ( kind )
@@ -867,25 +865,21 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
867
865
id = 3 and result = this .getElse ( )
868
866
}
869
867
870
- private predicate hasInitialization ( ) { exists ( stmt . getInitialization ( ) ) }
868
+ abstract predicate hasInitialization ( ) ;
871
869
872
- private TranslatedStmt getInitialization ( ) {
873
- result = getTranslatedStmt ( stmt .getInitialization ( ) )
874
- }
870
+ abstract TranslatedStmt getInitialization ( ) ;
875
871
876
- private TranslatedCondition getCondition ( ) {
877
- result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
878
- }
872
+ abstract TranslatedCondition getCondition ( ) ;
879
873
880
874
private Instruction getFirstConditionInstruction ( EdgeKind kind ) {
881
875
result = this .getCondition ( ) .getFirstInstruction ( kind )
882
876
}
883
877
884
- private TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt . getThen ( ) ) }
878
+ abstract TranslatedStmt getThen ( ) ;
885
879
886
- private TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt . getElse ( ) ) }
880
+ abstract TranslatedStmt getElse ( ) ;
887
881
888
- private predicate hasElse ( ) { exists ( stmt . getElse ( ) ) }
882
+ abstract predicate hasElse ( ) ;
889
883
890
884
override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) { none ( ) }
891
885
@@ -914,76 +908,44 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
914
908
}
915
909
}
916
910
917
- class TranslatedConstExprIfStmt extends TranslatedStmt , ConditionContext {
918
- override ConstexprIfStmt stmt ;
919
-
920
- override Instruction getFirstInstruction ( EdgeKind kind ) {
921
- if this .hasInitialization ( )
922
- then result = this .getInitialization ( ) .getFirstInstruction ( kind )
923
- else result = this .getFirstConditionInstruction ( kind )
924
- }
925
-
926
- override Instruction getALastInstructionInternal ( ) {
927
- result = this .getElse ( ) .getALastInstruction ( ) or result = this .getThen ( ) .getALastInstruction ( )
928
- }
929
-
930
- override TranslatedElement getLastChild ( ) { result = this .getElse ( ) or result = this .getThen ( ) }
931
-
932
- override TranslatedElement getChildInternal ( int id ) {
933
- id = 0 and result = this .getInitialization ( )
934
- or
935
- id = 1 and result = this .getCondition ( )
936
- or
937
- id = 2 and result = this .getThen ( )
938
- or
939
- id = 3 and result = this .getElse ( )
940
- }
911
+ class TranslatedIfStmt extends TranslatedIfLikeStmt {
912
+ override IfStmt stmt ;
941
913
942
- private predicate hasInitialization ( ) { exists ( stmt .getInitialization ( ) ) }
914
+ override predicate hasInitialization ( ) { exists ( stmt .getInitialization ( ) ) }
943
915
944
- private TranslatedStmt getInitialization ( ) {
916
+ override TranslatedStmt getInitialization ( ) {
945
917
result = getTranslatedStmt ( stmt .getInitialization ( ) )
946
918
}
947
919
948
- private TranslatedCondition getCondition ( ) {
920
+ override TranslatedCondition getCondition ( ) {
949
921
result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
950
922
}
951
923
952
- private Instruction getFirstConditionInstruction ( EdgeKind kind ) {
953
- result = this .getCondition ( ) .getFirstInstruction ( kind )
954
- }
924
+ override TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
955
925
956
- private TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
926
+ override TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt .getElse ( ) ) }
957
927
958
- private TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt .getElse ( ) ) }
928
+ override predicate hasElse ( ) { exists ( stmt .getElse ( ) ) }
929
+ }
959
930
960
- private predicate hasElse ( ) { exists ( stmt .getElse ( ) ) }
931
+ class TranslatedConstExprIfStmt extends TranslatedIfLikeStmt {
932
+ override ConstexprIfStmt stmt ;
961
933
962
- override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) { none ( ) }
934
+ override predicate hasInitialization ( ) { exists ( stmt . getInitialization ( ) ) }
963
935
964
- override Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) {
965
- child = this .getCondition ( ) and
966
- result = this .getThen ( ) .getFirstInstruction ( kind )
936
+ override TranslatedStmt getInitialization ( ) {
937
+ result = getTranslatedStmt ( stmt .getInitialization ( ) )
967
938
}
968
939
969
- override Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) {
970
- child = this .getCondition ( ) and
971
- if this .hasElse ( )
972
- then result = this .getElse ( ) .getFirstInstruction ( kind )
973
- else result = this .getParent ( ) .getChildSuccessor ( this , kind )
940
+ override TranslatedCondition getCondition ( ) {
941
+ result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
974
942
}
975
943
976
- override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) {
977
- child = this .getInitialization ( ) and
978
- result = this .getFirstConditionInstruction ( kind )
979
- or
980
- ( child = this .getThen ( ) or child = this .getElse ( ) ) and
981
- result = this .getParent ( ) .getChildSuccessor ( this , kind )
982
- }
944
+ override TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
983
945
984
- override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
985
- none ( )
986
- }
946
+ override TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt . getElse ( ) ) }
947
+
948
+ override predicate hasElse ( ) { exists ( stmt . getElse ( ) ) }
987
949
}
988
950
989
951
abstract class TranslatedLoop extends TranslatedStmt , ConditionContext {
0 commit comments