// Private methods /*----------------------------------------------------------------------------- * Function: RecurseFillEntries * Description: Stores in values all the entries in the current table and * its parents as well *---------------------------------------------------------------------------*/ 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); } }
/*----------------------------------------------------------------------------- * Function: NestedSymbolTable (ctor) * Description: Creates a new symbol table, child of parent, starting in the * specified offset *---------------------------------------------------------------------------*/ public NestedSymbolTable(NestedSymbolTable <T> parent, int offset) { this.Parent = parent; this.baseOffset = offset; this.NextOffset = offset; this.storage = new Dictionary <string, SymbolEntry <T> >(); this.Nested = new List <NestedSymbolTable <T> >(); if (parent != null) { this.entriesCount = parent.entriesCount; parent.Nested.Add(this); } else { this.entriesCount = 0; } }
/*----------------------------------------------------------------------------- * Function: NestedSymbolTable (ctor) * Description: Creates a new symbol table nested within parent *---------------------------------------------------------------------------*/ public NestedSymbolTable(NestedSymbolTable <T> parent) : this(parent, parent == null? 0 : parent.NextOffset) { }