Skip to content

Commit

Permalink
Sync emit_type
Browse files Browse the repository at this point in the history
  • Loading branch information
aheejin committed Jun 21, 2024
1 parent dcd8076 commit b23a5ea
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/js-api/wasm-module-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,16 @@ class Binary {
}
}

emit_type(type) {
if ((typeof type) == 'number') {
this.emit_u8(type >= 0 ? type : type & kLeb128Mask);
} else {
this.emit_u8(type.opcode);
if ('depth' in type) this.emit_u8(type.depth);
this.emit_heap_type(type.heap_type);
}
}

emit_header() {
this.emit_bytes([
kWasmH0, kWasmH1, kWasmH2, kWasmH3, kWasmV0, kWasmV1, kWasmV2, kWasmV3
Expand Down Expand Up @@ -925,11 +935,11 @@ class WasmModuleBuilder {
section.emit_u8(kWasmFunctionTypeForm);
section.emit_u32v(type.params.length);
for (let param of type.params) {
section.emit_u8(param);
section.emit_type(param);
}
section.emit_u32v(type.results.length);
for (let result of type.results) {
section.emit_u8(result);
section.emit_type(result);
}
}
});
Expand Down

0 comments on commit b23a5ea

Please sign in to comment.