Skip to content

Commit 99ac5e2

Browse files
committed
Use new wast parser in wasm2js
When generating assertions, traverse the `WASTScript` data structure rather than interleaving assertion parsing with emitting.
1 parent 921644c commit 99ac5e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2627
-2634
lines changed

src/emscripten-optimizer/simple_ast.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
#include "snprintf.h"
3939
#include "support/safe_integer.h"
4040

41-
#define err(str) fprintf(stderr, str "\n");
4241
#define errv(str, ...) fprintf(stderr, str "\n", __VA_ARGS__);
43-
#define printErr err
42+
#define printErr(str) fprintf(stderr, str "\n");
4443

4544
namespace cashew {
4645

src/parser/wast-parser.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,15 @@ Result<WASTScript> wast(Lexer& in) {
397397
while (!in.empty()) {
398398
size_t line = in.position().line;
399399
auto cmd = command(in);
400-
if (cmd.getErr() && cmds.empty()) {
400+
if (auto* err = cmd.getErr(); err && cmds.empty()) {
401401
// The entire script might be a single module comprising a sequence of
402402
// module fields with a top-level `(module ...)`.
403403
auto wasm = std::make_shared<Module>();
404-
CHECK_ERR(parseModule(*wasm, in.buffer));
404+
auto parsed = parseModule(*wasm, in.buffer);
405+
if (parsed.getErr()) {
406+
// No, that wasn't the problem. Return the original error.
407+
return Err{err->msg};
408+
}
405409
cmds.push_back({WASTModule{std::move(wasm)}, line});
406410
return cmds;
407411
}

0 commit comments

Comments
 (0)