40
40
import com .oracle .graal .python .builtins .objects .common .SequenceNodes ;
41
41
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
42
42
import com .oracle .graal .python .builtins .objects .range .PRange ;
43
- import com .oracle .graal .python .builtins .objects .type .LazyPythonClass ;
44
43
import com .oracle .graal .python .nodes .ErrorMessages ;
45
44
import com .oracle .graal .python .nodes .control .GetIteratorExpressionNode .GetIteratorNode ;
46
45
import com .oracle .graal .python .nodes .control .GetNextNode ;
@@ -71,15 +70,15 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
71
70
abstract static class PythonArrayNode extends PythonBuiltinNode {
72
71
73
72
@ Specialization (guards = "isNoValue(initializer)" )
74
- PArray array (LazyPythonClass cls , String typeCode , @ SuppressWarnings ("unused" ) PNone initializer ) {
73
+ PArray array (Object cls , String typeCode , @ SuppressWarnings ("unused" ) PNone initializer ) {
75
74
/**
76
75
* TODO @param typeCode should be a char, not a string
77
76
*/
78
77
return makeEmptyArray (cls , typeCode .charAt (0 ));
79
78
}
80
79
81
80
@ Specialization
82
- PArray arrayWithRangeInitializer (LazyPythonClass cls , String typeCode , PRange range ) {
81
+ PArray arrayWithRangeInitializer (Object cls , String typeCode , PRange range ) {
83
82
if (!typeCode .equals ("i" )) {
84
83
typeError (typeCode , range );
85
84
}
@@ -99,7 +98,7 @@ PArray arrayWithRangeInitializer(LazyPythonClass cls, String typeCode, PRange ra
99
98
}
100
99
101
100
@ Specialization
102
- PArray arrayWithSequenceInitializer (LazyPythonClass cls , String typeCode , String str ) {
101
+ PArray arrayWithSequenceInitializer (Object cls , String typeCode , String str ) {
103
102
if (!typeCode .equals ("c" )) {
104
103
typeError (typeCode , str );
105
104
}
@@ -128,7 +127,7 @@ protected boolean isDoubleArray(String typeCode) {
128
127
}
129
128
130
129
@ Specialization (guards = "isByteArray(typeCode)" )
131
- PArray arrayByteInitializer (VirtualFrame frame , LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
130
+ PArray arrayByteInitializer (VirtualFrame frame , Object cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
132
131
@ Cached ("createCast()" ) CastToByteNode castToByteNode ,
133
132
@ Cached ("create()" ) GetIteratorNode getIterator ,
134
133
@ Cached ("create()" ) GetNextNode next ,
@@ -153,15 +152,15 @@ PArray arrayByteInitializer(VirtualFrame frame, LazyPythonClass cls, @SuppressWa
153
152
}
154
153
155
154
@ Specialization (guards = "isCharArray(typeCode)" )
156
- PArray arrayCharInitializer (LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
155
+ PArray arrayCharInitializer (Object cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
157
156
@ Cached SequenceNodes .GetSequenceStorageNode getSequenceStorageNode ,
158
157
@ Cached SequenceStorageNodes .ToByteArrayNode toByteArrayNode ) {
159
158
byte [] byteArray = toByteArrayNode .execute (getSequenceStorageNode .execute (initializer ));
160
159
return factory ().createArray (cls , byteArray );
161
160
}
162
161
163
162
@ Specialization (guards = "isIntArray(typeCode)" )
164
- PArray arrayIntInitializer (VirtualFrame frame , LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
163
+ PArray arrayIntInitializer (VirtualFrame frame , Object cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
165
164
@ Cached ("create()" ) GetIteratorNode getIterator ,
166
165
@ Cached ("create()" ) GetNextNode next ,
167
166
@ Cached ("create()" ) IsBuiltinClassProfile errorProfile ,
@@ -190,7 +189,7 @@ PArray arrayIntInitializer(VirtualFrame frame, LazyPythonClass cls, @SuppressWar
190
189
}
191
190
192
191
@ Specialization (guards = "isLongArray(typeCode)" )
193
- PArray arrayLongInitializer (VirtualFrame frame , LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
192
+ PArray arrayLongInitializer (VirtualFrame frame , Object cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
194
193
@ Cached ("create()" ) GetIteratorNode getIterator ,
195
194
@ Cached ("create()" ) GetNextNode next ,
196
195
@ Cached ("create()" ) IsBuiltinClassProfile errorProfile ,
@@ -219,7 +218,7 @@ PArray arrayLongInitializer(VirtualFrame frame, LazyPythonClass cls, @SuppressWa
219
218
}
220
219
221
220
@ Specialization (guards = "isDoubleArray(typeCode)" )
222
- PArray arrayDoubleInitializer (VirtualFrame frame , LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
221
+ PArray arrayDoubleInitializer (VirtualFrame frame , Object cls , @ SuppressWarnings ("unused" ) String typeCode , PSequence initializer ,
223
222
@ Cached ("create()" ) GetIteratorNode getIterator ,
224
223
@ Cached ("create()" ) GetNextNode next ,
225
224
@ Cached ("create()" ) IsBuiltinClassProfile errorProfile ,
@@ -251,7 +250,7 @@ PArray arrayDoubleInitializer(VirtualFrame frame, LazyPythonClass cls, @Suppress
251
250
252
251
@ Specialization
253
252
@ TruffleBoundary
254
- PArray arrayWithObjectInitializer (@ SuppressWarnings ("unused" ) LazyPythonClass cls , @ SuppressWarnings ("unused" ) String typeCode , Object initializer ) {
253
+ PArray arrayWithObjectInitializer (@ SuppressWarnings ("unused" ) Object cls , @ SuppressWarnings ("unused" ) String typeCode , Object initializer ) {
255
254
if (!(isIntArray (typeCode ) || isByteArray (typeCode ) || isDoubleArray (typeCode ) || isCharArray (typeCode ))) {
256
255
// TODO implement support for typecodes: b, B, u, h, H, i, I, l, L, q, Q, f or d
257
256
throw raise (ValueError , ErrorMessages .BAD_TYPECODE );
@@ -260,7 +259,7 @@ PArray arrayWithObjectInitializer(@SuppressWarnings("unused") LazyPythonClass cl
260
259
}
261
260
262
261
@ Specialization (guards = "!isString(typeCode)" )
263
- PArray noArray (@ SuppressWarnings ("unused" ) LazyPythonClass cls , Object typeCode , @ SuppressWarnings ("unused" ) Object initializer ) {
262
+ PArray noArray (@ SuppressWarnings ("unused" ) Object cls , Object typeCode , @ SuppressWarnings ("unused" ) Object initializer ) {
264
263
throw raise (TypeError , ErrorMessages .ARG_MUST_BE_UNICODE , "array()" , 1 , typeCode );
265
264
}
266
265
0 commit comments