const std = @import("std"); const Instruction = @import("instruction.zig").Instruction; const Self = @This(); instruction: Instruction, next: ?*Self = null, pub fn create(instruction: Instruction, node_pool: *std.heap.MemoryPool(Self)) !*Self { const node = try node_pool.create(); node.* = .{ .instruction = instruction }; return node; } pub fn deinit(self: *Self) void { if (self.next) |next| { next.deinit(); } self.* = undefined; } pub fn clone( self: *Self, node_pool: *std.heap.MemoryPool(Self), ) !*Self { const self_clone = try node_pool.create(); self_clone.instruction = self.instruction; if (self.next) |next| { self_clone.next = try next.clone(node_pool); } else { self_clone.next = null; } return self_clone; }