6262import com .oracle .graal .python .builtins .objects .cext .capi .CApiGuards ;
6363import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes ;
6464import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .AsPythonObjectNode ;
65- import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .GetNativeNullNode ;
6665import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .PRaiseNativeNode ;
6766import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .TransformExceptionToNativeNode ;
6867import com .oracle .graal .python .builtins .objects .cext .capi .PythonNativeWrapper ;
@@ -164,33 +163,30 @@ public abstract static class PyBytesConcatNode extends PythonBinaryBuiltinNode {
164163 @ Specialization
165164 public Object concat (VirtualFrame frame , PBytes original , Object newPart ,
166165 @ Cached BytesBuiltins .AddNode addNode ,
167- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
168- @ Cached GetNativeNullNode getNativeNullNode ) {
166+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
169167 try {
170168 return addNode .execute (frame , original , newPart );
171169 } catch (PException e ) {
172170 transformExceptionToNativeNode .execute (e );
173- return getNativeNullNode . execute ();
171+ return getContext (). getNativeNull ();
174172 }
175173 }
176174
177175 @ Specialization (guards = {"!isPBytes(original)" , "isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
178176 public Object concatNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
179177 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
180178 @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
181- @ Cached GetNativeNullNode getNativeNullNode ,
182179 @ 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" );
184181 }
185182
186183 @ Specialization (guards = {"!isPBytes(original)" , "!isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
187184 public Object concat (VirtualFrame frame , Object original , @ SuppressWarnings ("unused" ) Object newPart ,
188185 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
189186 @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
190187 @ Cached StrNode strNode ,
191- @ Cached GetNativeNullNode getNativeNullNode ,
192188 @ 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 );
194190 }
195191
196192 protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -204,33 +200,30 @@ public abstract static class PyBytesJoinNode extends PythonBinaryBuiltinNode {
204200 @ Specialization
205201 public Object join (VirtualFrame frame , PBytes original , Object newPart ,
206202 @ Cached BytesBuiltins .JoinNode joinNode ,
207- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
208- @ Cached GetNativeNullNode getNativeNullNode ) {
203+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
209204 try {
210205 return joinNode .execute (frame , original , newPart );
211206 } catch (PException e ) {
212207 transformExceptionToNativeNode .execute (e );
213- return getNativeNullNode . execute ();
208+ return getContext (). getNativeNull ();
214209 }
215210 }
216211
217212 @ Specialization (guards = {"!isPBytes(original)" , "isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
218213 public Object joinNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
219214 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
220215 @ 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" );
224218 }
225219
226220 @ Specialization (guards = {"!isPBytes(original)" , "!isBytesSubtype(frame, original, getClassNode, isSubtypeNode)" })
227221 public Object join (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object original , @ SuppressWarnings ("unused" ) Object newPart ,
228222 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
229223 @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
230224 @ 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 );
234227 }
235228
236229 protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -245,14 +238,13 @@ public abstract static class PyBytesFromFormatNode extends PythonBinaryBuiltinNo
245238 public Object fromFormat (VirtualFrame frame , String fmt , Object args ,
246239 @ Cached ModNode modeNode ,
247240 @ Cached EncodeNode encodeNode ,
248- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
249- @ Cached GetNativeNullNode getNativeNullNode ) {
241+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
250242 try {
251243 Object formated = modeNode .execute (frame , fmt , args );
252244 return encodeNode .execute (frame , formated , PNone .NONE , PNone .NONE );
253245 } catch (PException e ) {
254246 transformExceptionToNativeNode .execute (e );
255- return getNativeNullNode . execute ();
247+ return getContext (). getNativeNull ();
256248 }
257249 }
258250 }
@@ -273,13 +265,12 @@ public Object fromObject(VirtualFrame frame, Object obj,
273265 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
274266 @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
275267 @ SuppressWarnings ("unused" ) @ Cached PyObjectLookupAttr lookupAttrNode ,
276- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
277- @ Cached GetNativeNullNode getNativeNullNode ) {
268+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
278269 try {
279270 return bytesNode .execute (frame , PythonBuiltinClassType .PBytes , obj , PNone .NO_VALUE , PNone .NO_VALUE );
280271 } catch (PException e ) {
281272 transformExceptionToNativeNode .execute (e );
282- return getNativeNullNode . execute ();
273+ return getContext (). getNativeNull ();
283274 }
284275 }
285276
@@ -288,9 +279,8 @@ public Object fromObject(VirtualFrame frame, Object obj,
288279 @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
289280 @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
290281 @ 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" );
294284 }
295285
296286 protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -306,7 +296,7 @@ protected boolean isAcceptedSubtype(VirtualFrame frame, Object obj, GetClassNode
306296 }
307297 }
308298
309- @ Builtin (name = "PyBytes_FromStringAndSize" , minNumOfPositionalArgs = 3 , declaresExplicitSelf = true )
299+ @ Builtin (name = "PyBytes_FromStringAndSize" , minNumOfPositionalArgs = 2 )
310300 @ GenerateNodeFactory
311301 @ ImportStatic (CApiGuards .class )
312302 abstract static class PyBytes_FromStringAndSize extends NativeBuiltin {
@@ -317,7 +307,7 @@ abstract static class PyBytes_FromStringAndSize extends NativeBuiltin {
317307 // PythonNativeObject)
318308
319309 @ Specialization
320- Object doGeneric (VirtualFrame frame , @ SuppressWarnings ( "unused" ) Object module , PythonNativeWrapper object , long size ,
310+ Object doGeneric (VirtualFrame frame , PythonNativeWrapper object , long size ,
321311 @ Cached AsPythonObjectNode asPythonObjectNode ,
322312 @ Exclusive @ Cached BytesNodes .ToBytesNode getByteArrayNode ,
323313 @ Shared ("toSulongNode" ) @ Cached CExtNodes .ToSulongNode toSulongNode ) {
@@ -333,16 +323,15 @@ Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object module,
333323 }
334324
335325 @ 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 ,
338327 @ Exclusive @ Cached GetByteArrayNode getByteArrayNode ,
339328 @ Shared ("toSulongNode" ) @ Cached CExtNodes .ToSulongNode toSulongNode ) {
340329 try {
341330 return toSulongNode .execute (factory ().createBytes (getByteArrayNode .execute (nativePointer , size )));
342331 } catch (InteropException e ) {
343- return raiseNative (frame , getNativeNullNode . execute ( module ), PythonErrorType .TypeError , "%m" , e );
332+ return raiseNative (frame , getContext (). getNativeNull ( ), PythonErrorType .TypeError , "%m" , e );
344333 } 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" );
346335 }
347336 }
348337 }
0 commit comments