Skip to content

Commit

Permalink
Update serialization schema
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Mar 18, 2024
1 parent cfd58b2 commit 5fecc9c
Showing 1 changed file with 196 additions and 89 deletions.
285 changes: 196 additions & 89 deletions specification/schema/hugr_schema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,6 @@
"title": "Conditional",
"type": "object"
},
"Const": {
"description": "A constant value definition.",
"properties": {
"parent": {
"title": "Parent",
"type": "integer"
},
"input_extensions": {
"$ref": "#/$defs/InputExtensions"
},
"op": {
"const": "Const",
"default": "Const",
"title": "Op"
},
"value": {
"$ref": "#/$defs/Value"
},
"typ": {
"$ref": "#/$defs/Type"
}
},
"required": [
"parent",
"value",
"typ"
],
"title": "Const",
"type": "object"
},
"CustomOp": {
"description": "A user-defined operation that can be downcasted by the extensions that define it.",
"properties": {
Expand Down Expand Up @@ -417,28 +387,37 @@
"title": "ExitBlock",
"type": "object"
},
"ExtensionVal": {
"ExtensionConst": {
"description": "An extension constant value, that can check it is of a given [CustomType].",
"properties": {
"v": {
"parent": {
"title": "Parent",
"type": "integer"
},
"input_extensions": {
"$ref": "#/$defs/InputExtensions"
},
"op": {
"const": "Const",
"default": "Const",
"title": "Op"
},
"c": {
"const": "Extension",
"default": "Extension",
"title": "V"
"title": "ConstTag"
},
"c": {
"maxItems": 1,
"minItems": 1,
"prefixItems": [
{}
],
"title": "C",
"type": "array"
"e": {
"title": "CustomConst"
}
},
"required": [
"c"
"parent",
"op",
"c",
"e"
],
"title": "ExtensionVal",
"title": "ExtensionConst",
"type": "object"
},
"ExtensionsArg": {
Expand Down Expand Up @@ -522,6 +501,39 @@
"title": "FuncDefn",
"type": "object"
},
"FunctionConst": {
"description": "A higher-order function value.",
"properties": {
"parent": {
"title": "Parent",
"type": "integer"
},
"input_extensions": {
"$ref": "#/$defs/InputExtensions"
},
"op": {
"const": "Const",
"default": "Const",
"title": "Op"
},
"c": {
"const": "Function",
"default": "Function",
"title": "ConstTag"
},
"hugr": {
"title": "Hugr"
}
},
"required": [
"parent",
"op",
"c",
"hugr"
],
"title": "FunctionConst",
"type": "object"
},
"FunctionType": {
"description": "A graph encoded as a value. It contains a concrete signature and a set of required resources.",
"properties": {
Expand Down Expand Up @@ -554,24 +566,6 @@
"title": "FunctionType",
"type": "object"
},
"FunctionVal": {
"description": "A higher-order function value.",
"properties": {
"v": {
"const": "Function",
"default": "Function",
"title": "V"
},
"hugr": {
"title": "Hugr"
}
},
"required": [
"hugr"
],
"title": "FunctionVal",
"type": "object"
},
"GeneralSum": {
"description": "General sum type that explicitly stores the types of the variants.",
"properties": {
Expand Down Expand Up @@ -828,7 +822,31 @@
"CallIndirect": "#/$defs/CallIndirect",
"Case": "#/$defs/Case",
"Conditional": "#/$defs/Conditional",
"Const": "#/$defs/Const",
"Const": {
"discriminator": {
"mapping": {
"Extension": "#/$defs/ExtensionConst",
"Function": "#/$defs/FunctionConst",
"Sum": "#/$defs/Sum",
"Tuple": "#/$defs/Tuple"
},
"propertyName": "c"
},
"oneOf": [
{
"$ref": "#/$defs/ExtensionConst"
},
{
"$ref": "#/$defs/FunctionConst"
},
{
"$ref": "#/$defs/Tuple"
},
{
"$ref": "#/$defs/Sum"
}
]
},
"DFG": "#/$defs/DFG",
"DataflowBlock": "#/$defs/DataflowBlock",
"DummyOp": "#/$defs/DummyOp",
Expand Down Expand Up @@ -858,7 +876,29 @@
"$ref": "#/$defs/FuncDecl"
},
{
"$ref": "#/$defs/Const"
"discriminator": {
"mapping": {
"Extension": "#/$defs/ExtensionConst",
"Function": "#/$defs/FunctionConst",
"Sum": "#/$defs/Sum",
"Tuple": "#/$defs/Tuple"
},
"propertyName": "c"
},
"oneOf": [
{
"$ref": "#/$defs/ExtensionConst"
},
{
"$ref": "#/$defs/FunctionConst"
},
{
"$ref": "#/$defs/Tuple"
},
{
"$ref": "#/$defs/Sum"
}
]
},
{
"$ref": "#/$defs/DummyOp"
Expand Down Expand Up @@ -1062,22 +1102,68 @@
"Sum": {
"description": "A Sum variant For any Sum type where this value meets the type of the variant indicated by the tag.",
"properties": {
"v": {
"parent": {
"default": 0,
"title": "Parent",
"type": "integer"
},
"input_extensions": {
"$ref": "#/$defs/InputExtensions"
},
"op": {
"const": "Const",
"default": "Const",
"title": "Op"
},
"c": {
"const": "Sum",
"default": "Sum",
"title": "V"
"title": "ConstTag"
},
"tag": {
"title": "Tag",
"type": "integer"
},
"value": {
"$ref": "#/$defs/Value"
"typ": {
"$ref": "#/$defs/Type"
},
"vs": {
"items": {
"discriminator": {
"mapping": {
"Extension": "#/$defs/ExtensionConst",
"Function": "#/$defs/FunctionConst",
"Sum": "#/$defs/Sum",
"Tuple": "#/$defs/Tuple"
},
"propertyName": "c"
},
"oneOf": [
{
"$ref": "#/$defs/ExtensionConst"
},
{
"$ref": "#/$defs/FunctionConst"
},
{
"$ref": "#/$defs/Tuple"
},
{
"$ref": "#/$defs/Sum"
}
]
},
"title": "Vs",
"type": "array"
}
},
"required": [
"parent",
"op",
"c",
"tag",
"value"
"typ",
"vs"
],
"title": "Sum",
"type": "object"
Expand Down Expand Up @@ -1166,22 +1252,59 @@
"type": "object"
},
"Tuple": {
"description": "A tuple.",
"description": "A constant tuple value.",
"properties": {
"v": {
"parent": {
"title": "Parent",
"type": "integer"
},
"input_extensions": {
"$ref": "#/$defs/InputExtensions"
},
"op": {
"const": "Const",
"default": "Const",
"title": "Op"
},
"c": {
"const": "Tuple",
"default": "Tuple",
"title": "V"
"title": "ConstTag"
},
"vs": {
"items": {
"$ref": "#/$defs/Value"
"discriminator": {
"mapping": {
"Extension": "#/$defs/ExtensionConst",
"Function": "#/$defs/FunctionConst",
"Sum": "#/$defs/Sum",
"Tuple": "#/$defs/Tuple"
},
"propertyName": "c"
},
"oneOf": [
{
"$ref": "#/$defs/ExtensionConst"
},
{
"$ref": "#/$defs/FunctionConst"
},
{
"$ref": "#/$defs/Tuple"
},
{
"$ref": "#/$defs/Sum"
}
]
},
"title": "Vs",
"type": "array"
}
},
"required": [
"parent",
"op",
"c",
"vs"
],
"title": "Tuple",
Expand Down Expand Up @@ -1503,22 +1626,6 @@
"title": "UnpackTuple",
"type": "object"
},
"Value": {
"anyOf": [
{
"$ref": "#/$defs/ExtensionVal"
},
{
"$ref": "#/$defs/FunctionVal"
},
{
"$ref": "#/$defs/Tuple"
},
{
"$ref": "#/$defs/Sum"
}
]
},
"Variable": {
"description": "A type variable identified by a de Bruijn index.",
"properties": {
Expand Down Expand Up @@ -1615,4 +1722,4 @@
],
"title": "Hugr",
"type": "object"
}
}

0 comments on commit 5fecc9c

Please sign in to comment.