[pypy-svn] r26574 - pypy/dist/pypy/rpython/rctypes

arigo at codespeak.net arigo at codespeak.net
Sat Apr 29 13:41:23 CEST 2006


Author: arigo
Date: Sat Apr 29 13:41:19 2006
New Revision: 26574

Modified:
   pypy/dist/pypy/rpython/rctypes/aarray.py
   pypy/dist/pypy/rpython/rctypes/achar_p.py
   pypy/dist/pypy/rpython/rctypes/aerrno.py
   pypy/dist/pypy/rpython/rctypes/afunc.py
   pypy/dist/pypy/rpython/rctypes/apointer.py
   pypy/dist/pypy/rpython/rctypes/aprimitive.py
   pypy/dist/pypy/rpython/rctypes/apyobject.py
   pypy/dist/pypy/rpython/rctypes/astringbuf.py
   pypy/dist/pypy/rpython/rctypes/astruct.py
   pypy/dist/pypy/rpython/rctypes/avoid_p.py
   pypy/dist/pypy/rpython/rctypes/rarray.py
   pypy/dist/pypy/rpython/rctypes/rchar_p.py
   pypy/dist/pypy/rpython/rctypes/rpointer.py
   pypy/dist/pypy/rpython/rctypes/rprimitive.py
   pypy/dist/pypy/rpython/rctypes/rpyobject.py
   pypy/dist/pypy/rpython/rctypes/rstringbuf.py
   pypy/dist/pypy/rpython/rctypes/rstruct.py
Log:
Sprinkle hop.exception_cannot_occur() in rctypes.


