Commit e5319c9b authored by nagayama15's avatar nagayama15

feature: Read the input module

parent 5baa09bc
......@@ -32,6 +32,6 @@ $ make
## 実行方法
```shell
$ kyut <input-wasm> <watermark>
$ snpi <input-wasm> <watermark>
$ pisn <input-wasm>
```
(module
(export "add2" (func $add2))
(export "add3" (func $add3))
(func $add2 (param $a i32) (param $b i32) (result i32)
(i32.add
(local.get $a)
(local.get $b)
)
)
(func $add3 (param $a i32) (param $b i32) (param $c i32) (result i32)
(i32.add
(i32.add
(local.get $a)
(local.get $b)
)
(local.get $c)
)
)
)
......@@ -6,10 +6,11 @@
# fmt::fmt
# )
add_executable(kyut
kyut.cpp
add_executable(snpi
snpi.cpp
)
target_link_libraries(kyut
target_link_libraries(snpi
binaryen::binaryen
fmt::fmt
)
#include <fmt/printf.h>
int main() {
fmt::print("Hello, {}\n", "kyut");
}
#include <fmt/printf.h>
#include <wasm-io.h>
int main(int argc, char *argv[]) {
// Parse command line options
if (argc != 2) {
fmt::print(std::cerr, "{} <input file>\n", argv[0]);
return 1;
}
const std::string inputFile = argv[1];
try {
// Read the input module
wasm::Module module;
wasm::ModuleReader{}.read(inputFile, module);
} catch (const wasm::ParseException &e) {
e.dump(std::cerr);
} catch (...) {
fmt::print(std::cerr, "unknown exception\n");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment