summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mods/vm.zig17
-rw-r--r--src/mods/wasm.zig2
2 files changed, 16 insertions, 3 deletions
diff --git a/src/mods/vm.zig b/src/mods/vm.zig
index 0d6cddf..a636cb3 100644
--- a/src/mods/vm.zig
+++ b/src/mods/vm.zig
@@ -107,7 +107,7 @@ pub const Runtime = struct {
std.log.err("Reached unreachable statement at IR counter {any}\n", .{frame.program_counter});
frame.code.print(std.io.getStdOut().writer()) catch {};
},
- .nop => @panic("UNIMPLEMENTED"),
+ .nop => {},
.br => {
frame.program_counter = index.u32;
continue;
@@ -130,8 +130,19 @@ pub const Runtime = struct {
.refisnull => @panic("UNIMPLEMENTED"),
.reffunc => @panic("UNIMPLEMENTED"),
- .drop => @panic("UNIMPLEMENTED"),
- .select => @panic("UNIMPLEMENTED"),
+ .drop => {
+ _ = self.stack.pop();
+ },
+ .select => {
+ const c = self.stack.pop().?.i32;
+ const val2 = self.stack.pop().?;
+ const val1 = self.stack.pop().?;
+ if (c != 0) {
+ try self.stack.append(val1);
+ } else {
+ try self.stack.append(val2);
+ }
+ },
.select_with_values => @panic("UNIMPLEMENTED"),
.localget => try self.stack.append(frame.locals[index.u32]),
diff --git a/src/mods/wasm.zig b/src/mods/wasm.zig
index 579309b..a49385e 100644
--- a/src/mods/wasm.zig
+++ b/src/mods/wasm.zig
@@ -12,10 +12,12 @@ pub const Type = enum(u8) {
pub const GlobalRuntime = struct {
functions: std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void),
+ // globals: [_]vm.Value,
pub fn init(allocator: Allocator) GlobalRuntime {
return GlobalRuntime{
.functions = std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void).init(allocator),
+ // .globals = .{}
};
}