/** Used by cloning code */ private IRClosure(IRClosure c, IRScope lexicalParent) { super(c, lexicalParent); this.closureId = lexicalParent.getNextClosureId(); setName("_CLOSURE_CLONE_" + closureId); this.startLabel = getNewLabel(getName() + "_START"); this.endLabel = getNewLabel(getName() + "_END"); this.body = (c.body instanceof InterpretedIRBlockBody19) ? new InterpretedIRBlockBody19(this, c.body.arity(), c.body.getArgumentType()) : new InterpretedIRBlockBody(this, c.body.arity(), c.body.getArgumentType()); this.addedGEBForUncaughtBreaks = false; }
/** Used by cloning code */ private IRClosure(IRClosure c, IRScope lexicalParent) { super(c, lexicalParent); this.closureId = lexicalParent.getNextClosureId(); setName("_CLOSURE_CLONE_" + closureId); this.startLabel = getNewLabel(getName() + "_START"); this.endLabel = getNewLabel(getName() + "_END"); this.body = (c.body instanceof InterpretedIRBlockBody19) ? new InterpretedIRBlockBody19(this, c.body.arity(), c.body.getArgumentType()) : new InterpretedIRBlockBody(this, c.body.arity(), c.body.getArgumentType()); this.addedGEBForUncaughtBreaks = false; }
private static void fixnumDownto(ThreadContext context, long from, long to, Block block) { // We must avoid "i--" integer overflow when (to == Long.MIN_VALUE). Ruby runtime = context.runtime; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i > to; i--) { block.yield(context, nil); } if (i >= to) { block.yield(context, nil); } } else { long i; for (i = from; i > to; i--) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i >= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
private static void fixnumDownto(ThreadContext context, long from, long to, Block block) { // We must avoid "i--" integer overflow when (to == Long.MIN_VALUE). Ruby runtime = context.runtime; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i > to; i--) { block.yield(context, nil); } if (i >= to) { block.yield(context, nil); } } else { long i; for (i = from; i > to; i--) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i >= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
private static void fixnumUpto(ThreadContext context, long from, long to, Block block) { // We must avoid "i++" integer overflow when (to == Long.MAX_VALUE). Ruby runtime = context.runtime; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i < to; i++) { block.yield(context, nil); } if (i <= to) { block.yield(context, nil); } } else { long i; for (i = from; i < to; i++) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i <= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
private static void fixnumUpto(ThreadContext context, long from, long to, Block block) { // We must avoid "i++" integer overflow when (to == Long.MAX_VALUE). Ruby runtime = context.runtime; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i < to; i++) { block.yield(context, nil); } if (i <= to) { block.yield(context, nil); } } else { long i; for (i = from; i < to; i++) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i <= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
private void fixnumEach(ThreadContext context, Ruby runtime, Block block) { // We must avoid integer overflows. long to = ((RubyFixnum) end).getLongValue(); if (isExclusive) { if (to == Long.MIN_VALUE) return; to--; } long from = ((RubyFixnum) begin).getLongValue(); if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i < to; i++) { block.yield(context, nil); } if (i <= to) { block.yield(context, nil); } } else { long i; for (i = from; i < to; i++) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i <= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
private void fixnumEach(ThreadContext context, Ruby runtime, Block block) { // We must avoid integer overflows. long to = ((RubyFixnum) end).getLongValue(); if (isExclusive) { if (to == Long.MIN_VALUE) return; to--; } long from = ((RubyFixnum) begin).getLongValue(); if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); long i; for (i = from; i < to; i++) { block.yield(context, nil); } if (i <= to) { block.yield(context, nil); } } else { long i; for (i = from; i < to; i++) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } if (i <= to) { block.yield(context, RubyFixnum.newFixnum(runtime, i)); } } }
boolean checkArity = block.type.checkArity; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS || block.arity() == Arity.NO_ARGUMENTS) { if (checkArity) {
boolean checkArity = block.type.checkArity; if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS || block.arity() == Arity.NO_ARGUMENTS) { if (checkArity) {
if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); for (int i = 0; i < ilen; i++) {
if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { IRubyObject nil = runtime.getNil(); for (int i = 0; i < ilen; i++) {