@@ -69,10 +69,12 @@ import org.opalj.tac.StaticFunctionCall
6969import org .opalj .tac .StaticMethodCall
7070import org .opalj .tac .StringConst
7171import org .opalj .tac .UVar
72+ import org .opalj .tac .V
7273import org .opalj .tac .Var
7374import org .opalj .tac .VirtualFunctionCall
7475import org .opalj .tac .VirtualMethodCall
7576import org .opalj .value .IsSReferenceValue
77+ import org .opalj .value .ValueInformation
7678
7779object ExprProcessor {
7880
@@ -84,17 +86,18 @@ object ExprProcessor {
8486 * @param code list where bytecode instructions should be added
8587 */
8688 def processExpression (
87- expr : Expr [_ ],
88- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
89+ expr : Expr [V ],
90+ uVarToLVIndex : Map [IntTrieSet , Int ],
8991 code : mutable.ListBuffer [CodeElement [Nothing ]]
9092 ): Unit = {
9193 expr match {
9294 case const : Const => loadConstant(const, code)
93- case variable : Var [_ ] => loadVariable(variable, uVarToLVIndex, code)
94- case getField : GetField [_ ] => processGetField(getField, uVarToLVIndex, code)
95+ case variable : Var [V ] => loadVariable(variable, uVarToLVIndex, code)
96+ case getField : GetField [V ] => processGetField(getField, uVarToLVIndex, code)
9597 case getStatic : GetStatic => processGetStatic(getStatic, code)
96- case binaryExpr : BinaryExpr [_] => processBinaryExpr(binaryExpr, uVarToLVIndex, code)
97- case call @ Call (declaringClass, isInterface, name, descriptor) =>
98+ case binaryExpr : BinaryExpr [V ] => processBinaryExpr(binaryExpr, uVarToLVIndex, code)
99+ case callExpr : Call [V @ unchecked] =>
100+ val call @ Call (declaringClass, isInterface, name, descriptor) = callExpr
98101 processCall(
99102 call,
100103 declaringClass,
@@ -105,33 +108,33 @@ object ExprProcessor {
105108 code
106109 )
107110 case newExpr : New => processNewExpr(newExpr.tpe, code)
108- case primitiveTypecastExpr : PrimitiveTypecastExpr [_ ] =>
111+ case primitiveTypecastExpr : PrimitiveTypecastExpr [V ] =>
109112 processPrimitiveTypeCastExpr(primitiveTypecastExpr, uVarToLVIndex, code)
110- case arrayLength : ArrayLength [_ ] => processArrayLength(arrayLength, uVarToLVIndex, code)
111- case arrayLoadExpr : ArrayLoad [_ ] => processArrayLoad(arrayLoadExpr, uVarToLVIndex, code)
112- case newArrayExpr : NewArray [_ ] => processNewArray(newArrayExpr, uVarToLVIndex, code)
113- case invokedynamicFunctionCall : InvokedynamicFunctionCall [_ ] =>
113+ case arrayLength : ArrayLength [V ] => processArrayLength(arrayLength, uVarToLVIndex, code)
114+ case arrayLoadExpr : ArrayLoad [V ] => processArrayLoad(arrayLoadExpr, uVarToLVIndex, code)
115+ case newArrayExpr : NewArray [V ] => processNewArray(newArrayExpr, uVarToLVIndex, code)
116+ case invokedynamicFunctionCall : InvokedynamicFunctionCall [V ] =>
114117 processInvokedynamicFunctionCall(invokedynamicFunctionCall, uVarToLVIndex, code)
115- case compare : Compare [_ ] => processCompare(compare, uVarToLVIndex, code)
116- case prefixExpr : PrefixExpr [_ ] => processPrefixExpr(prefixExpr, uVarToLVIndex, code)
117- case instanceOf : InstanceOf [_ ] => processInstanceOf(instanceOf, uVarToLVIndex, code)
118+ case compare : Compare [V ] => processCompare(compare, uVarToLVIndex, code)
119+ case prefixExpr : PrefixExpr [V ] => processPrefixExpr(prefixExpr, uVarToLVIndex, code)
120+ case instanceOf : InstanceOf [V ] => processInstanceOf(instanceOf, uVarToLVIndex, code)
118121 case _ =>
119122 throw new UnsupportedOperationException (" Unsupported expression type" + expr)
120123 }
121124 }
122125
123126 private def processInstanceOf (
124- instanceOf : InstanceOf [_ ],
125- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
127+ instanceOf : InstanceOf [V ],
128+ uVarToLVIndex : Map [IntTrieSet , Int ],
126129 code : mutable.ListBuffer [CodeElement [Nothing ]]
127130 ): Unit = {
128131 ExprProcessor .processExpression(instanceOf.value, uVarToLVIndex, code)
129132 code += INSTANCEOF (instanceOf.cmpTpe)
130133 }
131134
132135 private def processPrefixExpr (
133- prefixExpr : PrefixExpr [_ ],
134- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
136+ prefixExpr : PrefixExpr [V ],
137+ uVarToLVIndex : Map [IntTrieSet , Int ],
135138 code : mutable.ListBuffer [CodeElement [Nothing ]]
136139 ): Unit = {
137140 // Process the operand (the expression being negated)
@@ -150,8 +153,8 @@ object ExprProcessor {
150153 }
151154
152155 private def processCompare (
153- compare : Compare [_ ],
154- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
156+ compare : Compare [V ],
157+ uVarToLVIndex : Map [IntTrieSet , Int ],
155158 code : mutable.ListBuffer [CodeElement [Nothing ]]
156159 ): Unit = {
157160 // Process the left expression
@@ -181,8 +184,8 @@ object ExprProcessor {
181184 }
182185
183186 private def processInvokedynamicFunctionCall (
184- invokedynamicFunctionCall : InvokedynamicFunctionCall [_ ],
185- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
187+ invokedynamicFunctionCall : InvokedynamicFunctionCall [V ],
188+ uVarToLVIndex : Map [IntTrieSet , Int ],
186189 code : mutable.ListBuffer [CodeElement [Nothing ]]
187190 ): Unit = {
188191 // Process each parameter
@@ -196,8 +199,8 @@ object ExprProcessor {
196199 }
197200
198201 private def processNewArray (
199- newArrayExpr : NewArray [_ ],
200- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
202+ newArrayExpr : NewArray [V ],
203+ uVarToLVIndex : Map [IntTrieSet , Int ],
201204 code : mutable.ListBuffer [CodeElement [Nothing ]]
202205 ): Unit = {
203206 // Process each parameter
@@ -215,8 +218,8 @@ object ExprProcessor {
215218 }
216219
217220 private def processArrayLoad (
218- arrayLoadExpr : ArrayLoad [_ ],
219- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
221+ arrayLoadExpr : ArrayLoad [V ],
222+ uVarToLVIndex : Map [IntTrieSet , Int ],
220223 code : mutable.ListBuffer [CodeElement [Nothing ]]
221224 ): Unit = {
222225 // Load the array reference onto the stack
@@ -241,15 +244,15 @@ object ExprProcessor {
241244 }
242245
243246 // Helper function to infer the element type from the array reference expression
244- def inferElementType (expr : Expr [_ ]): Type = {
245- expr.asInstanceOf [ UVar [_]] .value.asInstanceOf [IsSReferenceValue [_]].theUpperTypeBound. asInstanceOf [ ArrayType ] match {
247+ def inferElementType (expr : Expr [V ]): Type = {
248+ expr.asVar .value.asInstanceOf [IsSReferenceValue [_]].theUpperTypeBound match {
246249 case ArrayType (componentType) => componentType
247250 case _ => throw new IllegalArgumentException (s " Expected an array type but found: ${expr.cTpe}" )
248251 }
249252 }
250253 private def processArrayLength (
251- arrayLength : ArrayLength [_ ],
252- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
254+ arrayLength : ArrayLength [V ],
255+ uVarToLVIndex : Map [IntTrieSet , Int ],
253256 code : mutable.ListBuffer [CodeElement [Nothing ]]
254257 ): Unit = {
255258 // Process the receiver object (e.g., aload_0 for `this`)
@@ -265,24 +268,26 @@ object ExprProcessor {
265268 }
266269
267270 def processCall (
268- call : Call [_ ],
271+ call : Call [V ],
269272 declaringClass : ReferenceType ,
270273 isInterface : Boolean ,
271274 methodName : String ,
272275 methodDescriptor : MethodDescriptor ,
273- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
276+ uVarToLVIndex : Map [IntTrieSet , Int ],
274277 code : mutable.ListBuffer [CodeElement [Nothing ]]
275278 ): Unit = {
276279 // Process each parameter
277280 for (param <- call.allParams) ExprProcessor .processExpression(param, uVarToLVIndex, code)
278- code += call match {
279- case _ : VirtualMethodCall [_] | _ : VirtualFunctionCall [_] =>
280- if (isInterface) INVOKEINTERFACE (declaringClass.asObjectType, methodName, methodDescriptor)
281- else INVOKEVIRTUAL (declaringClass, methodName, methodDescriptor)
282- case _ : NonVirtualMethodCall [_] | _ : NonVirtualFunctionCall [_] =>
283- INVOKESPECIAL (declaringClass.asObjectType, isInterface, methodName, methodDescriptor)
284- case _ : StaticMethodCall [_] | _ : StaticFunctionCall [_] =>
285- INVOKESTATIC (declaringClass.asObjectType, isInterface, methodName, methodDescriptor)
281+ code += {
282+ call match {
283+ case _ : VirtualMethodCall [V ] | _ : VirtualFunctionCall [V ] =>
284+ if (isInterface) INVOKEINTERFACE (declaringClass.asObjectType, methodName, methodDescriptor)
285+ else INVOKEVIRTUAL (declaringClass, methodName, methodDescriptor)
286+ case _ : NonVirtualMethodCall [V ] | _ : NonVirtualFunctionCall [V ] =>
287+ INVOKESPECIAL (declaringClass.asObjectType, isInterface, methodName, methodDescriptor)
288+ case _ : StaticMethodCall [V ] | _ : StaticFunctionCall [V ] =>
289+ INVOKESTATIC (declaringClass.asObjectType, isInterface, methodName, methodDescriptor)
290+ }
286291 }
287292 }
288293
@@ -312,13 +317,13 @@ object ExprProcessor {
312317 }
313318
314319 // Method to get LVIndex for a variable
315- private def getVariableLvIndex (variable : Var [_ ], uVarToLVIndex : mutable. Map [IntTrieSet , Int ]): Int = {
320+ private def getVariableLvIndex (variable : Var [V ], uVarToLVIndex : Map [IntTrieSet , Int ]): Int = {
316321 variable match {
317- case duVar : DUVar [_ ] =>
322+ case duVar : DUVar [ValueInformation ] =>
318323 val uVarDefSites = uVarToLVIndex.find { case (defSites, _) =>
319324 duVar match {
320- case dVar : DVar [_ ] => defSites.contains(dVar.origin )
321- case uVar : UVar [_ ] => defSites.exists(uVar.defSites .contains)
325+ case dVar : DVar [ValueInformation ] => defSites.contains(dVar.originatedAt )
326+ case uVar : UVar [ValueInformation ] => defSites.exists(uVar.definedBy .contains)
322327 }
323328 }
324329 uVarDefSites match {
@@ -330,8 +335,8 @@ object ExprProcessor {
330335 }
331336
332337 private def loadVariable (
333- variable : Var [_ ],
334- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
338+ variable : Var [V ],
339+ uVarToLVIndex : Map [IntTrieSet , Int ],
335340 code : mutable.ListBuffer [CodeElement [Nothing ]]
336341 ): Unit = {
337342 val index = getVariableLvIndex(variable, uVarToLVIndex)
@@ -351,8 +356,8 @@ object ExprProcessor {
351356 }
352357
353358 def storeVariable (
354- variable : Var [_ ],
355- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
359+ variable : Var [V ],
360+ uVarToLVIndex : Map [IntTrieSet , Int ],
356361 code : mutable.ListBuffer [CodeElement [Nothing ]]
357362 ): Unit = {
358363 val index : Int = getVariableLvIndex(variable, uVarToLVIndex)
@@ -372,8 +377,8 @@ object ExprProcessor {
372377 }
373378
374379 private def processGetField (
375- getField : GetField [_ ],
376- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
380+ getField : GetField [V ],
381+ uVarToLVIndex : Map [IntTrieSet , Int ],
377382 code : mutable.ListBuffer [CodeElement [Nothing ]]
378383 ): Unit = {
379384 // Load the object reference onto the stack
@@ -390,8 +395,8 @@ object ExprProcessor {
390395 }
391396
392397 private def processBinaryExpr (
393- binaryExpr : BinaryExpr [_ ],
394- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
398+ binaryExpr : BinaryExpr [V ],
399+ uVarToLVIndex : Map [IntTrieSet , Int ],
395400 code : mutable.ListBuffer [CodeElement [Nothing ]]
396401 ): Unit = {
397402 // process the left expr and save the pc to give in the right expr processing
@@ -445,8 +450,8 @@ object ExprProcessor {
445450 }
446451 }
447452 private def processPrimitiveTypeCastExpr (
448- primitiveTypecastExpr : PrimitiveTypecastExpr [_ ],
449- uVarToLVIndex : mutable. Map [IntTrieSet , Int ],
453+ primitiveTypecastExpr : PrimitiveTypecastExpr [V ],
454+ uVarToLVIndex : Map [IntTrieSet , Int ],
450455 code : mutable.ListBuffer [CodeElement [Nothing ]]
451456 ): Unit = {
452457 // First, process the operand expression and add its instructions to the buffer
0 commit comments