[Wasm] Extract common some logic of eqeqSymbol processing in BuiltInsLowering
This commit is contained in:
+9
-8
@@ -53,6 +53,11 @@ class BuiltInsLowering(val context: WasmBackendContext) : FileLoweringPass {
|
|||||||
return irCall(call, symbols.floatEqualityFunctions.getValue(irBuiltins.doubleType))
|
return irCall(call, symbols.floatEqualityFunctions.getValue(irBuiltins.doubleType))
|
||||||
}
|
}
|
||||||
irBuiltins.eqeqSymbol -> {
|
irBuiltins.eqeqSymbol -> {
|
||||||
|
fun callRefIsNull(expr: IrExpression): IrCall {
|
||||||
|
val refIsNull = if (expr.type.erasedUpperBound?.isExternal == true) symbols.externRefIsNull else symbols.refIsNull
|
||||||
|
return builder.irCall(refIsNull).apply { putValueArgument(0, expr) }
|
||||||
|
}
|
||||||
|
|
||||||
val lhs = call.getValueArgument(0)!!
|
val lhs = call.getValueArgument(0)!!
|
||||||
val rhs = call.getValueArgument(1)!!
|
val rhs = call.getValueArgument(1)!!
|
||||||
val lhsType = lhs.type
|
val lhsType = lhs.type
|
||||||
@@ -63,14 +68,10 @@ class BuiltInsLowering(val context: WasmBackendContext) : FileLoweringPass {
|
|||||||
return irCall(call, newSymbol)
|
return irCall(call, newSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lhs.isNullConst()) {
|
if (lhs.isNullConst()) return callRefIsNull(rhs)
|
||||||
val refIsNull = if (rhsType.erasedUpperBound?.isExternal == true) symbols.externRefIsNull else symbols.refIsNull
|
|
||||||
return builder.irCall(refIsNull).apply { putValueArgument(0, rhs) }
|
if (rhs.isNullConst()) return callRefIsNull(lhs)
|
||||||
}
|
|
||||||
if (rhs.isNullConst()) {
|
|
||||||
val refIsNull = if (lhsType.erasedUpperBound?.isExternal == true) symbols.externRefIsNull else symbols.refIsNull
|
|
||||||
return builder.irCall(refIsNull).apply { putValueArgument(0, lhs) }
|
|
||||||
}
|
|
||||||
if (!lhsType.isNullable()) {
|
if (!lhsType.isNullable()) {
|
||||||
return irCall(call, lhsType.findEqualsMethod().symbol, argumentsAsReceivers = true)
|
return irCall(call, lhsType.findEqualsMethod().symbol, argumentsAsReceivers = true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user