Modified: pypy/dist/pypy/rpython/rctypes/aarray.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/aarray.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/aarray.py	Sat Apr 29 13:41:19 2006
@@ -14,6 +14,7 @@
         from pypy.rpython.error import TyperError
         from pypy.rpython.rmodel import inputconst
         r_array = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_array.allocate_instance(hop.llops)
         if hop.nb_args > r_array.length:
             raise TyperError("too many arguments for an array of length %d" % (

Modified: pypy/dist/pypy/rpython/rctypes/achar_p.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/achar_p.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/achar_p.py	Sat Apr 29 13:41:19 2006
@@ -11,6 +11,7 @@
     def specialize_call(self, hop):
         string_repr = hop.rtyper.type_system.rstr.string_repr
         r_char_p = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_char_p.allocate_instance(hop.llops)
         if len(hop.args_s):
             v_value, = hop.inputargs(string_repr)

Modified: pypy/dist/pypy/rpython/rctypes/aerrno.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/aerrno.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/aerrno.py	Sat Apr 29 13:41:19 2006
@@ -30,6 +30,7 @@
 
     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
+        hop.exception_cannot_occur()
         return hop.llops.gencapicall('geterrno', [],
                                      resulttype = lltype.Signed,
                                      includes = (),

Modified: pypy/dist/pypy/rpython/rctypes/afunc.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/afunc.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/afunc.py	Sat Apr 29 13:41:19 2006
@@ -119,6 +119,7 @@
         #else:
         #   no 'includes': hack to trigger in GenC a PyErr_Occurred() check
 
+        hop.exception_cannot_occur()
         v_result = hop.llops.gencapicall(fnname, unwrapped_args_v,
                                          resulttype = RESTYPE,
                                          **kwds)

Modified: pypy/dist/pypy/rpython/rctypes/apointer.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/apointer.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/apointer.py	Sat Apr 29 13:41:19 2006
@@ -45,6 +45,7 @@
 
     def specialize_call(hop):
         r_ptr = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_ptr.allocate_instance(hop.llops)
         if len(hop.args_s):
             v_contentsbox, = hop.inputargs(r_ptr.r_contents)
@@ -70,4 +71,5 @@
 
     def specialize_call(self, hop):
         assert hop.s_result.is_constant()
+        hop.exception_cannot_occur()
         return hop.inputconst(lltype.Void, hop.s_result.const)

Modified: pypy/dist/pypy/rpython/rctypes/aprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/aprimitive.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/aprimitive.py	Sat Apr 29 13:41:19 2006
@@ -28,6 +28,7 @@
 
     def specialize_call(self, hop):
         r_primitive = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_primitive.allocate_instance(hop.llops)
         if len(hop.args_s):
             v_value, = hop.inputargs(r_primitive.ll_type)

Modified: pypy/dist/pypy/rpython/rctypes/apyobject.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/apyobject.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/apyobject.py	Sat Apr 29 13:41:19 2006
@@ -12,6 +12,7 @@
     def specialize_call(self, hop):
         from pypy.rpython.robject import pyobj_repr
         r_pyobject = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_pyobject.allocate_instance(hop.llops)
         if len(hop.args_s):
             [v_input] = hop.inputargs(pyobj_repr)

Modified: pypy/dist/pypy/rpython/rctypes/astringbuf.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/astringbuf.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/astringbuf.py	Sat Apr 29 13:41:19 2006
@@ -27,6 +27,7 @@
         from pypy.rpython.lltypesystem import lltype
         [v_length] = hop.inputargs(lltype.Signed)
         r_stringbuf = hop.r_result
+        hop.exception_cannot_occur()
         return hop.genop("malloc_varsize", [
             hop.inputconst(lltype.Void, r_stringbuf.lowleveltype.TO),
             v_length,
@@ -60,6 +61,7 @@
         from pypy.rpython.error import TyperError
         [s_arg] = hop.args_s
         [r_arg] = hop.args_r
+        hop.exception_cannot_occur()
         if isinstance(s_arg, SomeCTypesObject):
             if s_arg.knowntype is StringBufferType:
                 # sizeof(string_buffer) == len(string_buffer)

Modified: pypy/dist/pypy/rpython/rctypes/astruct.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/astruct.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/astruct.py	Sat Apr 29 13:41:19 2006
@@ -13,6 +13,7 @@
     def specialize_call(self, hop, **kwds_i):
         from pypy.rpython.error import TyperError
         r_struct = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_struct.allocate_instance(hop.llops)
         index_by_name = {}
         name_by_index = {}

Modified: pypy/dist/pypy/rpython/rctypes/avoid_p.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/avoid_p.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/avoid_p.py	Sat Apr 29 13:41:19 2006
@@ -14,6 +14,7 @@
 
     def specialize_call(self, hop):
         r_void_p = hop.r_result
+        hop.exception_cannot_occur()
         v_result = r_void_p.allocate_instance(hop.llops)
         return v_result
 
@@ -72,4 +73,5 @@
             # cast to pointer
             v_result = hop.genop('cast_adr_to_ptr', [v_adr],
                                  resulttype = hop.r_result.ll_type)
+        hop.exception_cannot_occur()
         return hop.r_result.return_value(hop.llops, v_result)

Modified: pypy/dist/pypy/rpython/rctypes/rarray.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rarray.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rarray.py	Sat Apr 29 13:41:19 2006
@@ -54,6 +54,7 @@
         assert s_attr.const == 'value'
         assert self.r_item.ll_type == lltype.Char  # .value: char arrays only
         v_box = hop.inputarg(self, 0)
+        hop.exception_cannot_occur()
         return hop.gendirectcall(ll_chararrayvalue, v_box)
 
     def get_c_data_of_item(self, llops, v_array, v_index):
@@ -103,6 +104,7 @@
 class __extend__(pairtype(ArrayRepr, IntegerRepr)):
     def rtype_getitem((r_array, r_int), hop):
         v_array, v_index = hop.inputargs(r_array, lltype.Signed)
+        hop.exception_cannot_occur()
         if isinstance(r_array.r_item, PrimitiveRepr):
             # primitive case (optimization; the below also works in this case)
             # NB. this optimization is invalid for PointerReprs!  See for
@@ -118,6 +120,7 @@
     def rtype_setitem((r_array, r_int), hop):
         v_array, v_index, v_item = hop.inputargs(r_array, lltype.Signed,
                                                  r_array.r_item)
+        hop.exception_cannot_occur()
         r_array.setitem(hop.llops, v_array, v_index, v_item)
 
 

Modified: pypy/dist/pypy/rpython/rctypes/rchar_p.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rchar_p.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rchar_p.py	Sat Apr 29 13:41:19 2006
@@ -45,6 +45,7 @@
         assert s_attr.is_constant()
         assert s_attr.const == 'value'
         v_char_p = hop.inputarg(self, 0)
+        hop.exception_cannot_occur()
         return self.getstring(hop.llops, v_char_p)
 
     def rtype_setattr(self, hop):

Modified: pypy/dist/pypy/rpython/rctypes/rpointer.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rpointer.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rpointer.py	Sat Apr 29 13:41:19 2006
@@ -57,6 +57,7 @@
         assert s_attr.const == 'contents'
         v_ptr = hop.inputarg(self, 0)
         v_c_ptr = self.getvalue(hop.llops, v_ptr)
+        hop.exception_cannot_occur()
         return self.r_contents.allocate_instance_ref(hop.llops, v_c_ptr)
 
     def rtype_setattr(self, hop):
@@ -74,6 +75,7 @@
         self = r_ptr
         v_ptr, v_index = hop.inputargs(self, lltype.Signed)
         v_c_ptr = self.getvalue(hop.llops, v_ptr)
+        hop.exception_cannot_occur()
         if isinstance(v_index, Constant) and v_index.value == 0:
             pass   # skip direct_ptradd
         else:
@@ -95,4 +97,5 @@
             # not supported by ctypes either
             raise TyperError("assignment to pointer[x] with x != 0")
         # copy the whole structure's content over
+        hop.exception_cannot_occur()
         genreccopy(hop.llops, v_new_c_data, v_target)

Modified: pypy/dist/pypy/rpython/rctypes/rprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rprimitive.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rprimitive.py	Sat Apr 29 13:41:19 2006
@@ -24,6 +24,7 @@
         assert s_attr.is_constant()
         assert s_attr.const == 'value'
         v_primitive = hop.inputarg(self, 0)
+        hop.exception_cannot_occur()
         return self.getvalue(hop.llops, v_primitive)
 
     def rtype_setattr(self, hop):

Modified: pypy/dist/pypy/rpython/rctypes/rpyobject.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rpyobject.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rpyobject.py	Sat Apr 29 13:41:19 2006
@@ -18,6 +18,7 @@
         assert s_attr.is_constant()
         assert s_attr.const == 'value'
         v_pyobj = hop.inputarg(self, 0)
+        hop.exception_cannot_occur()
         return self.getvalue(hop.llops, v_pyobj)
 
     def rtype_setattr(self, hop):

Modified: pypy/dist/pypy/rpython/rctypes/rstringbuf.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rstringbuf.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rstringbuf.py	Sat Apr 29 13:41:19 2006
@@ -20,6 +20,7 @@
         assert s_attr.is_constant()
         assert s_attr.const == 'value'
         v_box = hop.inputarg(self, 0)
+        hop.exception_cannot_occur()
         return hop.gendirectcall(ll_chararrayvalue, v_box)
 
     def get_c_data_of_item(self, llops, v_stringbuf, v_index):
@@ -41,6 +42,7 @@
     def rtype_getitem((r_stringbuf, r_int), hop):
         v_stringbuf, v_index = hop.inputargs(r_stringbuf, lltype.Signed)
         v_array = r_stringbuf.get_c_data(hop.llops, v_stringbuf)
+        hop.exception_cannot_occur()
         return hop.genop('getarrayitem', [v_array, v_index],
                          resulttype = lltype.Char)
 
@@ -49,6 +51,7 @@
                                                      lltype.Signed,
                                                      lltype.Char)
         v_array = r_stringbuf.get_c_data(hop.llops, v_stringbuf)
+        hop.exception_cannot_occur()
         hop.genop('setarrayitem', [v_array, v_index, v_item])
 
 class __extend__(pairtype(StringBufRepr, AbstractSliceRepr)):

Modified: pypy/dist/pypy/rpython/rctypes/rstruct.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rstruct.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rstruct.py	Sat Apr 29 13:41:19 2006
@@ -87,6 +87,7 @@
         name = s_attr.const
         r_field = self.r_fields[name]
         v_struct, v_attr = hop.inputargs(self, lltype.Void)
+        hop.exception_cannot_occur()
         if isinstance(r_field, PrimitiveRepr):
             # primitive case (optimization; the below also works in this case)
             # NB. this optimization is invalid for PointerReprs!  See for



More information about the Pypy-commit mailing list