예제 #1
0
 public LllSymbol(LllSymbol copyFrom)
 {
     Name        = copyFrom.Name;
     CName       = copyFrom.CName;
     Extra       = copyFrom.Extra;
     MangledName = copyFrom.MangledName;
 }
예제 #2
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);
            }
        }
예제 #3
0
        public void Add(LllSymbol symbol)
        {
            var funcSym = symbol as LllFunction;

            if (funcSym != null)
            {
                var func = funcSym.Extra as AstFunc;
                if (func.IsGeneric)
                {
                    GenericSymbols.Add(symbol);
                    return;
                }
            }
            var structSym = symbol as LllStruct;

            if (structSym != null)
            {
                var @struct = structSym.Struct;
                if (@struct.IsGeneric)
                {
                    GenericSymbols.Add(symbol);
                    return;
                }
            }
            ConcreteSymbols.Add(symbol);
        }
예제 #4
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);
            }
        }
예제 #5
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);
            }
        }