Skip to content

Commit

Permalink
[Truffle] - Implements Symbol#swapcase
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Feb 16, 2015
1 parent 7300969 commit 7b12a6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ public RubyString chr(RubyString string) {
}
}

static class StringNodesHelper {
public static class StringNodesHelper {

@TruffleBoundary
public static ByteList capitalize(RubyString string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.util.ByteList;

@CoreClass(name = "Symbol")
public abstract class SymbolNodes {
Expand Down Expand Up @@ -230,4 +231,25 @@ public int size(RubySymbol symbol) {

}

@CoreMethod(names = { "swapcase"})
public abstract static class SwapcaseNode extends CoreMethodNode {

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

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

@Specialization
public RubySymbol swapcase(RubySymbol symbol) {
notDesignedForCompilation();

ByteList byteList = StringNodes.StringNodesHelper.swapcase(symbol.toRubyString());
return getContext().newSymbol(byteList);
}

}

}

0 comments on commit 7b12a6a

Please sign in to comment.