Skip to content

Commit 9d751ef

Browse files
committed
Truffle::Ropes.debug_print_rope for native ropes
1 parent 015a9bf commit 9d751ef

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,25 @@ protected Object debugPrintLazyInt(LazyIntRope rope, int currentLevel, boolean p
866866
return nil;
867867
}
868868

869+
@TruffleBoundary
870+
@Specialization
871+
protected Object debugPrintNative(NativeRope rope, int currentLevel, boolean printString) {
872+
printPreamble(currentLevel);
873+
874+
System.err.println(String.format(
875+
"%s (%s; BL: %d; CL: %d; CR: %s; P: 0x%x, S: %d; E: %s)",
876+
printString ? RopeOperations.escape(rope) : "<skipped>",
877+
rope.getClass().getSimpleName(),
878+
rope.byteLength(),
879+
rope.characterLength(),
880+
rope.getCodeRange(),
881+
rope.getNativePointer().getAddress(),
882+
rope.getNativePointer().getSize(),
883+
rope.getEncoding()));
884+
885+
return nil;
886+
}
887+
869888
private void printPreamble(int level) {
870889
if (level > 0) {
871890
for (int i = 0; i < level; i++) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ protected Object debugPrint(Object string, boolean printString,
8080
System.err.println("LD = Left Depth (ConcatRope only)");
8181
System.err.println("RD = Right Depth (ConcatRope only)");
8282
System.err.println("E = Encoding");
83+
System.err.println("P = Native Pointer (NativeRope only)");
84+
System.err.println("S = Native Size (NativeRope only)");
8385

8486
return debugPrintRopeNode.executeDebugPrint(strings.getRope(string), 0, printString);
8587
}

0 commit comments

Comments
 (0)