public object Eval(object form) { ScriptSource scriptSource = Engine.CreateScriptSourceFromString("<internal>"); Expression expr = Generator.Eval(GetLanguageContext(), form); LambdaExpression ast = Expression.Lambda(expr); ast = new GlobalLookupRewriter().RewriteLambda(ast); ScriptCode code = new ScriptCode(ast, GetSourceUnit(scriptSource)); return code.Run(); }
protected object InvokeTarget(LambdaExpression code, Scope scope) { if (scope == _optimizedScope) { return _optimizedTarget(scope, LanguageContext); } // new scope, compile unoptimized code and use that. if (_unoptimizedTarget == null) { // TODO: fix generated DLR ASTs - languages should remove their usage // of GlobalVariables and then this can go away. Expression<DlrMainCallTarget> lambda = new GlobalLookupRewriter().RewriteLambda(code); _unoptimizedTarget = lambda.Compile(SourceUnit.EmitDebugSymbols); } return _unoptimizedTarget(scope, LanguageContext); }
private static object LoadFromPushbackReader(ScriptSource scriptSource, TextReader pbr, bool addPrint) { object ret = null; object eofVal = new object(); object form; while ((form = LispReader.read(pbr, false, eofVal, false)) != eofVal) { LambdaExpression ast = Generator.Generate(form, addPrint); ast = new GlobalLookupRewriter().RewriteLambda(ast); ScriptCode code = new ScriptCode(ast, GetSourceUnit(scriptSource)); ret = code.Run(); } return ret; }