コード例 #1
0
        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);
            }
        }
コード例 #2
0
        private LookupCompilationDelegate CompileBody(LightExpression <LookupCompilationDelegate> lambda)
        {
            LookupCompilationDelegate func;

            var extractConstant = ExtractConstant(lambda);

            if (extractConstant != null)
            {
                // skip compiling for really simple code
                object value = extractConstant.Value;
                return((codeCtx, functionCode) => value);
            }

            PythonContext pc = (PythonContext)Ast.CompilerContext.SourceUnit.LanguageContext;

            if (ShouldInterpret(pc))
            {
                func = lambda.Compile(pc.Options.CompilationThreshold);
            }
            else
            {
                func = lambda.ReduceToLambda().Compile(pc.EmitDebugSymbols(Ast.CompilerContext.SourceUnit));
            }

            return(func);
        }