[Wasm] Require location for buildStructSet and fix all usages
This commit is contained in:
+4
-1
@@ -220,17 +220,20 @@ class BodyGenerator(
|
||||
val field = expression.symbol.owner
|
||||
val receiver = expression.receiver
|
||||
|
||||
val location = expression.getSourceLocation()
|
||||
|
||||
if (receiver != null) {
|
||||
generateExpression(receiver)
|
||||
generateExpression(expression.value)
|
||||
body.buildStructSet(
|
||||
struct = context.referenceGcType(field.parentAsClass.symbol),
|
||||
fieldId = context.getStructFieldRef(field),
|
||||
location
|
||||
)
|
||||
body.commentPreviousInstr { "name: ${field.name}, type: ${field.type.render()}" }
|
||||
} else {
|
||||
generateExpression(expression.value)
|
||||
body.buildSetGlobal(context.referenceGlobalField(expression.symbol), expression.getSourceLocation())
|
||||
body.buildSetGlobal(context.referenceGlobalField(expression.symbol), location)
|
||||
body.commentPreviousInstr { "type: ${field.type.render()}" }
|
||||
}
|
||||
|
||||
|
||||
@@ -158,9 +158,10 @@ abstract class WasmExpressionBuilder {
|
||||
buildInstr(WasmOp.STRUCT_NEW, location, WasmImmediate.GcType(struct))
|
||||
}
|
||||
|
||||
fun buildStructSet(struct: WasmSymbol<WasmTypeDeclaration>, fieldId: WasmSymbol<Int>) {
|
||||
fun buildStructSet(struct: WasmSymbol<WasmTypeDeclaration>, fieldId: WasmSymbol<Int>, location: SourceLocation) {
|
||||
buildInstr(
|
||||
WasmOp.STRUCT_SET,
|
||||
location,
|
||||
WasmImmediate.GcType(struct),
|
||||
WasmImmediate.StructFieldIdx(fieldId)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user