File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -320,21 +320,36 @@ static boolean doString(TruffleString str,
320
320
}
321
321
TruffleStringIterator it = createCodePointIteratorNode .execute (str , TS_ENCODING );
322
322
int c = nextNode .execute (it );
323
- if (c != '_' && !hasProperty ( c , UProperty . XID_START )) {
323
+ if (c != '_' && !isIdentifierStart ( c )) {
324
324
return false ;
325
325
}
326
326
while (it .hasNext ()) {
327
327
c = nextNode .execute (it );
328
- if (!hasProperty ( c , UProperty . XID_CONTINUE )) {
328
+ if (!isIdentifierPart ( c )) {
329
329
return false ;
330
330
}
331
331
}
332
332
return true ;
333
333
}
334
334
335
335
@ TruffleBoundary
336
- static boolean hasProperty (int codePoint , int property ) {
337
- return UCharacter .hasBinaryProperty (codePoint , property );
336
+ static boolean isIdentifierStart (int codePoint ) {
337
+ if (ImageInfo .inImageBuildtimeCode ()) {
338
+ // Avoid initializing ICU4J at image build time
339
+ return Character .isUnicodeIdentifierStart (codePoint );
340
+ } else {
341
+ return UCharacter .hasBinaryProperty (codePoint , UProperty .XID_START );
342
+ }
343
+ }
344
+
345
+ @ TruffleBoundary
346
+ static boolean isIdentifierPart (int codePoint ) {
347
+ if (ImageInfo .inImageBuildtimeCode ()) {
348
+ // Avoid initializing ICU4J at image build time
349
+ return Character .isUnicodeIdentifierPart (codePoint );
350
+ } else {
351
+ return UCharacter .hasBinaryProperty (codePoint , UProperty .XID_CONTINUE );
352
+ }
338
353
}
339
354
}
340
355
You can’t perform that action at this time.
0 commit comments