62
62
import com .oracle .graal .python .builtins .objects .cext .capi .CApiGuards ;
63
63
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes ;
64
64
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .AsPythonObjectNode ;
65
- import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .GetNativeNullNode ;
66
65
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .PRaiseNativeNode ;
67
66
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .TransformExceptionToNativeNode ;
68
67
import com .oracle .graal .python .builtins .objects .cext .capi .PythonNativeWrapper ;
@@ -164,33 +163,30 @@ public abstract static class PyBytesConcatNode extends PythonBinaryBuiltinNode {
164
163
@ Specialization
165
164
public Object concat (VirtualFrame frame , PBytes original , Object newPart ,
166
165
@ Cached BytesBuiltins .AddNode addNode ,
167
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
168
- @ Cached GetNativeNullNode getNativeNullNode ) {
166
+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
169
167
try {
170
168
return addNode .execute (frame , original , newPart );
171
169
} catch (PException e ) {
172
170
transformExceptionToNativeNode .execute (e );
173
- return getNativeNullNode . execute ();
171
+ return getContext (). getNativeNull ();
174
172
}
175
173
}
176
174
177
175
@ Specialization (guards = {"!isPBytes(original)" , "isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
178
176
public Object concatNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
179
177
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
180
178
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
181
- @ Cached GetNativeNullNode getNativeNullNode ,
182
179
@ Cached PRaiseNativeNode raiseNativeNode ) {
183
- return raiseNativeNode .raise (frame , getNativeNullNode . execute (), PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
180
+ return raiseNativeNode .raise (frame , getContext (). getNativeNull (), PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
184
181
}
185
182
186
183
@ Specialization (guards = {"!isPBytes(original)" , "!isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
187
184
public Object concat (VirtualFrame frame , Object original , @ SuppressWarnings ("unused" ) Object newPart ,
188
185
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
189
186
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
190
187
@ Cached StrNode strNode ,
191
- @ Cached GetNativeNullNode getNativeNullNode ,
192
188
@ Cached PRaiseNativeNode raiseNativeNode ) {
193
- return raiseNativeNode .raise (frame , getNativeNullNode . execute (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , original ), original );
189
+ return raiseNativeNode .raise (frame , getContext (). getNativeNull (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , original ), original );
194
190
}
195
191
196
192
protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -204,33 +200,30 @@ public abstract static class PyBytesJoinNode extends PythonBinaryBuiltinNode {
204
200
@ Specialization
205
201
public Object join (VirtualFrame frame , PBytes original , Object newPart ,
206
202
@ Cached BytesBuiltins .JoinNode joinNode ,
207
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
208
- @ Cached GetNativeNullNode getNativeNullNode ) {
203
+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
209
204
try {
210
205
return joinNode .execute (frame , original , newPart );
211
206
} catch (PException e ) {
212
207
transformExceptionToNativeNode .execute (e );
213
- return getNativeNullNode . execute ();
208
+ return getContext (). getNativeNull ();
214
209
}
215
210
}
216
211
217
212
@ Specialization (guards = {"!isPBytes(original)" , "isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
218
213
public Object joinNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
219
214
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
220
215
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
221
- @ Cached PRaiseNativeNode raiseNativeNode ,
222
- @ Cached GetNativeNullNode getNativeNullNode ) {
223
- return raiseNativeNode .raise (frame , getNativeNullNode .execute (), PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
216
+ @ Cached PRaiseNativeNode raiseNativeNode ) {
217
+ return raiseNativeNode .raise (frame , getContext ().getNativeNull (), PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
224
218
}
225
219
226
220
@ Specialization (guards = {"!isPBytes(original)" , "!isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
227
221
public Object join (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
228
222
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
229
223
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
230
224
@ Cached StrNode strNode ,
231
- @ Cached PRaiseNativeNode raiseNativeNode ,
232
- @ Cached GetNativeNullNode getNativeNullNode ) {
233
- return raiseNativeNode .raise (frame , getNativeNullNode .execute (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , original ), original );
225
+ @ Cached PRaiseNativeNode raiseNativeNode ) {
226
+ return raiseNativeNode .raise (frame , getContext ().getNativeNull (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , original ), original );
234
227
}
235
228
236
229
protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -245,14 +238,13 @@ public abstract static class PyBytesFromFormatNode extends PythonBinaryBuiltinNo
245
238
public Object fromFormat (VirtualFrame frame , String fmt , Object args ,
246
239
@ Cached ModNode modeNode ,
247
240
@ Cached EncodeNode encodeNode ,
248
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
249
- @ Cached GetNativeNullNode getNativeNullNode ) {
241
+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
250
242
try {
251
243
Object formated = modeNode .execute (frame , fmt , args );
252
244
return encodeNode .execute (frame , formated , PNone .NONE , PNone .NONE );
253
245
} catch (PException e ) {
254
246
transformExceptionToNativeNode .execute (e );
255
- return getNativeNullNode . execute ();
247
+ return getContext (). getNativeNull ();
256
248
}
257
249
}
258
250
}
@@ -273,13 +265,12 @@ public Object fromObject(VirtualFrame frame, Object obj,
273
265
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
274
266
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
275
267
@ SuppressWarnings ("unused" ) @ Cached PyObjectLookupAttr lookupAttrNode ,
276
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
277
- @ Cached GetNativeNullNode getNativeNullNode ) {
268
+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
278
269
try {
279
270
return bytesNode .execute (frame , PythonBuiltinClassType .PBytes , obj , PNone .NO_VALUE , PNone .NO_VALUE );
280
271
} catch (PException e ) {
281
272
transformExceptionToNativeNode .execute (e );
282
- return getNativeNullNode . execute ();
273
+ return getContext (). getNativeNull ();
283
274
}
284
275
}
285
276
@@ -288,9 +279,8 @@ public Object fromObject(VirtualFrame frame, Object obj,
288
279
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
289
280
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
290
281
@ SuppressWarnings ("unused" ) @ Cached PyObjectLookupAttr lookupAttrNode ,
291
- @ Cached PRaiseNativeNode raiseNativeNode ,
292
- @ Cached GetNativeNullNode getNativeNullNode ) {
293
- return raiseNativeNode .raise (frame , getNativeNullNode .execute (), TypeError , CANNOT_CONVERT_P_OBJ_TO_S , obj , "bytes" );
282
+ @ Cached PRaiseNativeNode raiseNativeNode ) {
283
+ return raiseNativeNode .raise (frame , getContext ().getNativeNull (), TypeError , CANNOT_CONVERT_P_OBJ_TO_S , obj , "bytes" );
294
284
}
295
285
296
286
protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -306,7 +296,7 @@ protected boolean isAcceptedSubtype(VirtualFrame frame, Object obj, GetClassNode
306
296
}
307
297
}
308
298
309
- @ Builtin (name = "PyBytes_FromStringAndSize" , minNumOfPositionalArgs = 3 , declaresExplicitSelf = true )
299
+ @ Builtin (name = "PyBytes_FromStringAndSize" , minNumOfPositionalArgs = 2 )
310
300
@ GenerateNodeFactory
311
301
@ ImportStatic (CApiGuards .class )
312
302
abstract static class PyBytes_FromStringAndSize extends NativeBuiltin {
@@ -317,7 +307,7 @@ abstract static class PyBytes_FromStringAndSize extends NativeBuiltin {
317
307
// PythonNativeObject)
318
308
319
309
@ Specialization
320
- Object doGeneric (VirtualFrame frame , @ SuppressWarnings ( "unused" ) Object module , PythonNativeWrapper object , long size ,
310
+ Object doGeneric (VirtualFrame frame , PythonNativeWrapper object , long size ,
321
311
@ Cached AsPythonObjectNode asPythonObjectNode ,
322
312
@ Exclusive @ Cached BytesNodes .ToBytesNode getByteArrayNode ,
323
313
@ Shared ("toSulongNode" ) @ Cached CExtNodes .ToSulongNode toSulongNode ) {
@@ -333,16 +323,15 @@ Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object module,
333
323
}
334
324
335
325
@ Specialization (guards = "!isNativeWrapper(nativePointer)" )
336
- Object doNativePointer (VirtualFrame frame , Object module , Object nativePointer , long size ,
337
- @ Exclusive @ Cached GetNativeNullNode getNativeNullNode ,
326
+ Object doNativePointer (VirtualFrame frame , Object nativePointer , long size ,
338
327
@ Exclusive @ Cached GetByteArrayNode getByteArrayNode ,
339
328
@ Shared ("toSulongNode" ) @ Cached CExtNodes .ToSulongNode toSulongNode ) {
340
329
try {
341
330
return toSulongNode .execute (factory ().createBytes (getByteArrayNode .execute (nativePointer , size )));
342
331
} catch (InteropException e ) {
343
- return raiseNative (frame , getNativeNullNode . execute ( module ), PythonErrorType .TypeError , "%m" , e );
332
+ return raiseNative (frame , getContext (). getNativeNull ( ), PythonErrorType .TypeError , "%m" , e );
344
333
} catch (OverflowException e ) {
345
- return raiseNative (frame , getNativeNullNode . execute ( module ), PythonErrorType .SystemError , "negative size passed" );
334
+ return raiseNative (frame , getContext (). getNativeNull ( ), PythonErrorType .SystemError , "negative size passed" );
346
335
}
347
336
}
348
337
}
0 commit comments