private void EnsureTracingTarget() { if (_tracingTarget == null) { PythonContext pc = (PythonContext)Ast.CompilerContext.SourceUnit.LanguageContext; var debugProperties = new PythonDebuggingPayload(null); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); var lambda = (Expression <LookupCompilationDelegate>)pc.DebugContext.TransformLambda((MSAst.LambdaExpression)Ast.GetLambda().Reduce(), debugInfo); LookupCompilationDelegate func; if (ShouldInterpret(pc)) { func = (LookupCompilationDelegate)CompilerHelpers.LightCompile(lambda, pc.Options.CompilationThreshold); } else { func = (LookupCompilationDelegate)lambda.Compile(pc.EmitDebugSymbols(Ast.CompilerContext.SourceUnit)); } _tracingTarget = func; debugProperties.Code = EnsureFunctionCode(_tracingTarget, true, true); } }
private void EnsureTracingTarget() { if (_tracingTarget == null) { PythonContext pc = (PythonContext)Ast.CompilerContext.SourceUnit.LanguageContext; var debugProperties = new PythonDebuggingPayload(null); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); var lambda = pc.DebugContext.TransformLambda(Ast.GetLambda(), debugInfo); _tracingTarget = CompileBody((Expression <Func <CodeContext /*!*/, FunctionCode /*!*/, object> >)lambda); debugProperties.Code = EnsureFunctionCode(_tracingTarget); } }
private void EnsureTracingTarget() { if (_tracingTarget == null) { PythonContext pc = (PythonContext)_context.SourceUnit.LanguageContext; var debugProperties = new PythonDebuggingPayload(null, _loopAndFinallyLocations, _handlerLocations); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); _tracingTarget = CompileBody((Expression<Func<CodeContext/*!*/, FunctionCode/*!*/, object>>)pc.DebugContext.TransformLambda(_lambda, debugInfo)); debugProperties.Code = EnsureFunctionCode(_tracingTarget); } }
/// <summary> /// Gets the LambdaExpression for tracing. /// /// If this is a generator function code then the lambda gets tranformed into the correct generator code. /// </summary> private LambdaExpression GetGeneratorOrNormalLambdaTracing(PythonContext context) { var debugProperties = new PythonDebuggingPayload(this); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); if ((Flags & FunctionAttributes.Generator) == 0) { return context.DebugContext.TransformLambda((LambdaExpression)Compiler.Ast.Node.RemoveFrame(_lambda.GetLambda()), debugInfo); } return Expression.Lambda( Code.Type, new GeneratorRewriter( _lambda.Name, Compiler.Ast.Node.RemoveFrame(Code.Body) ).Reduce( _lambda.ShouldInterpret, _lambda.EmitDebugSymbols, context.Options.CompilationThreshold, Code.Parameters, x => (Expression<Func<MutableTuple, object>>)context.DebugContext.TransformLambda(x, debugInfo) ), Code.Name, Code.Parameters ); }
private void EnsureTracingTarget() { if (_tracingTarget == null) { PythonContext pc = (PythonContext)Ast.CompilerContext.SourceUnit.LanguageContext; var debugProperties = new PythonDebuggingPayload(null); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); var lambda = (Expression<LookupCompilationDelegate>)pc.DebugContext.TransformLambda((MSAst.LambdaExpression)Ast.GetLambda().Reduce(), debugInfo); LookupCompilationDelegate func; if (ShouldInterpret(pc)) { func = (LookupCompilationDelegate)CompilerHelpers.LightCompile(lambda, pc.Options.CompilationThreshold); } else { func = (LookupCompilationDelegate)lambda.Compile(pc.EmitDebugSymbols(Ast.CompilerContext.SourceUnit)); } _tracingTarget = func; debugProperties.Code = EnsureFunctionCode(_tracingTarget, true, true); } }
/// <summary> /// Gets the LambdaExpression for tracing. /// /// If this is a generator function code then the lambda gets tranformed into the correct generator code. /// </summary> private LambdaExpression GetGeneratorOrNormalLambdaTracing(PythonContext context) { var debugProperties = new PythonDebuggingPayload(this, _loopAndFinallyLocations, _handlerLocations); var debugInfo = new Microsoft.Scripting.Debugging.CompilerServices.DebugLambdaInfo( null, // IDebugCompilerSupport null, // lambda alias false, // optimize for leaf frames null, // hidden variables null, // variable aliases debugProperties // custom payload ); if ((_flags & FunctionAttributes.Generator) == 0) { return context.DebugContext.TransformLambda(_lambda, debugInfo); } return Expression.Lambda( Code.Type, new GeneratorRewriter( _name, Code.Body ).Reduce( _shouldInterpret, _debuggable, Code.Parameters, x => (Expression<Func<MutableTuple, object>>)context.DebugContext.TransformLambda(x, debugInfo) ), Code.Name, Code.Parameters ); }