Skip to content

Commit 3314837

Browse files
committed
Fix Truffle deprecation warnings
1 parent d5ae248 commit 3314837

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/main/java/org/truffleruby/core/regexp/ClassicRegexp.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ private static boolean all7Bit(byte[] bytes) {
665665
public static TStringWithEncoding quote19(ATStringWithEncoding bs) {
666666
final boolean asciiOnly = bs.isAsciiOnly();
667667
boolean metaFound = false;
668+
final var tencoding = bs.encoding.tencoding;
668669

669670
var iterator = bs.createCodePointIterator();
670671
while (iterator.hasNext()) {
671-
final int c = iterator.nextUncached();
672+
final int c = iterator.nextUncached(tencoding);
672673

673674
switch (c) {
674675
case '[':
@@ -712,7 +713,7 @@ public static TStringWithEncoding quote19(ATStringWithEncoding bs) {
712713
iterator = bs.createCodePointIterator();
713714
while (iterator.hasNext()) {
714715
int p = iterator.getByteIndex();
715-
final int c = iterator.nextUncached();
716+
final int c = iterator.nextUncached(tencoding);
716717

717718
if (c == -1) {
718719
int after = iterator.getByteIndex();
@@ -919,11 +920,12 @@ public static void appendRegexpString(TStringBuilder to, TStringWithEncoding ful
919920
var str = fullStr.substring(start, len);
920921

921922
final var enc = str.encoding.jcoding;
923+
final var tencoding = str.encoding.tencoding;
922924
var iterator = str.createCodePointIterator();
923925

924926
boolean needEscape = false;
925927
while (iterator.hasNext()) {
926-
final int c = iterator.nextUncached();
928+
final int c = iterator.nextUncached(tencoding);
927929
if ((c >= 0 && Encoding.isAscii(c)) && (c == '/' || !enc.isPrint(c))) {
928930
needEscape = true;
929931
break;
@@ -936,10 +938,10 @@ public static void appendRegexpString(TStringBuilder to, TStringWithEncoding ful
936938
iterator = str.createCodePointIterator();
937939
while (iterator.hasNext()) {
938940
final int p = iterator.getByteIndex();
939-
final int c = iterator.nextUncached();
941+
final int c = iterator.nextUncached(tencoding);
940942

941943
if (c == '\\' && iterator.hasNext()) {
942-
iterator.nextUncached();
944+
iterator.nextUncached(tencoding);
943945
to.append(str, p, iterator.getByteIndex() - p);
944946
} else if (c == '/') {
945947
to.append((byte) '\\');

src/main/java/org/truffleruby/core/string/StringHelperNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ byte[] invert(RubyString string, TruffleStringIterator iterator, byte[] initialB
510510

511511
while (iterator.hasNext()) {
512512
int p = iterator.getByteIndex();
513-
int c = nextNode.execute(iterator);
513+
int c = nextNode.execute(iterator, encoding);
514514

515515
if ((lowerToUpper && StringSupport.isAsciiLowercase(c)) ||
516516
(upperToLower && StringSupport.isAsciiUppercase(c))) {

src/main/java/org/truffleruby/core/string/StringNodes.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ Object eachCodePoint(Object string, RubyProc block,
12731273
var iterator = createCodePointIteratorNode.execute(tstring, tencoding, ErrorHandling.RETURN_NEGATIVE);
12741274

12751275
while (iterator.hasNext()) {
1276-
int codePoint = nextNode.execute(iterator);
1276+
int codePoint = nextNode.execute(iterator, tencoding);
12771277

12781278
if (codePoint == -1) {
12791279
invalidCodePointProfile.enter(this);
@@ -1313,7 +1313,7 @@ Object codePointsWithoutBlock(Object string, Nil unusedBlock,
13131313

13141314
int i = 0;
13151315
while (iterator.hasNext()) {
1316-
int codePoint = nextNode.execute(iterator);
1316+
int codePoint = nextNode.execute(iterator, tencoding);
13171317

13181318
if (codePoint == -1) {
13191319
invalidCodePointProfile.enter(this);
@@ -1639,7 +1639,7 @@ static Object lstripBangSingleByte(RubyString string,
16391639
var tencoding = encoding.tencoding;
16401640

16411641
var iterator = createCodePointIteratorNode.execute(tstring, tencoding, ErrorHandling.RETURN_NEGATIVE);
1642-
int codePoint = nextNode.execute(iterator);
1642+
int codePoint = nextNode.execute(iterator, tencoding);
16431643

16441644
// Check the first code point to see if it's broken. In the case of strings without leading spaces,
16451645
// this check can avoid having to compile the while loop.
@@ -1657,7 +1657,7 @@ static Object lstripBangSingleByte(RubyString string,
16571657

16581658
while (iterator.hasNext()) {
16591659
int byteIndex = iterator.getByteIndex();
1660-
codePoint = nextNode.execute(iterator);
1660+
codePoint = nextNode.execute(iterator, tencoding);
16611661

16621662
if (codePoint == -1) {
16631663
badCodePointProfile.enter(node);
@@ -1780,7 +1780,7 @@ static Object rstripBangNonEmptyString(RubyString string,
17801780

17811781
var iterator = createBackwardCodePointIteratorNode.execute(tstring, tencoding,
17821782
ErrorHandling.RETURN_NEGATIVE);
1783-
int codePoint = previousNode.execute(iterator);
1783+
int codePoint = previousNode.execute(iterator, tencoding);
17841784

17851785
// Check the last code point to see if it's broken. In the case of strings without trailing spaces,
17861786
// this check can avoid having to compile the while loop.
@@ -1798,7 +1798,7 @@ static Object rstripBangNonEmptyString(RubyString string,
17981798

17991799
while (iterator.hasPrevious()) {
18001800
int byteIndex = iterator.getByteIndex();
1801-
codePoint = previousNode.execute(iterator);
1801+
codePoint = previousNode.execute(iterator, tencoding);
18021802

18031803
if (codePoint == -1) {
18041804
badCodePointProfile.enter(node);
@@ -3023,7 +3023,7 @@ Object capitalizeAsciiCodePoints(RubyString string, int caseMappingOptions,
30233023
byte[] bytes = null;
30243024

30253025
var iterator = createCodePointIteratorNode.execute(tstring, tencoding, ErrorHandling.RETURN_NEGATIVE);
3026-
int firstCodePoint = nextNode.execute(iterator);
3026+
int firstCodePoint = nextNode.execute(iterator, tencoding);
30273027
if (firstCharIsLowerProfile.profile(this, StringSupport.isAsciiLowercase(firstCodePoint))) {
30283028
bytes = copyByteArray(tstring, tencoding);
30293029
bytes[0] ^= 0x20;
@@ -3289,7 +3289,7 @@ static Object stringAwkSplit(Object string, int limit, Object block,
32893289
int e = 0, b = 0, iterations = 0;
32903290
try {
32913291
while (loopProfile.inject(node, iterator.hasNext())) {
3292-
int c = nextNode.execute(iterator);
3292+
int c = nextNode.execute(iterator, tencoding);
32933293
int p = iterator.getByteIndex();
32943294
iterations++;
32953295

@@ -3521,7 +3521,7 @@ private static TruffleString rbStrEscape(AbstractTruffleString tstring, RubyEnco
35213521

35223522
while (iterator.hasNext()) {
35233523
final int p = iterator.getByteIndex();
3524-
int c = iterator.nextUncached();
3524+
int c = iterator.nextUncached(tencoding);
35253525

35263526
if (c == -1) {
35273527
int n = iterator.getByteIndex() - p;

src/main/java/org/truffleruby/core/string/StringSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,10 +1226,10 @@ public static int multiByteCasecmp(RubyEncoding enc, AbstractTruffleString selfT
12261226

12271227
while (selfIterator.hasNext() && otherIterator.hasNext()) {
12281228
final int selfPos = selfIterator.getByteIndex();
1229-
final int c = selfIterator.nextUncached();
1229+
final int c = selfIterator.nextUncached(selfEncoding);
12301230

12311231
final int otherPos = otherIterator.getByteIndex();
1232-
final int oc = otherIterator.nextUncached();
1232+
final int oc = otherIterator.nextUncached(otherEncoding);
12331233

12341234
if (enc.isAsciiCompatible && (c >= 0 && Encoding.isAscii(c)) && (oc >= 0 && Encoding.isAscii(oc))) {
12351235
byte uc = AsciiTables.ToUpperCaseTable[c];

0 commit comments

Comments
 (0)