using Qrakhen.Qamp.Core.Collections; namespace Qrakhen.Qamp.Core.Values.Objects; public class ObjTable(int size = 4096) { public static readonly ObjTable Shared = new ObjTable(4096); private readonly Table _table = new Table(size); public Obj? Get(Address address) => _table[address]; public T? Get(Address address) where T : Obj => _table[address] as T; public bool TryGet(Address address, out Obj? obj) => _table.TryGet(address, out obj); public void Free(Address address) => _table.Free(address); public Address Register(Obj obj) => _table.Add(obj); } public class Obj : ITypedValue { internal bool __GC_Marked = false; internal int __GC_Count = 1; internal readonly Address __Address; // unsure lol public readonly ValueType Type; public ValueType ValueType => Type; public Obj(ValueType type) { Type = type; __Address = ObjTable.Shared.Register(this); } public static Value Create(Obj obj) { return new Value(Ptr.Create(obj)); } public override string ToString() => "Obj"; }