@@ -1268,18 +1268,60 @@ public String toString() {
1268
1268
}
1269
1269
1270
1270
@ ExportMessage
1271
- protected boolean isMemberReadable (String member ,
1272
- @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
1273
- @ Cached GetLazyClassNode getClassNode ,
1274
- @ Cached GetNameNode getNameNode ) {
1275
- return DynamicObjectNativeWrapper .GP_OBJECT .equals (member ) || NativeMemberNames .isValid (member ) ||
1276
- ReadObjectNativeMemberNode .isPyDateTimeCAPIType (getNameNode .execute (getClassNode .execute (lib .getDelegate (this ))));
1271
+ @ ImportStatic ({PGuards .class , NativeMemberNames .class , DynamicObjectNativeWrapper .class })
1272
+ abstract static class IsMemberReadable {
1273
+
1274
+ @ SuppressWarnings ("unused" )
1275
+ @ Specialization (guards = {"stringEquals(cachedName, name, stringProfile)" , "isValid(cachedName)" })
1276
+ static boolean isReadableNativeMembers (PythonObjectNativeWrapper receiver , String name ,
1277
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ,
1278
+ @ Cached (value = "name" , allowUncached = true ) String cachedName ) {
1279
+ return true ;
1280
+ }
1281
+
1282
+ @ SuppressWarnings ("unused" )
1283
+ @ Specialization (guards = "stringEquals(GP_OBJECT, name, stringProfile)" )
1284
+ static boolean isReadableCachedGP (PythonObjectNativeWrapper receiver , String name ,
1285
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ) {
1286
+ return true ;
1287
+ }
1288
+
1289
+ static boolean isPyTimeMemberReadable (PythonObjectNativeWrapper receiver , PythonNativeWrapperLibrary lib , GetLazyClassNode getClassNode , GetNameNode getNameNode ) {
1290
+ return ReadObjectNativeMemberNode .isPyDateTimeCAPIType (getNameNode .execute (getClassNode .execute (lib .getDelegate (receiver ))));
1291
+ }
1292
+
1293
+ @ SuppressWarnings ("unused" )
1294
+ @ Specialization (guards = "isPyTimeMemberReadable(receiver, lib, getClassNode, getNameNode)" )
1295
+ static boolean isReadablePyTime (PythonObjectNativeWrapper receiver , String name ,
1296
+ @ CachedLibrary ("receiver" ) PythonNativeWrapperLibrary lib ,
1297
+ @ Cached GetLazyClassNode getClassNode ,
1298
+ @ Cached GetNameNode getNameNode ) {
1299
+ return true ;
1300
+ }
1301
+
1302
+ @ Specialization
1303
+ @ TruffleBoundary
1304
+ static boolean isReadableFallback (PythonObjectNativeWrapper receiver , String name ,
1305
+ @ CachedLibrary ("receiver" ) PythonNativeWrapperLibrary lib ,
1306
+ @ Cached GetLazyClassNode getClassNode ,
1307
+ @ Cached GetNameNode getNameNode ) {
1308
+ return DynamicObjectNativeWrapper .GP_OBJECT .equals (name ) || NativeMemberNames .isValid (name ) ||
1309
+ ReadObjectNativeMemberNode .isPyDateTimeCAPIType (getNameNode .execute (getClassNode .execute (lib .getDelegate (receiver ))));
1310
+ }
1277
1311
}
1278
1312
1279
1313
@ ExportMessage
1280
- @ Override
1281
- public boolean isMemberModifiable (String member ) {
1282
- return NativeMemberNames .isValid (member );
1314
+ @ ImportStatic ({PGuards .class , NativeMemberNames .class , DynamicObjectNativeWrapper .class })
1315
+ abstract static class IsMemberModifiable {
1316
+
1317
+ @ SuppressWarnings ("unused" )
1318
+ @ Specialization (guards = "stringEquals(cachedName, name, stringProfile)" )
1319
+ static boolean isModifiableCached (PythonObjectNativeWrapper receiver , String name ,
1320
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ,
1321
+ @ Cached (value = "name" , allowUncached = true ) String cachedName ,
1322
+ @ Cached (value = "isValid(name)" , allowUncached = true ) boolean isValid ) {
1323
+ return isValid ;
1324
+ }
1283
1325
}
1284
1326
}
1285
1327
@@ -1398,10 +1440,31 @@ public static PrimitiveNativeWrapper createDouble(double val) {
1398
1440
return new PrimitiveNativeWrapper (val );
1399
1441
}
1400
1442
1401
- @ Override
1402
1443
@ ExportMessage
1403
- protected boolean isMemberReadable (String member ) {
1404
- return member .equals (DynamicObjectNativeWrapper .GP_OBJECT ) || NativeMemberNames .isValid (member );
1444
+ @ ImportStatic ({PGuards .class , NativeMemberNames .class , DynamicObjectNativeWrapper .class })
1445
+ abstract static class IsMemberReadable {
1446
+
1447
+ @ SuppressWarnings ("unused" )
1448
+ @ Specialization (guards = {"stringEquals(cachedName, name, stringProfile)" , "isValid(cachedName)" })
1449
+ static boolean isReadableNativeMembers (PrimitiveNativeWrapper receiver , String name ,
1450
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ,
1451
+ @ Cached (value = "name" , allowUncached = true ) String cachedName ) {
1452
+ return true ;
1453
+ }
1454
+
1455
+ @ SuppressWarnings ("unused" )
1456
+ @ Specialization (guards = "stringEquals(GP_OBJECT, name, stringProfile)" )
1457
+ static boolean isReadableCachedGP (PrimitiveNativeWrapper receiver , String name ,
1458
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ) {
1459
+ return true ;
1460
+ }
1461
+
1462
+ @ Specialization
1463
+ @ TruffleBoundary
1464
+ static boolean isReadableFallback (@ SuppressWarnings ("unused" ) PrimitiveNativeWrapper receiver , String name ) {
1465
+ return DynamicObjectNativeWrapper .GP_OBJECT .equals (name ) || NativeMemberNames .isValid (name );
1466
+ }
1467
+
1405
1468
}
1406
1469
1407
1470
@ ExportMessage
0 commit comments