guppylang-internals 0.21.0__py3-none-any.whl → 0.21.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- guppylang_internals/__init__.py +1 -1
- guppylang_internals/checker/expr_checker.py +2 -0
- guppylang_internals/compiler/expr_compiler.py +2 -0
- guppylang_internals/decorator.py +30 -12
- guppylang_internals/dummy_decorator.py +5 -0
- {guppylang_internals-0.21.0.dist-info → guppylang_internals-0.21.1.dist-info}/METADATA +2 -2
- {guppylang_internals-0.21.0.dist-info → guppylang_internals-0.21.1.dist-info}/RECORD +9 -9
- {guppylang_internals-0.21.0.dist-info → guppylang_internals-0.21.1.dist-info}/WHEEL +0 -0
- {guppylang_internals-0.21.0.dist-info → guppylang_internals-0.21.1.dist-info}/licenses/LICENCE +0 -0
guppylang_internals/__init__.py
CHANGED
|
@@ -828,6 +828,8 @@ def python_value_to_hugr(v: Any, exp_ty: Type, ctx: CompilerContext) -> hv.Value
|
|
|
828
828
|
return hugr.std.collections.static_array.StaticArrayVal(
|
|
829
829
|
vs, elem_ty.to_hugr(ctx), name=f"static_pyarray.{next(tmp_vars)}"
|
|
830
830
|
)
|
|
831
|
+
case None:
|
|
832
|
+
return hugr.val.Unit
|
|
831
833
|
case _:
|
|
832
834
|
return None
|
|
833
835
|
return None
|
guppylang_internals/decorator.py
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
import inspect
|
|
3
|
-
from
|
|
4
|
-
from types import FrameType
|
|
5
|
-
from typing import ParamSpec, TypeVar
|
|
4
|
+
from typing import TYPE_CHECKING, ParamSpec, TypeVar
|
|
6
5
|
|
|
7
6
|
from hugr import ops
|
|
8
7
|
from hugr import tys as ht
|
|
9
8
|
|
|
10
|
-
from guppylang.defs import (
|
|
11
|
-
GuppyDefinition,
|
|
12
|
-
GuppyFunctionDefinition,
|
|
13
|
-
)
|
|
14
9
|
from guppylang_internals.compiler.core import (
|
|
15
10
|
CompilerContext,
|
|
16
11
|
GlobalConstId,
|
|
@@ -27,6 +22,7 @@ from guppylang_internals.definition.custom import (
|
|
|
27
22
|
)
|
|
28
23
|
from guppylang_internals.definition.ty import OpaqueTypeDef, TypeDef
|
|
29
24
|
from guppylang_internals.definition.wasm import RawWasmFunctionDef
|
|
25
|
+
from guppylang_internals.dummy_decorator import _dummy_custom_decorator, sphinx_running
|
|
30
26
|
from guppylang_internals.engine import DEF_STORE
|
|
31
27
|
from guppylang_internals.std._internal.checker import WasmCallChecker
|
|
32
28
|
from guppylang_internals.std._internal.compiler.wasm import (
|
|
@@ -34,12 +30,9 @@ from guppylang_internals.std._internal.compiler.wasm import (
|
|
|
34
30
|
WasmModuleDiscardCompiler,
|
|
35
31
|
WasmModuleInitCompiler,
|
|
36
32
|
)
|
|
37
|
-
from guppylang_internals.tys.arg import Argument
|
|
38
33
|
from guppylang_internals.tys.builtin import (
|
|
39
34
|
WasmModuleTypeDef,
|
|
40
35
|
)
|
|
41
|
-
from guppylang_internals.tys.param import Parameter
|
|
42
|
-
from guppylang_internals.tys.subst import Inst
|
|
43
36
|
from guppylang_internals.tys.ty import (
|
|
44
37
|
FuncInput,
|
|
45
38
|
FunctionType,
|
|
@@ -48,6 +41,16 @@ from guppylang_internals.tys.ty import (
|
|
|
48
41
|
NumericType,
|
|
49
42
|
)
|
|
50
43
|
|
|
44
|
+
if TYPE_CHECKING:
|
|
45
|
+
import builtins
|
|
46
|
+
from collections.abc import Callable, Sequence
|
|
47
|
+
from types import FrameType
|
|
48
|
+
|
|
49
|
+
from guppylang.defs import GuppyDefinition, GuppyFunctionDefinition
|
|
50
|
+
from guppylang_internals.tys.arg import Argument
|
|
51
|
+
from guppylang_internals.tys.param import Parameter
|
|
52
|
+
from guppylang_internals.tys.subst import Inst
|
|
53
|
+
|
|
51
54
|
T = TypeVar("T")
|
|
52
55
|
P = ParamSpec("P")
|
|
53
56
|
|
|
@@ -78,6 +81,7 @@ def custom_function(
|
|
|
78
81
|
that case, the function signature can be omitted if a custom call compiler is
|
|
79
82
|
provided.
|
|
80
83
|
"""
|
|
84
|
+
from guppylang.defs import GuppyFunctionDefinition
|
|
81
85
|
|
|
82
86
|
def dec(f: Callable[P, T]) -> GuppyFunctionDefinition[P, T]:
|
|
83
87
|
call_checker = checker or DefaultCallChecker()
|
|
@@ -119,6 +123,7 @@ def hugr_op(
|
|
|
119
123
|
|
|
120
124
|
def extend_type(defn: TypeDef) -> Callable[[type], type]:
|
|
121
125
|
"""Decorator to add new instance functions to a type."""
|
|
126
|
+
from guppylang.defs import GuppyDefinition
|
|
122
127
|
|
|
123
128
|
def dec(c: type) -> type:
|
|
124
129
|
for val in c.__dict__.values():
|
|
@@ -147,6 +152,8 @@ def custom_type(
|
|
|
147
152
|
For generic types, a callable may be passed that takes the type arguments of a
|
|
148
153
|
concrete instantiation.
|
|
149
154
|
"""
|
|
155
|
+
from guppylang.defs import GuppyDefinition
|
|
156
|
+
|
|
150
157
|
mk_hugr_ty = (
|
|
151
158
|
(lambda args, ctx: hugr_ty) if isinstance(hugr_ty, ht.Type) else hugr_ty
|
|
152
159
|
)
|
|
@@ -176,6 +183,8 @@ def custom_type(
|
|
|
176
183
|
def wasm_module(
|
|
177
184
|
filename: str, filehash: int
|
|
178
185
|
) -> Callable[[builtins.type[T]], GuppyDefinition]:
|
|
186
|
+
from guppylang.defs import GuppyDefinition
|
|
187
|
+
|
|
179
188
|
def dec(cls: builtins.type[T]) -> GuppyDefinition:
|
|
180
189
|
# N.B. Only one module per file and vice-versa
|
|
181
190
|
wasm_module = WasmModuleTypeDef(
|
|
@@ -229,6 +238,8 @@ def wasm_module(
|
|
|
229
238
|
|
|
230
239
|
|
|
231
240
|
def wasm(f: Callable[P, T]) -> GuppyFunctionDefinition[P, T]:
|
|
241
|
+
from guppylang.defs import GuppyFunctionDefinition
|
|
242
|
+
|
|
232
243
|
func = RawWasmFunctionDef(
|
|
233
244
|
DefId.fresh(),
|
|
234
245
|
f.__name__,
|
|
@@ -243,4 +254,11 @@ def wasm(f: Callable[P, T]) -> GuppyFunctionDefinition[P, T]:
|
|
|
243
254
|
return GuppyFunctionDefinition(func)
|
|
244
255
|
|
|
245
256
|
|
|
246
|
-
#
|
|
257
|
+
# Override decorators with dummy versions if we're running a sphinx build
|
|
258
|
+
if not TYPE_CHECKING and sphinx_running():
|
|
259
|
+
custom_function = _dummy_custom_decorator
|
|
260
|
+
hugr_op = _dummy_custom_decorator
|
|
261
|
+
extend_type = _dummy_custom_decorator
|
|
262
|
+
custom_type = _dummy_custom_decorator
|
|
263
|
+
wasm_module = _dummy_custom_decorator
|
|
264
|
+
wasm = _dummy_custom_decorator()
|
|
@@ -64,6 +64,11 @@ class _DummyGuppy:
|
|
|
64
64
|
return None
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
def _dummy_custom_decorator(*args: Any, **kwargs: Any) -> Any:
|
|
68
|
+
"""Dummy version of custom decorators that are used during Sphinx builds."""
|
|
69
|
+
return lambda f: f
|
|
70
|
+
|
|
71
|
+
|
|
67
72
|
def sphinx_running() -> bool:
|
|
68
73
|
"""Checks if guppylang was imported during a sphinx build."""
|
|
69
74
|
# This is the most general solution available at the moment.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: guppylang-internals
|
|
3
|
-
Version: 0.21.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.21.1
|
|
4
|
+
Summary: Compiler internals for `guppylang` package.
|
|
5
5
|
Author-email: Mark Koch <mark.koch@quantinuum.com>, TKET development team <tket-support@quantinuum.com>
|
|
6
6
|
Maintainer-email: Mark Koch <mark.koch@quantinuum.com>, TKET development team <tket-support@quantinuum.com>
|
|
7
7
|
License: Apache License
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
guppylang_internals/__init__.py,sha256=
|
|
1
|
+
guppylang_internals/__init__.py,sha256=itclzLi3ilVxnsjfxQmX3NQavLE3_ewrLWPM20dd-oM,130
|
|
2
2
|
guppylang_internals/ast_util.py,sha256=I-SdMwi5cgSQRSV1C1RsBXeU2ovLEvvUpTzpoRwrIeE,11799
|
|
3
|
-
guppylang_internals/decorator.py,sha256
|
|
3
|
+
guppylang_internals/decorator.py,sha256=-A3Xml0uvS4DJGd138ZjdP9aiK_orHCaJpF8IR0JSu8,8742
|
|
4
4
|
guppylang_internals/diagnostic.py,sha256=VCpIhyVD8KPtk0GDYMa8XH0lKVsRbsWNu_ucE2jQT2I,18395
|
|
5
|
-
guppylang_internals/dummy_decorator.py,sha256=
|
|
5
|
+
guppylang_internals/dummy_decorator.py,sha256=LXTXrdcrr55YzerX3qrHS23q6S9pVdpUAvhprWzKH6E,2330
|
|
6
6
|
guppylang_internals/engine.py,sha256=KM3iY2gz5RrtEB44AWuz8P16Gk-ItDuUpsG9cDMtFyg,10251
|
|
7
7
|
guppylang_internals/error.py,sha256=fjHsbglnH9GtcsLF4sSry7FTjrLoiyQ-L1JS3uGirx0,3393
|
|
8
8
|
guppylang_internals/experimental.py,sha256=ad3Ti6ncUdQA6MiXRyj45GvzlSx3Ww7PhrEpnrb79kI,2937
|
|
@@ -18,7 +18,7 @@ guppylang_internals/cfg/cfg.py,sha256=q2mYWVyzl0-CVlQWcpjphyBqmS5zuRw-CiS2esa3Xk
|
|
|
18
18
|
guppylang_internals/checker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
guppylang_internals/checker/cfg_checker.py,sha256=uye3h4zVV5056QOuUBS5MPrvh4wUbuNKV1LwETOStJk,14730
|
|
20
20
|
guppylang_internals/checker/core.py,sha256=5c2X8AHwSBGQdk2eMiplhQ5lnl78bxQA2mJm3MFUty0,17675
|
|
21
|
-
guppylang_internals/checker/expr_checker.py,sha256=
|
|
21
|
+
guppylang_internals/checker/expr_checker.py,sha256=m9tCxVFjlM2YheFI3wp09dktb7rRFn9Blf5qLjBq2ms,58751
|
|
22
22
|
guppylang_internals/checker/func_checker.py,sha256=zpYJ4vj6Xe0cmhF43ISV7rnRqGqel6jZQQfY8oFv9yU,10090
|
|
23
23
|
guppylang_internals/checker/linearity_checker.py,sha256=cHvJSqFKWpkLqO7uAwz7OBmxtAi8ZN_K7afMrspkXy4,34719
|
|
24
24
|
guppylang_internals/checker/stmt_checker.py,sha256=2wh7HNzCFwe9WjhV66XxWQ2wMJjze7L860o4aG_RU48,18123
|
|
@@ -31,7 +31,7 @@ guppylang_internals/checker/errors/wasm.py,sha256=tRpNhC8IZBkv6Nkn_dMRwGpDdZklv7
|
|
|
31
31
|
guppylang_internals/compiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
guppylang_internals/compiler/cfg_compiler.py,sha256=nGQmPYhXzicZ16_-8sgFC-sfLxMFEDSGd1Xf0j7LTK0,9039
|
|
33
33
|
guppylang_internals/compiler/core.py,sha256=5Xitt3L8xwd3XKR_nRCU9fzEVRM9O31t8wnJd56IqKs,25405
|
|
34
|
-
guppylang_internals/compiler/expr_compiler.py,sha256=
|
|
34
|
+
guppylang_internals/compiler/expr_compiler.py,sha256=KJyR22YjSz9ya3Ug_w4Esgnar3NOQ1zyLoWQR_e-s9E,41282
|
|
35
35
|
guppylang_internals/compiler/func_compiler.py,sha256=0bo28RNsFZDYmllle-yFUXKC0UJsLl2TVjr3gvDMJVA,3377
|
|
36
36
|
guppylang_internals/compiler/hugr_extension.py,sha256=eFUcxzBZoVzXV-AqEOJlh_rJkyuS3vFv1WKGOHjloJs,7966
|
|
37
37
|
guppylang_internals/compiler/qtm_platform_extension.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -92,7 +92,7 @@ guppylang_internals/tys/printing.py,sha256=F60SZsvqDRNMQSbgNDfBDt2pYQH2ueaZo7Obm
|
|
|
92
92
|
guppylang_internals/tys/subst.py,sha256=REFbw2POB6wGw-NBOZ4K4T6gE5FZe6nQ_VjcUmhOxCs,3430
|
|
93
93
|
guppylang_internals/tys/ty.py,sha256=ejvC8fg-BpaCf0Cs9sZIBjaKW2yQwapOG_KbThCkoKg,30973
|
|
94
94
|
guppylang_internals/tys/var.py,sha256=zACXv2IvGrqjDryC6lMyZpNnDb3SBRM2SlTOyq6WJdo,1173
|
|
95
|
-
guppylang_internals-0.21.
|
|
96
|
-
guppylang_internals-0.21.
|
|
97
|
-
guppylang_internals-0.21.
|
|
98
|
-
guppylang_internals-0.21.
|
|
95
|
+
guppylang_internals-0.21.1.dist-info/METADATA,sha256=ua-2taLysfoPW7pLTNiFXqIlL7OZKen079IamfYEh9M,14817
|
|
96
|
+
guppylang_internals-0.21.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
97
|
+
guppylang_internals-0.21.1.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
98
|
+
guppylang_internals-0.21.1.dist-info/RECORD,,
|
|
File without changes
|
{guppylang_internals-0.21.0.dist-info → guppylang_internals-0.21.1.dist-info}/licenses/LICENCE
RENAMED
|
File without changes
|