Skip to content

Commit 015a9bf

Browse files
committed
Truffle::Ropes.native_rope
1 parent 09683f1 commit 015a9bf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/org/truffleruby/core/rope/TruffleRopesNodes.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.truffleruby.builtins.CoreMethod;
1515
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
1616
import org.truffleruby.builtins.CoreModule;
17+
import org.truffleruby.cext.CExtNodes;
1718
import org.truffleruby.core.rope.ConcatRope.ConcatState;
1819
import org.truffleruby.core.string.RubyString;
1920
import org.truffleruby.core.string.StringNodes;
@@ -164,6 +165,18 @@ protected RubyString flattenRope(Object string,
164165

165166
}
166167

168+
@CoreMethod(names = "convert_to_native", onSingleton = true, required = 1)
169+
public abstract static class NativeRopeNode extends CoreMethodArrayArgumentsNode {
170+
171+
@Specialization
172+
protected RubyString nativeRope(RubyString string,
173+
@Cached CExtNodes.StringToNativeNode toNativeNode) {
174+
toNativeNode.executeToNative(string);
175+
return string;
176+
}
177+
178+
}
179+
167180
/* Truffle.create_simple_string creates a string 'test' without any part of the string escaping. Useful for testing
168181
* compilation of String because most other ways to construct a string can currently escape. */
169182

0 commit comments

Comments
 (0)