Replace bool with b1, b8, b16, ...

The b1 type is an abstract boolean value. The others are concrete
representations.
This commit is contained in:
Jakob Stoklund Olesen
2016-04-01 15:32:00 -07:00
parent 4b265c2ee3
commit f72f47aece
4 changed files with 64 additions and 17 deletions

View File

@@ -95,6 +95,20 @@ class FloatType(ScalarType):
def __repr__(self):
return 'FloatType(bits={})'.format(self.bits)
class BoolType(ScalarType):
"""A concrete scalar boolean type."""
def __init__(self, bits):
assert bits > 0, 'BoolType must have positive number of bits'
super(BoolType, self).__init__(
name='b{:d}'.format(bits),
membytes=bits/8,
doc="A boolean type with {} bits.".format(bits))
self.bits = bits
def __repr__(self):
return 'BoolType(bits={})'.format(self.bits)
#
# Parametric polymorphism.
#