Skip to content

Commit

Permalink
[Truffle] Use visibility flag in #respond_to?.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Oct 12, 2014
1 parent 04b44d7 commit 7b8a61f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Expand Up @@ -1517,15 +1517,18 @@ public boolean require(RubyString feature) {
public abstract static class RespondToNode extends CoreMethodNode {

@Child protected DispatchHeadNode dispatch;
@Child protected DispatchHeadNode dispatchIgnoreVisibility;

public RespondToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
dispatch = new DispatchHeadNode(context, false, Dispatch.MissingBehavior.CALL_METHOD_MISSING);
dispatchIgnoreVisibility = new DispatchHeadNode(context, true, Dispatch.MissingBehavior.CALL_METHOD_MISSING);
}

public RespondToNode(RespondToNode prev) {
super(prev);
dispatch = prev.dispatch;
dispatchIgnoreVisibility = prev.dispatchIgnoreVisibility;
}

@Specialization
Expand All @@ -1534,9 +1537,12 @@ public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name,
}

@Specialization
public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name, boolean dontCheckVisibility) {
// TODO(CS): check visibility flag
return dispatch.doesRespondTo(frame, name, object);
public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name, boolean ignoreVisibility) {
if (ignoreVisibility) {
return dispatchIgnoreVisibility.doesRespondTo(frame, name, object);
} else {
return dispatch.doesRespondTo(frame, name, object);
}
}

@Specialization
Expand All @@ -1545,9 +1551,12 @@ public boolean doesRespondTo(VirtualFrame frame, Object object, RubySymbol name,
}

@Specialization
public boolean doesRespondTo(VirtualFrame frame, Object object, RubySymbol name, boolean dontCheckVisibility) {
// TODO(CS): check visibility flag
return dispatch.doesRespondTo(frame, name, object);
public boolean doesRespondTo(VirtualFrame frame, Object object, RubySymbol name, boolean ignoreVisibility) {
if (ignoreVisibility) {
return dispatchIgnoreVisibility.doesRespondTo(frame, name, object);
} else {
return dispatch.doesRespondTo(frame, name, object);
}
}

}
Expand Down

0 comments on commit 7b8a61f

Please sign in to comment.