diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 20:54:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 20:55:30 -0800 |
commit | d8c2d69dd253bd6f67e1f3c374be2c20d43dfc03 (patch) | |
tree | 39cfe002d1ff5d58f462a8472ac79c28ead43a2e /src/asm2wasm.h | |
parent | bb6f33c9f19581e2ea60b46653bb1a10ced4a2eb (diff) | |
download | binaryen-d8c2d69dd253bd6f67e1f3c374be2c20d43dfc03.tar.gz binaryen-d8c2d69dd253bd6f67e1f3c374be2c20d43dfc03.tar.bz2 binaryen-d8c2d69dd253bd6f67e1f3c374be2c20d43dfc03.zip |
save module and base of mapped imported globals, and fix writing of mapped imported globals
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 2bb76610b..e5ba3a499 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -79,14 +79,18 @@ class Asm2WasmBuilder { unsigned address; WasmType type; bool import; // if true, this is an import - we should read the value, not just set a zero + IString module, base; MappedGlobal() : address(0), type(none), import(false) {} - MappedGlobal(unsigned address, WasmType type, bool import) : address(address), type(type), import(import) {} + MappedGlobal(unsigned address, WasmType type, bool import, IString module, IString base) : address(address), type(type), import(import), module(module), base(base) {} }; + +public: std::map<IString, MappedGlobal> mappedGlobals; - void allocateGlobal(IString name, WasmType type, bool import) { +private: + void allocateGlobal(IString name, WasmType type, bool import, IString module = IString(), IString base = IString()) { assert(mappedGlobals.find(name) == mappedGlobals.end()); - mappedGlobals.emplace(name, MappedGlobal(nextGlobal, type, import)); + mappedGlobals.emplace(name, MappedGlobal(nextGlobal, type, import, module, base)); nextGlobal += 8; assert(nextGlobal < maxGlobal); } @@ -369,7 +373,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { } if (type != WasmType::none) { // wasm has no imported constants, so allocate a global, and we need to write the value into that - allocateGlobal(name, type, true); + allocateGlobal(name, type, true, import.module, import.base); } else { wasm.imports.emplace(name, import); } |