Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new wast parser in wasm2js #6606

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/emscripten-optimizer/simple_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
#include "snprintf.h"
#include "support/safe_integer.h"

#define err(str) fprintf(stderr, str "\n");
#define errv(str, ...) fprintf(stderr, str "\n", __VA_ARGS__);
#define printErr err
#define printErr(str) fprintf(stderr, str "\n");

namespace cashew {

Expand Down
8 changes: 6 additions & 2 deletions src/parser/wast-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,15 @@ Result<WASTScript> wast(Lexer& in) {
while (!in.empty()) {
size_t line = in.position().line;
auto cmd = command(in);
if (cmd.getErr() && cmds.empty()) {
if (auto* err = cmd.getErr(); err && cmds.empty()) {
// The entire script might be a single module comprising a sequence of
// module fields with a top-level `(module ...)`.
auto wasm = std::make_shared<Module>();
CHECK_ERR(parseModule(*wasm, in.buffer));
auto parsed = parseModule(*wasm, in.buffer);
if (parsed.getErr()) {
// No, that wasn't the problem. Return the original error.
return Err{err->msg};
}
cmds.push_back({WASTModule{std::move(wasm)}, line});
return cmds;
}
Expand Down
Loading
Loading