aboutsummaryrefslogtreecommitdiff
path: root/src/interpreter.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-07-30 00:31:14 +0200
committerJulien Dessaux2022-07-30 00:31:14 +0200
commitaa56929ff7e03cd563d951782ba72e06be2a6935 (patch)
tree54501fa0e6af07581d998ebc5e2fe7fa373828a7 /src/interpreter.zig
parentRemoved useless imports (diff)
downloadzigfunge98-aa56929ff7e03cd563d951782ba72e06be2a6935.tar.gz
zigfunge98-aa56929ff7e03cd563d951782ba72e06be2a6935.tar.bz2
zigfunge98-aa56929ff7e03cd563d951782ba72e06be2a6935.zip
Reworked io functions to take a configurable reader or writer
Diffstat (limited to '')
-rw-r--r--src/interpreter.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/interpreter.zig b/src/interpreter.zig
index a947d6f..05c4516 100644
--- a/src/interpreter.zig
+++ b/src/interpreter.zig
@@ -13,19 +13,19 @@ pub const Interpreter = struct {
self.field.deinit();
self.allocator.destroy(self);
}
- pub fn init(allocator: std.mem.Allocator, reader: anytype, ioFunctions: io.Functions, args: []const []const u8) !*Interpreter {
+ pub fn init(allocator: std.mem.Allocator, fileReader: anytype, args: []const []const u8) !*Interpreter {
var i = try allocator.create(Interpreter);
errdefer allocator.destroy(i);
i.allocator = allocator;
- i.field = try field.Field.init_from_reader(allocator, reader);
+ i.field = try field.Field.init_from_reader(allocator, fileReader);
errdefer i.field.deinit();
- i.pointer = try pointer.Pointer.init(std.testing.allocator, i.field, ioFunctions, args);
+ i.pointer = try pointer.Pointer.init(std.testing.allocator, i.field, args);
errdefer i.pointer.deinit();
return i;
}
- pub fn run(self: *Interpreter) !i64 {
+ pub fn run(self: *Interpreter, ioContext: anytype) !i64 {
while (true) {
- if (try self.pointer.exec()) |ret| {
+ if (try self.pointer.exec(ioContext)) |ret| {
if (ret.code) |code| {
return code;
} else {