2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-26 03:38:25 +08:00

Add zero/one accessors to TBool, TInt, TFloat.

This commit is contained in:
whitequark 2015-07-16 16:03:24 +03:00
parent bcd1832203
commit f8e51e07d5

View File

@ -3,6 +3,7 @@ The :mod:`builtins` module contains the builtin Python
and ARTIQ types, such as int or float.
"""
from collections import OrderedDict
from . import types
# Types
@ -15,16 +16,40 @@ class TBool(types.TMono):
def __init__(self):
super().__init__("bool")
@staticmethod
def zero():
return False
@staticmethod
def one():
return True
class TInt(types.TMono):
def __init__(self, width=None):
if width is None:
width = types.TVar()
super().__init__("int", {"width": width})
@staticmethod
def zero():
return 0
@staticmethod
def one():
return 1
class TFloat(types.TMono):
def __init__(self):
super().__init__("float")
@staticmethod
def zero():
return 0.0
@staticmethod
def one():
return 1.0
class TList(types.TMono):
def __init__(self, elt=None):
if elt is None: