diff options
author | Julien Dessaux | 2022-06-12 15:57:54 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-06-12 15:57:54 +0200 |
commit | dc0952685eac9bb8ade8d4c12ebf802844a4869f (patch) | |
tree | ca7030ff13a9c24bf15280e50db62f6473c4feee /src/interpreter.zig | |
parent | Pass the sanity test (diff) | |
download | zigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.tar.gz zigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.tar.bz2 zigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.zip |
Implemented basic cli
Diffstat (limited to '')
-rw-r--r-- | src/interpreter.zig | 10 |
1 files changed, 7 insertions, 3 deletions
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 { |