46
46
import com .oracle .graal .python .nodes .argument .ReadIndexedArgumentNode ;
47
47
import com .oracle .graal .python .nodes .statement .StatementNode ;
48
48
import com .oracle .graal .python .nodes .subscript .DeleteItemNode ;
49
+ import com .oracle .truffle .api .dsl .Bind ;
49
50
import com .oracle .truffle .api .dsl .Cached ;
50
51
import com .oracle .truffle .api .dsl .Specialization ;
51
52
import com .oracle .truffle .api .frame .VirtualFrame ;
55
56
public abstract class DeleteClassAttributeNode extends StatementNode {
56
57
private final String identifier ;
57
58
58
- @ Child private StatementNode deleteNsItem ;
59
-
60
59
DeleteClassAttributeNode (String identifier ) {
61
60
this .identifier = identifier ;
61
+ }
62
+
63
+ protected StatementNode createDeleteNsItem () {
62
64
ReadIndexedArgumentNode namespace = ReadIndexedArgumentNode .create (0 );
63
- this . deleteNsItem = PythonLanguage .getCurrent ().getNodeFactory ().createDeleteItem (namespace .asExpression (), this . identifier );
65
+ return PythonLanguage .getCurrent ().getNodeFactory ().createDeleteItem (namespace .asExpression (), identifier );
64
66
}
65
67
66
68
public static DeleteClassAttributeNode create (String name ) {
@@ -77,15 +79,17 @@ Object getLocalsDict(VirtualFrame frame) {
77
79
}
78
80
79
81
@ Specialization (guards = "localsDict != null" )
80
- void deleteFromLocals (@ SuppressWarnings ( "unused" ) VirtualFrame frame ,
81
- @ Cached ("getLocalsDict(frame)" ) Object localsDict ,
82
+ void deleteFromLocals (VirtualFrame frame ,
83
+ @ Bind ("getLocalsDict(frame)" ) Object localsDict ,
82
84
@ Cached ("create()" ) DeleteItemNode delItemNode ) {
83
85
// class namespace overrides closure
84
86
delItemNode .executeWith (frame , localsDict , identifier );
85
87
}
86
88
87
- @ Specialization
88
- void delete (VirtualFrame frame ) {
89
+ @ Specialization (guards = "localsDict == null" )
90
+ void delete (VirtualFrame frame ,
91
+ @ Bind ("getLocalsDict(frame)" ) Object localsDict ,
92
+ @ Cached ("createDeleteNsItem()" ) StatementNode deleteNsItem ) {
89
93
// delete attribute actual attribute
90
94
deleteNsItem .executeVoid (frame );
91
95
}
0 commit comments