Skip to content
Permalink
Browse files
[Truffle] Use visibility flag in #respond_to?.
  • Loading branch information
chrisseaton committed Oct 12, 2014
1 parent 04b44d7 commit 7b8a61f8a44ed4cbed00ebd5067f9a0129f97384
Showing 1 changed file with 15 additions and 6 deletions.
@@ -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
@@ -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
@@ -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);
}
}

}

0 comments on commit 7b8a61f

Please sign in to comment.