本文整理汇总了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);
}
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}