Add correct interpretation for unsigned arrays in vararg method handler
This commit is contained in:
+16
-1
@@ -648,7 +648,22 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
||||
else -> listOf(result)
|
||||
}
|
||||
}
|
||||
stack.pushReturnValue(args.toPrimitiveStateArray(expression.type))
|
||||
|
||||
val array = when (expression.type.classifierOrFail.descriptor.name.asString()) {
|
||||
"UByteArray", "UShortArray", "UIntArray", "ULongArray" -> {
|
||||
val owner = expression.type.classOrNull!!.owner
|
||||
val constructor = owner.primaryConstructor!!
|
||||
val storageParameter = constructor.valueParameters.single()
|
||||
val primitiveArray = args.map { ((it as Common).fields.single().state as Primitive<*>).value }
|
||||
val unsignedArray = primitiveArray.toPrimitiveStateArray(storageParameter.type)
|
||||
Common(owner).apply {
|
||||
setSuperClassRecursive()
|
||||
fields.add(Variable(storageParameter.descriptor, unsignedArray))
|
||||
}
|
||||
}
|
||||
else -> args.toPrimitiveStateArray(expression.type)
|
||||
}
|
||||
stack.pushReturnValue(array)
|
||||
return Next
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -193,7 +193,9 @@ object ArrayConstructor : IntrinsicBase() {
|
||||
for (i in 0 until size) {
|
||||
val indexVar = listOf(Variable(index.descriptor, i.toState(index.type)))
|
||||
// TODO throw exception if label != RETURN
|
||||
stack.newFrame(initPool = indexVar) { initLambda.irFunction.body!!.interpret() }.check(ReturnLabel.RETURN) { return it }
|
||||
stack.newFrame(asSubFrame = initLambda.irFunction.isLocal || initLambda.irFunction.isInline, initPool = indexVar) {
|
||||
initLambda.irFunction.body!!.interpret()
|
||||
}.check(ReturnLabel.RETURN) { return it }
|
||||
arrayValue[i] = stack.popReturnValue().let { (it as? Wrapper)?.value ?: (it as? Primitive<*>)?.value ?: it }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user