public virtual void GenSimple(CodeGenContext context) { // thisblock.localsN.vid context.ldarg(0); context.ldfld(block.frameFields[depth - 1]); context.ldfld(field); }
internal override void Assign(CodeGenContext context, Node rhs) { // object value = rhs; bool created; ISimple value = context.PreCompute(rhs, "rhs", out created); // thisblock.localsN.SetDynamic("vid", value); context.ldarg(0); context.ldfld(block.frameFields[depth - 1]); context.ldstr(Name); value.GenSimple(context); context.call(Runtime.Frame.SetDynamic); value.GenSimple(context); context.ReleaseLocal(value, created); }
public virtual void GenSimple(CodeGenContext context) { context.ldloc(0); context.ldfld(field); }
public override void GenSimple(CodeGenContext context) { // thisblock.localsN.GetDynamic("vid"); context.ldarg(0); context.ldfld(block.frameFields[depth - 1]); context.ldstr(Name); context.call(Runtime.Frame.GetDynamic); }
internal override void Assign(CodeGenContext context, Node rhs) { // object value = rhs; bool created; ISimple value = context.PreCompute(rhs, "rhs", out created); // thisblock.localsN.vid = value; context.ldarg(0); context.ldfld(block.frameFields[depth - 1]); value.GenSimple(context); context.stfld(field); value.GenSimple(context); context.ReleaseLocal(value, created); }
internal void LoadBlock0(CodeGenContext context) { if (context.HasArg(Runtime.ArgListRef)) { context.ldarg("args"); // args.block context.ldfld(Runtime.ArgList.block); } else if (context.HasArg(Runtime.ProcRef)) { context.ldarg("block"); } else context.ldnull(); }
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); }
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); }
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); } }
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); }
internal override void GenCode0(CodeGenContext context) { context.newLine(location); if (context.labels != null && context.labels.Retry != null) context.Goto(context.labels.Retry); else { System.Diagnostics.Debug.Assert(this.parent_scope is BLOCK); // throw new Ruby.RetryException(block.defining_scope); context.ldarg(0); // current Ruby.MethodBody context.ldfld(Runtime.Block.defining_scope); context.newobj(Runtime.RetryException.ctor); context.throwOp(); } }
internal override void GenCode0(CodeGenContext context) { context.newLine(location); if (return_val != null) return_val.GenCode(context); else context.ldnull(); if (context.labels != null && context.labels.Break != null) { context.stloc(parent_scope.returnTemp); context.Goto(context.labels.Break); } else { System.Diagnostics.Debug.Assert(this.parent_scope is BLOCK); //throw new Ruby.BreakException(return_value, this.defining_scope); context.ldarg(0); // current Ruby.MethodBody context.ldfld(Runtime.Block.defining_scope); context.newobj(Runtime.BreakException.ctor); context.throwOp(); } }
internal override void GenCode0(CodeGenContext context) { if (id is string) context.ldstr((string)id); else if (id is VALUE && ((VALUE)id).value is string) context.ldstr((string)((VALUE)id).value); else { ((Node)id).GenCode(context); context.ldfld(Runtime.String.value); } context.newobj(Runtime.Symbol.ctor); }
internal override void GenCode0(CodeGenContext context) { MethodDef BlockN_constructor = GenerateClassForMethod(context); // new Ruby.Proc(recv, block, new BlockN(locals, this.locals1, this.locals2 ...), arity); context.ldarg("recv"); // recv LoadBlock(context); context.ldloc(0); // locals if (block_parent is BLOCK) foreach (FieldDef field in ((BLOCK)block_parent).frameFields) { // this.localsN context.ldarg(0); context.ldfld(field); } context.newobj(BlockN_constructor); context.ldc_i4(arity); context.newobj(Runtime.Proc.ctor); }
internal void LoadBlock(CodeGenContext context) { context.ldloc(0); context.ldfld(Runtime.Frame.block_arg); }
internal void CatchReturnException(CodeGenContext context, PERWAPI.TryBlock tryBlock) { // catch (Ruby.ReturnException exception) { ... } context.StartBlock(Clause.Catch); { PERWAPI.CILLabel falseLabel = context.NewLabel(); int exception = context.StoreInTemp("exception", Runtime.ReturnExceptionRef, location); // if (exception.scope == thisframe) context.ldloc(exception); context.ldfld(Runtime.ReturnException.scope); context.ldloc(0); context.bne(falseLabel); // returnTemp = exception.return_value; context.ldloc(exception); context.ldfld(Runtime.ReturnException.return_value); context.stloc(returnTemp); context.Goto(context.labels.Return); // falseLabel: context.CodeLabel(falseLabel); // throw exception context.rethrow(); context.ReleaseLocal(exception, true); } context.EndCatchBlock(Runtime.ReturnExceptionRef, tryBlock); }
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); }