diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-09 13:33:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-09 13:33:15 -0700 |
commit | 1db8ae1f4909b5949a48a2266fce6eef2edd6742 (patch) | |
tree | b8cba9eadf58c7cf83792623a15b1ae17f165d64 /src/wasm-binary.h | |
parent | f6d5a9df297997af5165ff164cb1609fbc0239e6 (diff) | |
parent | b519fd87f7f1e1adead0ed648f29301303518ff0 (diff) | |
download | binaryen-1db8ae1f4909b5949a48a2266fce6eef2edd6742.tar.gz binaryen-1db8ae1f4909b5949a48a2266fce6eef2edd6742.tar.bz2 binaryen-1db8ae1f4909b5949a48a2266fce6eef2edd6742.zip |
Merge pull request #461 from WebAssembly/spec-update
Spec test update
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index c889f1418..a5cf0fe5c 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1164,13 +1164,14 @@ class WasmBinaryBuilder { Module& wasm; MixedArena& allocator; std::vector<char>& input; + std::function<void ()> onError; bool debug; size_t pos = 0; int32_t startIndex = -1; public: - WasmBinaryBuilder(Module& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug) {} + WasmBinaryBuilder(Module& wasm, std::vector<char>& input, std::function<void ()> onError, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), onError(onError), debug(debug) {} void read() { @@ -1225,7 +1226,7 @@ public: } uint8_t getInt8() { - assert(more()); + if (!more()) onError(); if (debug) std::cerr << "getInt8: " << (int)(uint8_t)input[pos] << " (at " << pos << ")" << std::endl; return input[pos++]; } @@ -1329,27 +1330,27 @@ public: void verifyInt8(int8_t x) { int8_t y = getInt8(); - assert(x == y); + if (x != y) onError(); } void verifyInt16(int16_t x) { int16_t y = getInt16(); - assert(x == y); + if (x != y) onError(); } void verifyInt32(int32_t x) { int32_t y = getInt32(); - assert(x == y); + if (x != y) onError(); } void verifyInt64(int64_t x) { int64_t y = getInt64(); - assert(x == y); + if (x != y) onError(); } void verifyFloat32(float x) { float y = getFloat32(); - assert(x == y); + if (x != y) onError(); } void verifyFloat64(double x) { double y = getFloat64(); - assert(x == y); + if (x != y) onError(); } void ungetInt8() { |