parameters: (array_type)
return_statement: return ArrayStruct
docstring: Return the Structure representation of the given *array_type*
      (an instance of types.ArrayCompatible).
  
      Note this does not call __array_wrap__ in case a new array structure
      is being created (rather than populated).
docstring_summary: Return the Structure representation of the given *array_type*
      (an instance of types.ArrayCompatible).
docstring_tokens: Return the Structure representation of the given * array_type * ( an instance of types . ArrayCompatible ) .
function: def make_array(array_type):
      """
      Return the Structure representation of the given *array_type*
      (an instance of types.ArrayCompatible).
  
      Note this does not call __array_wrap__ in case a new array structure
      is being created (rather than populated).
      """
      real_array_type = array_type.as_array
      base = cgutils.create_struct_proxy(real_array_type)
      ndim = real_array_type.ndim
  
      class ArrayStruct(base):
  
          def _make_refs(self, ref):
              sig = signature(real_array_type, array_type)
              try:
                  array_impl = self._context.get_function('__array__', sig)
              except NotImplementedError:
                  return super(ArrayStruct, self)._make_refs(ref)
  
              # Return a wrapped structure and its unwrapped reference
              datamodel = self._context.data_model_manager[array_type]
              be_type = self._get_be_type(datamodel)
              if ref is None:
                  outer_ref = cgutils.alloca_once(self._builder, be_type,
                                                  zfill=True)
              else:
                  outer_ref = ref
              # NOTE: __array__ is called with a pointer and expects a pointer
              # in return!
              ref = array_impl(self._builder, (outer_ref,))
              return outer_ref, ref
  
          @property
          def shape(self):
              """
              Override .shape to inform LLVM that its elements are all positive.
              """
              builder = self._builder
              if ndim == 0:
                  return base.__getattr__(self, "shape")
  
              # Unfortunately, we can't use llvm.assume as its presence can
              # seriously pessimize performance,
              # *and* the range metadata currently isn't improving anything here,
              # see https://llvm.org/bugs/show_bug.cgi?id=23848 !
              ptr = self._get_ptr_by_name("shape")
              dims = []
              for i in range(ndim):
                  dimptr = cgutils.gep_inbounds(builder, ptr, 0, i)
                  load = builder.load(dimptr)
                  dims.append(load)
                  mark_positive(builder, load)
  
              return cgutils.pack_array(builder, dims)
  
      return ArrayStruct
function_tokens: def make_array ( array_type ) : real_array_type = array_type . as_array base = cgutils . create_struct_proxy ( real_array_type ) ndim = real_array_type . ndim class ArrayStruct ( base ) : def _make_refs ( self , ref ) : sig = signature ( real_array_type , array_type ) try : array_impl = self . _context . get_function ( '__array__' , sig ) except NotImplementedError : return super ( ArrayStruct , self ) . _make_refs ( ref ) # Return a wrapped structure and its unwrapped reference datamodel = self . _context . data_model_manager [ array_type ] be_type = self . _get_be_type ( datamodel ) if ref is None : outer_ref = cgutils . alloca_once ( self . _builder , be_type , zfill = True ) else : outer_ref = ref # NOTE: __array__ is called with a pointer and expects a pointer # in return! ref = array_impl ( self . _builder , ( outer_ref , ) ) return outer_ref , ref @ property def shape ( self ) : """
              Override .shape to inform LLVM that its elements are all positive.
              """ builder = self . _builder if ndim == 0 : return base . __getattr__ ( self , "shape" ) # Unfortunately, we can't use llvm.assume as its presence can # seriously pessimize performance, # *and* the range metadata currently isn't improving anything here, # see https://llvm.org/bugs/show_bug.cgi?id=23848 ! ptr = self . _get_ptr_by_name ( "shape" ) dims = [ ] for i in range ( ndim ) : dimptr = cgutils . gep_inbounds ( builder , ptr , 0 , i ) load = builder . load ( dimptr ) dims . append ( load ) mark_positive ( builder , load ) return cgutils . pack_array ( builder , dims ) return ArrayStruct