private static PrettyPrinter.Node ShowStackNode(ImmutableDictionary <int, TiNode> heap, TiNode node) => node switch {
private static (ImmutableDictionary <int, TiNode>, int) Allocate(ImmutableDictionary <int, TiNode> heap, TiNode node) { var addr = heap.Keys.Max() + 1; var newHeap = heap.Add(addr, node); return(newHeap, addr); }
private static (ImmutableDictionary <int, TiNode>, int) AssignOrAllocate(int?addr, ImmutableDictionary <int, TiNode> heap, TiNode node) { return(addr.HasValue ? (Assign(addr.Value, heap, node), addr.Value) : Allocate(heap, node)); }
private static ImmutableDictionary <int, TiNode> Assign(int addr, ImmutableDictionary <int, TiNode> heap, TiNode node) { return(heap.SetItem(addr, node)); }
public Marked(TiNode node) { Node = node; }