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:
parent
bcd1832203
commit
f8e51e07d5
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user