static ConSymbolInfo LookupCon(string name, GlobalSymbolInfo gsi) { SymbolInfo si = gsi.SymbolTable.Lookup(new SimpleToken(null, SimpleTokenType.Id, name, 0, 0)); if (si == null) { return null; } else { ConSymbolInfo csi = si as ConSymbolInfo; if (csi == null) { throw new ParseException(name + " must be a CON", si.IdToken); } return csi; } }
public static GlobalSymbolInfo Add(SimpleToken token, ObjectFileSymbolTable objectFileSymbolTable) { // New global symbols are added to the global symbol table and to globalList (at the end). // Existing global symbols are moved to the end of globalList. This is done to duplicate // PropTool's behavior. Why PropTool does what it does I have no idea. // 7/24 Finally realized why: when the objects are laid out in this order, all // the inter-object offsets are positive. GlobalSymbolInfo gsi = GlobalSymbolTable.Lookup(token); if (gsi == null) { gsi = new GlobalSymbolInfo(token, objectFileSymbolTable); globalSymbolTable.AddSymbolInfo(gsi); globalList.Add(gsi); } else { if (!gsi.AlreadyRead) throw new ParseException("Circular object reference", token); for (int i = 0; i < globalList.Count; ++i) { if (globalList[i] == gsi) { globalList.RemoveAt(i); globalList.Add(gsi); break; } } } return gsi; }