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


C# CodeGenContext.ldloc方法代码示例

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


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

示例1: GenSimple

 public virtual void GenSimple(CodeGenContext context)
 {
     context.ldloc(0);
     context.ldfld(field);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:5,代码来源:Variables.cs

示例2: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            // String.Concat(String.Concat(arg1, arg2), args, ...);

            head.GenCode0(context);

            if (head.nd_next != null)
            {
                int first = context.StoreInTemp("head", Runtime.StringRef, head.location);

                for (Node n = head.nd_next; n != null; n = n.nd_next)
                {
                    n.GenCode0(context);
                    int second = context.StoreInTemp("tail", Runtime.StringRef, n.location);

                    context.ldloc(first);
                    context.ldloc(second);
                    context.callvirt(Runtime.String.Concat);
                    context.stloc(first);

                    context.ReleaseLocal(second, true);
                }

                context.ldloc(first);

                context.ReleaseLocal(first, true);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:28,代码来源:Strings.cs

示例3: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            // hash = new Hash();
            context.newobj(Runtime.Hash.ctor);
            int hash = context.StoreInTemp("hash", Runtime.HashRef, location);

            Node entry = elements;
            while (entry != null)
            {
                bool key_created, value_created;

                ISimple key = context.PreCompute0(entry, "key", out key_created);
                entry = entry.nd_next;
                ISimple value = context.PreCompute0(entry, "value", out value_created);
                entry = entry.nd_next;

                // hash.Add(key, value);
                context.ldloc(hash);
                key.GenSimple(context);
                value.GenSimple(context);
                context.callvirt(Runtime.Hash.Add);

                context.ReleaseLocal(key, key_created);
                context.ReleaseLocal(value, value_created);
            }

            context.ldloc(hash);

            context.ReleaseLocal(hash, true);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:30,代码来源:Values.cs

示例4: ReturnArray

 protected void ReturnArray(CodeGenContext context)
 {
     // Ruby.Eval.Return(array, caller);
     array.GenCode(context);
     context.ldloc(0);
     context.call(Runtime.Eval.Return);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:7,代码来源:ControlFlow.cs

示例5: GenCall

        internal void GenCall(CodeGenContext context)
        {
            int result = context.CreateLocal("result", PrimitiveType.Object);

            PERWAPI.CILLabel endLabel = context.NewLabel();
            PERWAPI.CILLabel retryLabel = context.NewLabel();

            context.CodeLabel(retryLabel);

            context.StartBlock(Clause.Try);
            {
                // object result = Call(...)
                GenCall0(context);
                context.stloc(result);

                context.Goto(endLabel);
            }
            PERWAPI.TryBlock tryBlock = context.EndTryBlock();
            context.StartBlock(Clause.Catch);
            {
                CatchBreakException(context, result, endLabel);
            }
            context.EndCatchBlock(Runtime.BreakExceptionRef, tryBlock);
            context.StartBlock(Clause.Catch);
            {
                CatchRetryException(context, retryLabel);
            }
            context.EndCatchBlock(Runtime.RetryExceptionRef, tryBlock);

            context.CodeLabel(endLabel);
            context.ldloc(result);

            context.ReleaseLocal(result, true);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:34,代码来源:Calls.cs

示例6: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            PERWAPI.CILLabel finalLabel = context.NewLabel();

            int RescueTemp = context.CreateLocal("rescueTemp", PERWAPI.PrimitiveType.Object);
            context.ldnull();
            context.stloc(RescueTemp);

            if (ensure != null)
            {
                context.StartBlock(Clause.Try); // outer try block with finally

                context.StartBlock(Clause.Try); // inner try block with catch
            }

            GenInnerBlock(context, RescueTemp);

            if (ensure != null)
            {
                context.Goto(finalLabel);

                PERWAPI.TryBlock innerTry = context.EndTryBlock();

                context.StartBlock(Clause.Catch);
                GenRescue(context, null, 0, null);
                context.EndCatchBlock(Runtime.SystemExceptionRef, innerTry);

                PERWAPI.TryBlock outerTry = context.EndTryBlock();
                
                // Fixme: reset labels to prevent branches out of finally block.    
                context.StartBlock(Clause.Finally);
                ensure.GenCode(context);
                if (context.Reachable())
                    context.pop();
                context.endfinally();
                context.EndFinallyBlock(outerTry);

                context.CodeLabel(finalLabel);
                context.newEndPoint(location);
            }

            context.ldloc(RescueTemp);

            context.ReleaseLocal(RescueTemp, true);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:45,代码来源:Exceptions.cs

示例7: CopySimple

        internal void CopySimple(CodeGenContext context, Scope scope)
        {
            if (block != null)
            {
                // locals.block = block;
                string bname = ID.ToDotNetName(block.vid);
                context.ldloc(0);
                LoadBlock(context);
                context.stfld(scope.GetFrameField(bname));
            }

            for (Node f = normal; f != null; f = f.nd_next)
            {
                string fname = ID.ToDotNetName(((VAR)f).vid);

                // local.f = f;
                context.ldloc(0);
                context.ldarg(fname);
                context.stfld(scope.GetFrameField(fname));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:21,代码来源:Formals.cs

示例8: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            if (qualified)
                if (scope != null)
                    scope.GenCode(context);
                else
                    context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
            else
                context.ruby_cbase(parent_scope);

            context.ldstr(vid.ToString());
            context.ldloc(0);
            context.call(Runtime.Eval.get_const);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:14,代码来源:Variables.cs

示例9: Defined

         internal override void Defined(CodeGenContext context)
        {
            if (qualified)
                if (scope != null)
                {
                    // object result;
                    int result = context.CreateLocal("result", PrimitiveType.Object);
                    PERWAPI.CILLabel endLabel = context.NewLabel();
                    // try {
                    context.StartBlock(Clause.Try);
                    {
                        // result = Eval.const_defined(scope, vid, caller);
                        scope.GenCode(context);
                        context.ldstr(vid.ToString());
                        context.ldloc(0);
                        context.call(Runtime.Eval.const_defined);
                        context.stloc(result);
                        context.leave(endLabel);
                    }
                    TryBlock block = context.EndTryBlock();
                    // catch (System.Exception) {
                    context.StartBlock(Clause.Catch);
                    {
                        // result = null;
                        context.ldnull();
                        context.stloc(result);
                        context.leave(endLabel);
                    }
                    context.EndCatchBlock(Runtime.SystemExceptionRef, block);

                    context.CodeLabel(endLabel);
                    context.ldloc(result);
                    context.ReleaseLocal(result, true);
                }
                else
                {
                    context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
                    context.ldstr(vid.ToString());
                    context.ldloc(0);
                    context.call(Runtime.Eval.const_defined);
                }
            else
            {
                context.ruby_cbase(parent_scope);
                context.ldstr(vid.ToString());
                context.ldloc(0);
                context.call(Runtime.Eval.const_defined);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:49,代码来源:Variables.cs

示例10: AddScopeBody

        internal void AddScopeBody(CodeGenContext context)
        {
            returnTemp = context.CreateLocal("returnTemp", PrimitiveType.Object);

            context.labels = new Labels();
            context.labels.Redo = context.NewLabel();
            context.labels.Return = context.NewLabel();

            // try { ... }
            context.StartBlock(Clause.Try);
            {
                if (BEGIN != null)
                    BEGIN.GenCode(context);

                context.CodeLabel(context.labels.Redo);

                if (body != null)
                {
                    body.GenCode(context);

                    if (context.Reachable())
                        context.stloc(returnTemp);
                }

                context.Goto(context.labels.Return);
            }
            PERWAPI.TryBlock tryBlock = context.EndTryBlock();        

            CatchReturnException(context, tryBlock);

            // ReturnLabel:
            //    return returnTemp;
            context.CodeLabel(context.labels.Return);
            context.newEndPoint(location);
            if (context.Method.GetRetType() != PERWAPI.PrimitiveType.Void)
                context.ldloc(returnTemp);
            context.ret();

            context.ReleaseLocal(returnTemp, true);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:40,代码来源:Scoping.cs

示例11: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            CodeGenContext Begin = context.CreateMethod(FileClass(), MethAttr.PublicStatic, "Begin" + (seq++), PrimitiveType.Object,
                    new Param(ParamAttr.Default, "recv", PrimitiveType.Object),
                    new Param(ParamAttr.Default, "caller", Runtime.FrameRef));

            Begin.startMethod(this.location);

            AddScopeLocals(Begin);

            AddScopeBody(Begin);

            Begin.ReleaseLocal(0, true);

            Begin.Close();


            // Begin(recv, caller);
            context.ldarg("recv");
            context.ldloc(0);
            context.call(Begin.Method);
            context.pop();
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:23,代码来源:Methods.cs

示例12: Assign

        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // Fixme: make sure CurrentRubyClass is not a singleton (see cvar_cbase)

            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // Ruby.Variables.cvar_set(caller, ruby_cref, "vid", value);
            context.ldloc(0);
            context.ruby_cbase(parent_scope);
            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.call(Runtime.Variables.cvar_set);

            context.ReleaseLocal(value, created);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:17,代码来源:Variables.cs

示例13: GenCode0

 internal override void GenCode0(CodeGenContext context)
 {
     // Eval.alias(ruby_class, lhs, rhs, myFrame);
     context.newLine(location);
     context.ruby_class(parent_scope);
     context.ldstr(lhs.ToString());
     context.ldstr(rhs.ToString());
     context.ldloc(0);
     context.call(Runtime.Eval.alias);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:10,代码来源:Operators.cs

示例14: GenCode0


//.........这里部分代码省略.........

            // Define singleton in file class so that it gets initialized by .cctor
            singletonField = FileClass().AddField(PERWAPI.FieldAttr.PublicStatic, internal_name, Runtime.ClassRef);
            newContext.CurrentRubyClass = singletonField;

            //    public MyClass() : base(singleton) { };
            CodeGenContext class_constructor = null; 
            if (defineInteropClass)
            {
                if (interopClass.GetMethod(".ctor", new Type[0]) == null)
                {
                    CodeGenContext class_constructor0 = newContext.CreateConstructor(interopClass);
                    class_constructor0.ldarg(0);
                    if (superClassConstructor0 != null)
                        class_constructor0.call(superClassConstructor0);
                    else
                    {
                        class_constructor0.ldsfld(singletonField);
                        class_constructor0.call(superClassConstructor1);
                    }
                    class_constructor0.ret();
                    class_constructor0.Close();
                }


                //    public MyClass(Class klass) : base(klass) { };
                MethodDef ctor = interopClass.GetMethod(".ctor", new Type[] { Runtime.ClassRef });
                //CodeGenContext class_constructor;
                if (ctor == null)
                {
                    class_constructor = newContext.CreateConstructor(interopClass, new Param(ParamAttr.Default, "klass", Runtime.ClassRef));
                    class_constructor.ldarg(0);
                    class_constructor.ldarg("klass");
                    class_constructor.call(superClassConstructor1);
                    class_constructor.ret();
                    class_constructor.Close();
                }
                else
                {
                    class_constructor = new CodeGenContext();
                    class_constructor.Method = ctor;
                }
            }

            //    internal static void Init_fullname(object scope, object super, object recv, Frame caller) {
            CodeGenContext Init = newContext.CreateMethod(FileClass(), MethAttr.PublicStatic, "Init_" + internal_name, PrimitiveType.Object,
                    new Param(ParamAttr.Default, "scope", PrimitiveType.Object),
                    new Param(ParamAttr.Default, "super", PrimitiveType.Object),
                    new Param(ParamAttr.Default, "recv", PrimitiveType.Object),
                    new Param(ParamAttr.Default, "caller", Runtime.FrameRef));

            skeleton.initMethod = Init.Method;

            Init.startMethod(this.location);

            AddScopeLocals(Init);

            // singleton = scope.define_???(...)
            DefineClass(Init, singletonField);

            // recv = singleton;
            Init.ldsfld(singletonField);
            Init.starg("recv");

            // Fixme: should be conditional
            // singleton.define_allocator(allocator);
            if (defineInteropClass)
            {
                FieldDef allocator = DefineAllocator(newContext, class_constructor.Method);
                if (allocator != null)
                {
                    Init.ldsfld(singletonField);
                    Init.ldsfld(allocator);
                    Init.call(Runtime.Class.define_alloc_func);
                }
            }

            AddScopeBody(Init);

            Init.ReleaseLocal(0, true);

            Init.Close();

            if (defineInteropClass)
                interopClasses.Pop();

            // --------------------- Return to old Context ----------------------------


            context.newLine(location);
            // Init(scope, super, recv, caller);
            scope.GenSimple(context);
            super.GenSimple(context);
            context.ldarg("recv");
            context.ldloc(0);
            context.call(Init.Method);

            context.ReleaseLocal(super, super_created);
            context.ReleaseLocal(scope, scope_created);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:101,代码来源:ClassesAndModules.cs

示例15: DefineClass

 internal override void DefineClass(CodeGenContext context, PERWAPI.FieldDef singleton)
 {
     // Class.define_module(scope, name.vid, caller);
     context.ldarg("scope");
     context.ldstr(name.vid.ToString());
     context.ldloc(0);
     context.call(Runtime.Class.rb_define_module);
     context.stsfld(singleton);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:9,代码来源:ClassesAndModules.cs


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