Implement interpretation of Char and Long classes from js stdlib
This commit is contained in:
+14
-1
@@ -458,7 +458,20 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
||||
val owner = constructorCall.symbol.owner
|
||||
val parent = owner.parent as IrClass
|
||||
if (parent.hasAnnotation(evaluateIntrinsicAnnotation)) {
|
||||
return Wrapper.getConstructorMethod(owner).invokeMethod(owner, newFrame).apply { data.pushReturnValue(newFrame) }
|
||||
return when (constructorCall.symbol.owner.parentAsClass.getEvaluateIntrinsicValue()) {
|
||||
"kotlin.Long" -> {
|
||||
val low = (valueParameters[0].state as Primitive<*>).value as Int
|
||||
val high = (valueParameters[1].state as Primitive<*>).value as Int
|
||||
data.pushReturnValue((high.toLong().shl(32) + low).toState(irBuiltIns.longType))
|
||||
Code.NEXT
|
||||
}
|
||||
"kotlin.Char" -> {
|
||||
val value = (valueParameters.single().state as Primitive<*>).value as Int
|
||||
data.pushReturnValue(value.toChar().toState(irBuiltIns.longType))
|
||||
Code.NEXT
|
||||
}
|
||||
else -> Wrapper.getConstructorMethod(owner).invokeMethod(owner, newFrame).apply { data.pushReturnValue(newFrame) }
|
||||
}
|
||||
}
|
||||
|
||||
if (parent.defaultType.isArray() || parent.defaultType.isPrimitiveArray()) {
|
||||
|
||||
+1
-1
@@ -228,9 +228,9 @@ class Wrapper(val value: Any, override val irClass: IrClass) : Complex(irClass,
|
||||
val fqName = this.getFqName()
|
||||
val owner = this.classOrNull?.owner
|
||||
return when {
|
||||
owner.hasAnnotation(evaluateIntrinsicAnnotation) -> Class.forName(owner!!.getEvaluateIntrinsicValue())
|
||||
this.isPrimitiveType() -> getPrimitiveClass(fqName!!, asObject)
|
||||
this.isArray() -> if (asObject) Array<Any?>::class.javaObjectType else Array<Any?>::class.java
|
||||
owner.hasAnnotation(evaluateIntrinsicAnnotation) -> Class.forName(owner!!.getEvaluateIntrinsicValue())
|
||||
//TODO primitive array
|
||||
this.isTypeParameter() -> Any::class.java
|
||||
else -> JavaToKotlinClassMap.mapKotlinToJava(FqNameUnsafe(fqName!!))?.let { Class.forName(it.asSingleFqName().toString()) }
|
||||
|
||||
Reference in New Issue
Block a user