[Wasm] Require location for buildStructNew and fix all usages
This commit is contained in:
+10
-7
@@ -134,9 +134,10 @@ class BodyGenerator(
|
||||
|
||||
check(wasmArrayType != null)
|
||||
|
||||
generateAnyParameters(arrayClass.symbol, expression.getSourceLocation())
|
||||
val location = expression.getSourceLocation()
|
||||
generateAnyParameters(arrayClass.symbol, location)
|
||||
if (!tryGenerateConstVarargArray(expression, wasmArrayType)) tryGenerateVarargArray(expression, wasmArrayType)
|
||||
body.buildStructNew(context.referenceGcType(expression.type.getRuntimeClass(irBuiltIns).symbol))
|
||||
body.buildStructNew(context.referenceGcType(expression.type.getRuntimeClass(irBuiltIns).symbol), location)
|
||||
}
|
||||
|
||||
override fun visitThrow(expression: IrThrow) {
|
||||
@@ -284,11 +285,12 @@ class BodyGenerator(
|
||||
}
|
||||
|
||||
if (expression.symbol.owner.hasWasmPrimitiveConstructorAnnotation()) {
|
||||
generateAnyParameters(klassSymbol, expression.getSourceLocation())
|
||||
val location = expression.getSourceLocation()
|
||||
generateAnyParameters(klassSymbol, location)
|
||||
for (i in 0 until expression.valueArgumentsCount) {
|
||||
generateExpression(expression.getValueArgument(i)!!)
|
||||
}
|
||||
body.buildStructNew(wasmGcType)
|
||||
body.buildStructNew(wasmGcType, location)
|
||||
body.commentPreviousInstr { "@WasmPrimitiveConstructor ctor call: ${klass.fqNameWhenAvailable}" }
|
||||
return
|
||||
}
|
||||
@@ -329,7 +331,7 @@ class BodyGenerator(
|
||||
generateDefaultInitializerForType(context.transformType(field.type), body)
|
||||
}
|
||||
}
|
||||
body.buildStructNew(context.referenceGcType(parentClass.symbol))
|
||||
body.buildStructNew(context.referenceGcType(parentClass.symbol), location)
|
||||
body.buildSetLocal(thisParameter, location)
|
||||
body.buildEnd()
|
||||
}
|
||||
@@ -351,9 +353,10 @@ class BodyGenerator(
|
||||
|
||||
private fun generateBox(expression: IrExpression, type: IrType) {
|
||||
val klassSymbol = type.getRuntimeClass(irBuiltIns).symbol
|
||||
generateAnyParameters(klassSymbol, expression.getSourceLocation())
|
||||
val location = expression.getSourceLocation()
|
||||
generateAnyParameters(klassSymbol, location)
|
||||
generateExpression(expression)
|
||||
body.buildStructNew(context.referenceGcType(klassSymbol))
|
||||
body.buildStructNew(context.referenceGcType(klassSymbol), location)
|
||||
body.commentPreviousInstr { "box" }
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -269,7 +269,7 @@ class DeclarationGenerator(
|
||||
buildRefNull(vtableStruct.fields[i].type.getHeapType())
|
||||
}
|
||||
}
|
||||
buildStructNew(vTableTypeReference)
|
||||
buildStructNew(vTableTypeReference, SourceLocation.NoLocation("Create instance of vtable struct"))
|
||||
}
|
||||
context.defineGlobalVTable(
|
||||
irClass = symbol,
|
||||
@@ -278,6 +278,7 @@ class DeclarationGenerator(
|
||||
}
|
||||
|
||||
private fun createClassITable(metadata: ClassMetadata) {
|
||||
val location = SourceLocation.NoLocation("Create instance of itable struct")
|
||||
val klass = metadata.klass
|
||||
if (klass.isAbstractOrSealed) return
|
||||
val supportedInterface = metadata.interfaces.firstOrNull()?.symbol ?: return
|
||||
@@ -313,9 +314,9 @@ class DeclarationGenerator(
|
||||
buildRefNull(WasmHeapType.Type(context.referenceFunctionType(method.function.symbol)))
|
||||
}
|
||||
}
|
||||
buildStructNew(iFaceVTableGcType)
|
||||
buildStructNew(iFaceVTableGcType, location)
|
||||
}
|
||||
buildStructNew(classInterfaceType)
|
||||
buildStructNew(classInterfaceType, location)
|
||||
}
|
||||
|
||||
val wasmClassIFaceGlobal = WasmGlobal(
|
||||
|
||||
@@ -153,8 +153,8 @@ abstract class WasmExpressionBuilder {
|
||||
)
|
||||
}
|
||||
|
||||
fun buildStructNew(struct: WasmSymbol<WasmTypeDeclaration>) {
|
||||
buildInstr(WasmOp.STRUCT_NEW, WasmImmediate.GcType(struct))
|
||||
fun buildStructNew(struct: WasmSymbol<WasmTypeDeclaration>, location: SourceLocation) {
|
||||
buildInstr(WasmOp.STRUCT_NEW, location, WasmImmediate.GcType(struct))
|
||||
}
|
||||
|
||||
fun buildStructSet(struct: WasmSymbol<WasmTypeDeclaration>, fieldId: WasmSymbol<Int>) {
|
||||
|
||||
Reference in New Issue
Block a user