@@ -85,56 +85,56 @@ public static CheckEncodingNode create() {
85
85
return TruffleRegexpNodesFactory .CheckEncodingNodeGen .create ();
86
86
}
87
87
88
- public abstract Encoding executeCheckEncoding (RubyRegexp regexp , Object str );
88
+ public final Encoding executeCheckEncoding (RubyRegexp regexp , Object string ) {
89
+ return executeInternal (regexp , stringLibrary .getRope (string ));
90
+ }
91
+
92
+ public abstract Encoding executeInternal (RubyRegexp regexp , Rope rope );
89
93
90
94
@ Specialization (guards = {
91
- "!isSameEncoding(regexp, string )" ,
92
- "isUSASCII(regexp, string )"
95
+ "!isSameEncoding(regexp, rope )" ,
96
+ "isUSASCII(regexp, rope )"
93
97
})
94
- protected Encoding checkEncodingAsciiOnly (RubyRegexp regexp , Object string ) {
98
+ protected Encoding checkEncodingAsciiOnly (RubyRegexp regexp , Rope rope ) {
95
99
return USASCIIEncoding .INSTANCE ;
96
100
}
97
101
98
102
@ Specialization (guards = {
99
- "isSameEncoding(regexp, string )"
103
+ "isSameEncoding(regexp, rope )"
100
104
})
101
- protected Encoding checkEncodingSameEncoding (RubyRegexp regexp , Object string ) {
105
+ protected Encoding checkEncodingSameEncoding (RubyRegexp regexp , Rope rope ) {
102
106
return regexp .regex .getEncoding ();
103
107
}
104
108
105
109
@ Specialization (guards = {
106
- "!isSameEncoding(regexp, string )" ,
107
- "!isUSASCII(regexp, string )" ,
108
- "isFixedEncoding(regexp, string )" ,
110
+ "!isSameEncoding(regexp, rope )" ,
111
+ "!isUSASCII(regexp, rope )" ,
112
+ "isFixedEncoding(regexp, rope )" ,
109
113
})
110
- protected Encoding checkEncodingFixedEncoding (RubyRegexp regexp , Object string ) {
114
+ protected Encoding checkEncodingFixedEncoding (RubyRegexp regexp , Rope rope ) {
111
115
return regexp .regex .getEncoding ();
112
116
}
113
117
114
118
@ Specialization (guards = {
115
- "!isSameEncoding(regexp, string )" ,
116
- "!isUSASCII(regexp, string )" ,
117
- "!isFixedEncoding(regexp, string )"
119
+ "!isSameEncoding(regexp, rope )" ,
120
+ "!isUSASCII(regexp, rope )" ,
121
+ "!isFixedEncoding(regexp, rope )"
118
122
})
119
- protected Encoding fallback (RubyRegexp regexp , Object string ) {
120
- return stringEncoding (string );
121
- }
122
-
123
- protected boolean isUSASCII (RubyRegexp regexp , Object string ) {
124
- return regexp .regex .getEncoding () == USASCIIEncoding .INSTANCE &&
125
- codeRangeNode .execute (stringLibrary .getRope (string )) == CodeRange .CR_7BIT ;
123
+ protected Encoding fallback (RubyRegexp regexp , Rope rope ) {
124
+ return rope .encoding ;
126
125
}
127
126
128
- protected boolean isFixedEncoding (RubyRegexp regexp , Object string ) {
129
- return regexp .options . isFixed () && stringEncoding ( string ). isAsciiCompatible () ;
127
+ protected boolean isSameEncoding (RubyRegexp regexp , Rope rope ) {
128
+ return regexp .regex . getEncoding () == rope . encoding ;
130
129
}
131
130
132
- protected boolean isSameEncoding (RubyRegexp regexp , Object string ) {
133
- return regexp .regex .getEncoding () == stringEncoding (string );
131
+ protected boolean isUSASCII (RubyRegexp regexp , Rope rope ) {
132
+ return regexp .regex .getEncoding () == USASCIIEncoding .INSTANCE &&
133
+ codeRangeNode .execute (rope ) == CodeRange .CR_7BIT ;
134
134
}
135
135
136
- protected Encoding stringEncoding ( Object string ) {
137
- return stringLibrary . getRope ( string ). getEncoding ();
136
+ protected boolean isFixedEncoding ( RubyRegexp regexp , Rope rope ) {
137
+ return regexp . options . isFixed () && rope . encoding . isAsciiCompatible ();
138
138
}
139
139
140
140
}
0 commit comments