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); }