コード例 #1
0
        /*-----------------------------------------------------------------------------
         * Function: GetEnumerator
         * Description: Returns an enumerator over the sorted array of entries
         *              We fill entries with recursiveFillEntries, which will store
         *              in the array the entries of the parents and the current
         *---------------------------------------------------------------------------*/
        public IEnumerator <SymbolEntry <T> > GetEnumerator()
        {
            SymbolEntry <T>[] values = new SymbolEntry <T> [this.entriesCount];

            recursiveFillEntries(this, values);

            Array.Sort(values, (a, b) => b.offset.CompareTo(a.offset));

            foreach (var i in values)
            {
                yield return(i);
            }
        }
コード例 #2
0
        /*-----------------------------------------------------------------------------
         * Function: NestedSymbolTable<T>::store
         * Description: Stores a symbol on the symbol table. Default size of the
         *              symbol on memory is 1. If there is a name clash, discards
         *              the old symbol. This may leave holes in the memory, could be
         *              optimized
         *---------------------------------------------------------------------------*/
        public int store(string name, T symbol, int size = 1)
        {
            int symbolOffset = this.NextOffset;

            if (!storage.ContainsKey(name))
            {
                this.entriesCount++;
            }
            this.size       += size;
            this.NextOffset += size;

            storage[name] = new SymbolEntry <T>(symbol, symbolOffset, size);

            return(symbolOffset);
        }