const builtin = @import("builtin"); const std = @import("std"); const value = @import("value.zig"); //const PairPool = @import("gc/PairPool.zig"); const PairPool = std.heap.MemoryPool(value.pair.Pair); // TODO const IstrSet = @import("gc/IstrSet.zig"); const Value = value.Value; const PairPtr = value.pair.PairPtr; const IstrPtr = value.istr.IstrPtr; pub const alloc = std.heap.smp_allocator; // Pairs var pair_pool: PairPool = undefined; pub fn makePair(v1: Value, v2: Value) PairPtr { init(); // TODO this is only here for the test suite const p = pair_pool.create(alloc) catch @panic("OOM"); p.car = v1; p.cdr = v2; return p; } // Interned strings var istr_set: IstrSet = undefined; pub fn internString(s: []const u8) value.istr.IstrPtr { init(); // TODO this is only here for the test suite return istr_set.add(alloc, s) catch @panic("OOM"); } // Init var need_init = true; pub fn init() void { if (!need_init) return; defer need_init = false; pair_pool = PairPool.initCapacity(alloc, 64) catch @panic("OOM"); istr_set = IstrSet.init(alloc) catch @panic("OOM"); }