public Define ( Symbol name, Datum value ) : |
||
name | Symbol | |
value | Datum | |
Résultat |
public static LexicalEnvironment Extend(LexicalEnvironment env) { env.Define("symbol->string", new SymbolToString().ToStack()); env.Define("string->symbol", new StringToSymbol().ToStack()); env.Define("gensym", new GenSym().ToStack()); return env; }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { env.Define("read", Read.Instance); env.Define("open-input-string", OpenInputString.Instance); env.Define("eof-object?", IsEof.Instance); env.Define("open-input-stream", OpenInputStream.Instance); return env; }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { // Invoke a given instance method on an object env.Define("make-instance-method", DelegateFunctions.MakeDatumFunction(MakeInstanceMethod, ",make-instance-method")); env.Define("get-static-method", DelegateFunctions.MakeDatumFunction(GetStaticMethod, ",get-static-method")); env.Define("get-type", new GetTypeFunction().ToStack()); env.Define("new", new New().ToStack()); env.Define("atom", new WrapAtom().ToStack()); // Define "dot" and "slash" as a macros which allow us to use // Clojure-style syntax for invoking and referring to methods. ResourceLoader.ExecuteResource(env, "LispEngine.ReflectionBinding.ReflectionBuiltins.lisp"); return env; }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { return env.Define("task-descriptions", MakeDatumFunction(getTaskDescriptions, ",task-descriptions")) .Define("execute-with-error-translator", ExecuteWithErrorTranslator.Instance) .Define("env-stack", MakeDatumFunction(getEnvironments, ",env-stack")) .Define("pending-results", MakeDatumFunction(getPendingResults, ",pending-results")) .Define("throw", MakeDatumFunction(throwMsg, ",throw")) .Define("get-env", MakeDatumFunction(getEnv, ",get-env")); }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { env = Arithmetic.Extend(env); env.Define("append", Append.Instance); env = SymbolFunctions.Extend(env); ResourceLoader.ExecuteResource(env, "LispEngine.Bootstrap.Builtins.lisp"); ResourceLoader.ExecuteResource(env, "LispEngine.Bootstrap.Library.lisp"); env = Reader.AddTo(env); return env; }
public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args) { var argList = args.ToArray(); if (argList.Length != 2) throw c.error("Expected 2 arguments: (define <symbol> <expression>). Got {0} instead", argList.Length); var name = argList[0].CastSymbol(); var expression = argList[1]; c = c.PushTask( tc => { env.Define(name, tc.Result); return tc;}, "define '{0}'", name); return c.Evaluate(env, expression); }
public static LexicalEnvironment Extend(LexicalEnvironment env) { return env .Define("+", makeOperation("+", (x, y) => x + y)) .Define("-", makeOperation("-", (x, y) => x - y)) .Define("*", makeOperation("*", (x, y) => x*y)) .Define("/", makeOperation("/", (x, y) => x/y)) .Define("<", makeOperation("<", (x, y) => x < y)) .Define(">", makeOperation(">", (x, y) => x > y)) .Define("bit-and", makeOperation("bit-and", (x , y) => x & y)) .Define("bit-or", makeOperation("bit-or", (x, y) => x | y)) .Define("bit-shift", makeOperation("bit-shift", (x, y) => x << y)); }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { env = env .Define("log", Log.Instance) .Define("lambda", Lambda.Instance) .Define("cons", DelegateFunctions.MakeDatumFunction(DatumHelpers.cons, ",cons")) .Define("set-car!", DelegateFunctions.MakeDatumFunction(DatumHelpers.setCar, ",set-car!")) .Define("set-cdr!", DelegateFunctions.MakeDatumFunction(DatumHelpers.setCdr, ",set-cdr!")) .Define("apply", Apply.Instance) .Define("eq?", EqualFunctions.Eq) .Define("equal?", EqualFunctions.Equal) .Define("quote", Quote.Instance) .Define("define", Define.Instance) .Define("set!", Set.Instance) .Define("begin", Begin.Instance) .Define("call-with-current-continuation", CallCC.Instance) .Define("eval", Eval.Instance) .Define("env", Env.Instance); env = DebugFunctions.AddTo(env); env = Macro.AddTo(env); env = VectorFunctions.AddTo(env); return env; }
public static LexicalEnvironment AddTo(LexicalEnvironment env) { env.Define("unmacro", Unmacro); env.Define("macro", Instance); return env; }
// This is a bit hacky - can't figure out a better way to "supply" the statistics // object yet. Basically, I want to expose "get-counter" to Lisp, but not "statistics" // itself... I guess. public LexicalEnvironment AddTo(LexicalEnvironment env) { env.Define("!get-statistics", DelegateFunctions.MakeFunction(Snapshot, "!get-statistics")); env.Define("!get-statistics-delta", DelegateFunctions.MakeFunction<Statistics, Statistics>(Delta, "!get-statistics-delta")); return env; }
// This is a bit hacky - can't figure out a better way to "supply" the statistics // object yet. Basically, I want to expose "get-counter" to Lisp, but not "statistics" // itself... I guess. public LexicalEnvironment AddTo(LexicalEnvironment env) { env.Define("!get-statistics", DelegateFunctions.MakeFunction(Snapshot, "!get-statistics")); env.Define("!get-statistics-delta", DelegateFunctions.MakeFunction <Statistics, Statistics>(Delta, "!get-statistics-delta")); return(env); }