diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-16 16:45:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-16 16:45:37 -0700 |
commit | 5126ebef968cd27ae3cb8f61357c95626c25ad25 (patch) | |
tree | 4dc99774c425d7b14c04f80b28303a78d022e5ec /src | |
parent | 444d7f66182c091b2e207a7bc842309f0925e228 (diff) | |
download | binaryen-5126ebef968cd27ae3cb8f61357c95626c25ad25.tar.gz binaryen-5126ebef968cd27ae3cb8f61357c95626c25ad25.tar.bz2 binaryen-5126ebef968cd27ae3cb8f61357c95626c25ad25.zip |
s-expression modules can have names
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-s-parser.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 1a9e71bd4..3f80f6f9e 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -272,12 +272,18 @@ class SExpressionWasmBuilder { public: // Assumes control of and modifies the input. - SExpressionWasmBuilder(Module& wasm, Element& module) : wasm(wasm), allocator(wasm.allocator), importCounter(0), globalCounter(0) { + SExpressionWasmBuilder(Module& wasm, Element& module, Name* moduleName = nullptr) : wasm(wasm), allocator(wasm.allocator), importCounter(0), globalCounter(0) { assert(module[0]->str() == MODULE); - if (module.size() > 1 && module[1]->isStr()) { + Index i = 1; + if (module[i]->dollared()) { + if (moduleName) { + *moduleName = module[i]->str(); + } + i++; + } + if (i < module.size() && module[i]->isStr()) { // these s-expressions contain a binary module, actually std::vector<char> data; - size_t i = 1; while (i < module.size()) { auto str = module[i++]->c_str(); if (auto size = strlen(str)) { @@ -289,13 +295,13 @@ public: return; } functionCounter = 0; - for (unsigned i = 1; i < module.size(); i++) { - preParseFunctionType(*module[i]); - preParseImports(*module[i]); + for (unsigned j = i; j < module.size(); j++) { + preParseFunctionType(*module[j]); + preParseImports(*module[j]); } functionCounter = 0; - for (unsigned i = 1; i < module.size(); i++) { - parseModuleElement(*module[i]); + for (unsigned j = i; j < module.size(); j++) { + parseModuleElement(*module[j]); } } |