Пример #1
0
        public void AddSymbol(LllSymbol symbol)
        {
            var uniqBot = _lllUniqueSymbols.Peek();

            if (uniqBot.ContainsKey(symbol.MangledName))
            {
                var sym = uniqBot[symbol.MangledName];
                var msg = string.Format(
                    "Error: {0} : Symbol `{1}' already declared at {2}.",
                    symbol.Extra.SourceInfo, symbol.Name, sym.Extra.SourceInfo);
                throw new SymbolAlreadyDeclaredException(msg);
            }
            uniqBot.Add(symbol.MangledName, symbol);
            var top = _lllSymbols.Peek();

            if (top.ContainsKey(symbol.Name))
            {
                top[symbol.Name].Add(symbol);
            }
            else
            {
                var symList = new LllSymbolList();
                symList.Add(symbol);
                top.Add(symbol.Name, symList);
            }
        }
Пример #2
0
        public void AddSymbolAtGlobalScope(LllSymbol symbol)
        {
            _lllUniqueSymbols.Last().Add(symbol.MangledName, symbol);
            var bottom = _lllSymbols.Peek();

            if (bottom.ContainsKey(symbol.Name))
            {
                bottom[symbol.Name].Add(symbol);
            }
            else
            {
                var symList = new LllSymbolList();
                symList.Add(symbol);
                bottom.Add(symbol.Name, symList);
            }
        }
Пример #3
0
        public void SetSymbolAtGlobalScope(LllSymbol symbol)
        {
            _lllUniqueSymbols.Last()[symbol.MangledName] = symbol;
            var bottom = _lllSymbols.Peek();

            if (bottom.ContainsKey(symbol.Name))
            {
                var withSharedName = bottom[symbol.Name];
                withSharedName.RemoveAll(sym => sym.MangledName == symbol.MangledName);
                withSharedName.Add(symbol);
            }
            else
            {
                var symList = new LllSymbolList();
                symList.Add(symbol);
                bottom.Add(symbol.Name, symList);
            }
        }