diff options
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index e2c0dbcee..b53ee44b5 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -1463,7 +1463,7 @@ private: } else { assert(inner.size() > 0 ? inner[0]->str() != IMPORT : true); // (memory (data ..)) format - parseData(*s[i]); + parseInnerData(*s[i]); wasm.memory.initial = wasm.memory.segments[0].data.size(); return; } @@ -1508,6 +1508,10 @@ private: i++; } auto* offset = parseExpression(s[i++]); + parseInnerData(s, i, offset); + } + + void parseInnerData(Element& s, Index i = 1, Expression* offset = nullptr) { std::vector<char> data; while (i < s.size()) { const char *input = s[i++]->c_str(); @@ -1515,6 +1519,9 @@ private: stringToBinary(input, size, data); } } + if (!offset) { + offset = allocator.alloc<Const>()->set(Literal(int32_t(0))); + } wasm.memory.segments.emplace_back(offset, data.data(), data.size()); } |