Skip to content

Commit 7b12a6a

Browse files
committed
[Truffle] - Implements Symbol#swapcase
1 parent 7300969 commit 7b12a6a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ public RubyString chr(RubyString string) {
19821982
}
19831983
}
19841984

1985-
static class StringNodesHelper {
1985+
public static class StringNodesHelper {
19861986

19871987
@TruffleBoundary
19881988
public static ByteList capitalize(RubyString string) {

truffle/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java

+22
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.jruby.truffle.runtime.core.RubyProc;
1818
import org.jruby.truffle.runtime.core.RubyString;
1919
import org.jruby.truffle.runtime.core.RubySymbol;
20+
import org.jruby.util.ByteList;
2021

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

231232
}
232233

234+
@CoreMethod(names = { "swapcase"})
235+
public abstract static class SwapcaseNode extends CoreMethodNode {
236+
237+
public SwapcaseNode(RubyContext context, SourceSection sourceSection) {
238+
super(context, sourceSection);
239+
}
240+
241+
public SwapcaseNode(SwapcaseNode prev) {
242+
super(prev);
243+
}
244+
245+
@Specialization
246+
public RubySymbol swapcase(RubySymbol symbol) {
247+
notDesignedForCompilation();
248+
249+
ByteList byteList = StringNodes.StringNodesHelper.swapcase(symbol.toRubyString());
250+
return getContext().newSymbol(byteList);
251+
}
252+
253+
}
254+
233255
}

0 commit comments

Comments
 (0)