public Symbol <AST> Resolve(string name, bool search_global, int line = -1) { if (EnclosingScope == null && !search_global) { return(null); } if (symbols.ContainsKey(name)) { return(symbols[name]); } Symbol <AST> rt = null; // if not here, check any enclosing scope if (EnclosingScope != null) { rt = EnclosingScope.Resolve(name, search_global); } if (rt == null && line > 0) { ConsoleColor restore = Console.ForegroundColor; Console.ForegroundColor = System.ConsoleColor.Red; Console.Error.WriteLine("line {0}: {1} is undefined", line, name); Console.ForegroundColor = restore; } return(rt); // not found }
public Symbol Resolve(String name) { Symbol o; if (Symbols.TryGetValue(name, out o)) { return(o); } if (EnclosingScope == null) { return(null); } return(EnclosingScope.Resolve(name)); }
public Symbol Resolve(string name) { Symbol s; if (this.Members.TryGetValue(name, out s)) { return(s); } else if (EnclosingScope != null) { return(EnclosingScope.Resolve(name)); } else { return(null); } }
/// <summary> ClassSymbol and MethodSymbol overload this.</summary> /// <param name="name">the symbol to resolve</param> /// <param name="search_global">search the global namespace?</param> /// <returns>Symbol</returns> public virtual Symbol <AST> ResolveSymbol(string name, bool search_global) { if (EnclosingScope == null && !search_global) { return(null); } if (Members.ContainsKey(name)) { return(Members[name]); } // if not here, check any parent scope if (EnclosingScope != null) { return(EnclosingScope.Resolve(name, search_global)); } return(null); // not found }