parameters: (self)
return_statement: return fn
docstring: Define the destructor if not already defined
docstring_summary: Define the destructor if not already defined
docstring_tokens: Define the destructor if not already defined
function: def define_dtor(self):
          "Define the destructor if not already defined"
          context = self._context
          builder = self._builder
          mod = builder.module
          # Declare dtor
          fnty = ir.FunctionType(ir.VoidType(), [cgutils.voidptr_t])
          fn = mod.get_or_insert_function(fnty, name='.dtor.list.{}'.format(self.dtype))
          if not fn.is_declaration:
              # End early if the dtor is already defined
              return fn
          fn.linkage = 'linkonce_odr'
          # Populate the dtor
          builder = ir.IRBuilder(fn.append_basic_block())
          base_ptr = fn.args[0]  # void*
  
          # get payload
          payload = ListPayloadAccessor(context, builder, self._ty, base_ptr)
  
          # Loop over all data to decref
          intp = payload.size.type
          with cgutils.for_range_slice(
                  builder, start=intp(0), stop=payload.size, step=intp(1),
                  intp=intp) as (idx, _):
              val = payload.getitem(idx)
              context.nrt.decref(builder, self.dtype, val)
          builder.ret_void()
          return fn
function_tokens: def define_dtor ( self ) : context = self . _context builder = self . _builder mod = builder . module # Declare dtor fnty = ir . FunctionType ( ir . VoidType ( ) , [ cgutils . voidptr_t ] ) fn = mod . get_or_insert_function ( fnty , name = '.dtor.list.{}' . format ( self . dtype ) ) if not fn . is_declaration : # End early if the dtor is already defined return fn fn . linkage = 'linkonce_odr' # Populate the dtor builder = ir . IRBuilder ( fn . append_basic_block ( ) ) base_ptr = fn . args [ 0 ] # void* # get payload payload = ListPayloadAccessor ( context , builder , self . _ty , base_ptr ) # Loop over all data to decref intp = payload . size . type with cgutils . for_range_slice ( builder , start = intp ( 0 ) , stop = payload . size , step = intp ( 1 ) , intp = intp ) as ( idx , _ ) : val = payload . getitem ( idx ) context . nrt . decref ( builder , self . dtype , val ) builder . ret_void ( ) return fn