Change signature in getArgsForMethodInvocation method
This commit is contained in:
+2
-2
@@ -152,7 +152,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
||||
|
||||
private suspend fun MethodHandle?.invokeMethod(irFunction: IrFunction, data: Frame): ExecutionResult {
|
||||
this ?: return handleIntrinsicMethods(irFunction, data)
|
||||
val result = this.invokeWithArguments(irFunction.getArgsForMethodInvocation(data))
|
||||
val result = this.invokeWithArguments(irFunction.getArgsForMethodInvocation(data.getAll()))
|
||||
data.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
|
||||
return Next
|
||||
@@ -165,7 +165,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
||||
data.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
}
|
||||
"arrayOf" -> {
|
||||
val result = irFunction.getArgsForMethodInvocation(data).toTypedArray()
|
||||
val result = irFunction.getArgsForMethodInvocation(data.getAll()).toTypedArray()
|
||||
data.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
}
|
||||
"arrayOfNulls" -> {
|
||||
|
||||
+4
-5
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.backend.common.interpreter
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.builtins.evaluateIntrinsicAnnotation
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.*
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.stack.Variable
|
||||
import org.jetbrains.kotlin.backend.common.interpreter.state.*
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -178,8 +178,8 @@ fun IrType.getFqName(): String? {
|
||||
return this.classOrNull?.owner?.fqNameForIrSerialization?.asString()
|
||||
}
|
||||
|
||||
fun IrFunction.getArgsForMethodInvocation(data: Frame): List<Any?> {
|
||||
val argsValues = data.getAll().map {
|
||||
fun IrFunction.getArgsForMethodInvocation(args: List<Variable>): List<Any?> {
|
||||
val argsValues = args.map {
|
||||
when (val state = it.state) {
|
||||
is ExceptionState -> state.getThisAsCauseForException()
|
||||
is Wrapper -> state.value
|
||||
@@ -191,9 +191,8 @@ fun IrFunction.getArgsForMethodInvocation(data: Frame): List<Any?> {
|
||||
// TODO if vararg isn't last parameter
|
||||
// must convert vararg array into separated elements for correct invoke
|
||||
if (this.valueParameters.lastOrNull()?.varargElementType != null) {
|
||||
val varargValue = argsValues.last()
|
||||
argsValues.removeAt(argsValues.size - 1)
|
||||
val varargState = data.getVariableState(this.valueParameters.last().descriptor)
|
||||
val varargValue = (varargState as? Wrapper)?.value ?: (varargState as Primitive<*>).value
|
||||
argsValues.addAll(varargValue as Array<out Any?>)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user