hdl.ast: allow typed int enums in Value.cast.
This commit is contained in:
parent
91d4513682
commit
58a0c68279
3 changed files with 31 additions and 4 deletions
|
|
@ -168,12 +168,12 @@ class Value(metaclass=ABCMeta):
|
|||
while True:
|
||||
if isinstance(obj, Value):
|
||||
return obj
|
||||
elif isinstance(obj, int):
|
||||
return Const(obj)
|
||||
elif isinstance(obj, Enum):
|
||||
return Const(obj.value, Shape.cast(type(obj)))
|
||||
elif isinstance(obj, ValueCastable):
|
||||
new_obj = obj.as_value()
|
||||
elif isinstance(obj, Enum):
|
||||
return Const(obj.value, Shape.cast(type(obj)))
|
||||
elif isinstance(obj, int):
|
||||
return Const(obj)
|
||||
else:
|
||||
raise TypeError("Object {!r} cannot be converted to an Amaranth value".format(obj))
|
||||
if new_obj is obj:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue