/// <summary> /// Creates the LambdaExpression which is the actual function body. /// </summary> private LightLambdaExpression EnsureFunctionLambda() { if (_dlrBody == null) { PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Creating FunctionBody"); _dlrBody = CreateFunctionLambda(); } return _dlrBody; }
public PythonGeneratorExpression(LightLambdaExpression lambda, int compilationThreshold) { _lambda = lambda; _compilationThreshold = compilationThreshold; }
internal override void RewriteBody(TotemAst.LookupVisitor visitor) { _dlrBody = null; // clear the cached body if we've been reduced MSAst.Expression funcCode = GlobalParent.Constant(GetOrMakeFunctionCode()); FuncCodeExpr = funcCode; Body = new TotemAst.RewrittenBodyStatement(Body, visitor.Visit(Body)); }
internal LightDelegateCreator(Interpreter interpreter, LightLambdaExpression lambda) { Assert.NotNull(lambda); _interpreter = interpreter; _lambda = lambda; }
private Delegate CompileLambda(LightLambdaExpression code, EventHandler<LightLambdaCompileEventArgs> handler) { #if EMIT_PDB if (_lambda.EmitDebugSymbols) { return CompilerHelpers.CompileToMethod((LambdaExpression)code.Reduce(), DebugInfoGenerator.CreatePdbGenerator(), true); } #endif if (_lambda.ShouldInterpret) { Delegate result = code.Compile(_lambda.GlobalParent.PyContext.Options.CompilationThreshold); // If the adaptive compiler decides to compile this function, we // want to store the new compiled target. This saves us from going // through the interpreter stub every call. var lightLambda = result.Target as LightLambda; if (lightLambda != null) { lightLambda.Compile += handler; } return result; } return code.Compile(); }
public TotemGeneratorExpression(LightLambdaExpression lambda, bool async, int compilationThreshold) { _lambda = lambda; _compilationThreshold = compilationThreshold; _async = async; }
internal override void RewriteBody(PythonAst.LookupVisitor visitor) { _dlrBody = null; _body = new PythonAst.RewrittenBodyStatement(Body, visitor.Visit(Body)); }
internal override LightLambdaExpression GetLambda() { if (_dlrBody == null) { PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Creating FunctionBody"); _dlrBody = MakeClassBody(); } return _dlrBody; }
private Delegate CompileLambda(LightLambdaExpression code, EventHandler<LightLambdaCompileEventArgs> handler) { if (_lambda.ShouldInterpret) { Delegate result = code.Compile(_lambda.GlobalParent.TotemContext.Options.CompilationThreshold); // If the adaptive compiler decides to compile this function, we // want to store the new compiled target. This saves us from going // through the interpreter stub every call. var lightLambda = result.Target as LightLambda; if (lightLambda != null) { lightLambda.Compile += handler; } return result; } return code.Compile(); }