Skip to content

Commit cabd1bc

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

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

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

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

7676
name: str
7777
signature: PolyFuncType
78+
link_name: str | None
7879

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

8590

hugr-py/src/hugr/ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,14 +1142,16 @@ class FuncDefn(DfParentOp):
11421142
the function.
11431143
"""
11441144

1145-
#: function name
1145+
#: function name - internal only
11461146
f_name: str
11471147
#: input types of the function
11481148
inputs: tys.TypeRow
11491149
# ? type parameters of the function if polymorphic
11501150
params: list[tys.TypeParam] = field(default_factory=list)
11511151
_outputs: tys.TypeRow | None = field(default=None, repr=False)
11521152
num_out: int = field(default=1, repr=False)
1153+
#: name for linking
1154+
link_name: str | None = None
11531155

11541156
@property
11551157
def outputs(self) -> tys.TypeRow:
@@ -1176,6 +1178,7 @@ def _to_serial(self, parent: Node) -> sops.FuncDefn:
11761178
parent=parent.idx,
11771179
name=self.f_name,
11781180
signature=self.signature._to_serial(),
1181+
link_name=self.link_name,
11791182
)
11801183

11811184
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
@@ -706,12 +706,24 @@
706706
},
707707
"signature": {
708708
"$ref": "#/$defs/PolyFuncType"
709+
},
710+
"link_name": {
711+
"anyOf": [
712+
{
713+
"type": "string"
714+
},
715+
{
716+
"type": "null"
717+
}
718+
],
719+
"title": "Link Name"
709720
}
710721
},
711722
"required": [
712723
"parent",
713724
"name",
714-
"signature"
725+
"signature",
726+
"link_name"
715727
],
716728
"title": "FuncDefn",
717729
"type": "object"

specification/schema/hugr_schema_strict_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,24 @@
706706
},
707707
"signature": {
708708
"$ref": "#/$defs/PolyFuncType"
709+
},
710+
"link_name": {
711+
"anyOf": [
712+
{
713+
"type": "string"
714+
},
715+
{
716+
"type": "null"
717+
}
718+
],
719+
"title": "Link Name"
709720
}
710721
},
711722
"required": [
712723
"parent",
713724
"name",
714-
"signature"
725+
"signature",
726+
"link_name"
715727
],
716728
"title": "FuncDefn",
717729
"type": "object"

specification/schema/testing_hugr_schema_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,24 @@
706706
},
707707
"signature": {
708708
"$ref": "#/$defs/PolyFuncType"
709+
},
710+
"link_name": {
711+
"anyOf": [
712+
{
713+
"type": "string"
714+
},
715+
{
716+
"type": "null"
717+
}
718+
],
719+
"title": "Link Name"
709720
}
710721
},
711722
"required": [
712723
"parent",
713724
"name",
714-
"signature"
725+
"signature",
726+
"link_name"
715727
],
716728
"title": "FuncDefn",
717729
"type": "object"

specification/schema/testing_hugr_schema_strict_live.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,24 @@
706706
},
707707
"signature": {
708708
"$ref": "#/$defs/PolyFuncType"
709+
},
710+
"link_name": {
711+
"anyOf": [
712+
{
713+
"type": "string"
714+
},
715+
{
716+
"type": "null"
717+
}
718+
],
719+
"title": "Link Name"
709720
}
710721
},
711722
"required": [
712723
"parent",
713724
"name",
714-
"signature"
725+
"signature",
726+
"link_name"
715727
],
716728
"title": "FuncDefn",
717729
"type": "object"

0 commit comments

Comments
 (0)