Skip to content

Commit

Permalink
feat(py): Allow setting the width of IntVal constants
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Aug 12, 2024
1 parent 07ccb17 commit 9940a0a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hugr-py/src/hugr/std/int.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, ClassVar

from typing_extensions import Self
Expand Down Expand Up @@ -73,9 +73,10 @@ class IntVal(val.ExtensionValue):
"""Custom value for an integer."""

v: int
width: int = field(default=5)

def to_value(self) -> val.Extension:
return val.Extension("int", INT_T, self.v)
return val.Extension("int", int_t(self.width), self.v)


OPS_EXTENSION: tys.ExtensionId = "arithmetic.int"
Expand Down

0 comments on commit 9940a0a

Please sign in to comment.