Esempio n. 1
0
    def offset(self):
        """ If this is a constant access (e.g. A(1))
        return the offset in bytes from the beginning of the
        variable in memory.

        Otherwise, if it's not constant (e.g. A(i))
        returns None
        """
        offset = 0
        # Now we must typecast each argument to a u16 (POINTER) type
        # i is the dimension ith index, b is the bound
        for i, b in zip(self.arglist, self.entry.bounds):
            tmp = i.children[0]
            if is_number(tmp) or is_const(tmp):
                if offset is not None:
                    offset = offset * b.count + tmp.value
            else:
                offset = None
                break

        if offset is not None:
            offset = TYPE.size(gl.SIZE_TYPE) + TYPE.size(gl.BOUND_TYPE) * len(
                self.arglist) + offset * self.type_.size

        return offset
Esempio n. 2
0
 def memsize(self):
     """ Total array cell + indexes size
     """
     return 2 * TYPE.size(gl.PTR_TYPE)
Esempio n. 3
0
 def size(self):
     return self.count * self.type_.size if self.scope != SCOPE.parameter else TYPE.size(
         gl.PTR_TYPE)
Esempio n. 4
0
 def test_size(self):
     for type_ in TYPE.types:
         t = SymbolBASICTYPE(type_)
         self.assertEqual(t.size, TYPE.size(type_))
Esempio n. 5
0
 def test_memsize(self):
     arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
     self.assertEqual(arr.memsize, 2 * TYPE.size(gl.PTR_TYPE))
Esempio n. 6
0
 def memsize(self):
     """ Total array cell + indexes size
     """
     return (2 + (2 if self.lbound_used or self.ubound_used else 0)
             ) * TYPE.size(gl.PTR_TYPE)
Esempio n. 7
0
 def test_memsize(self):
     arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
     self.assertEqual(
         arr.memsize,
         arr.size + 1 + TYPE.size(gl.BOUND_TYPE) * len(arr.bounds))
Esempio n. 8
0
 def size(self):
     return TYPE.size(self.type_)
Esempio n. 9
0
 def memsize(self):
     """ Total array cell + indexes size
     """
     return self.size + 1 + TYPE.size(gl.BOUND_TYPE) * len(self.bounds)