@@ -1406,19 +1406,18 @@ static RubyString forceEncoding(RubyString string, Object newEncoding,
1406
1406
@ CoreMethod (names = "getbyte" , required = 1 , lowerFixnum = 1 )
1407
1407
public abstract static class StringGetByteNode extends CoreMethodArrayArgumentsNode {
1408
1408
1409
- @ Child private StringHelperNodes .NormalizeIndexNode normalizeIndexNode = StringHelperNodes .NormalizeIndexNode
1410
- .create ();
1411
1409
@ Child private TruffleString .ReadByteNode readByteNode = TruffleString .ReadByteNode .create ();
1412
1410
1413
1411
@ Specialization
1414
1412
Object getByte (Object string , int index ,
1415
1413
@ Cached InlinedConditionProfile indexOutOfBoundsProfile ,
1416
- @ Cached RubyStringLibrary libString ) {
1414
+ @ Cached RubyStringLibrary libString ,
1415
+ @ Cached StringHelperNodes .NormalizeIndexNode normalizeIndexNode ) {
1417
1416
var tstring = libString .getTString (string );
1418
1417
var encoding = libString .getEncoding (string ).tencoding ;
1419
1418
int byteLength = tstring .byteLength (encoding );
1420
1419
1421
- final int normalizedIndex = normalizeIndexNode .executeNormalize (index , byteLength );
1420
+ final int normalizedIndex = normalizeIndexNode .executeNormalize (this , index , byteLength );
1422
1421
1423
1422
if (indexOutOfBoundsProfile .profile (this , (normalizedIndex < 0 ) || (normalizedIndex >= byteLength ))) {
1424
1423
return nil ;
@@ -3329,18 +3328,16 @@ private static Object[] addSubstring(Node node, CallBlockNode yieldNode, Object[
3329
3328
@ Primitive (name = "string_byte_substring" , lowerFixnum = { 1 , 2 })
3330
3329
public abstract static class StringByteSubstringPrimitiveNode extends PrimitiveArrayArgumentsNode {
3331
3330
3332
- @ Child private StringHelperNodes .NormalizeIndexNode normalizeIndexNode = StringHelperNodes .NormalizeIndexNode
3333
- .create ();
3334
-
3335
3331
@ Specialization
3336
3332
Object stringByteSubstring (Object string , int index , NotProvided length ,
3337
3333
@ Cached @ Exclusive InlinedConditionProfile indexOutOfBoundsProfile ,
3338
3334
@ Cached @ Shared RubyStringLibrary libString ,
3339
- @ Cached @ Shared TruffleString .SubstringByteIndexNode substringNode ) {
3335
+ @ Cached @ Shared TruffleString .SubstringByteIndexNode substringNode ,
3336
+ @ Cached @ Shared StringHelperNodes .NormalizeIndexNode normalizeIndexNode ) {
3340
3337
var tString = libString .getTString (string );
3341
3338
var encoding = libString .getEncoding (string );
3342
3339
final int stringByteLength = tString .byteLength (encoding .tencoding );
3343
- final int normalizedIndex = normalizeIndexNode .executeNormalize (index , stringByteLength );
3340
+ final int normalizedIndex = normalizeIndexNode .executeNormalize (this , index , stringByteLength );
3344
3341
3345
3342
if (indexOutOfBoundsProfile .profile (this , normalizedIndex < 0 || normalizedIndex >= stringByteLength )) {
3346
3343
return nil ;
@@ -3355,15 +3352,16 @@ Object stringByteSubstring(Object string, int index, int length,
3355
3352
@ Cached @ Exclusive InlinedConditionProfile indexOutOfBoundsProfile ,
3356
3353
@ Cached @ Exclusive InlinedConditionProfile lengthTooLongProfile ,
3357
3354
@ Cached @ Shared RubyStringLibrary libString ,
3358
- @ Cached @ Shared TruffleString .SubstringByteIndexNode substringNode ) {
3355
+ @ Cached @ Shared TruffleString .SubstringByteIndexNode substringNode ,
3356
+ @ Cached @ Shared StringHelperNodes .NormalizeIndexNode normalizeIndexNode ) {
3359
3357
if (negativeLengthProfile .profile (this , length < 0 )) {
3360
3358
return nil ;
3361
3359
}
3362
3360
3363
3361
var tString = libString .getTString (string );
3364
3362
var encoding = libString .getEncoding (string );
3365
3363
final int stringByteLength = tString .byteLength (encoding .tencoding );
3366
- final int normalizedIndex = normalizeIndexNode .executeNormalize (index , stringByteLength );
3364
+ final int normalizedIndex = normalizeIndexNode .executeNormalize (this , index , stringByteLength );
3367
3365
3368
3366
if (indexOutOfBoundsProfile .profile (this , normalizedIndex < 0 || normalizedIndex > stringByteLength )) {
3369
3367
return nil ;
@@ -4280,7 +4278,8 @@ Object stringSubstringGeneric(Object string, int codePointOffset, int codePointL
4280
4278
return nil ;
4281
4279
}
4282
4280
4283
- int normalizedCodePointOffset = normalizeIndexNode .executeNormalize (codePointOffset , stringCodePointLength );
4281
+ int normalizedCodePointOffset = normalizeIndexNode .executeNormalize (this , codePointOffset ,
4282
+ stringCodePointLength );
4284
4283
if (negativeIndexProfile .profile (this , normalizedCodePointOffset < 0 )) {
4285
4284
return nil ;
4286
4285
}
0 commit comments