@@ -106,6 +106,26 @@ predicate inheritanceConversionTypes(
106106 toType = convert .getResultType ( )
107107}
108108
109+ private signature class ConversionInstruction extends UnaryInstruction ;
110+
111+ module Conversion< ConversionInstruction I> {
112+ signature predicate hasTypes ( I instr , Type fromType , Type toType ) ;
113+
114+ module Using< hasTypes / 3 project> {
115+ pragma [ nomagic]
116+ predicate hasOperandAndTypes ( I convert , Instruction unary , Type fromType , Type toType ) {
117+ project ( convert , fromType , toType ) and
118+ unary = convert .getUnary ( )
119+ }
120+ }
121+ }
122+
123+ pragma [ nomagic]
124+ predicate hasObjectAndField ( FieldAddressInstruction fai , Instruction object , Field f ) {
125+ fai .getObjectAddress ( ) = object and
126+ fai .getField ( ) = f
127+ }
128+
109129/** Gets the HashCons value of an address computed by `instr`, if any. */
110130TGlobalAddress globalAddress ( Instruction instr ) {
111131 result = TGlobalVariable ( instr .( VariableAddressInstruction ) .getAstVariable ( ) )
@@ -117,25 +137,27 @@ TGlobalAddress globalAddress(Instruction instr) {
117137 result = TLoad ( globalAddress ( load .getSourceAddress ( ) ) )
118138 )
119139 or
120- exists ( ConvertInstruction convert , Type fromType , Type toType | instr = convert |
121- uncheckedConversionTypes ( convert , fromType , toType ) and
122- result = TConversion ( "unchecked" , globalAddress ( convert .getUnary ( ) ) , fromType , toType )
140+ exists ( Type fromType , Type toType , Instruction unary |
141+ Conversion< ConvertInstruction > :: Using< uncheckedConversionTypes / 3 > :: hasOperandAndTypes ( instr ,
142+ unary , fromType , toType ) and
143+ result = TConversion ( "unchecked" , globalAddress ( unary ) , fromType , toType )
123144 )
124145 or
125- exists ( CheckedConvertOrNullInstruction convert , Type fromType , Type toType | instr = convert |
126- checkedConversionTypes ( convert , fromType , toType ) and
127- result = TConversion ( "checked" , globalAddress ( convert .getUnary ( ) ) , fromType , toType )
146+ exists ( Type fromType , Type toType , Instruction unary |
147+ Conversion< CheckedConvertOrNullInstruction > :: Using< checkedConversionTypes / 3 > :: hasOperandAndTypes ( instr ,
148+ unary , fromType , toType ) and
149+ result = TConversion ( "checked" , globalAddress ( unary ) , fromType , toType )
128150 )
129151 or
130- exists ( InheritanceConversionInstruction convert , Type fromType , Type toType | instr = convert |
131- inheritanceConversionTypes ( convert , fromType , toType ) and
132- result = TConversion ( "inheritance" , globalAddress ( convert .getUnary ( ) ) , fromType , toType )
152+ exists ( Type fromType , Type toType , Instruction unary |
153+ Conversion< InheritanceConversionInstruction > :: Using< inheritanceConversionTypes / 3 > :: hasOperandAndTypes ( instr ,
154+ unary , fromType , toType ) and
155+ result = TConversion ( "inheritance" , globalAddress ( unary ) , fromType , toType )
133156 )
134157 or
135- exists ( FieldAddressInstruction fai | instr = fai |
136- result =
137- TFieldAddress ( globalAddress ( pragma [ only_bind_into ] ( fai .getObjectAddress ( ) ) ) ,
138- pragma [ only_bind_out ] ( fai .getField ( ) ) )
158+ exists ( FieldAddressInstruction fai , Instruction object , Field f | instr = fai |
159+ hasObjectAndField ( fai , object , f ) and
160+ result = TFieldAddress ( globalAddress ( object ) , f )
139161 )
140162 or
141163 result = globalAddress ( instr .( PointerOffsetInstruction ) .getLeft ( ) )
0 commit comments