DefinitionBuilder¶
- class hugr.build.dfg.DefinitionBuilder(hugr: Hugr[OpVar])[source]¶
Bases:
Generic[OpVar]- Base class for builders that can define constants, and allow access
to the Module for declaring/defining functions and aliases.
As this class may be a root node, it does not extend ParentBuilder.
Methods
Add a static constant to the graph.
Allows access to the Module at the root of the Hugr (outside the scope of this builder, perhaps outside the entrypoint).
Attributes
Metadata associated with this builder's root node.
hugr- add_const(value: val.Value, parent: ToNode | None = None) Node[source]¶
Add a static constant to the graph.
- Parameters:
value – The constant value to add.
parent – The parent node of the constant. Defaults to the entrypoint node.
- Returns:
The node holding the
Constoperation.
Example
>>> dfg = Dfg() >>> const_n = dfg.add_const(val.TRUE) >>> dfg.hugr[const_n].op Const(TRUE)
- property metadata: NodeMetadata¶
Metadata associated with this builder’s root node.