internal override void Defined(CodeGenContext context) { context.PushTrue(); context.box(PrimitiveType.Boolean); }
internal override void GenCode0(CodeGenContext context) { bool start_created, finish_created; ISimple start = context.PreCompute(beg, "beg", out start_created); ISimple finish = context.PreCompute(end, "end", out finish_created); start.GenSimple(context); finish.GenSimple(context); context.PushTrue(); context.newobj(Runtime.Range.ctor); context.ReleaseLocal(start, start_created); context.ReleaseLocal(finish, finish_created); }
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); } }
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); } }
internal override ISimple GenArgList(CodeGenContext context, out bool created) { bool single = true; // ArgList arglist = new ArgList(); context.newobj(Runtime.ArgList.ctor); int arglist = context.StoreInTemp("arglist", Runtime.ArgListRef, location); int added = 0; for (Node arg = parameters; arg != null; arg = arg.nd_next) { //object argument = arg; bool argument_created; ISimple argument = context.PreCompute0(arg, "arg", out argument_created); // arglist.Add(argument); context.ldloc(arglist); argument.GenSimple(context); context.callvirt(Runtime.ArgList.Add); added++; context.ReleaseLocal(argument, argument_created); } if (added != 1) single = false; if (hashlist != null) { // object hash = hashlist; bool hash_created; ISimple hash = context.PreCompute(new HASH(hashlist, hashlist.location), "hashlist", out hash_created); // arglist.Add(hash); context.ldloc(arglist); hash.GenSimple(context); context.callvirt(Runtime.ArgList.Add); single = false; context.ReleaseLocal(hash, hash_created); } if (array != null) { // object list = array; bool list_created; ISimple list = context.PreCompute(array, "array", out list_created); // arglist.AddArray(list, caller); context.ldloc(arglist); list.GenSimple(context); context.ldloc(0); context.callvirt(Runtime.ArgList.AddArray); single = false; context.ReleaseLocal(list, list_created); } if (block != null) { // object b = block; bool b_created; ISimple b = context.PreCompute(block, "block", Runtime.ProcRef, out b_created); // arglist.block = b; context.ldloc(arglist); b.GenSimple(context); context.stfld(Runtime.ArgList.block); context.ReleaseLocal(b, b_created); } if (single) { context.ldloc(arglist); context.PushTrue(); context.stfld(Runtime.ArgList.single_arg); } created = true; return new LOCAL(arglist, location); }
public void GenSimple(CodeGenContext context) { context.PushTrue(); context.box(PrimitiveType.Boolean); }