mirror of https://github.com/m-labs/artiq.git
Add zero/one accessors to TBool, TInt, TFloat.
This commit is contained in:
parent
bcd1832203
commit
f8e51e07d5
|
@ -3,6 +3,7 @@ The :mod:`builtins` module contains the builtin Python
|
||||||
and ARTIQ types, such as int or float.
|
and ARTIQ types, such as int or float.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from collections import OrderedDict
|
||||||
from . import types
|
from . import types
|
||||||
|
|
||||||
# Types
|
# Types
|
||||||
|
@ -15,16 +16,40 @@ class TBool(types.TMono):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("bool")
|
super().__init__("bool")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def zero():
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def one():
|
||||||
|
return True
|
||||||
|
|
||||||
class TInt(types.TMono):
|
class TInt(types.TMono):
|
||||||
def __init__(self, width=None):
|
def __init__(self, width=None):
|
||||||
if width is None:
|
if width is None:
|
||||||
width = types.TVar()
|
width = types.TVar()
|
||||||
super().__init__("int", {"width": width})
|
super().__init__("int", {"width": width})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def zero():
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def one():
|
||||||
|
return 1
|
||||||
|
|
||||||
class TFloat(types.TMono):
|
class TFloat(types.TMono):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("float")
|
super().__init__("float")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def zero():
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def one():
|
||||||
|
return 1.0
|
||||||
|
|
||||||
class TList(types.TMono):
|
class TList(types.TMono):
|
||||||
def __init__(self, elt=None):
|
def __init__(self, elt=None):
|
||||||
if elt is None:
|
if elt is None:
|
||||||
|
|
Loading…
Reference in New Issue