Replace bool with b1, b8, b16, ...
The b1 type is an abstract boolean value. The others are concrete representations.
This commit is contained in:
@@ -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.
|
||||
#
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
The cretonne.types module predefines all the Cretonne scalar types.
|
||||
"""
|
||||
|
||||
from . import ScalarType, IntType, FloatType
|
||||
from . import ScalarType, IntType, FloatType, BoolType
|
||||
|
||||
#: Boolean.
|
||||
bool = ScalarType('bool', 0,
|
||||
b1 = ScalarType('b1', 0,
|
||||
"""
|
||||
A boolean value that is either true or false.
|
||||
""")
|
||||
|
||||
b8 = BoolType(8) #: 8-bit bool.
|
||||
b16 = BoolType(16) #: 16-bit bool.
|
||||
b32 = BoolType(32) #: 32-bit bool.
|
||||
b64 = BoolType(64) #: 64-bit bool.
|
||||
|
||||
i8 = IntType(8) #: 8-bit int.
|
||||
i16 = IntType(16) #: 16-bit int.
|
||||
i32 = IntType(32) #: 32-bit int.
|
||||
|
||||
Reference in New Issue
Block a user