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


C# CodeGen.EmitReturn方法代码示例

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


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

示例1: Emit

 internal override void Emit(CodeGen cg)
 {
     cg.EmitPosition(this);
     cg.EmitReturn(expr);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:Statements.cs

示例2: EmitFunctionBody

        private void EmitFunctionBody(CodeGen cg, CodeGen ocg)
        {
            if (HasEnvironment) {
                cg.ContextSlot = cg.EnvironmentSlot = CreateEnvironment(cg);
            }
            if (cg.ContextSlot == null && IsClosure) {
                cg.ContextSlot = cg.StaticLinkSlot;
            }

            // Populate the environment with slots
            if (ocg != null) {
                CreateGlobalSlots(cg, ocg);
                CreateClosureSlots(cg);
            }
            CreateLocalSlots(cg);
            EmitTupleParams(cg);
            Body.Emit(cg);
            cg.EmitReturn(null);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:19,代码来源:FuncDef.cs

示例3: EmitGeneratorBody

        private void EmitGeneratorBody(CodeGen cg, CodeGen ocg)
        {
            // Create the GenerateNext function
            CodeGen ncg = cg.DefineMethod(name.GetString() + "$g" + counter++, typeof(bool),
                new Type[] { typeof(Generator), typeof(object).MakeByRefType() },
                new String[] { "$gen", "$ret" });
            ncg.Context = cg.Context;

            PromoteLocalsToEnvironment();
            ncg.FuncOrClassName = name.ToString();
            ncg.EmitSetTraceBackUpdateStatus(false);

            // Namespace without er factory - all locals must exist ahead of time
            ncg.Names = new Namespace(null);
            Slot generator = ncg.GetArgumentSlot(0);
            ncg.StaticLinkSlot = new FieldSlot(generator, typeof(Generator).GetField("staticLink"));
            if (HasEnvironment) {
                cg.EnvironmentSlot = CreateEnvironment(cg);
                EnvironmentFactory ef = this.environmentFactory;
                Slot envSlotCast = new CastSlot(
                    new FieldSlot(generator, typeof(Generator).GetField("environment")),
                    ef.EnvironmentType
                    );
                Slot envSlot = ncg.GetLocalTmp(ef.EnvironmentType);
                // setup the environment and static link slots
                ncg.EnvironmentSlot = envSlot;
                ncg.ContextSlot = envSlot;
                // pull the environment into typed local variable
                envSlot.EmitSet(ncg, envSlotCast);
                InheritEnvironment(ncg);
                CreateGeneratorTemps(ef, ncg);
            } else {
                ncg.ContextSlot = ncg.StaticLinkSlot;
            }
            ncg.ModuleSlot = new PropertySlot(ncg.ContextSlot, typeof(ICallerContext).GetProperty("Module"));

            CreateClosureSlots(ncg);
            CreateGlobalSlots(ncg, ocg);

            // Emit the generator body using the typed er
            EmitGenerator(ncg);

            // Initialize the generator
            EmitTupleParams(cg);

            // Create instance of the generator
            cg.EmitStaticLinkOrNull();
            cg.EmitEnvironmentOrNull();
            cg.EmitDelegate(ncg, typeof(Generator.NextTarget), null);
            cg.EmitNew(typeof(Generator), new Type[] { typeof(FunctionEnvironmentDictionary), typeof(FunctionEnvironmentDictionary), typeof(Generator.NextTarget) });
            cg.EmitReturn();
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:52,代码来源:FuncDef.cs

示例4: Generate

 public virtual void Generate(CodeGen cg, Slot contextSlot, Slot[] argSlots)
 {
     cg.EmitConvertToObject(returnType);
     cg.EmitReturn();
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:MethodBinder.cs

示例5: EmitBody

 protected internal override void EmitBody(CodeGen cg)
 {
     if (!cg.HasAllocator) {
         // In the interpreted case, we do not have an allocator yet
         Debug.Assert(cg.InterpretedMode);
         cg.Allocator = CompilerHelpers.CreateFrameAllocator();
     }
     cg.Allocator.Block = this;
     CreateEnvironmentFactory(true, cg);
     EmitGeneratorBody(cg);
     cg.EmitReturn();
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:12,代码来源:GeneratorCodeBlock.cs

示例6: Emit

 public override void Emit(CodeGen cg)
 {
     //cg.EmitPosition(Start, End);
     cg.EmitReturn(_expr);
     //cg.EmitSequencePointNone();
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:6,代码来源:ReturnStatement.cs

示例7: EmitBaseMethodDispatch

 /// <summary>
 /// Loads all the incoming arguments of cg and forwards them to mi which
 /// has the same signature and then returns the result
 /// </summary>
 private static void EmitBaseMethodDispatch(MethodInfo mi, CodeGen cg)
 {
     if (!mi.IsAbstract) {
         cg.EmitThis();
         foreach (Slot argSlot in cg.argumentSlots) argSlot.EmitGet(cg);
         cg.EmitCall(OpCodes.Call, mi, null); // base call must be non-virtual
         cg.EmitReturn();
     } else {
         cg.EmitThis();
         cg.EmitString(mi.Name);
         cg.EmitCall(typeof(Ops), "MissingInvokeMethodException");
         cg.Emit(OpCodes.Throw);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:18,代码来源:NewTypeMaker.cs

示例8: EmitFinallyFlowControl

        /// <summary>
        /// If the finally statement contains break, continue, return or yield, we need to
        /// handle the control flow statement after we exit out of finally via OpCodes.Endfinally.
        /// </summary>
        private static void EmitFinallyFlowControl(CodeGen cg, TryFlowResult flow, Slot flag)
        {
            if (flow.Return || flow.Yield) {
                Debug.Assert(flag != null);

                Label noReturn = cg.DefineLabel();

                flag.EmitGet(cg);
                cg.EmitInt(CodeGen.BranchForReturn);
                cg.Emit(OpCodes.Bne_Un, noReturn);

                if (cg.IsGenerator) {
                    // return true from the generator method
                    cg.Emit(OpCodes.Ldc_I4_1);
                    cg.EmitReturn();
                } else if (flow.Any) {
                    // return the actual value
                    cg.EmitReturnValue();
                    cg.EmitReturn();
                }
                cg.MarkLabel(noReturn);
            }

            // Only emit break handling if it is actually needed
            if (flow.Break) {
                Debug.Assert(flag != null);

                Label noReturn = cg.DefineLabel();
                flag.EmitGet(cg);
                cg.EmitInt(CodeGen.BranchForBreak);
                cg.Emit(OpCodes.Bne_Un, noReturn);
                cg.EmitBreak();
                cg.MarkLabel(noReturn);
            }

            // Only emit continue handling if it if actually needed
            if (flow.Continue) {
                Debug.Assert(flag != null);

                Label noReturn = cg.DefineLabel();
                flag.EmitGet(cg);
                cg.EmitInt(CodeGen.BranchForContinue);
                cg.Emit(OpCodes.Bne_Un, noReturn);
                cg.EmitContinue();
                cg.MarkLabel(noReturn);
            }
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:51,代码来源:TryStatement.cs


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