const std = @import("std"); const Block = @import("../block.zig"); const Node = @import("../node.zig"); const Rule = @import("../../rule.zig"); pub fn optimize_block( blocks: []Block, raw: *Block, target: *Block, node_pool: *std.heap.MemoryPool(Node), allocator: std.mem.Allocator, ) !void { target.* = try raw.clone(allocator, node_pool); _ = blocks; //for (target.heads.items) |head| { // try hard_link_right_recursion(target, head); //} } pub fn hard_link_right_recursion( block: *Block, current: *Node, ) !void { switch (current.instruction) { .call => |id| if (id == block.id) { if (current.next.?.instruction == .@"return") { current.instruction = .{ .jump = &block.heads }; return; } }, else => {}, } if (current.next) |next| { try hard_link_right_recursion(block, next); } }