Skip to content

Commit

Permalink
[IR] Bug fixes in defined? IR generation
Browse files Browse the repository at this point in the history
  • Loading branch information
subbuss committed Aug 30, 2011
1 parent aca9535 commit b63fce5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/org/jruby/compiler/ir/IRBuilder.java
Expand Up @@ -1243,10 +1243,10 @@ private Operand protectCodeWithRescue(IRScope m, CodeBlock protectedCode, Object
// Verify that the exception is of type 'JumpException'.
// Since this is JRuby implementation Java code, we dont need EQQ here.
// SSS FIXME: Hardcoded exception class name!
m.addInstr(new InstanceOfInstr(eqqResult, exc, "org.jruby.exceptions.JumpException"));
m.addInstr(new InstanceOfInstr(eqqResult, exc, "org.jruby.RubyException"));
m.addInstr(new BEQInstr(eqqResult, BooleanLiteral.FALSE, uncaughtLabel));
Object v2 = rescueBlock.run(rescueBlockArgs); // YIELD: Run the protected code block
if (v2 != null) m.addInstr(new CopyInstr(rv, (Operand)v1));
if (v2 != null) m.addInstr(new CopyInstr(rv, Nil.NIL));
m.addInstr(new JumpInstr(rEndLabel));
m.addInstr(new LABEL_Instr(uncaughtLabel));
m.addInstr(new THROW_EXCEPTION_Instr(exc));
Expand Down Expand Up @@ -1567,7 +1567,7 @@ public Operand run(Object[] args) {
s.addInstr(new BNEInstr(cm, Nil.NIL, l));
s.addInstr(new JRubyImplCallInstr(cm, JRubyImplementationMethod.SELF_METACLASS, getSelf(s), NO_ARGS));
s.addInstr(new LABEL_Instr(l));
return buildDefinitionCheck(s, JRubyImplementationMethod.CLASS_VAR_DEFINED, cm, iVisited.getName(), "class-variable");
return buildDefinitionCheck(s, JRubyImplementationMethod.CLASS_VAR_DEFINED, cm, iVisited.getName(), "class variable");
}
case ATTRASSIGNNODE:
{
Expand Down Expand Up @@ -1632,7 +1632,8 @@ public Operand run(Object[] args) {
CodeBlock protectedCode = new CodeBlock() {
public Operand run(Object[] args) {
build((Node)args[0], (IRScope)args[1]);
return Nil.NIL;
// always an expression as long as we get through here without an exception!
return new StringLiteral("expression");
}
};
// rescue block
Expand All @@ -1641,10 +1642,7 @@ public Operand run(Object[] args) {
};

// Try verifying definition, and if we get an JumpException exception, process it with the rescue block above
protectCodeWithRescue(s, protectedCode, new Object[]{node, s}, rescueBlock, null);

// always an expression as long as we didn't get an exception in the code above
return new StringLiteral("expression");
return protectCodeWithRescue(s, protectedCode, new Object[]{node, s}, rescueBlock, null);
}
}

Expand Down

0 comments on commit b63fce5

Please sign in to comment.