private static Object.Object EvalIdentifier(Ast.Identifier node, Object.Environment env) { if (env.Exist(node.Value)) { return(env.Get(node.Value)); } if (builtins.ContainsKey(node.Value)) { return(builtins[node.Value]); } return(new Object.Error { Message = $"identifier not found: {node.Value}" }); }
static Object.Object evalIdentifier(ast.Identifier node, Object.Environment env) { Object.Object val = env.Get(node.Value); if (val != null) { return(val); } Object.Builtin builtin; if (evaluator_builtins.builtins.TryGetValue(node.Value, out builtin)) { return(builtin); } return(newError("identifier not found: " + node.Value));; }
private static MonkeyObject evalIdentifier(Identifier id, Object.Environment environment) { if (environment.Get(id.Value, out var value)) { return(value); } if (Builtins.builtins.TryGetValue(id.Value, out var builtin)) { return(builtin); } return(new MonkeyError { Message = $"identifier not found: {id.Value}" }); }
static Object.Macro isMacroCall(ast.CallExpression exp, Object.Environment env) { if (!(exp.Function is ast.Identifier)) { return(null); } ast.Identifier identifier = (ast.Identifier)exp.Function; Object.Object obj = env.Get(identifier.Value); if (obj == null) { return(null); } if (!(obj is Object.Macro)) { return(null); } Object.Macro macro = (Object.Macro)obj; return(macro); }