当前位置: 首页>>代码示例>>C#>>正文


C# LightCompiler.Compile方法代码示例

本文整理汇总了C#中Microsoft.Scripting.Interpreter.LightCompiler.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# LightCompiler.Compile方法的具体用法?C# LightCompiler.Compile怎么用?C# LightCompiler.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Scripting.Interpreter.LightCompiler的用法示例。


在下文中一共展示了LightCompiler.Compile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInstruction

 public virtual Instruction GetInstruction(LightCompiler compiler) {
     compiler.Compile(_context);
     if (_isLocal) {
         return new LookupNameInstruction(_name);
     } else {
         return new LookupGlobalNameInstruction(_name);
     }
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:8,代码来源:LightGlobalRewriter.cs

示例2: AddInstructions

        public void AddInstructions(LightCompiler compiler) {
            Instruction instr = DynamicInstructionN.CreateUntypedInstruction(_binder, ArgumentCount);
            if (instr == null) {
                var lightBinder = _binder as ILightCallSiteBinder;
                if (lightBinder == null || !lightBinder.AcceptsArgumentArray) {
                    compiler.Compile(Reduce());
                    return;
                }

                Debug.Assert(Type == typeof(object));
                instr = new DynamicSplatInstruction(ArgumentCount, CallSite<Func<CallSite, ArgumentArray, object>>.Create(_binder));
            }

            for (int i = 0; i < ArgumentCount; i++) {
                compiler.Compile(GetArgument(i));
            }

            compiler.Instructions.Emit(instr);
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:19,代码来源:LightDynamicExpression.cs

示例3: AddInstructions

 public void AddInstructions(LightCompiler compiler) {
     compiler.Compile(_target);
     switch (Type.GetTypeCode(_binder.Type)) {
         case TypeCode.Boolean:
             compiler.Instructions.Emit(BooleanConversionInstruction.Instance);
             break;
         default:
             compiler.Instructions.Emit(new TypedConversionInstruction(_binder.Type));
             break;
     }
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:11,代码来源:DynamicConvertExpression.cs

示例4: AddInstructions

 public override void AddInstructions(LightCompiler compiler)
 {
     if (Argument0.Type == typeof(CodeContext))
     {
         compiler.Compile(Argument0);
         compiler.Compile(Argument1);
         compiler.Instructions.EmitDynamic<CodeContext, object, object>(Binder);
     }
     else if (Argument1.Type == typeof(CodeContext))
     {
         // GetMember sites
         compiler.Compile(Argument0);
         compiler.Compile(Argument1);
         compiler.Instructions.EmitDynamic<object, CodeContext, object>(Binder);
     }
     else
     {
         base.AddInstructions(compiler);
     }
 }
开发者ID:Alxandr,项目名称:IronTotem,代码行数:20,代码来源:TotemDynamicExpression.cs

示例5: AddInstructions

 public void AddInstructions(LightCompiler compiler)
 {
     compiler.Compile(FunctionDefinition._functionParam);
     compiler.Instructions.Emit(GetLocalClosureFromFunctionInstruction.Instance);
 }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:5,代码来源:GetLocalClosureFromFunctionExpression.cs

示例6: AddInstructions

        public override void AddInstructions(LightCompiler compiler) {
            if (ArgumentCount > 15) {
                compiler.Compile(Reduce());
            } else if (GetArgument(0).Type == typeof(CodeContext)) {
                for (int i = 0; i < ArgumentCount; i++) {
                    compiler.Compile(GetArgument(i));
                }

                switch(ArgumentCount) {
                    case 1: compiler.Instructions.EmitDynamic<CodeContext, object>(Binder); break;
                    case 2: compiler.Instructions.EmitDynamic<CodeContext, object, object>(Binder); break;
                    case 3: compiler.Instructions.EmitDynamic<CodeContext, object, object, object>(Binder); break;
                    case 4: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object>(Binder); break;
                    case 5: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object>(Binder); break;
                    case 6: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object>(Binder); break;
                    case 7: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object>(Binder); break;
                    case 8: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object>(Binder); break;
                    case 9: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 10: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 11: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 12: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 13: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 14: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
                    case 15: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;                    
                }
            } else {
                base.AddInstructions(compiler);
            }
        }
开发者ID:jschementi,项目名称:iron,代码行数:29,代码来源:PythonDynamicExpression.cs

示例7: switch

        void IInstructionProvider.AddInstructions(LightCompiler compiler) {
            if (NeedComparisonTransformation()) {
                // chained comparisons aren't supported for optimized light compiling
                compiler.Compile(Reduce());
                return;
            }

            switch (_op) {
                case PythonOperator.Is:
                    compiler.Compile(_left);
                    compiler.Compile(_right);
                    compiler.Instructions.Emit(IsInstruction.Instance);
                    break;
                case PythonOperator.IsNot:
                    compiler.Compile(_left);
                    compiler.Compile(_right);
                    compiler.Instructions.Emit(IsNotInstruction.Instance);
                    break;
                default:
                    compiler.Compile(Reduce());
                    break;
            }
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:23,代码来源:BinaryExpression.cs

示例8: CreateFunctionInstructions

        private void CreateFunctionInstructions(LightCompiler compiler) {
            // emit context if we have a special local context
            CodeContext globalContext = null;

            // potential optimization to avoid loading the context:
            /*if (Parent.LocalContext == PythonAst._globalContext) {
                globalContext = GlobalParent.ModuleContext.GlobalContext;
            } else*/ {
                compiler.Compile(Parent.LocalContext);
            }

            // emit name if necessary
            PythonGlobalVariableExpression name = GetVariableExpression(_nameVariable) as PythonGlobalVariableExpression;
            PythonGlobal globalName = null;
            if (name == null) {
                compiler.Compile(((IPythonGlobalExpression)GetVariableExpression(_nameVariable)).RawValue());
            } else {
                globalName = name.Global;
            }

            // emit defaults
            int defaultCount = 0;
            for (int i = _parameters.Length - 1; i >= 0; i--) {
                var param = _parameters[i];

                if (param.DefaultValue != null) {
                    compiler.Compile(AstUtils.Convert(param.DefaultValue, typeof(object)));
                    defaultCount++;
                }
            }

            compiler.Instructions.Emit(new FunctionDefinitionInstruction(globalContext, this, defaultCount, globalName));
        }
开发者ID:mstram,项目名称:ironruby,代码行数:33,代码来源:FunctionDefinition.cs

示例9: AddInstructions

 public void AddInstructions(LightCompiler compiler)
 {
     compiler.Compile(FunctionDefinition._functionParam);
     compiler.Instructions.Emit(GetParentContextFromFunctionInstruction.Instance);
 }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:5,代码来源:GetParentContextFromFunctionExpression.cs

示例10: switch

        void IInstructionProvider.AddInstructions(LightCompiler compiler) {
            if (_target is NameExpression && ((NameExpression)_target).Name == "unicode") {
                compiler.Compile(Reduce());
                return;
            }

            for (int i = 0; i < _args.Length; i++) {
                if (!_args[i].GetArgumentInfo().IsSimple) {
                    compiler.Compile(Reduce());
                    return;
                }
            }

            switch (_args.Length) {
                #region Generated Python Call Expression Instruction Switch

                // *** BEGIN GENERATED CODE ***
                // generated by function: gen_call_expression_instruction_switch from: generate_calls.py

                case 0:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Instructions.Emit(new Invoke0Instruction(Parent.PyContext));
                    return;
                case 1:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Instructions.Emit(new Invoke1Instruction(Parent.PyContext));
                    return;
                case 2:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Compile(_args[1].Expression);
                    compiler.Instructions.Emit(new Invoke2Instruction(Parent.PyContext));
                    return;
                case 3:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Compile(_args[1].Expression);
                    compiler.Compile(_args[2].Expression);
                    compiler.Instructions.Emit(new Invoke3Instruction(Parent.PyContext));
                    return;
                case 4:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Compile(_args[1].Expression);
                    compiler.Compile(_args[2].Expression);
                    compiler.Compile(_args[3].Expression);
                    compiler.Instructions.Emit(new Invoke4Instruction(Parent.PyContext));
                    return;
                case 5:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Compile(_args[1].Expression);
                    compiler.Compile(_args[2].Expression);
                    compiler.Compile(_args[3].Expression);
                    compiler.Compile(_args[4].Expression);
                    compiler.Instructions.Emit(new Invoke5Instruction(Parent.PyContext));
                    return;
                case 6:
                    compiler.Compile(Parent.LocalContext);
                    compiler.Compile(_target);
                    compiler.Compile(_args[0].Expression);
                    compiler.Compile(_args[1].Expression);
                    compiler.Compile(_args[2].Expression);
                    compiler.Compile(_args[3].Expression);
                    compiler.Compile(_args[4].Expression);
                    compiler.Compile(_args[5].Expression);
                    compiler.Instructions.Emit(new Invoke6Instruction(Parent.PyContext));
                    return;

                // *** END GENERATED CODE ***

                #endregion
            }
            compiler.Compile(Reduce());
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:82,代码来源:CallExpression.cs

示例11:

 void IInstructionProvider.AddInstructions(LightCompiler compiler) {
     // the interpreter deals with jumps out of finally blocks just fine:
     compiler.Compile(_body);
 }
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:FinallyFlowControlExpression.cs

示例12: AddInstructions

 public void AddInstructions(LightCompiler compiler) {
     compiler.Compile(_target);
     compiler.Compile(_codeContext);
     compiler.Instructions.Emit(new GetMemberInstruction(_binder));
 }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:5,代码来源:DynamicGetMemberExpression.cs

示例13: LookupGlobalInstruction

 Instruction IInstructionProvider.GetInstruction(LightCompiler compiler) {
     compiler.Compile(_scope);
     return new LookupGlobalInstruction(_name, _isLocal);
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:4,代码来源:PythonGlobalVariableExpression.cs

示例14: GetInstruction

 public Instruction GetInstruction(LightCompiler compiler) {
     compiler.Compile(_value);
     return new PythonSetGlobalInstruction(_global.Global);
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:4,代码来源:PythonGlobalVariableExpression.cs

示例15:

 void IInstructionProvider.AddInstructions(LightCompiler compiler) {
     // optimizing bool conversions does no good in the light compiler
     compiler.Compile(ReduceWorker(false));
 }
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:IfStatement.cs


注:本文中的Microsoft.Scripting.Interpreter.LightCompiler.Compile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。