From: Brendan Hansen Date: Fri, 2 Jul 2021 03:48:27 +0000 (-0500) Subject: initial commit X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=4a2d00be83efb08ae6b4ba36dc02f1a4de4e2bca;p=onyx-wasm-analyzer.git initial commit --- 4a2d00be83efb08ae6b4ba36dc02f1a4de4e2bca diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..714b2bf --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ + +ONYX_MODULE_DIRECTORY=/home/brendan/dev/c/onyx + +FLAGS= +[ ! -z "$DEBUG" ] && FLAGS=--print-function-mappings + +onyx -V --no-colors $FLAGS \ + -I $ONYX_MODULE_DIRECTORY \ + src/build.onyx + diff --git a/data/dummy.onyx b/data/dummy.onyx new file mode 100644 index 0000000..7995cb5 --- /dev/null +++ b/data/dummy.onyx @@ -0,0 +1,7 @@ +#load "core/std" + +use package core + +main :: (args: [] cstr) { + println("Hello World!"); +} diff --git a/data/test.wasm b/data/test.wasm new file mode 100644 index 0000000..f676e35 Binary files /dev/null and b/data/test.wasm differ diff --git a/src/build.onyx b/src/build.onyx new file mode 100644 index 0000000..43e4702 --- /dev/null +++ b/src/build.onyx @@ -0,0 +1,12 @@ +#load "core/std" + +#load "modules/wasm_utils/module" +#load "modules/json/module" + +#if (package runtime).Runtime == (package runtime).Runtime_Js { + #load "modules/webgl2/module" + #load "modules/immediate_mode/module" + #load "modules/ui/module" +} + +#load "src/main" diff --git a/src/main.onyx b/src/main.onyx new file mode 100644 index 0000000..8e1a0dc --- /dev/null +++ b/src/main.onyx @@ -0,0 +1,16 @@ + +use package core +#private_file wasm :: package wasm_utils + +main :: (args: [] cstr) { + + wasm_data := #file_contents "data/test.wasm"; + + wasm_binary := wasm.load(wasm_data); + println("Loaded sections"); + + for ^entry: wasm_binary.section_locations.entries { + printf("Section number: {}\nOffset: {}\n", entry.key, entry.value); + } +} +