public static Symbol get_symbol(string name, out bool was_defined) { Symbol sym; was_defined = symbol_world.TryGetValue(name, out sym); if (!was_defined) { sym = new Symbol(name); symbol_world.Add(name, sym); } return sym; }
public object lookup(TxtLocation loc, Symbol sym) { object def; if (definitions.TryGetValue(sym, out def)) { return def; } else if (m_parent != null) { return m_parent.lookup(loc, sym); } else if (m_trap(sym, out def)) { return def; } else { throw new InterpreterException(loc, sym.name + " is undefined"); } }
public static string get_abbrev(Symbol sym) { if (sym == quote) { return "'"; } else if (sym == quasiquotation) { return "`"; } else if (sym == unquote) { return ","; } else if (sym == unquote_splicing) { return ",@"; } else { return null; } }
public void visit_value(Symbol s) { scount++; }
private bool GetSymbol(string name, out Symbol symbol) => symbols.TryGetValue(name, out symbol);
public override void visit(Symbol o) { if (m_atom != null) m_atom.visit(o); }
bool write_abbrev(Symbol sym) { string abbrev = Abbrev.get_abbrev(sym); if (abbrev != null) { m_writer.Append(abbrev); return true; } else { return false; } }
static bool no_trap(Symbol sym, out object def) { def = null; return false; }
public void AddMacro(Symbol sym, SpecialForm.Macro m) { definitions.Add(sym, new SpecialForm(m)); }
public void AddFn(Symbol sym, Closure.Fn fn) { definitions.Add(sym, new Closure(fn)); }
public void Add(Symbol sym, object def) { definitions.Add(sym, def); }
public override void visit(Symbol o) { base.visit(o); m_print.print(outbox); }
public override void visit(Symbol o) { outbox.put(m_env.lookup(m_loc, o)); }
public virtual void visit(Symbol o) { visit((object)o); }