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


C# CodeGenContext.br方法代码示例

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


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

示例1: GenCode0

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

            // if (Eval.Test(cond))
            cond.GenCode(context);
            context.call(Runtime.Eval.Test);
            context.brfalse(elseLabel);
            body.GenCode(context);
            context.br(endLabel);
            context.CodeLabel(elseLabel);
            _else.GenCode(context);
            context.CodeLabel(endLabel);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:15,代码来源:Stmts.cs

示例2: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            context.ldloc(0);
            context.call(Runtime.Frame.get_Tilde);
            PERWAPI.CILLabel label1 = context.NewLabel();
            context.brfalse(label1);
            context.ldloc(0);
            context.call(Runtime.Frame.get_Tilde);
            context.ldloc(0);

            switch (ch)
            {
                case '&':
                    context.callvirt(Runtime.Match.last_match);
                    break;
                case '`':
                    context.callvirt(Runtime.Match.match_pre);
                    break;               
                case '\'':
                    context.callvirt(Runtime.Match.match_post);
                    break;                
                case '+':
                    context.callvirt(Runtime.Match.match_last);
                    break;
                default:
                    throw new NotImplementedException("BACK_REF $" + ch);
            }
            PERWAPI.CILLabel label2 = context.NewLabel();
            context.br(label2);
            context.CodeLabel(label1);
            context.ldnull();
            context.CodeLabel(label2);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:33,代码来源:Variables.cs

