JVM IR: do not use AsmUtil.genToString
AsmUtil.genToString requires an instance of KotlinTypeMapper and calls KotlinTypeMapper.mapToCallableMethod inside, which (in subsequent commits) we're getting rid of in the IR backend
This commit is contained in:
+16
-10
@@ -695,17 +695,17 @@ class ExpressionCodegen(
|
|||||||
// Convert single arg to string.
|
// Convert single arg to string.
|
||||||
val arg = expression.arguments[0]
|
val arg = expression.arguments[0]
|
||||||
val result = arg.accept(this, data).boxInlineClasses(arg.type).materialized
|
val result = arg.accept(this, data).boxInlineClasses(arg.type).materialized
|
||||||
if (!arg.type.isString())
|
if (!arg.type.isString()) {
|
||||||
AsmUtil.genToString(StackValue.onStack(result.type), result.type, result.kotlinType, typeMapper.kotlinTypeMapper)
|
result.genToString(mv)
|
||||||
.put(expression.asmType, mv)
|
}
|
||||||
}
|
}
|
||||||
arity == 2 && expression.arguments[0].type.isStringClassType() -> {
|
arity == 2 && expression.arguments[0].type.isStringClassType() -> {
|
||||||
// Call the stringPlus intrinsic
|
// Call the stringPlus intrinsic
|
||||||
expression.arguments.forEach {
|
for (argument in expression.arguments) {
|
||||||
val result = it.accept(this, data).boxInlineClasses(it.type).materialized
|
val result = argument.accept(this, data).boxInlineClasses(argument.type).materialized
|
||||||
val type = result.type
|
if (result.type.sort != Type.OBJECT) {
|
||||||
if (type.sort != Type.OBJECT)
|
result.genToString(mv)
|
||||||
AsmUtil.genToString(StackValue.onStack(type), type, result.kotlinType, typeMapper.kotlinTypeMapper).put(expression.asmType, mv)
|
}
|
||||||
}
|
}
|
||||||
mv.invokestatic(
|
mv.invokestatic(
|
||||||
IrIntrinsicMethods.INTRINSICS_CLASS_NAME,
|
IrIntrinsicMethods.INTRINSICS_CLASS_NAME,
|
||||||
@@ -717,8 +717,8 @@ class ExpressionCodegen(
|
|||||||
else -> {
|
else -> {
|
||||||
// Use StringBuilder to concatenate.
|
// Use StringBuilder to concatenate.
|
||||||
genStringBuilderConstructor(mv)
|
genStringBuilderConstructor(mv)
|
||||||
expression.arguments.forEach {
|
for (argument in expression.arguments) {
|
||||||
genInvokeAppendMethod(mv, it.accept(this, data).boxInlineClasses(it.type).materialized.type, null)
|
genInvokeAppendMethod(mv, argument.accept(this, data).boxInlineClasses(argument.type).materialized.type, null)
|
||||||
}
|
}
|
||||||
mv.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false)
|
mv.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false)
|
||||||
}
|
}
|
||||||
@@ -726,6 +726,12 @@ class ExpressionCodegen(
|
|||||||
return expression.onStack
|
return expression.onStack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun MaterialValue.genToString(v: InstructionAdapter) {
|
||||||
|
val asmType =
|
||||||
|
if (irType.getClass()?.isInline == true) OBJECT_TYPE else stringValueOfType(type)
|
||||||
|
v.invokestatic("java/lang/String", "valueOf", Type.getMethodDescriptor(AsmTypes.JAVA_STRING_TYPE, asmType), false)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitWhileLoop(loop: IrWhileLoop, data: BlockInfo): PromisedValue {
|
override fun visitWhileLoop(loop: IrWhileLoop, data: BlockInfo): PromisedValue {
|
||||||
val continueLabel = markNewLabel()
|
val continueLabel = markNewLabel()
|
||||||
val endLabel = Label()
|
val endLabel = Label()
|
||||||
|
|||||||
Reference in New Issue
Block a user