Skip to content

Commit

Permalink
Showing 4 changed files with 42 additions and 44 deletions.
25 changes: 8 additions & 17 deletions core/src/main/java/org/jruby/ir/runtime/IRBreakJump.java
Original file line number Diff line number Diff line change
@@ -5,29 +5,20 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.cli.Options;

public class IRBreakJump extends RuntimeException implements Unrescuable {
public class IRBreakJump extends IRJump implements Unrescuable {
public DynamicScope scopeToReturnTo;
public IRubyObject breakValue;
public boolean caughtByLambda;
public boolean breakInEval;

private IRBreakJump() {}

public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv) {
IRBreakJump bj = new IRBreakJump();
bj.scopeToReturnTo = scopeToReturnTo;
bj.breakValue = rv;
bj.caughtByLambda = false;
bj.breakInEval = false;
return bj;
private IRBreakJump(DynamicScope scopeToReturnTo, IRubyObject rv) {
this.scopeToReturnTo = scopeToReturnTo;
this.breakValue = rv;
this.caughtByLambda = false;
this.breakInEval = false;
}

@Override
public Throwable fillInStackTrace() {
if (Options.JUMP_BACKTRACE.load()) {
return super.fillInStackTrace();
}

return this;
public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv) {
return new IRBreakJump(scopeToReturnTo, rv);
}
}
25 changes: 25 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRJump.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jruby.ir.runtime;

import org.jruby.util.cli.Options;

/**
* Created by headius on 3/10/16.
*/
public class IRJump extends RuntimeException {
public IRJump() {
super();
}

public IRJump(String message) {
super(message);
}

@Override
public Throwable fillInStackTrace() {
if (Options.JUMP_BACKTRACE.load()) {
return super.fillInStackTrace();
}

return this;
}
}
25 changes: 8 additions & 17 deletions core/src/main/java/org/jruby/ir/runtime/IRReturnJump.java
Original file line number Diff line number Diff line change
@@ -4,30 +4,21 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.util.cli.Options;

public class IRReturnJump extends RuntimeException implements Unrescuable {
public DynamicScope methodToReturnFrom;
public Object returnValue;
public class IRReturnJump extends IRJump implements Unrescuable {
public final DynamicScope methodToReturnFrom;
public final Object returnValue;

private IRReturnJump() {}
private IRReturnJump(DynamicScope scope, Object rv) {
this.methodToReturnFrom = scope;
this.returnValue = rv;
}

public static IRReturnJump create(DynamicScope scope, Object rv) {
IRReturnJump rj = new IRReturnJump();
rj.methodToReturnFrom = scope;
rj.returnValue = rv;
return rj;
return new IRReturnJump(scope, rv);
}

@Override
public String toString() {
return "IRReturnJump:<" + methodToReturnFrom + ":" + returnValue + ">";
}

@Override
public Throwable fillInStackTrace() {
if (Options.JUMP_BACKTRACE.load()) {
return super.fillInStackTrace();
}

return this;
}
}
Original file line number Diff line number Diff line change
@@ -14,19 +14,10 @@
// through an exception object (just like IRReturnJump and IRBreakJump)
// and let it go through exception handlers which ensure that frame/scope
// are updated properly and ruby-level ensure code is run.
public class IRWrappedLambdaReturnValue extends RuntimeException implements Unrescuable {
public class IRWrappedLambdaReturnValue extends IRJump implements Unrescuable {
public final IRubyObject returnValue;

public IRWrappedLambdaReturnValue(IRubyObject v) {
this.returnValue = v;
}

@Override
public Throwable fillInStackTrace() {
if (Options.JUMP_BACKTRACE.load()) {
return super.fillInStackTrace();
}

return this;
}
}

0 comments on commit 28082e3

Please sign in to comment.