From c618d5daa8a7c0255c027b2c9af5dbc19bef5dae Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 8 Dec 2023 19:38:29 +0800 Subject: [PATCH] core: add ConstGeneric --- artiq/language/core.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/artiq/language/core.py b/artiq/language/core.py index bcf4a7f8b..00cbae3a3 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -12,7 +12,7 @@ from artiq.language import import_cache __all__ = [ - "Kernel", "KernelInvariant", "virtual", + "Kernel", "KernelInvariant", "virtual", "ConstGeneric", "round64", "floor64", "ceil64", "extern", "kernel", "portable", "nac3", "rpc", "print_rpc", @@ -35,6 +35,12 @@ class KernelInvariant(Generic[T]): class virtual(Generic[T]): pass +class _ConstGenericMarker: + pass + +def ConstGeneric(name, constraint): + return TypeVar(name, _ConstGenericMarker, constraint) + def round64(x): return round(x)