35
35
import static com .oracle .graal .python .nodes .SpecialAttributeNames .__SELF__ ;
36
36
import static com .oracle .graal .python .nodes .SpecialMethodNames .__CALL__ ;
37
37
import static com .oracle .graal .python .nodes .SpecialMethodNames .__EQ__ ;
38
- import static com .oracle .graal .python .nodes .SpecialMethodNames .__REDUCE__ ;
39
38
import static com .oracle .graal .python .nodes .SpecialMethodNames .__HASH__ ;
39
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__REDUCE__ ;
40
40
41
41
import java .util .List ;
42
42
@@ -235,14 +235,22 @@ public abstract static class NameNode extends PythonUnaryBuiltinNode {
235
235
Object getName (VirtualFrame frame , PBuiltinMethod method ,
236
236
@ Cached .Shared ("toJavaStringNode" ) @ Cached CastToJavaStringNode toJavaStringNode ,
237
237
@ Cached .Shared ("pol" ) @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary pol ) {
238
- return toJavaStringNode .execute (pol .lookupAttribute (method .getFunction (), frame , __NAME__ ));
238
+ try {
239
+ return toJavaStringNode .execute (pol .lookupAttribute (method .getFunction (), frame , __NAME__ ));
240
+ } catch (CannotCastException cce ) {
241
+ throw CompilerDirectives .shouldNotReachHere ();
242
+ }
239
243
}
240
244
241
245
@ Specialization
242
246
Object getName (VirtualFrame frame , PMethod method ,
243
247
@ Cached .Shared ("toJavaStringNode" ) @ Cached CastToJavaStringNode toJavaStringNode ,
244
248
@ Cached .Shared ("pol" ) @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary pol ) {
245
- return toJavaStringNode .execute (pol .lookupAttribute (method .getFunction (), frame , __NAME__ ));
249
+ try {
250
+ return toJavaStringNode .execute (pol .lookupAttribute (method .getFunction (), frame , __NAME__ ));
251
+ } catch (CannotCastException cce ) {
252
+ throw CompilerDirectives .shouldNotReachHere ();
253
+ }
246
254
}
247
255
}
248
256
@@ -292,7 +300,7 @@ private Object getQualName(VirtualFrame frame, Object self, Object func, TypeNod
292
300
293
301
try {
294
302
String typeQualName = toJavaStringNode .execute (pol .lookupAttributeStrict (type , frame , __QUALNAME__ ));
295
- return composeQualName ( typeQualName , getName (frame , func , toJavaStringNode , pol ));
303
+ return PythonUtils . format ( "%s.%s" , typeQualName , getName (frame , func , toJavaStringNode , pol ));
296
304
} catch (CannotCastException cce ) {
297
305
throw raise (PythonBuiltinClassType .TypeError , ErrorMessages .IS_NOT_A , __QUALNAME__ , "unicode object" );
298
306
}
@@ -301,11 +309,6 @@ private Object getQualName(VirtualFrame frame, Object self, Object func, TypeNod
301
309
private String getName (VirtualFrame frame , Object func , CastToJavaStringNode toJavaStringNode , PythonObjectLibrary pol ) {
302
310
return toJavaStringNode .execute (pol .lookupAttribute (func , frame , __NAME__ ));
303
311
}
304
-
305
- @ CompilerDirectives .TruffleBoundary
306
- private static Object composeQualName (String typeQualName , String name ) {
307
- return String .format ("%s.%s" , typeQualName , name );
308
- }
309
312
}
310
313
311
314
@ Builtin (name = __REDUCE__ , minNumOfPositionalArgs = 1 , maxNumOfPositionalArgs = 2 )
0 commit comments