Skip to content

Commit

Permalink
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -50,13 +50,6 @@ public Object readConstant(VirtualFrame frame, Object module, String name) {

@Override
public Object isDefined(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();

if (name.equals("Encoding")) {
// Work-around so I don't have to load the iconv library - runners/formatters/junit.rb.
return createString("constant");
}

final RubyConstant constant;
try {
constant = lookupConstantNode.executeLookupConstant(frame);
Original file line number Diff line number Diff line change
@@ -37,19 +37,12 @@ public Object execute(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();

final RubyContext context = getContext();
final String name = (String) readConstantNode.nameNode.execute(frame);

if (name.equals("Encoding")) {
// Work-around so I don't have to load the iconv library - runners/formatters/junit.rb.
return createString("constant");
}

final Object moduleObject;
final Object module;
try {
moduleObject = readConstantNode.moduleNode.execute(frame);
module = readConstantNode.moduleNode.execute(frame);
} catch (RaiseException e) {
/* If we are looking up a constant in a constant that is itself undefined, we return Nil
* rather than raising the error. Eg.. defined?(Defined::Undefined1::Undefined2).
@@ -64,7 +57,7 @@ public Object isDefined(VirtualFrame frame) {

final RubyConstant constant;
try {
constant = readConstantNode.lookupConstantNode.executeLookupConstant(frame, moduleObject, name);
constant = readConstantNode.lookupConstantNode.executeLookupConstant(frame, module, name);
} catch (RaiseException e) {
if (((RubyBasicObject) e.getRubyException()).getLogicalClass() == context.getCoreLibrary().getTypeErrorClass()) {
// module is not a class/module

0 comments on commit 4a420c6

Please sign in to comment.