[WASM] Fix invalid fields name section emit

This commit is contained in:
Igor Yakovlev
2022-06-15 18:51:15 +02:00
parent eb19d39cbf
commit bf575f73a2
@@ -168,9 +168,9 @@ class WasmIrToBinary(outputStream: OutputStream, val module: WasmModule, val mod
// Experimental fields name section // Experimental fields name section
// https://github.com/WebAssembly/gc/issues/193 // https://github.com/WebAssembly/gc/issues/193
appendSection(10u) { appendSection(10u) {
appendVectorSize(module.gcTypes.size) val structDeclarations = module.gcTypes.filterIsInstance<WasmStructDeclaration>()
module.gcTypes.forEach { appendVectorSize(structDeclarations.size)
if (it is WasmStructDeclaration) { structDeclarations.forEach {
appendModuleFieldReference(it) appendModuleFieldReference(it)
appendVectorSize(it.fields.size) appendVectorSize(it.fields.size)
it.fields.forEachIndexed { index, field -> it.fields.forEachIndexed { index, field ->
@@ -181,7 +181,6 @@ class WasmIrToBinary(outputStream: OutputStream, val module: WasmModule, val mod
} }
} }
} }
}
private fun appendInstr(instr: WasmInstr) { private fun appendInstr(instr: WasmInstr) {
val opcode = instr.operator.opcode val opcode = instr.operator.opcode