pyGHDL.libghdl.utils

Generators and helpers on top of the raw libghdl bindings.

Iterating a chain, a list or an flist, and resolving the leftmost source location of a node, are needed everywhere and are ugly against the raw API, so they live here.

Functions


Functions

pyGHDL.libghdl.utils.name_image(Id)[source]

Lookup a Id and return its string.

Return type:

str

Returns:

The identifier’s text.

Parameters:

Id (NameId)

pyGHDL.libghdl.utils.fields_image(idx)[source]

String representation of fields idx.

Return type:

str

Returns:

The field’s name.

Parameters:

idx (int)

pyGHDL.libghdl.utils.kind_image(k)[source]

String representation of Iir_Kind k.

Return type:

str

Returns:

The node kind’s name.

Parameters:

k (int)

pyGHDL.libghdl.utils.types_image(t)[source]

String representation of types t.

Return type:

str

Returns:

The field type’s name.

Parameters:

t (int)

pyGHDL.libghdl.utils.attr_image(a)[source]

String representation of Attr a.

Return type:

str

Returns:

The attribute’s name.

Parameters:

a (int)

pyGHDL.libghdl.utils.leftest_location(n)[source]

Return the location of the leftmost token of a node.

A node’s own location is the token the parser considered characteristic, which for a subtype indication or a name is not the first one written. This walks left until there is nothing further.

Parameters:

n – The IIR node to locate.

Returns:

The location of the leftmost token, or No_Location if n is Null_Iir.

pyGHDL.libghdl.utils.fields_iter(n)[source]

Iterate on fields of node n.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the node’s fields.

pyGHDL.libghdl.utils.chain_iter(n)[source]

Iterate of a chain headed by node n.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the elements of the chain, in order.

pyGHDL.libghdl.utils.chain_to_list(n)[source]

Convert a chain headed by node n to a Python list.

Return type:

List[Any]

Returns:

The elements of the chain, in order.

pyGHDL.libghdl.utils.nodes_iter(n)[source]

Iterate all nodes of n, including n. Nodes are returned only once.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the node and all its sub-nodes.

pyGHDL.libghdl.utils.list_iter(lst)[source]

Iterate all elements of the Iir_List lst.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the elements of the list, in order.

pyGHDL.libghdl.utils.flist_iter(lst)[source]

Iterate all elements of the Iir_Flist lst.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the elements of the flist, in order.

pyGHDL.libghdl.utils.declarations_iter(n)[source]

Iterate all declarations in node n.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the declarations of the node.

pyGHDL.libghdl.utils.concurrent_stmts_iter(n)[source]

Iterate concurrent statements in node n.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the concurrent statements of the node.

pyGHDL.libghdl.utils.constructs_iter(n)[source]

Iterate library units, concurrent statements and declarations that appear directly within a declarative part.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the declarations and concurrent statements of the node.

pyGHDL.libghdl.utils.sequential_iter(n)[source]

Iterate sequential statements. The first node must be either a process or a subprogram body.

Return type:

Generator[Any, None, None]

Returns:

Generator yielding the sequential statements of the node.