[IR] Simplify logic of constructing unsigned number in interpreter
This way it is a little less "hacky". We are looking only for "data" property, and as long as this property is declared in constructor, we can safely assume we will get the correct one even if it is renamed.
This commit is contained in:
+8
-6
@@ -19,7 +19,10 @@ import org.jetbrains.kotlin.ir.interpreter.intrinsics.IntrinsicEvaluator
|
|||||||
import org.jetbrains.kotlin.ir.interpreter.proxy.wrap
|
import org.jetbrains.kotlin.ir.interpreter.proxy.wrap
|
||||||
import org.jetbrains.kotlin.ir.interpreter.stack.CallStack
|
import org.jetbrains.kotlin.ir.interpreter.stack.CallStack
|
||||||
import org.jetbrains.kotlin.ir.interpreter.state.*
|
import org.jetbrains.kotlin.ir.interpreter.state.*
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||||
|
import org.jetbrains.kotlin.ir.types.isArray
|
||||||
|
import org.jetbrains.kotlin.ir.types.isUnsignedType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -89,11 +92,10 @@ internal class DefaultCallInterceptor(override val interpreter: IrInterpreter) :
|
|||||||
verify(handleIntrinsicMethods(irConstructor)) { "Unsupported intrinsic constructor: ${irConstructor.render()}" }
|
verify(handleIntrinsicMethods(irConstructor)) { "Unsupported intrinsic constructor: ${irConstructor.render()}" }
|
||||||
}
|
}
|
||||||
irClass.defaultType.isUnsignedType() -> {
|
irClass.defaultType.isUnsignedType() -> {
|
||||||
// Check for type is a hack needed for Native;
|
val propertyName = irClass.inlineClassRepresentation?.underlyingPropertyName
|
||||||
// in UInt, for example, we may have (after lowerings, I guess) additional property "$companion".
|
val propertySymbol = irClass.declarations.filterIsInstance<IrProperty>()
|
||||||
// Check for fake overrides is a hack needed for Wasm;
|
.single { it.name == propertyName && it.getter?.extensionReceiverParameter == null }
|
||||||
// in UInt, for example, we may have additional typeInfo and hashCode properties declared in "Any"
|
.symbol
|
||||||
val propertySymbol = irClass.declarations.single { it is IrProperty && !it.isFakeOverride && it.getter?.returnType?.isPrimitiveType() == true }.symbol
|
|
||||||
callStack.pushState(receiver.apply { this.setField(propertySymbol, args.single()) })
|
callStack.pushState(receiver.apply { this.setField(propertySymbol, args.single()) })
|
||||||
}
|
}
|
||||||
else -> defaultAction()
|
else -> defaultAction()
|
||||||
|
|||||||
Reference in New Issue
Block a user