Added executing of and
This commit is contained in:
parent
916115c7cd
commit
28420f53b0
2 changed files with 16 additions and 3 deletions
|
|
@ -107,7 +107,7 @@ pub const Runtime = struct {
|
||||||
std.log.err("Reached unreachable statement at IR counter {any}\n", .{frame.program_counter});
|
std.log.err("Reached unreachable statement at IR counter {any}\n", .{frame.program_counter});
|
||||||
frame.code.print(std.io.getStdOut().writer()) catch {};
|
frame.code.print(std.io.getStdOut().writer()) catch {};
|
||||||
},
|
},
|
||||||
.nop => @panic("UNIMPLEMENTED"),
|
.nop => {},
|
||||||
.br => {
|
.br => {
|
||||||
frame.program_counter = index.u32;
|
frame.program_counter = index.u32;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -130,8 +130,19 @@ pub const Runtime = struct {
|
||||||
.refisnull => @panic("UNIMPLEMENTED"),
|
.refisnull => @panic("UNIMPLEMENTED"),
|
||||||
.reffunc => @panic("UNIMPLEMENTED"),
|
.reffunc => @panic("UNIMPLEMENTED"),
|
||||||
|
|
||||||
.drop => @panic("UNIMPLEMENTED"),
|
.drop => {
|
||||||
.select => @panic("UNIMPLEMENTED"),
|
_ = 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"),
|
.select_with_values => @panic("UNIMPLEMENTED"),
|
||||||
|
|
||||||
.localget => try self.stack.append(frame.locals[index.u32]),
|
.localget => try self.stack.append(frame.locals[index.u32]),
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,12 @@ pub const Type = enum(u8) {
|
||||||
|
|
||||||
pub const GlobalRuntime = struct {
|
pub const GlobalRuntime = struct {
|
||||||
functions: std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void),
|
functions: std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void),
|
||||||
|
// globals: [_]vm.Value,
|
||||||
|
|
||||||
pub fn init(allocator: Allocator) GlobalRuntime {
|
pub fn init(allocator: Allocator) GlobalRuntime {
|
||||||
return GlobalRuntime{
|
return GlobalRuntime{
|
||||||
.functions = std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void).init(allocator),
|
.functions = std.StringHashMap(*const fn (stack: *std.ArrayList(vm.Value)) void).init(allocator),
|
||||||
|
// .globals = .{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue