} // the method declaration itself public MethodSymbolTable(ClassSymbolTable parentClass, DeclaringNode methodDeclaring, ErrorSummary errorSummary) { _parentClass = parentClass; MethodDeclaring = methodDeclaring; _methodVarDeclarings = new Dictionary <string, DeclaringNode>(); _errorSummary = errorSummary; }
public object Visit(InterfaceDeclaringNode n, object o) { _currentScopeLevel = 1; _currentClassST = new ClassSymbolTable(n, _stdlib, _errorSummary); n.InterfaceMethods.Accept(this, null); AddToGlobalTable(n.Identifier.Value, _currentClassST); return(null); }
private void AddToGlobalTable(string ident, ClassSymbolTable classST) { if (_globalTable.ContainsKey(ident)) { _errorSummary.AddError(new SemanticError($"'{ident}' is already declared", classST.ClassDeclaring.SourcePosition)); } else { _globalTable.Add(ident, classST); } }
public object Visit(ClassDeclaringNode n, object o) { _currentScopeLevel = 1; _currentClassST = new ClassSymbolTable(n, _stdlib, _errorSummary); n.Implements.Accept(this, null); n.Variables.Accept(this, null); n.Constructor.Accept(this, null); n.Methods.Accept(this, null); AddToGlobalTable(n.Identifier.Value, _currentClassST); return(null); }