summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-io.cpp')
-rw-r--r--src/wasm/wasm-io.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index b94fc8470..55892975b 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -24,19 +24,31 @@
// binary.
//
-#include "wasm-io.h"
#include "support/debug.h"
#include "wasm-binary.h"
#include "wasm-s-parser.h"
+#include "wat-parser.h"
+
+#include "wasm-io.h"
namespace wasm {
+bool useNewWATParser = false;
+
#define DEBUG_TYPE "writer"
static void readTextData(std::string& input, Module& wasm, IRProfile profile) {
- SExpressionParser parser(const_cast<char*>(input.c_str()));
- Element& root = *parser.root;
- SExpressionWasmBuilder builder(wasm, *root[0], profile);
+ if (useNewWATParser) {
+ std::string_view in(input.c_str());
+ if (auto parsed = WATParser::parseModule(wasm, in);
+ auto err = parsed.getErr()) {
+ Fatal() << err->msg;
+ }
+ } else {
+ SExpressionParser parser(const_cast<char*>(input.c_str()));
+ Element& root = *parser.root;
+ SExpressionWasmBuilder builder(wasm, *root[0], profile);
+ }
}
void ModuleReader::readText(std::string filename, Module& wasm) {