summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp44
1 files changed, 4 insertions, 40 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 40bd6288d..7da6ae0a5 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -49,11 +49,9 @@ int unhex(char c) {
namespace wasm {
-static Name STRUCT("struct"), FIELD("field"), ARRAY("array"),
- FUNC_SUBTYPE("func_subtype"), STRUCT_SUBTYPE("struct_subtype"),
- ARRAY_SUBTYPE("array_subtype"), EXTENDS("extends"), REC("rec"), I8("i8"),
- I16("i16"), DECLARE("declare"), ITEM("item"), OFFSET("offset"), SUB("sub"),
- FINAL("final");
+static Name STRUCT("struct"), FIELD("field"), ARRAY("array"), REC("rec"),
+ I8("i8"), I16("i16"), DECLARE("declare"), ITEM("item"), OFFSET("offset"),
+ SUB("sub"), FINAL("final");
static Address getAddress(const Element* s) {
return std::stoll(s->toString());
@@ -959,51 +957,17 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) {
} else {
if (kind == FUNC) {
builder[index] = parseSignatureDef(def, 0);
- } else if (kind == FUNC_SUBTYPE) {
- builder[index].setOpen();
- builder[index] = parseSignatureDef(def, 1);
- super = def[def.size() - 1];
- if (!super->dollared() && super->str() == FUNC) {
- // OK; no supertype
- super = nullptr;
- }
} else if (kind == STRUCT) {
builder[index] = parseStructDef(def, index, 0);
- } else if (kind == STRUCT_SUBTYPE) {
- builder[index].setOpen();
- builder[index] = parseStructDef(def, index, 1);
- super = def[def.size() - 1];
- if (!super->dollared() && super->str() == DATA) {
- // OK; no supertype
- super = nullptr;
- }
} else if (kind == ARRAY) {
builder[index] = parseArrayDef(def);
- } else if (kind == ARRAY_SUBTYPE) {
- builder[index].setOpen();
- builder[index] = parseArrayDef(def);
- super = def[def.size() - 1];
- if (!super->dollared() && super->str() == DATA) {
- // OK; no supertype
- super = nullptr;
- }
} else {
throw ParseException("unknown heaptype kind", kind.line, kind.col);
}
}
if (super) {
- if (!super->dollared()) {
- throw ParseException("unknown supertype", super->line, super->col);
- }
- } else if (elementStartsWith(elem[elem.size() - 1], EXTENDS)) {
- // '(' 'extends' $supertype ')'
- builder[index].setOpen();
- Element& extends = *elem[elem.size() - 1];
- super = extends[1];
- }
- if (super) {
auto it = typeIndices.find(super->toString());
- if (it == typeIndices.end()) {
+ if (!super->dollared() || it == typeIndices.end()) {
throw ParseException("unknown supertype", super->line, super->col);
}
builder[index].subTypeOf(builder[it->second]);