diff --git a/core.wat b/core.wat new file mode 100644 index 0000000..0c2f501 --- /dev/null +++ b/core.wat @@ -0,0 +1,102 @@ +(module $core.wasm + (type (;0;) (func (param i32) (result i64))) + (func $preinit (type 0) (param i32) (result i64) + (local i32 i32 i64 i64 i64) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 0 + i32.const 2 + i32.lt_u + br_if 0 (;@3;) + local.get 0 + i32.const -1 + i32.add + local.tee 1 + i32.const 7 + i32.and + local.set 2 + local.get 0 + i32.const -2 + i32.add + i32.const 7 + i32.ge_u + br_if 1 (;@2;) + i64.const 1 + local.set 3 + i64.const 0 + local.set 4 + br 2 (;@1;) + end + local.get 0 + i64.extend_i32_u + return + end + local.get 1 + i32.const -8 + i32.and + local.set 0 + i64.const 1 + local.set 3 + i64.const 0 + local.set 4 + loop ;; label = @2 + local.get 3 + local.get 4 + i64.add + local.tee 4 + local.get 3 + i64.add + local.tee 3 + local.get 4 + i64.add + local.tee 4 + local.get 3 + i64.add + local.tee 3 + local.get 4 + i64.add + local.tee 4 + local.get 3 + i64.add + local.tee 3 + local.get 4 + i64.add + local.tee 4 + local.get 3 + i64.add + local.set 3 + local.get 0 + i32.const -8 + i32.add + local.tee 0 + br_if 0 (;@2;) + end + end + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + local.get 3 + local.set 5 + loop ;; label = @2 + local.get 5 + local.get 4 + i64.add + local.set 3 + local.get 5 + local.set 4 + local.get 3 + local.set 5 + local.get 2 + i32.const -1 + i32.add + local.tee 2 + br_if 0 (;@2;) + end + end + local.get 3) + (memory (;0;) 16) + (global $__stack_pointer (mut i32) (i32.const 1048576)) + (export "memory" (memory 0)) + (export "preinit" (func $preinit))) diff --git a/src/mods/vm.zig b/src/mods/vm.zig index c990fb4..aa9a5a5 100644 --- a/src/mods/vm.zig +++ b/src/mods/vm.zig @@ -116,11 +116,8 @@ pub const Runtime = struct { const opcode: IR.Opcode = frame.code.opcodes[frame.program_counter]; const index = frame.code.indices[frame.program_counter]; switch (opcode) { - // TODO(ernesto): How should we handle unreachable? - // Like this .@"unreachable" => { std.log.err("Reached unreachable statement at IR counter {any}\n", .{frame.program_counter}); - //frame.code.print(std.io.getStdOut().writer()) catch {}; }, .nop => {}, .br => { @@ -137,7 +134,12 @@ pub const Runtime = struct { .@"return" => break :loop, .call => { // TODO: figure out how many parameters to push - try self.call(allocator, index.u32, &[_]Value{}); + var parameters = std.ArrayList(Value).init(allocator); + defer parameters.deinit(); + for (self.module.functions[index.u32].func_type.parameters) |_| { + try parameters.append(self.stack.pop().?); + } + try self.call(allocator, index.u32, parameters.items); }, .call_indirect => @panic("UNIMPLEMENTED"), @@ -228,33 +230,6 @@ pub const Runtime = struct { .datadrop => @panic("UNIMPLEMENTED"), .memorycopy => @panic("UNIMPLEMENTED"), .memoryfill => @panic("UNIMPLEMENTED"), - // 0x36 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u32); - // try self.stack.append(Value{ .i32 = decodeLittleEndian(i32, self.memory[start..end]) }); - // }, - // 0x37 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u32); - // encodeLittleEndian(i32, @constCast(&self.memory[start..end]), self.stack.pop().?.i32); - // }, - // 0x38 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u64); - // encodeLittleEndian(i64, @constCast(&self.memory[start..end]), self.stack.pop().?.i64); - // }, .i32_const => { try self.stack.append(Value{ .i32 = frame.code.indices[frame.program_counter].i32 }); @@ -262,7 +237,6 @@ pub const Runtime = struct { .i64_const => { try self.stack.append(Value{ .i64 = frame.code.indices[frame.program_counter].i64 }); }, - .f32_const => @panic("UNIMPLEMENTED"), .f64_const => @panic("UNIMPLEMENTED"), @@ -445,448 +419,6 @@ pub const Runtime = struct { .vecinst => @panic("UNIMPLEMENTED"), } - // switch (byte) { - // 0x02 => { - // var depth: usize = 1; - // var pc = frame.program_counter; - // while (depth > 0) { - // const opcode = frame.code[pc]; - // const operand = frame.code[pc + 1]; - // if ((opcode == 0x02 and operand == 0x40) or (opcode == 0x03 and operand == 0x40) or (opcode == 0x04 and operand == 0x40)) { - // depth += 1; - // pc += 1; - // } else if (opcode == 0x0B) { - // depth -= 1; - // } - // pc += 1; - // } - // try self.labels.append(pc); - // frame.program_counter += 1; - // }, - // 0x03 => { - // try self.labels.append(frame.program_counter - 1); - // frame.program_counter += 1; - // for_loop = true; - // }, - // 0x0c => { - // const label = leb128Decode(u32, frame.code[frame.program_counter..]); - // var address = @as(usize, 0); - // for (0..(label.val + (if (label.val == 0) @as(u32, 1) else @as(u32, 0)))) |_| { - // address = self.labels.pop().?; - // } - // frame.program_counter = address; - // }, - // 0x0d => { - // if (self.stack.pop().?.i32 != 0) { - // const label = leb128Decode(u32, frame.code[frame.program_counter..]); - // var address = @as(usize, 0); - // for (0..(label.val + (if (label.val == 0) @as(u32, 1) else @as(u32, 0)))) |_| { - // address = self.labels.pop().?; - // } - // frame.program_counter = address; - // } else { - // frame.program_counter += 1; - // } - // }, - - // 0x20 => { - // const integer = leb128Decode(u32, frame.code[frame.program_counter..]); - - // frame.program_counter += integer.len; - // try self.stack.append(frame.locals[integer.val]); - // }, - // 0x21 => { - // const integer = leb128Decode(u32, frame.code[frame.program_counter..]); - - // frame.program_counter += integer.len; - // frame.locals[integer.val] = self.stack.pop().?; - // }, - // 0x22 => { - // const integer = leb128Decode(u32, frame.code[frame.program_counter..]); - - // frame.program_counter += integer.len; - // const a = self.stack.pop().?; - // frame.locals[integer.val] = a; - // try self.stack.append(a); - // }, - // 0x28 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u32); - // try self.stack.append(Value{ .i32 = decodeLittleEndian(i32, self.memory[start..end]) }); - // }, - // 0x29 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u64); - // try self.stack.append(Value{ .i64 = decodeLittleEndian(i64, self.memory[start..end]) }); - // }, - // 0x36 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u32); - // try self.stack.append(Value{ .i32 = decodeLittleEndian(i32, self.memory[start..end]) }); - // }, - // 0x37 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u32); - // encodeLittleEndian(i32, @constCast(&self.memory[start..end]), self.stack.pop().?.i32); - // }, - // 0x38 => { - // const address = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += address.len; - // const offset = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += offset.len; - // const start = (address.val + offset.val); - // const end = start + @sizeOf(u64); - // encodeLittleEndian(i64, @constCast(&self.memory[start..end]), self.stack.pop().?.i64); - // }, - // 0x41 => { - // const integer = leb128Decode(i32, frame.code[frame.program_counter..]); - - // frame.program_counter += integer.len; - // try self.stack.append(Value{ .i32 = integer.val }); - // }, - // 0x42 => { - // const integer = leb128Decode(i64, frame.code[frame.program_counter..]); - - // frame.program_counter += integer.len; - // try self.stack.append(Value{ .i64 = integer.val }); - // }, - // 0x45 => { - // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 == 0))) }); - // }, - // 0x46 => { - // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 == self.stack.pop().?.i32))) }); - // }, - // 0x47 => { - // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 != self.stack.pop().?.i32))) }); - // }, - // // 0x48 => { - // // const a = self.stack.pop().?.i32; - // // const b = self.stack.pop().?.i32; - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(b < a))) }); - // // }, - // 0x49 => { - // const a = self.stack.pop().?.i32; - // const b = self.stack.pop().?.i32; - // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(b < a))) }); - // }, - // // 0x4b => { - // // const b = self.stack.pop().?.i32; - // // const a = self.stack.pop().?.i32; - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(a > b))) }); - // // }, - // // 0x4d => { - // // const b = self.stack.pop().?.i32; - // // const a = self.stack.pop().?.i32; - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(b <= a))) }); - // // }, - // // 0x4a => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 > self.stack.pop().?.i32))) }); - // // }, - // // 0x4b => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(@as(u32, @bitCast(self.stack.pop().?.i32)) > @as(u32, @bitCast(self.stack.pop().?.i32))))) }); - // // }, - // // 0x4c => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 <= self.stack.pop().?.i32))) }); - // // }, - // // 0x4d => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(@as(u32, @bitCast(self.stack.pop().?.i32)) <= @as(u32, @bitCast(self.stack.pop().?.i32))))) }); - // // }, - // // 0x4e => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i32 >= self.stack.pop().?.i32))) }); - // // }, - // 0x4f => { - // const a = self.stack.pop().?.i32; - // const b = self.stack.pop().?.i32; - // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(a >= b))) }); - // }, - - // 0x50 => { - // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 == 0))) }); - // }, - // 0x51 => { - // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 == self.stack.pop().?.i64))) }); - // }, - // 0x52 => { - // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 != self.stack.pop().?.i64))) }); - // }, - // // 0x53 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 < self.stack.pop().?.i64))) }); - // // }, - // // 0x54 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(@as(u64, @bitCast(self.stack.pop().?.i64)) < @as(u64, @bitCast(self.stack.pop().?.i64))))) }); - // // }, - // // 0x55 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 > self.stack.pop().?.i64))) }); - // // }, - // // 0x56 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(@as(u64, @bitCast(self.stack.pop().?.i64)) > @as(u64, @bitCast(self.stack.pop().?.i64))))) }); - // // }, - // // 0x57 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 <= self.stack.pop().?.i64))) }); - // // }, - // // 0x58 => { - // // try self.stack.append(Value{ .i64 = @intCast(@as(u1, @bitCast(@as(u64, @bitCast(self.stack.pop().?.i64)) <= @as(u64, @bitCast(self.stack.pop().?.i64))))) }); - // // }, - // // 0x59 => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(self.stack.pop().?.i64 >= self.stack.pop().?.i64))) }); - // // }, - // // 0x5a => { - // // try self.stack.append(Value{ .i32 = @intCast(@as(u1, @bitCast(@as(u64, @bitCast(self.stack.pop().?.i64)) >= @as(u64, @bitCast(self.stack.pop().?.i64))))) }); - // // }, - - // // 0x67 => { - // // var i = @as(i32, 0); - // // const number = self.stack.pop().?.i32; - // // for (0..@sizeOf(i32)) |b| { - // // if (number & (@as(i32, 0x1) << @intCast((@sizeOf(i32) - b - 1))) == 1) { - // // break; - // // } - // // i += 1; - // // } - // // try self.stack.append(Value{ .i32 = i }); - // // }, - // // 0x68 => { - // // var i = @as(i32, 0); - // // const number = self.stack.pop().?.i32; - // // for (0..@sizeOf(i32)) |b| { - // // if (number & (@as(i32, 0x1) << @intCast(b)) == 1) { - // // break; - // // } - // // i += 1; - // // } - // // try self.stack.append(Value{ .i32 = i }); - // // }, - // // 0x69 => { - // // var i = @as(i32, 0); - // // const number = self.stack.pop().?.i32; - // // for (0..@sizeOf(i32)) |b| { - // // if (number & (@as(i32, 0x1) << @intCast(b)) == 1) { - // // i += 1; - // // } - // // } - // // try self.stack.append(Value{ .i32 = i }); - // // }, - // 0x6a => { - // const a = self.stack.pop().?; - // const b = self.stack.pop().?; - // try self.stack.append(.{ .i32 = a.i32 + b.i32 }); - // }, - // // 0x6b => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 - b.i32 }); - // // }, - // // 0x6c => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 * b.i32 }); - // // }, - // // 0x6d => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = @divTrunc(a.i32, b.i32) }); - // // }, - // // 0x6e => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = @as(i32, @bitCast(@as(u32, @bitCast(a.i32)) / @as(u32, @bitCast(b.i32)))) }); - // // }, - // // 0x6f => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = @rem(a.i32, b.i32) }); - // // }, - // // 0x70 => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = @as(i32, @bitCast(@as(u32, @bitCast(a.i32)) % @as(u32, @bitCast(b.i32)))) }); - // // }, - // 0x71 => { - // const a = self.stack.pop().?; - // const b = self.stack.pop().?; - // try self.stack.append(.{ .i32 = a.i32 & b.i32 }); - // }, - // // 0x72 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 | b.i32 }); - // // }, - // // 0x73 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 ^ b.i32 }); - // // }, - // // 0x74 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 << @intCast(b.i32) }); - // // }, - // // 0x75 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = a.i32 >> @intCast(b.i32) }); - // // }, - // // 0x76 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = @as(i32, @bitCast(@as(u32, @bitCast(a.i32)) >> @intCast(@as(u32, @bitCast(b.i32))))) }); - // // }, - // // 0x77 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = (a.i32 << @intCast(@as(u32, @bitCast(b.i32)))) | (a.i32 >> @intCast((@sizeOf(u32) * 8 - b.i32))) }); - // // }, - // // 0x78 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i32 = (a.i32 >> @intCast(@as(u32, @bitCast(b.i32)))) | (a.i32 << @intCast((@sizeOf(u32) * 8 - b.i32))) }); - // // }, - - // // 0x79 => { - // // var i = @as(i64, 0); - // // const number = self.stack.pop().?.i64; - // // for (0..@sizeOf(i64)) |b| { - // // if (number & (@as(i64, 0x1) << @intCast((@sizeOf(i64) - b - 1))) == 1) { - // // break; - // // } - // // i += 1; - // // } - // // try self.stack.append(Value{ .i64 = i }); - // // }, - // // 0x7a => { - // // var i = @as(i64, 0); - // // const number = self.stack.pop().?.i64; - // // for (0..@sizeOf(i64)) |b| { - // // if (number & (@as(i64, 0x1) << @intCast(b)) == 1) { - // // break; - // // } - // // i += 1; - // // } - // // try self.stack.append(Value{ .i64 = i }); - // // }, - // // 0x7b => { - // // var i = @as(i64, 0); - // // const number = self.stack.pop().?.i64; - // // for (0..@sizeOf(i64)) |b| { - // // if (number & (@as(i64, 0x1) << @intCast(b)) == 1) { - // // i += 1; - // // } - // // } - // // try self.stack.append(Value{ .i64 = i }); - // // }, - // 0x7c => { - // const a = self.stack.pop().?; - // const b = self.stack.pop().?; - // try self.stack.append(.{ .i64 = a.i64 + b.i64 }); - // }, - // // 0x7d => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 - b.i64 }); - // // }, - // // 0x7e => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 * b.i64 }); - // // }, - // // 0x7f => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = @divTrunc(a.i64, b.i64) }); - // // }, - // // 0x80 => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = @as(i64, @bitCast(@as(u64, @bitCast(a.i64)) / @as(u64, @bitCast(b.i64)))) }); - // // }, - // // 0x81 => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = @rem(a.i64, b.i64) }); - // // }, - // // 0x82 => { - // // const b = self.stack.pop().?; - // // const a = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = @as(i64, @bitCast(@as(u64, @bitCast(a.i64)) % @as(u64, @bitCast(b.i64)))) }); - // // }, - // // 0x83 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 & b.i64 }); - // // }, - // // 0x84 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 | b.i64 }); - // // }, - // // 0x85 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 ^ b.i64 }); - // // }, - // // 0x86 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 << @intCast(b.i64) }); - // // }, - // // 0x87 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = a.i64 >> @intCast(b.i64) }); - // // }, - // // 0x88 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = @as(i64, @bitCast(@as(u64, @bitCast(a.i64)) >> @intCast(@as(u64, @bitCast(b.i64))))) }); - // // }, - // // 0x89 => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = (a.i64 << @intCast(@as(u64, @bitCast(b.i64)))) | (a.i64 >> @intCast((@sizeOf(u64) * 8 - b.i64))) }); - // // }, - // // 0x8a => { - // // const a = self.stack.pop().?; - // // const b = self.stack.pop().?; - // // try self.stack.append(.{ .i64 = (a.i64 >> @intCast(@as(u64, @bitCast(b.i64)))) | (a.i64 << @intCast((@sizeOf(u64) * 8 - b.i64))) }); - // // }, - - // 0xad => { - // try self.stack.append(.{ .i64 = self.stack.pop().?.i32 }); - // }, - - // 0x0f => { - // break :loop; - // }, - // 0x10 => { - // const integer = leb128Decode(u32, frame.code[frame.program_counter..]); - // frame.program_counter += integer.len; - - // self.call(allocator, integer.val, &[_]usize@panic("UNIMPLEMENTED"),) catch @panic("UNIMPLEMENTED"),; - // }, - // 0xb => { - // _ = self.labels.pop(); - // if (for_loop) { - // for_loop = false; - // } - // }, - // else => std.log.err("instruction @panic("UNIMPLEMENTED"), not implemented\n", .{byte}), - // } frame.program_counter += 1; } } @@ -938,6 +470,7 @@ pub const Runtime = struct { allocator.free(frame.locals); }, .external => { + std.log.err("TODO: Handle external function {any}\n", .{function}); // TODO(ernesto): handle external functions // const name = self.module.imports[f.external].name; // if (self.global_runtime.functions.get(name)) |external| {