Skip to content
Permalink
Browse files
[Truffle] Regexp#=~ should not try the reverse operation.
  • Loading branch information
eregon committed Nov 3, 2014
1 parent f2b0494 commit b8bdaac0117b36bc45b961a6c678800cd0a8ea4b
Showing 1 changed file with 6 additions and 6 deletions.
@@ -63,16 +63,12 @@ public Object match(RubyRegexp regexp, RubyString string) {
@CoreMethod(names = "=~", required = 1)
public abstract static class MatchOperatorNode extends CoreMethodNode {

@Child protected DispatchHeadNode matchNode;

public MatchOperatorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
matchNode = new DispatchHeadNode(context);
}

public MatchOperatorNode(MatchOperatorNode prev) {
super(prev);
matchNode = prev.matchNode;
}

@Specialization
@@ -83,10 +79,14 @@ public Object match(RubyRegexp regexp, RubyString string) {
}

@Specialization
public Object match(VirtualFrame frame, RubyRegexp regexp, RubyBasicObject other) {
public Object match(RubyRegexp regexp, RubyBasicObject other) {
notDesignedForCompilation();

return matchNode.call(frame, other, "=~", null, regexp);
if (other instanceof RubyString) {
return match(regexp, (RubyString) other);
} else {
return getContext().getCoreLibrary().getNilObject();
}
}

}

0 comments on commit b8bdaac

Please sign in to comment.