diff --git a/src/buzz_api.zig b/src/buzz_api.zig index b9324b8b..40ea7576 100644 --- a/src/buzz_api.zig +++ b/src/buzz_api.zig @@ -15,6 +15,7 @@ const FunctionNode = @import("node.zig").FunctionNode; const dumpStack = @import("disassembler.zig").dumpStack; const ZigType = @import("zigtypes.zig").Type; const Token = @import("token.zig").Token; +const MIRJIT = @import("mirjit.zig"); const Value = _value.Value; const valueToStringAlloc = _value.valueToStringAlloc; @@ -618,6 +619,11 @@ export fn bz_newVM(self: *VM) ?*VM { return null; }; + vm.mir_jit = if (BuildOptions.jit) + MIRJIT.init(vm) + else + null; + return vm; } @@ -633,9 +639,11 @@ export fn bz_startVM(self: *VM) void { ) catch @panic("Out of memory"); } -export fn bz_deinitVM(_: *VM) void { - // FIXME - // self.deinit(); +export fn bz_deinitVM(self: *VM) void { + if (self.mir_jit) |*jit| { + jit.deinit(); + } + self.deinit(); } export fn bz_compile(self: *VM, source: ?[*]const u8, source_len: usize, file_name: ?[*]const u8, file_name_len: usize) ?*ObjFunction {