72
72
import com .oracle .graal .python .builtins .objects .str .PString ;
73
73
import com .oracle .graal .python .builtins .objects .type .PythonBuiltinClass ;
74
74
import com .oracle .graal .python .builtins .objects .type .PythonClass ;
75
+ import com .oracle .graal .python .nodes .BuiltinNames ;
75
76
import com .oracle .graal .python .nodes .PBaseNode ;
76
77
import com .oracle .graal .python .nodes .PGuards ;
77
78
import com .oracle .graal .python .nodes .SpecialAttributeNames ;
@@ -162,7 +163,7 @@ public Object access(PythonNativeWrapper object, String key) {
162
163
@ ImportStatic ({NativeMemberNames .class , SpecialMethodNames .class , SpecialAttributeNames .class })
163
164
@ TypeSystemReference (PythonArithmeticTypes .class )
164
165
abstract static class ReadNativeMemberNode extends PBaseNode {
165
- @ Child GetClassNode getClass = GetClassNode . create () ;
166
+ @ Child GetClassNode getClassNode ;
166
167
@ Child private ToSulongNode toSulongNode ;
167
168
@ Child private HashingStorageNodes .GetItemNode getItemNode ;
168
169
@ Child private CExtNodes .SizeofWCharNode sizeofWcharNode ;
@@ -186,7 +187,7 @@ int doObRefcnt(@SuppressWarnings("unused") Object o, @SuppressWarnings("unused")
186
187
187
188
@ Specialization (guards = "eq(OB_TYPE, key)" )
188
189
Object doObType (Object object , @ SuppressWarnings ("unused" ) String key ) {
189
- return getToSulongNode ().execute (getClass . execute (object ));
190
+ return getToSulongNode ().execute (getClass (object ));
190
191
}
191
192
192
193
@ Specialization (guards = "eq(OB_SIZE, key)" )
@@ -425,6 +426,12 @@ Object doImFunc(PBuiltinMethod object, @SuppressWarnings("unused") String key) {
425
426
return getToSulongNode ().execute (object .getFunction ());
426
427
}
427
428
429
+ // @Specialization(guards = {"isMemoryView(object)", "eq(MEMORYVIEW_FLAGS)" })
430
+ // Object doImFunc(PythonObject object, @SuppressWarnings("unused") String key,
431
+ // @Cached("create()") ReadAttributeFromObjectNode readAttrNode) {
432
+ // return readAttrNode.execute(object, NativeMemberNames.MEMORYVIEW_FLAGS);
433
+ // }
434
+
428
435
@ Fallback
429
436
Object doGeneric (Object object , String key ) {
430
437
// This is the preliminary generic case: There are native members we know that they
@@ -443,6 +450,11 @@ protected boolean eq(String expected, String actual) {
443
450
return expected .equals (actual );
444
451
}
445
452
453
+ protected boolean isMemoryView (Object obj ) {
454
+ // TODO
455
+ return getClass (obj ).getName ().equals (BuiltinNames .MEMORYVIEW );
456
+ }
457
+
446
458
public static ReadNativeMemberNode create () {
447
459
return ReadNativeMemberNodeGen .create ();
448
460
}
@@ -470,6 +482,14 @@ private int sizeofWchar() {
470
482
}
471
483
return (int ) sizeofWcharNode .execute ();
472
484
}
485
+
486
+ private PythonClass getClass (Object obj ) {
487
+ if (getClassNode == null ) {
488
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
489
+ getClassNode = insert (GetClassNode .create ());
490
+ }
491
+ return getClassNode .execute (obj );
492
+ }
473
493
}
474
494
475
495
@ Resolve (message = "WRITE" )
0 commit comments