From dc0952685eac9bb8ade8d4c12ebf802844a4869f Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 12 Jun 2022 15:57:54 +0200 Subject: Implemented basic cli --- src/interpreter.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/interpreter.zig') diff --git a/src/interpreter.zig b/src/interpreter.zig index 5702336..1ab07c9 100644 --- a/src/interpreter.zig +++ b/src/interpreter.zig @@ -8,14 +8,18 @@ pub const Interpreter = struct { pointer: *pointer.Pointer, pub fn deinit(self: *Interpreter) void { + self.pointer.deinit(); + self.field.deinit(); self.allocator.destroy(self); } - pub fn init(allocator: std.mem.Allocator, f: *field.Field, p: *pointer.Pointer) !*Interpreter { + pub fn init(allocator: std.mem.Allocator, reader: anytype, ioFunctions: ?pointer.IOFunctions, args: []const []const u8) !*Interpreter { var i = try allocator.create(Interpreter); errdefer allocator.destroy(i); i.allocator = allocator; - i.field = f; - i.pointer = p; + i.field = try field.Field.init_from_reader(allocator, reader); + errdefer i.field.deinit(); + i.pointer = try pointer.Pointer.init(std.testing.allocator, i.field, ioFunctions, args); + errdefer i.pointer.deinit(); return i; } pub fn run(self: *Interpreter) !i64 { -- cgit v1.2.3