ModelImport

class hugr.model.load.ModelImport(module: Module)[source]

Bases: object

Helper to import a Hugr.

Methods

add_module_metadata

add_node

Add a model Node to the Hugr and record its in- and out-links.

enter_symbol

exit_symbol

import_block

import_cfg_region

Import an entire CFG region from the model into the Hugr.

import_dfg_region

Import an entire DFG region from the model into the Hugr.

import_node_in_dfg

Import a model Node within a DFG region.

import_node_in_module

Import a model Node at the Hugr Module level.

import_signature

import_type

Import the type from a model Term.

import_type_arg

Import a TypeArg from a model Term.

import_type_param

Import a TypeParam from a model Term.

import_type_row

import_value

link_ports

Add links to the Hugr according to the recorded data.

link_static_ports

lookup_var

record_in_links

Record a bunch of links entering the given Hugr Node with the given names.

record_out_links

Record a bunch of links exiting the given Hugr Node with the given names.

Attributes

local_vars

current_symbol

link_prefix

linked_ports

static_edges

module

symbols

fn_nodes

fn_calls

hugr

add_node(node: Node, operation: Op, parent: Node, num_outs: int | None = None) Node[source]

Add a model Node to the Hugr and record its in- and out-links.

import_cfg_region(region: Region, signature: FunctionType, parent: Node)[source]

Import an entire CFG region from the model into the Hugr.

import_dfg_region(region: Region, parent: Node)[source]

Import an entire DFG region from the model into the Hugr.

import_node_in_dfg(node: Node, parent: Node) Node[source]

Import a model Node within a DFG region.

Returns the Hugr Node corresponding to the model Node. The correspondence is almost 1-1, but a LoadConst model Node requires two Hugr Nodes (Const and LoadConst); in this case the LoadConst is returned.

import_node_in_module(node: Node, link_prefix: int) Node | None[source]

Import a model Node at the Hugr Module level.

import_type(term: Term) Type[source]

Import the type from a model Term.

import_type_arg(term: Term) TypeArg[source]

Import a TypeArg from a model Term.

import_type_param(term: Term, bound: TypeBound = TypeBound.Linear) TypeParam[source]

Import a TypeParam from a model Term.

Add links to the Hugr according to the recorded data.

Record a bunch of links entering the given Hugr Node with the given names.

Record a bunch of links exiting the given Hugr Node with the given names.