Skip to content

Commit 2a87593

Browse files
committed
Fix boolean fatfinger.
1 parent 3c3edd5 commit 2a87593

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

core/src/main/java/org/jruby/ir/IRBuilder.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ public Operand run() {
14241424
}
14251425
case VCALLNODE:
14261426
return addResultInstr(scope, new RuntimeHelperCall(scope.createTemporaryVariable(), IS_DEFINED_METHOD,
1427-
new Operand[] { scope.getSelf(), new StringLiteral(((VCallNode) node).getName()), Boolean.FALSE}));
1427+
new Operand[] { scope.getSelf(), new StringLiteral(((VCallNode) node).getName()), manager.getFalse()}));
14281428
case YIELDNODE:
14291429
return buildDefinitionCheck(scope, new BlockGivenInstr(scope.createTemporaryVariable(), scope.getYieldClosureVariable()), "yield");
14301430
case ZSUPERNODE:
@@ -1491,7 +1491,7 @@ public Operand run() {
14911491
* ----------------------------------------------------------------- */
14921492
Label undefLabel = scope.getNewLabel();
14931493
Variable tmpVar = addResultInstr(scope, new RuntimeHelperCall(scope.createTemporaryVariable(), IS_DEFINED_METHOD,
1494-
new Operand[]{scope.getSelf(), new StringLiteral(((FCallNode) node).getName()), Boolean.FALSE}));
1494+
new Operand[]{scope.getSelf(), new StringLiteral(((FCallNode) node).getName()), manager.getFalse()}));
14951495
addInstr(scope, BEQInstr.create(tmpVar, manager.getNil(), undefLabel));
14961496
Operand argsCheckDefn = buildGetArgumentDefinition(((FCallNode) node).getArgsNode(), scope, "method");
14971497
return buildDefnCheckIfThenPaths(scope, undefLabel, argsCheckDefn);
@@ -1546,7 +1546,7 @@ public Operand run() {
15461546
Variable tmpVar = scope.createTemporaryVariable();
15471547
Operand receiver = build(attrAssign.getReceiverNode(), scope);
15481548
addInstr(scope, new RuntimeHelperCall(tmpVar, IS_DEFINED_METHOD,
1549-
new Operand[] { receiver, new StringLiteral(attrAssign.getName()), Boolean.TRUE }));
1549+
new Operand[] { receiver, new StringLiteral(attrAssign.getName()), manager.getTrue() }));
15501550
addInstr(scope, BEQInstr.create(tmpVar, manager.getNil(), undefLabel));
15511551
Operand argsCheckDefn = buildGetArgumentDefinition(attrAssign.getArgsNode(), scope, "assignment");
15521552
return buildDefnCheckIfThenPaths(scope, undefLabel, argsCheckDefn);
@@ -3200,7 +3200,7 @@ public Operand buildReturn(ReturnNode returnNode, IRScope s) {
32003200
// If this happens to be a module body, the runtime throws a local jump error if the
32013201
// closure is a proc. If the closure is a lambda, then this becomes a normal return.
32023202
IRMethod m = s.getNearestMethod();
3203-
addInstr(s, new RuntimeHelperCall(null, CHECK_FOR_LJE, new Operand[] { m == null ? Boolean.TRUE : Boolean.FALSE }));
3203+
addInstr(s, new RuntimeHelperCall(null, CHECK_FOR_LJE, new Operand[] { m == null ? manager.getTrue() : manager.getFalse() }));
32043204
retVal = processEnsureRescueBlocks(s, retVal);
32053205
addInstr(s, new NonlocalReturnInstr(retVal, m == null ? "--none--" : m.getName()));
32063206
} else if (s.isModuleBody()) {

core/src/main/java/org/jruby/ir/IRManager.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class IRManager {
2424
private int dummyMetaClassCount = 0;
2525
private final IRModuleBody object = new IRClassBody(this, null, "Object", "", 0, null);
2626
private final Nil nil = new Nil();
27+
private final Boolean tru = new Boolean(true);
28+
private final Boolean fals = new Boolean(false);
2729

2830
// Listeners for debugging and testing of IR
2931
private Set<CompilerPassListener> passListeners = new HashSet<CompilerPassListener>();
@@ -62,11 +64,11 @@ public Nil getNil() {
6264
}
6365

6466
public org.jruby.ir.operands.Boolean getTrue() {
65-
return Boolean.TRUE;
67+
return tru;
6668
}
6769

6870
public org.jruby.ir.operands.Boolean getFalse() {
69-
return Boolean.FALSE;
71+
return fals;
7072
}
7173

7274
public IRModuleBody getObject() {

core/src/main/java/org/jruby/ir/operands/Boolean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Boolean extends ImmutableLiteral {
99
public static final Boolean TRUE = new Boolean(true);
1010
public static final Boolean FALSE = new Boolean(false);
1111

12-
private Boolean(boolean truthy) {
12+
public Boolean(boolean truthy) {
1313
super(OperandType.BOOLEAN);
1414

1515
this.truthy = truthy;

0 commit comments

Comments
 (0)