res = 0
brlen = len(self.br)
for i, key in self.br.items():
+ log("asint", i, key, self.si[key])
bit = self.si[key].value
#log("asint", i, key, bit)
res |= bit << ((brlen-i-1) if msb0 else i)
return SelectableInt(self.value >> b.value, self.bits)
def __getitem__(self, key):
+ print ("SelectableInt.__getitem__", self, key, type(key))
+ assert type(key) != tuple # XXX error here
if isinstance(key, SelectableInt):
key = key.value
if isinstance(key, int):
start = self.bits - key.stop
bits = stop - start
- #log ("__getitem__ slice num bits", start, stop, bits)
+ log ("__getitem__ slice num bits", start, stop, bits)
mask = (1 << bits) - 1
value = (self.value >> start) & mask
log("getitem", stop, start, self.bits, hex(self.value), value)
if instance is None:
return self.__field
res = FieldSelectableInt(si=instance, br=self.__field)
+ print ("FieldProperty", res, type(res.br))
return res.asint(msb0=True)
class BitsProperty: