diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-19 09:49:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:03 -0700 |
commit | 266e922cddf0a5c78ed22f046eeebc053a9305c0 (patch) | |
tree | 2dec707b00304b1a6c888efb8f2c1b9a19ce38f3 /src/wasm-s-parser.h | |
parent | 9660c200eff60c10266a85aae0637b495c4cba39 (diff) | |
download | binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.tar.gz binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.tar.bz2 binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.zip |
use globals in asm2wasm
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 60cc21e26..65335c1be 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -949,9 +949,16 @@ private: auto ret = allocator.alloc<GetGlobal>(); ret->name = s[1]->str(); auto* global = wasm.checkGlobal(ret->name); - if (!global) throw ParseException("bad get_global name", s.line, s.col); - ret->type = global->type; - return ret; + if (global) { + ret->type = global->type; + return ret; + } + auto* import = wasm.checkImport(ret->name); + if (import && import->kind == Import::Global) { + ret->type = import->globalType; + return ret; + } + throw ParseException("bad get_global name", s.line, s.col); } Expression* makeSetGlobal(Element& s) { @@ -1434,7 +1441,7 @@ private: } else if (s[2]->str() == TABLE) { im->kind = Import::Table; } else if (s[2]->str() == GLOBAL) { - im->kind = Import::Table; + im->kind = Import::Global; } else { WASM_UNREACHABLE(); } |