(self, address)
Retrieve data from data memory: array space
Retrieve data from data memory: array space
Retrieve data from data memory : array space
def get_memory(self, address):
        """Retrieve data from data memory: array space """
        name_addr = -1
        arr_addr = -1
        the_arr = None
        for name in self._array_memory:
            name_try, arr_try = self._array_memory[name]
            if name_try <= address and name_try > name_addr:
                name_addr, arr_addr = name_try, arr_try
                the_arr = name
        if the_arr is None:
            return -1
        var_current = self._memory.var_current()
        if address >= var_current + arr_addr:
            offset = address - arr_addr - var_current
            if offset >= self.array_size_bytes(the_arr):
                return -1
            byte_array = self._buffers[the_arr]
            return byte_array[offset]
        else:
            offset = address - name_addr - var_current
            if offset < max(3, len(the_arr))+1:
                return get_name_in_memory(the_arr, offset)
            else:
                offset -= max(3, len(the_arr))+1
                dimensions = self._dims[the_arr]
                data_rep = struct.pack(
                    '<HB',
                    self.array_size_bytes(the_arr) + 1 + 2*len(dimensions),
                    len(dimensions)
                )
                for d in dimensions:
                    data_rep += struct.pack('<H', d + 1 - self._base)
                return data_rep[offset]
def get_memory ( self , address ) : name_addr = - 1 arr_addr = - 1 the_arr = None for name in self . _array_memory : name_try , arr_try = self . _array_memory [ name ] if name_try <= address and name_try > name_addr : name_addr , arr_addr = name_try , arr_try the_arr = name if the_arr is None : return - 1 var_current = self . _memory . var_current ( ) if address >= var_current + arr_addr : offset = address - arr_addr - var_current if offset >= self . array_size_bytes ( the_arr ) : return - 1 byte_array = self . _buffers [ the_arr ] return byte_array [ offset ] else : offset = address - name_addr - var_current if offset < max ( 3 , len ( the_arr ) ) + 1 : return get_name_in_memory ( the_arr , offset ) else : offset -= max ( 3 , len ( the_arr ) ) + 1 dimensions = self . _dims [ the_arr ] data_rep = struct . pack ( '<HB' , self . array_size_bytes ( the_arr ) + 1 + 2 * len ( dimensions ) , len ( dimensions ) ) for d in dimensions : data_rep += struct . pack ( '<H' , d + 1 - self . _base ) return data_rep [ offset ]