Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit f7ea587

Browse files
aheejinrossberg
authored andcommitted
[test] Exception -> Tag in wasm-module-builder.js
The section name has changed to the tag section a few years ago. This adds the corresponding changes added in WebAssembly/exception-handling#252 and WebAssembly/exception-handling#256.
1 parent f7ac90b commit f7ea587

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

test/js-api/wasm-module-builder.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let kElementSectionCode = 9; // Elements section
6565
let kCodeSectionCode = 10; // Function code
6666
let kDataSectionCode = 11; // Data segments
6767
let kDataCountSectionCode = 12; // Data segment count (between Element & Code)
68-
let kExceptionSectionCode = 13; // Exception section (between Global & Export)
68+
let kTagSectionCode = 13; // Tag section (between Memory & Global)
6969

7070
// Name section types
7171
let kModuleNameCode = 0;
@@ -104,13 +104,13 @@ let kExternalFunction = 0;
104104
let kExternalTable = 1;
105105
let kExternalMemory = 2;
106106
let kExternalGlobal = 3;
107-
let kExternalException = 4;
107+
let kExternalTag = 4;
108108

109109
let kTableZero = 0;
110110
let kMemoryZero = 0;
111111
let kSegmentZero = 0;
112112

113-
let kExceptionAttribute = 0;
113+
let kTagAttribute = 0;
114114

115115
// Useful signatures
116116
let kSig_i_i = makeSig([kWasmI32], [kWasmI32]);
@@ -681,15 +681,15 @@ class WasmModuleBuilder {
681681
this.exports = [];
682682
this.globals = [];
683683
this.tables = [];
684-
this.exceptions = [];
684+
this.tags = [];
685685
this.functions = [];
686686
this.element_segments = [];
687687
this.data_segments = [];
688688
this.explicit = [];
689689
this.num_imported_funcs = 0;
690690
this.num_imported_globals = 0;
691691
this.num_imported_tables = 0;
692-
this.num_imported_exceptions = 0;
692+
this.num_imported_tags = 0;
693693
return this;
694694
}
695695

@@ -752,11 +752,11 @@ class WasmModuleBuilder {
752752
return table;
753753
}
754754

755-
addException(type) {
755+
addTag(type) {
756756
let type_index = (typeof type) == "number" ? type : this.addType(type);
757-
let except_index = this.exceptions.length + this.num_imported_exceptions;
758-
this.exceptions.push(type_index);
759-
return except_index;
757+
let tag_index = this.tags.length + this.num_imported_tags;
758+
this.tags.push(type_index);
759+
return tag_index;
760760
}
761761

762762
addFunction(name, type) {
@@ -804,14 +804,14 @@ class WasmModuleBuilder {
804804
return this.num_imported_tables++;
805805
}
806806

807-
addImportedException(module, name, type) {
808-
if (this.exceptions.length != 0) {
809-
throw new Error('Imported exceptions must be declared before local ones');
807+
addImportedTag(module, name, type) {
808+
if (this.tags.length != 0) {
809+
throw new Error('Imported tags must be declared before local ones');
810810
}
811811
let type_index = (typeof type) == "number" ? type : this.addType(type);
812-
let o = {module: module, name: name, kind: kExternalException, type: type_index};
812+
let o = {module: module, name: name, kind: kExternalTag, type: type_index};
813813
this.imports.push(o);
814-
return this.num_imported_exceptions++;
814+
return this.num_imported_tags++;
815815
}
816816

817817
addExport(name, index) {
@@ -938,8 +938,8 @@ class WasmModuleBuilder {
938938
section.emit_u8(has_max ? 1 : 0); // flags
939939
section.emit_u32v(imp.initial); // initial
940940
if (has_max) section.emit_u32v(imp.maximum); // maximum
941-
} else if (imp.kind == kExternalException) {
942-
section.emit_u32v(kExceptionAttribute);
941+
} else if (imp.kind == kExternalTag) {
942+
section.emit_u32v(kTagAttribute);
943943
section.emit_u32v(imp.type);
944944
} else {
945945
throw new Error("unknown/unsupported import kind " + imp.kind);
@@ -1036,13 +1036,13 @@ class WasmModuleBuilder {
10361036
});
10371037
}
10381038

1039-
// Add exceptions.
1040-
if (wasm.exceptions.length > 0) {
1041-
if (debug) print("emitting exceptions @ " + binary.length);
1042-
binary.emit_section(kExceptionSectionCode, section => {
1043-
section.emit_u32v(wasm.exceptions.length);
1044-
for (let type of wasm.exceptions) {
1045-
section.emit_u32v(kExceptionAttribute);
1039+
// Add tags.
1040+
if (wasm.tags.length > 0) {
1041+
if (debug) print("emitting tags @ " + binary.length);
1042+
binary.emit_section(kTagSectionCode, section => {
1043+
section.emit_u32v(wasm.tags.length);
1044+
for (let type of wasm.tags) {
1045+
section.emit_u32v(kTagAttribute);
10461046
section.emit_u32v(type);
10471047
}
10481048
});

0 commit comments

Comments
 (0)