aboutsummaryrefslogtreecommitdiff
path: root/src/interpreter.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-06-12 15:57:54 +0200
committerJulien Dessaux2022-06-12 15:57:54 +0200
commitdc0952685eac9bb8ade8d4c12ebf802844a4869f (patch)
treeca7030ff13a9c24bf15280e50db62f6473c4feee /src/interpreter.zig
parentPass the sanity test (diff)
downloadzigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.tar.gz
zigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.tar.bz2
zigfunge98-dc0952685eac9bb8ade8d4c12ebf802844a4869f.zip
Implemented basic cli
Diffstat (limited to '')
-rw-r--r--src/interpreter.zig10
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 {