diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-30 00:15:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-30 00:15:33 +0200 |
commit | 67a96ae60085366b59d64bc997c9e6525c247e27 (patch) | |
tree | 76338e649b18b572c5ad184641c029b16344f0f2 /src/wasm/wasm-s-parser.cpp | |
parent | 7d673ce83206349159a68fe683bc7da02dcdaf98 (diff) | |
download | binaryen-67a96ae60085366b59d64bc997c9e6525c247e27.tar.gz binaryen-67a96ae60085366b59d64bc997c9e6525c247e27.tar.bz2 binaryen-67a96ae60085366b59d64bc997c9e6525c247e27.zip |
Fix applying default / unify SExpr and Wasm builder names (#3179)
SExpressionWasmBuilder was not applying default memory and table import names on the memory and table, unlike on functions, globals and events, where it applies them. Also aligns default import names to use the same shorter forms as in binary parsing.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 63157b314..462d440d8 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2360,17 +2360,17 @@ void SExpressionWasmBuilder::parseImport(Element& s) { } if (!name.is()) { if (kind == ExternalKind::Function) { - name = Name("import$function$" + std::to_string(functionCounter++)); + name = Name("fimport$" + std::to_string(functionCounter++)); functionNames.push_back(name); } else if (kind == ExternalKind::Global) { - name = Name("import$global" + std::to_string(globalCounter++)); + name = Name("gimport$" + std::to_string(globalCounter++)); globalNames.push_back(name); } else if (kind == ExternalKind::Memory) { - name = Name("import$memory$" + std::to_string(0)); + name = Name("mimport$" + std::to_string(0)); } else if (kind == ExternalKind::Table) { - name = Name("import$table$" + std::to_string(0)); + name = Name("timport$" + std::to_string(0)); } else if (kind == ExternalKind::Event) { - name = Name("import$event" + std::to_string(eventCounter++)); + name = Name("eimport$" + std::to_string(eventCounter++)); eventNames.push_back(name); } else { throw ParseException("invalid import", s[3]->line, s[3]->col); @@ -2422,6 +2422,7 @@ void SExpressionWasmBuilder::parseImport(Element& s) { global->mutable_ = mutable_; wasm.addGlobal(global.release()); } else if (kind == ExternalKind::Table) { + wasm.table.name = name; wasm.table.module = module; wasm.table.base = base; if (j < inner.size() - 1) { @@ -2439,6 +2440,7 @@ void SExpressionWasmBuilder::parseImport(Element& s) { j++; // funcref // ends with the table element type } else if (kind == ExternalKind::Memory) { + wasm.memory.name = name; wasm.memory.module = module; wasm.memory.base = base; if (inner[j]->isList()) { |