28
28
29
29
public final class TRegexCache {
30
30
31
- // atStart =false
31
+ // onlyMatchAtStart =false
32
32
private Object usAsciiRegex ;
33
33
private Object latin1Regex ;
34
34
private Object utf8Regex ;
35
35
private Object binaryRegex ;
36
36
37
- // atStart =true
37
+ // onlyMatchAtStart =true
38
38
private Object usAsciiRegexAtStart ;
39
39
private Object latin1RegexAtStart ;
40
40
private Object utf8RegexAtStart ;
41
41
private Object binaryRegexAtStart ;
42
42
43
- public Object getUSASCIIRegex (boolean atStart ) {
44
- return atStart ? usAsciiRegexAtStart : usAsciiRegex ;
43
+ public Object getUSASCIIRegex (boolean onlyMatchAtStart ) {
44
+ return onlyMatchAtStart ? usAsciiRegexAtStart : usAsciiRegex ;
45
45
}
46
46
47
- public Object getLatin1Regex (boolean atStart ) {
48
- return atStart ? latin1RegexAtStart : latin1Regex ;
47
+ public Object getLatin1Regex (boolean onlyMatchAtStart ) {
48
+ return onlyMatchAtStart ? latin1RegexAtStart : latin1Regex ;
49
49
}
50
50
51
- public Object getUTF8Regex (boolean atStart ) {
52
- return atStart ? utf8RegexAtStart : utf8Regex ;
51
+ public Object getUTF8Regex (boolean onlyMatchAtStart ) {
52
+ return onlyMatchAtStart ? utf8RegexAtStart : utf8Regex ;
53
53
}
54
54
55
- public Object getBinaryRegex (boolean atStart ) {
56
- return atStart ? binaryRegexAtStart : binaryRegex ;
55
+ public Object getBinaryRegex (boolean onlyMatchAtStart ) {
56
+ return onlyMatchAtStart ? binaryRegexAtStart : binaryRegex ;
57
57
}
58
58
59
59
@ TruffleBoundary
60
- public Object compile (RubyContext context , RubyRegexp regexp , boolean atStart , RubyEncoding encoding ,
60
+ public Object compile (RubyContext context , RubyRegexp regexp , boolean onlyMatchAtStart , RubyEncoding encoding ,
61
61
TRegexCompileNode node ) {
62
- Object tregex = compileTRegex (context , regexp , atStart , encoding );
62
+ Object tregex = compileTRegex (context , regexp , onlyMatchAtStart , encoding );
63
63
if (tregex == null ) {
64
64
tregex = Nil .INSTANCE ;
65
65
if (context .getOptions ().WARN_TRUFFLE_REGEX_COMPILE_FALLBACK ) {
66
66
node .getWarnOnFallbackNode ().call (
67
67
context .getCoreLibrary ().truffleRegexpOperationsModule ,
68
68
"warn_fallback_regex" ,
69
69
regexp ,
70
- atStart ,
70
+ onlyMatchAtStart ,
71
71
encoding );
72
72
}
73
73
} else if (isBacktracking (tregex )) {
@@ -76,31 +76,31 @@ public Object compile(RubyContext context, RubyRegexp regexp, boolean atStart, R
76
76
context .getCoreLibrary ().truffleRegexpOperationsModule ,
77
77
"warn_backtracking" ,
78
78
regexp ,
79
- atStart ,
79
+ onlyMatchAtStart ,
80
80
encoding );
81
81
}
82
82
}
83
83
84
84
if (encoding == Encodings .US_ASCII ) {
85
- if (atStart ) {
85
+ if (onlyMatchAtStart ) {
86
86
usAsciiRegexAtStart = tregex ;
87
87
} else {
88
88
usAsciiRegex = tregex ;
89
89
}
90
90
} else if (encoding == Encodings .ISO_8859_1 ) {
91
- if (atStart ) {
91
+ if (onlyMatchAtStart ) {
92
92
latin1RegexAtStart = tregex ;
93
93
} else {
94
94
latin1Regex = tregex ;
95
95
}
96
96
} else if (encoding == Encodings .UTF_8 ) {
97
- if (atStart ) {
97
+ if (onlyMatchAtStart ) {
98
98
utf8RegexAtStart = tregex ;
99
99
} else {
100
100
utf8Regex = tregex ;
101
101
}
102
102
} else if (encoding == Encodings .BINARY ) {
103
- if (atStart ) {
103
+ if (onlyMatchAtStart ) {
104
104
binaryRegexAtStart = tregex ;
105
105
} else {
106
106
binaryRegex = tregex ;
@@ -136,7 +136,8 @@ public static String toTRegexEncoding(RubyEncoding encoding) {
136
136
}
137
137
138
138
@ TruffleBoundary
139
- private static Object compileTRegex (RubyContext context , RubyRegexp regexp , boolean atStart , RubyEncoding enc ) {
139
+ private static Object compileTRegex (RubyContext context , RubyRegexp regexp , boolean onlyMatchAtStart ,
140
+ RubyEncoding enc ) {
140
141
String tRegexEncoding = TRegexCache .toTRegexEncoding (enc );
141
142
if (tRegexEncoding == null ) {
142
143
return null ;
@@ -166,7 +167,7 @@ private static Object compileTRegex(RubyContext context, RubyRegexp regexp, bool
166
167
processedRegexpSource = TStringUtils .toJavaStringOrThrow (latin1string , Encodings .ISO_8859_1 );
167
168
}
168
169
169
- String flags = optionsToFlags (regexp .options , atStart );
170
+ String flags = optionsToFlags (regexp .options , onlyMatchAtStart );
170
171
171
172
String ignoreAtomicGroups = context .getOptions ().TRUFFLE_REGEX_IGNORE_ATOMIC_GROUPS
172
173
? ",IgnoreAtomicGroups=true"
@@ -187,7 +188,7 @@ private static Object compileTRegex(RubyContext context, RubyRegexp regexp, bool
187
188
}
188
189
}
189
190
190
- public static String optionsToFlags (RegexpOptions options , boolean atStart ) {
191
+ public static String optionsToFlags (RegexpOptions options , boolean onlyMatchAtStart ) {
191
192
StringBuilder flags = new StringBuilder (4 );
192
193
if (options .isMultiline ()) {
193
194
flags .append ('m' );
@@ -198,7 +199,7 @@ public static String optionsToFlags(RegexpOptions options, boolean atStart) {
198
199
if (options .isExtended ()) {
199
200
flags .append ('x' );
200
201
}
201
- if (atStart ) {
202
+ if (onlyMatchAtStart ) {
202
203
flags .append ('y' );
203
204
}
204
205
return flags .toString ();
0 commit comments