/// <summary> /// Stores in values all the entries in the current table and its parents as well /// </summary> /// <param name="current"></param> /// <param name="values"></param> /// <returns></returns> private int RecursiveFillEntries(NestedSymbolTable <T> current, SymbolEntry <T>[] values) { if (current == null) { return(0); } else { int offset = RecursiveFillEntries(current.Parent, values); current._storage.Values.CopyTo(values, offset); return(offset + current._storage.Count); } }
/// <summary> /// Creates a new symbol table, child of parent, starting in the specified offset /// </summary> /// <param name="parent"></param> /// <param name="offset"></param> public NestedSymbolTable(NestedSymbolTable <T> parent, int offset) { Parent = parent; _baseOffset = offset; _nextOffset = offset; _storage = new Dictionary <string, SymbolEntry <T> >(); Nested = new List <NestedSymbolTable <T> >(); if (parent != null) { _entriesCount = parent._entriesCount; parent.Nested.Add(this); } else { _entriesCount = 0; } }
/// <summary> /// Creates a new symbol table nested within parent /// </summary> /// <param name="parent"></param> public NestedSymbolTable(NestedSymbolTable <T> parent) : this(parent, (parent == null ? 0 : parent._nextOffset)) { }