diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-09 10:48:34 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-09 10:48:34 -0700 |
commit | aca5642e0d8d17c31c86f6da3dff4256ae53babd (patch) | |
tree | 41a178f9cd266ccad20322216e171b7c9f531ceb /src/wasm-s-parser.h | |
parent | 795303fcbca40586ed9b0cd3b4406fb3f41a6d34 (diff) | |
download | binaryen-aca5642e0d8d17c31c86f6da3dff4256ae53babd.tar.gz binaryen-aca5642e0d8d17c31c86f6da3dff4256ae53babd.tar.bz2 binaryen-aca5642e0d8d17c31c86f6da3dff4256ae53babd.zip |
parse binary modules encoded in wats
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 298f155ee..3187ce63c 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -27,6 +27,7 @@ #include <limits> #include "wasm.h" +#include "wasm-binary.h" #include "asmjs/shared-constants.h" #include "mixed_arena.h" #include "parsing.h" @@ -248,6 +249,19 @@ public: // Assumes control of and modifies the input. SExpressionWasmBuilder(Module& wasm, Element& module, std::function<void ()> onError) : wasm(wasm), allocator(wasm.allocator), onError(onError), importCounter(0) { assert(module[0]->str() == MODULE); + if (module.size() > 1 && module[1]->isStr()) { + // these s-expressions contain a binary module, actually + auto str = module[1]->c_str(); + if (auto size = strlen(str)) { + std::vector<char> data; + stringToBinary(str, size, data); + WasmBinaryBuilder binaryBuilder(wasm, data, false); + binaryBuilder.read(); + } else { + onError(); + } + return; + } functionCounter = 0; for (unsigned i = 1; i < module.size(); i++) { preParseFunctionType(*module[i]); |