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


C# CodeGenContext.throwOp方法代码示例

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


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

示例1: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            context.newLine(location);

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

            if (this.parent_scope is BLOCK)
            {
                //throw new Ruby.ReturnException(return_value, this.defining_scope);
                context.ldarg(0);  // current Ruby.MethodBody
                context.ldfld(Runtime.Block.defining_scope);
                context.newobj(Runtime.ReturnException.ctor);
                context.throwOp();
            }
            else if (this.parent_scope is BEGIN)
            {
                //throw new Ruby.ReturnException(return_value, caller);
                context.ldarg("caller");
                context.newobj(Runtime.ReturnException.ctor);
                context.throwOp();
            }
            else
            {
                // return
                context.stloc(parent_scope.returnTemp);
                context.Goto(context.labels.Return);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:31,代码来源:ControlFlow.cs

示例2: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            int RescueTemp = context.CreateLocal("rescueTemp", PERWAPI.PrimitiveType.Object);
            int ExceptionTemp = context.CreateLocal("exceptionTemp", PERWAPI.PrimitiveType.Object);

            PERWAPI.CILLabel endLabel = context.NewLabel();

            context.StartBlock(Clause.Try);
            {
                expr.GenCode(context);
                if (context.Reachable())
                {
                    context.stloc(RescueTemp);
                    context.Goto(endLabel);
                }
            }
            PERWAPI.TryBlock tryBlock = context.EndTryBlock();

            context.StartBlock(Clause.Catch);
            {
                PERWAPI.CILLabel stdErrLabel = context.NewLabel();
                context.stloc(ExceptionTemp);
                context.ldloc(ExceptionTemp);
                context.ldfld(Runtime.RubyException.parent);
                context.isinst(Runtime.StandardErrorRef);
                context.brtrue(stdErrLabel);
                context.ldloc(ExceptionTemp);
                context.throwOp();
                context.CodeLabel(stdErrLabel);
                rescue.GenCode(context);
                if (context.Reachable())
                {
                    context.stloc(RescueTemp);
                    context.Goto(endLabel);
                }
            }

            context.EndCatchBlock(Runtime.RubyExceptionRef, tryBlock);

            context.CodeLabel(endLabel);

            context.ldloc(RescueTemp);

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

示例3: CopyNormalFormals

        private void CopyNormalFormals(CodeGenContext context, Scope scope)
        {
            PERWAPI.CILLabel OKLabel = context.NewLabel();

            if (min_args > 0)
            {
                // if (args.Length < min_args)
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.get_Length);
                int length = context.StoreInTemp("length", PrimitiveType.Int32, location);
                context.ldloc(length);
                context.ldc_i4(min_args);
                context.bge(OKLabel);

                //context.Inst(Op.clt);
                //context.brfalse(OKLabel);

                // context.Branch(BranchOp.bge, OKLabel);

                // throw new ArgumentError(string.Format("wrong number of arguments ({0} for {1})", args.Length, arity).raise(caller);
                // FIXME: next line needs a String
                context.ldstr("wrong number of arguments ({0} for {1})");
                context.ldloc(length);
                context.box(PrimitiveType.Int32);
                context.ldc_i4(min_args);
                context.box(PrimitiveType.Int32);
                context.call(Runtime.SystemString.Format);
                context.newobj(Runtime.ArgumentError.ctor);
                context.ldloc(0);
                context.callvirt(Runtime.Exception.raise);
                context.throwOp();

                context.ReleaseLocal(length, true);

                // OKLabel:
                context.CodeLabel(OKLabel);
            }

            // Copy parameters to locals
            for (Node f = normal; f != null; f = f.nd_next)
            {
                string name = ID.ToDotNetName(((VAR)f).vid);

                // local.f = args.GetNext();
                context.ldloc(0);
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.GetNext);
                context.stfld(scope.GetFrameField(name));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:50,代码来源:Formals.cs

示例4: CatchBreakException

        private void CatchBreakException(CodeGenContext context, int result, PERWAPI.CILLabel endLabel)
        {
            // catch (Exception exception)
            int exception = context.StoreInTemp("exception", Runtime.BreakExceptionRef, location);
            PERWAPI.CILLabel reThrowLabel = context.NewLabel();

            // if (exception.scope != current_frame) goto reThrowLabel; 
            context.ldloc(0);
            context.ldloc(exception);
            context.ldfld(Runtime.BreakException.scope);
            context.bne( reThrowLabel);

            // result = exception.return_value;
            context.ldloc(exception);
            context.ldfld(Runtime.BreakException.return_value);
            context.stloc(result);

            // goto endLabel;
            context.Goto(endLabel);

            // reThrowLabel:
            context.CodeLabel(reThrowLabel);

            // throw exception;
            context.ldloc(exception);
            context.throwOp();

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

示例5: CatchRetryException

        private void CatchRetryException(CodeGenContext context, PERWAPI.CILLabel retryLabel)
        {
            // catch (Exception exception)
            int exception = context.StoreInTemp("exception", Runtime.RetryExceptionRef, location);
            PERWAPI.CILLabel reThrowLabel = context.NewLabel();

            // if (exception.scope != current_frame) goto reThrowLabel; 
            context.ldloc(0);
            context.ldloc(exception);
            context.ldfld(Runtime.RetryException.scope);
            context.bne( reThrowLabel);

            // goto retryLabel
            context.Goto(retryLabel);

            // reThrowLabel:
            context.CodeLabel(reThrowLabel);

            // throw exception;
            context.ldloc(exception);
            context.throwOp();

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


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