Skip to content

Commit d495080

Browse files
committed
Add link_name to hugr-py FuncDefn, update schema
1 parent adc258a commit d495080

File tree

7 files changed

+63
-11
lines changed

7 files changed

+63
-11
lines changed

hugr-py/src/hugr/_serialization/ops.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ class FuncDefn(BaseOp):
7676

7777
name: str
7878
signature: PolyFuncType
79+
link_name: str | None
7980

8081
def deserialize(self) -> ops.FuncDefn:
8182
poly_func = self.signature.deserialize()
8283
return ops.FuncDefn(
83-
self.name, inputs=poly_func.body.input, _outputs=poly_func.body.output
84+
self.name,
85+
params=poly_func.params,
86+
inputs=poly_func.body.input,
87+
_outputs=poly_func.body.output,
88+
link_name=self.link_name,
8489
)
8590

8691

hugr-py/src/hugr/ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,14 +1037,16 @@ class FuncDefn(DfParentOp):
10371037
the function.
10381038
"""
10391039

1040-
#: function name
1040+
#: function name - internal only
10411041
f_name: str
10421042
#: input types of the function
10431043
inputs: tys.TypeRow
10441044
# ? type parameters of the function if polymorphic
10451045
params: list[tys.TypeParam] = field(default_factory=list)
10461046
_outputs: tys.TypeRow | None = field(default=None, repr=False)
10471047
num_out: int = field(default=1, repr=False)
1048+
#: name for linking
1049+
link_name: str | None = None
10481050

10491051
@property
10501052
def outputs(self) -> tys.TypeRow:
@@ -1071,6 +1073,7 @@ def _to_serial(self, parent: Node) -> sops.FuncDefn:
10711073
parent=parent.idx,
10721074
name=self.f_name,
10731075
signature=self.signature._to_serial(),
1076+
link_name=self.link_name,
10741077
)
10751078

10761079
def inner_signature(self) -> tys.FunctionType:

specification/schema/hugr_schema_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,24 @@
645645
},
646646
"signature": {
647647
"$ref": "#/$defs/PolyFuncType"
648+
},
649+
"link_name": {
650+
"anyOf": [
651+
{
652+
"type": "string"
653+
},
654+
{
655+
"type": "null"
656+
}
657+
],
658+
"title": "Link Name"
648659
}
649660
},
650661
"required": [
651662
"parent",
652663
"name",
653-
"signature"
664+
"signature",
665+
"link_name"
654666
],
655667
"title": "FuncDefn",
656668
"type": "object"

specification/schema/hugr_schema_strict_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,24 @@
645645
},
646646
"signature": {
647647
"$ref": "#/$defs/PolyFuncType"
648+
},
649+
"link_name": {
650+
"anyOf": [
651+
{
652+
"type": "string"
653+
},
654+
{
655+
"type": "null"
656+
}
657+
],
658+
"title": "Link Name"
648659
}
649660
},
650661
"required": [
651662
"parent",
652663
"name",
653-
"signature"
664+
"signature",
665+
"link_name"
654666
],
655667
"title": "FuncDefn",
656668
"type": "object"

specification/schema/testing_hugr_schema_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,24 @@
645645
},
646646
"signature": {
647647
"$ref": "#/$defs/PolyFuncType"
648+
},
649+
"link_name": {
650+
"anyOf": [
651+
{
652+
"type": "string"
653+
},
654+
{
655+
"type": "null"
656+
}
657+
],
658+
"title": "Link Name"
648659
}
649660
},
650661
"required": [
651662
"parent",
652663
"name",
653-
"signature"
664+
"signature",
665+
"link_name"
654666
],
655667
"title": "FuncDefn",
656668
"type": "object"

specification/schema/testing_hugr_schema_strict_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,24 @@
645645
},
646646
"signature": {
647647
"$ref": "#/$defs/PolyFuncType"
648+
},
649+
"link_name": {
650+
"anyOf": [
651+
{
652+
"type": "string"
653+
},
654+
{
655+
"type": "null"
656+
}
657+
],
658+
"title": "Link Name"
648659
}
649660
},
650661
"required": [
651662
"parent",
652663
"name",
653-
"signature"
664+
"signature",
665+
"link_name"
654666
],
655667
"title": "FuncDefn",
656668
"type": "object"

uv.lock

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)