Skip to content
Permalink
Browse files
[Truffle] Implement Symbol#<=>.
  • Loading branch information
eregon committed Nov 3, 2014
1 parent 271942a commit 5fa23b00c5ed124f294ec450ddb421546b9f78bf
Showing 1 changed file with 19 additions and 0 deletions.
@@ -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());
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 {

0 comments on commit 5fa23b0

Please sign in to comment.