示例3: GenCode

        internal void GenCode(CodeGenContext context, PERWAPI.CILLabel endLabel, int RescueTemp, int exception)
        {
            for (RESCUE_CLAUSE clause = this; clause != null; clause = clause.next)
            {
                PERWAPI.CILLabel nextClause = context.NewLabel();
                PERWAPI.CILLabel thisClause = context.NewLabel();

                context.ldc_i4(0);
                LOCAL exceptionCaught = context.StoreInLocal("caught", PERWAPI.PrimitiveType.Boolean, this.location);

                for (Node type = clause.types; type != null; type = type.nd_next)
                {
                    PERWAPI.CILLabel label1 = context.NewLabel();

                    // Precompute each separately to avoid computing a list of types
                    type.GenCode0(context);
                    LOCAL tt = context.StoreInLocal("type", PERWAPI.PrimitiveType.Object, type.location);

                    new METHOD_CALL(tt, ID.intern(Tokens.tEQQ), new AST.LOCAL(exception, type.location), type.location).GenCode(context);

                    context.ReleaseLocal(tt.local, true);

                    context.call(Runtime.Eval.Test);
                    context.brfalse(label1);
                    context.PushTrue();
                    context.stloc(exceptionCaught.local);
                    context.CodeLabel(label1);                  
                }

                context.ldloc(exceptionCaught.local);
                context.brtrue(thisClause);
                context.ReleaseLocal(exceptionCaught.local, true);

                context.br(nextClause);

                context.CodeLabel(thisClause);

                if (clause.var != null)
                {
                    clause.var.Assign(context, new AST.LOCAL(exception, clause.var.location));
                    context.pop();
                }

                if (clause.body != null)
                    clause.body.GenCode(context);
                else
                    context.ldnull();

                if (context.Reachable())
                    context.stloc(RescueTemp);

                // reset $!
                //Eval.ruby_errinfo.value = null;
                context.ldsfld(Runtime.Eval.ruby_errinfo);
                context.ldnull();
                context.stfld(Runtime.global_variable.value);

                context.Goto(endLabel);

                context.CodeLabel(nextClause);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:62,代码来源:Exceptions.cs

示例4: GenRescue

        internal void GenRescue(CodeGenContext context, PERWAPI.CILLabel endLabel, int RescueTemp, RESCUE_CLAUSE clauses)
        {
            // catch (System.Exception e) {

            int e = context.StoreInTemp("e", Runtime.SystemExceptionRef, location);

            //if (e is Ruby.ControlException)
            PERWAPI.CILLabel else1 = context.NewLabel();
            context.ldloc(e);
            context.isinst(Runtime.ControlExceptionRef);
            context.brfalse(else1);
            //    throw e;
            context.rethrow();
            context.CodeLabel(else1);

            // Ruby.Exception exception;
            int exception = context.CreateLocal("exception", Runtime.ExceptionRef);

            //if (!(e is Ruby.RubyException))
            PERWAPI.CILLabel else2 = context.NewLabel();
            PERWAPI.CILLabel end = context.NewLabel();
            context.ldloc(e);
            context.isinst(Runtime.RubyExceptionRef);
            context.brtrue(else2);
            //    exception = new Ruby.CLRException(frame, e);
            context.ldloc(0);
            context.ldloc(e);
            context.newobj(Runtime.CLRException.ctor);
            context.stloc(exception);
            context.br(end);

            //else
            context.CodeLabel(else2);
            //     exception = (Ruby.RubyException)e.parent;
            context.ldloc(e);
            context.cast(Runtime.RubyExceptionRef);
            context.ldfld(Runtime.RubyException.parent);
            context.stloc(exception);

            context.CodeLabel(end);

            //Eval.ruby_errinfo.value = exception;
            context.ldsfld(Runtime.Eval.ruby_errinfo);
            context.ldloc(exception);
            context.stfld(Runtime.global_variable.value);

            if (clauses != null)
                clauses.GenCode(context, endLabel, RescueTemp, exception);

            context.rethrow();

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

示例5: GenCode0

 internal override void GenCode0(CodeGenContext context)
 {
     context.newLine(location);
     if (lhs is ARRAY_ACCESS) // for array access -> need to avoid recomputation of lhs index
         ((ARRAY_ACCESS)lhs).AssignOp(context, op, rhs);
     else if (lhs is CVAR && op == "||")
     {
         CILLabel alreadyDefined1 = new CILLabel();
         CILLabel alreadyDefined2 = new CILLabel();
         CILLabel alreadyDefined3 = new CILLabel();
         Node lhsDefined = new DEFINED(lhs, location);
         lhsDefined.GenCode(context);
         context.brtrue(alreadyDefined1);
         lhs.Assign(context, rhs);
         context.br(alreadyDefined2);
         context.CodeLabel(alreadyDefined1);
         lhs.Assign(context, METHOD_CALL.Create(lhs, op, rhs, location));
         context.CodeLabel(alreadyDefined2);
     }
     else
         lhs.Assign(context, METHOD_CALL.Create(lhs, op, rhs, location));
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:22,代码来源:Assignments.cs

示例6: Defined

          internal override void Defined(CodeGenContext context)
        {
            PERWAPI.CILLabel undefined_label = context.NewLabel();
            PERWAPI.CILLabel end_label = context.NewLabel();

            for (Node arg = parameters; arg != null; arg = arg.nd_next)
            {
                arg.Defined(context);
                context.brfalse(undefined_label);
            }

            if (array != null)
            {
                array.Defined(context);
                context.brfalse(undefined_label);
            }

            if (hashlist != null)
            {
                hashlist.Defined(context);
                context.brfalse(undefined_label);
            }

            if (block != null)
            {
                block.Defined(context);
                context.brfalse(undefined_label);
            }

            context.PushTrue();
            context.box(PrimitiveType.Boolean);

            if (!IsEmpty)
            {
                context.br(end_label);

                context.CodeLabel(undefined_label);
                context.PushFalse();
                context.box(PrimitiveType.Boolean);

                context.CodeLabel(end_label);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:43,代码来源:Args.cs

示例7: CopyOptionalFormals

        private void CopyOptionalFormals(CodeGenContext context, Scope scope)
        {
            for (ASSIGNMENT opt = (ASSIGNMENT)optional; opt != null; opt = (ASSIGNMENT)opt.nd_next)
            {
                PERWAPI.CILLabel runout_label = context.NewLabel();
                PERWAPI.CILLabel end_label = context.NewLabel();

                string name = ID.ToDotNetName(((VAR)(opt.lhs)).vid);
                Node defaultValue = opt.rhs;

  

                // if (args.RunOut()) goto RunOut
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.RunOut);
                context.brtrue(runout_label);

                // locals.name = args.GetNext();
                context.ldloc(0);
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.GetNext);
                context.br(end_label);

                // RunOut:
                context.CodeLabel(runout_label);

                // object def = defaultValue;
                bool created;
                ISimple def = context.PreCompute(defaultValue, "default", out created);

                // locals.name = defaultValue
                context.ldloc(0);
                def.GenSimple(context);

                context.ReleaseLocal(def, created);

                context.CodeLabel(end_label);

                // locals.name = ...
                context.stfld(scope.GetFrameField(name));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:42,代码来源:Formals.cs

示例8: GenCode

        internal void GenCode(CodeGenContext context, PERWAPI.CILLabel endLabel)
        {
            PERWAPI.CILLabel elseLabel = context.NewLabel();

            context.newLine(comparison.location);
            // if (comparision.ToRubyArray().includes(true, caller))
            bool created;
            ISimple list = comparison.GenArgList(context, out created);
            list.GenSimple(context);
            context.ReleaseLocal(list, created);
            context.callvirt(Runtime.ArgList.ToRubyArray);
            new TRUE(comparison.location).GenCode(context);
            context.ldloc(0);
            context.callvirt(Runtime.Array.includes);
            context.brfalse(elseLabel);

            if (body != null)
            {
                context.newStartPoint(body.location);
                body.GenCode(context);
            }
            else
                context.ldnull();

            context.br(endLabel);
            context.CodeLabel(elseLabel);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:27,代码来源:Stmts.cs


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