From df383e13bb9ecaf9b8abd2099e6cf0d3f6b1474d Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Tue, 17 Sep 2024 10:24:30 +0100 Subject: [PATCH 1/2] Add Definition.compile (unused) This reverts commit 1377272dd2271a4be19f333542e0edd536d5f8f1. --- guppylang/definition/common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/guppylang/definition/common.py b/guppylang/definition/common.py index 14c11880..73e8278b 100644 --- a/guppylang/definition/common.py +++ b/guppylang/definition/common.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, ClassVar, TypeAlias from hugr.build.dfg import DefinitionBuilder, OpVar +from hugr.ext import Package if TYPE_CHECKING: from guppylang.checker.core import Globals @@ -72,6 +73,10 @@ def description(self) -> str: a function, but got {description of this definition} instead". """ + def compile(self) -> Package: + assert self.id.module is not None + return self.id.module.compile() + class ParsableDef(Definition): """Abstract base class for raw definitions that still require parsing. From 85fcddf41908c706e616aac83dbca3a5e23b440a Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Mon, 23 Sep 2024 16:56:24 +0100 Subject: [PATCH 2/2] use definition compilation in compile_gupy util --- tests/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/util.py b/tests/util.py index 8049f48b..3ada07b2 100644 --- a/tests/util.py +++ b/tests/util.py @@ -31,8 +31,8 @@ def compile_guppy(fn) -> Package: ), "`@compile_guppy` does not support extra arguments." module = GuppyModule("module") - guppylang.decorator.guppy(module)(fn) - return module.compile() + defn = guppylang.decorator.guppy(module)(fn) + return defn.compile() def dump_llvm(hugr: Hugr | Package):