diff options
author | Ernesto Lanchares <elancha98@proton.me> | 2025-03-23 13:38:57 +0000 |
---|---|---|
committer | Lorenzo Torres <torres@sideros.org> | 2025-03-23 14:39:49 +0100 |
commit | b7854d7325dfe35ca41e56dcccfb8fb7b7d0aa22 (patch) | |
tree | 407925432c7c092ef763ae205c1936fa50bfb5e7 /src/main.zig | |
parent | 00d695e5f08ddff7ba66f2dd1aea4cdaf14f45e7 (diff) |
Big rework of the parser!
It now follows a more functional style but it
should be waaay easier to add functionality.
Probably the parser is a bit slower than the
previous one but the code is much cleaner and a
good enough compiler should be able to inline the
function calls and make it par with the previous
one.
As a TODO, runtime structs should not depends on
the parser, but I think that is a topic for
another commit.
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index 597011d..97aa5bf 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5,7 +5,7 @@ const window = @import("rendering/window.zig"); const config = @import("config"); const Renderer = @import("rendering/renderer_vulkan.zig"); const math = @import("math.zig"); -const Parser = @import("mods/parse.zig"); +const Parser = @import("mods/Parser.zig"); const vm = @import("mods/vm.zig"); const wasm = @import("mods/wasm.zig"); const components = @import("ecs/components.zig"); @@ -28,10 +28,19 @@ pub fn main() !void { //defer global_runtime.deinit(); //try global_runtime.addFunction("debug", wasm.debug); - //const file = try std.fs.cwd().openFile("assets/core.wasm", .{}); - //const module = try Parser.parseWasm(allocator, file.reader()); - //var runtime = try vm.Runtime.init(allocator, module, &global_runtime); - //defer runtime.deinit(allocator); + // const file = try std.fs.cwd().openFile("assets/core.wasm", .{}); + // const all = try file.readToEndAlloc(allocator, 1_000_000); // 1 MB + // var parser = Parser{ + // .bytes = all, + // .byte_idx = 0, + // .allocator = allocator, + // }; + // const module = parser.parseModule() catch |err| { + // std.debug.print("[ERROR]: error at byte {x}(0x{x})\n", .{ parser.byte_idx, parser.bytes[parser.byte_idx] }); + // return err; + // }; + // var runtime = try vm.Runtime.init(allocator, module, &global_runtime); + // defer runtime.deinit(allocator); //var parameters = [_]usize{}; //try runtime.callExternal(allocator, "preinit", ¶meters); |