-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make FuncDecl/FuncDefn polymorphic (#692)
* Change FuncDecl and FuncDefn from storing FunctionType to PolyFuncType * Change `declare_function` and other builder methods to take PolyFuncType rather than Signature. The input-extensions of the Signature were only used for the FuncDefn node itself and it seems saner, and tests pass ok, for the builder to set the input-extensions of the FuncDefn node itself to pure==empty in all cases. Note this makes #695 slightly even more severe, but I feel we should just take this into account when fixing that bug. * Much of the bulk of the PR is thus changing (someFunctionType)`.pure()` to `.into()`... * Restructure validation. Break out the op-type specific checks that type args were declared, into a hierarchical traversal (rather than iterating over the Hugr's nodes), so they can gather binders from the nearest enclosing FuncDefn (potentially several levels above in the hierarchy). Move `validate_port` (and hence `validate_edge`) here because ports/edges inside a FuncDefn may have types using its parameters. * Also do not allow Static edges to refer to TVs declared outside. (The Static edge from a polymorphic FuncDefn contains a PolyFuncType i.e. declaring its own type vars, so they are not free.) * Update OpDef to properly check_args etc. reflecting that we may need to pass some args to the binary function and then more args to the *returned* PolyFuncType. * Also drop `impl TypeParametrised for OpDef` * Add TypeArgs to Call, and builder `fn call()`; also give the latter an ExtensionRegistry argument * Finally add `impl From<TypeBound> for TypeParam`, which we probably should have done much earlier.
- Loading branch information
Showing
27 changed files
with
372 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.