public void insert(string name, int kind, ASTNode node) { // treat inferface, classe and function names as case insensitive if (kind == SymbolTable.INTERFACE || kind == SymbolTable.CLASS || kind == SymbolTable.FUNCTION) { name = name.ToLower(); } SymbolTableEntry entry = new SymbolTableEntry(name, kind, node); // a new class member? if (kind == SymbolTable.CLASS_VARIABLE) { if (ClassMembers.Contains(name)) { Report.Error(306, name); } ClassMembers.Add(name); } // no symbol with this name exists, so add it if (Entries[name] == null) { Hashtable value = new Hashtable(); value[kind] = entry; Entries[name] = value; } // a symbol with this name already exists else { Hashtable value = (Hashtable)Entries[name]; // but with another kind, so add it if (value[kind] == null) { value[kind] = entry; } // with kind reserved word, class, interface, class variable or function, so report error else { switch (kind) { case SymbolTable.RESERVED_WORD: Report.Error(201, name, node.Line, node.Column); break; case SymbolTable.CLASS: Report.Error(202, name, node.Line, node.Column); break; case SymbolTable.INTERFACE: Report.Error(220, name, node.Line, node.Column); break; case SymbolTable.CLASS_VARIABLE: Report.Error(204, name, node.Line, node.Column); break; case SymbolTable.FUNCTION: Report.Error(211, name, node.Line, node.Column); break; } } } }
public void insert(string name, int kind, ASTNode node) { // treat inferface, classe and function names as case insensitive if (kind == SymbolTable.INTERFACE || kind == SymbolTable.CLASS || kind == SymbolTable.FUNCTION) name = name.ToLower(); SymbolTableEntry entry = new SymbolTableEntry(name, kind, node); // a new class member? if (kind == SymbolTable.CLASS_VARIABLE) { if (ClassMembers.Contains(name)) Report.Error(306, name); ClassMembers.Add(name); } // no symbol with this name exists, so add it if (Entries[name] == null) { Hashtable value = new Hashtable(); value[kind] = entry; Entries[name] = value; } // a symbol with this name already exists else { Hashtable value = (Hashtable)Entries[name]; // but with another kind, so add it if (value[kind] == null) value[kind] = entry; // with kind reserved word, class, interface, class variable or function, so report error else switch (kind) { case SymbolTable.RESERVED_WORD: Report.Error(201, name, node.Line, node.Column); break; case SymbolTable.CLASS: Report.Error(202, name, node.Line, node.Column); break; case SymbolTable.INTERFACE: Report.Error(220, name, node.Line, node.Column); break; case SymbolTable.CLASS_VARIABLE: Report.Error(204, name, node.Line, node.Column); break; case SymbolTable.FUNCTION: Report.Error(211, name, node.Line, node.Column); break; } } }