Skip to content

Commit

Permalink
[Truffle] Implement Symbol#<=>.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Nov 3, 2014
1 parent 271942a commit 5fa23b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java
Expand Up @@ -67,6 +67,25 @@ protected boolean notSymbol(RubySymbol a, Object b) {

}

@CoreMethod(names = "<=>", required = 1)
public abstract static class CompareNode extends CoreMethodNode {

public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public CompareNode(CompareNode prev) {
super(prev);
}

@Specialization
public int compare(RubySymbol a, RubySymbol b) {
notDesignedForCompilation();

return a.toString().compareTo(b.toString());

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Nov 3, 2014

Contributor

RubySymbols are unique so can't this just be reference equality? Then it should ok for compilation.

Oh - sorry it's compare to - ignore me.

}
}

@CoreMethod(names = "all_symbols", onSingleton = true)
public abstract static class AllSymbolsNode extends CoreMethodNode {

Expand Down

0 comments on commit 5fa23b0

Please sign in to comment.