41
41
package com .oracle .graal .python .builtins .objects .exception ;
42
42
43
43
import static com .oracle .graal .python .nodes .SpecialMethodNames .J___GETSTATE__ ;
44
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .J___INIT__ ;
44
45
import static com .oracle .graal .python .nodes .SpecialMethodNames .J___REDUCE__ ;
45
46
import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
46
47
import static com .oracle .graal .python .util .PythonUtils .tsLiteral ;
47
48
48
49
import java .util .List ;
49
50
50
- import com .oracle .graal .python .PythonLanguage ;
51
- import com .oracle .graal .python .annotations .Slot ;
52
- import com .oracle .graal .python .annotations .Slot .SlotKind ;
53
- import com .oracle .graal .python .annotations .Slot .SlotSignature ;
54
51
import com .oracle .graal .python .builtins .Builtin ;
55
52
import com .oracle .graal .python .builtins .CoreFunctions ;
56
53
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
61
58
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes ;
62
59
import com .oracle .graal .python .builtins .objects .dict .PDict ;
63
60
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
64
- import com .oracle .graal .python .builtins .objects .type .TpSlots ;
65
61
import com .oracle .graal .python .nodes .ErrorMessages ;
66
62
import com .oracle .graal .python .nodes .PRaiseNode ;
67
63
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
70
66
import com .oracle .graal .python .nodes .function .builtins .PythonVarargsBuiltinNode ;
71
67
import com .oracle .graal .python .nodes .object .GetClassNode ;
72
68
import com .oracle .graal .python .nodes .object .GetDictIfExistsNode ;
73
- import com .oracle .graal .python .runtime .object .PFactory ;
69
+ import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
74
70
import com .oracle .truffle .api .dsl .Bind ;
75
71
import com .oracle .truffle .api .dsl .Cached ;
76
72
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
84
80
@ CoreFunctions (extendClasses = PythonBuiltinClassType .AttributeError )
85
81
public final class AttributeErrorBuiltins extends PythonBuiltins {
86
82
87
- public static final TpSlots SLOTS = AttributeErrorBuiltinsSlotsGen .SLOTS ;
88
-
89
83
@ Override
90
84
protected List <? extends NodeFactory <? extends PythonBuiltinBaseNode >> getNodeFactories () {
91
85
return AttributeErrorBuiltinsFactory .getFactories ();
@@ -98,10 +92,9 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
98
92
private static final TruffleString T_NAME = tsLiteral ("name" );
99
93
private static final TruffleString T_OBJ = tsLiteral ("obj" );
100
94
101
- private static final BaseExceptionAttrNode .StorageFactory ATTR_FACTORY = (args ) -> new Object [NUM_ATTRS ];
95
+ private static final BaseExceptionAttrNode .StorageFactory ATTR_FACTORY = (args , factory ) -> new Object [NUM_ATTRS ];
102
96
103
- @ Slot (value = SlotKind .tp_init , isComplex = true )
104
- @ SlotSignature (minNumOfPositionalArgs = 1 , takesVarArgs = true , takesVarKeywordArgs = true )
97
+ @ Builtin (name = J___INIT__ , minNumOfPositionalArgs = 1 , takesVarArgs = true , takesVarKeywordArgs = true )
105
98
@ GenerateNodeFactory
106
99
abstract static class InitNode extends PythonVarargsBuiltinNode {
107
100
@@ -124,7 +117,7 @@ static Object init(PBaseException self, Object[] args, PKeyword[] kwargs,
124
117
} else if (equalObjNode .execute (kwName , T_OBJ , TS_ENCODING )) {
125
118
attrs [IDX_OBJ ] = kw .getValue ();
126
119
} else {
127
- throw raiseNode .raise (inliningTarget , PythonBuiltinClassType .TypeError , ErrorMessages .S_IS_AN_INVALID_ARG_FOR_S , kw .getName (), "AttributeError" );
120
+ throw raiseNode .raise (PythonBuiltinClassType .TypeError , ErrorMessages .S_IS_AN_INVALID_ARG_FOR_S , kw .getName (), "AttributeError" );
128
121
}
129
122
}
130
123
self .setExceptionAttributes (attrs );
@@ -163,7 +156,7 @@ static Object get(PBaseException self,
163
156
@ Cached GetDictIfExistsNode getDictIfExistsNode ,
164
157
@ Cached HashingStorageNodes .HashingStorageSetItem setHashingStorageItem ,
165
158
@ Cached HashingStorageNodes .HashingStorageCopy copyStorageNode ,
166
- @ Bind PythonLanguage language ) {
159
+ @ Cached PythonObjectFactory factory ) {
167
160
PDict dict = getDictIfExistsNode .execute (self );
168
161
/*
169
162
* Note from CPython: We specifically are not pickling the obj attribute since there are
@@ -173,7 +166,7 @@ static Object get(PBaseException self,
173
166
if (name != null ) {
174
167
HashingStorage storage = (dict != null ) ? copyStorageNode .execute (inliningTarget , dict .getDictStorage ()) : EmptyStorage .INSTANCE ;
175
168
storage = setHashingStorageItem .execute (inliningTarget , storage , T_NAME , name );
176
- return PFactory .createDict (language , storage );
169
+ return factory .createDict (storage );
177
170
} else if (dict != null ) {
178
171
return dict ;
179
172
} else {
@@ -192,11 +185,11 @@ static Object reduce(VirtualFrame frame, PBaseException self,
192
185
@ Cached GetClassNode getClassNode ,
193
186
@ Cached ExceptionNodes .GetArgsNode getArgsNode ,
194
187
@ Cached GetStateNode getStateNode ,
195
- @ Bind PythonLanguage language ) {
188
+ @ Cached PythonObjectFactory factory ) {
196
189
Object clazz = getClassNode .execute (inliningTarget , self );
197
190
Object args = getArgsNode .execute (inliningTarget , self );
198
191
Object state = getStateNode .execute (frame , self );
199
- return PFactory .createTuple (language , new Object []{clazz , args , state });
192
+ return factory .createTuple (new Object []{clazz , args , state });
200
193
}
201
194
}
202
195
}
0 commit comments