iqm.cpc.compiler.compiler.CompilationStage#

class iqm.cpc.compiler.compiler.CompilationStage(name)#

Bases: object

Sequence of compiler passes that are applied to the data.

The data and context are returned after all passes have been applied. A pass is a function that takes the data and context as arguments and returns the modified data and context. The context is a dictionary that can contain any information that needs to be passed between the passes.

Methods

add_passes(*pass_functions)

Add multiple passes to the stage.

ready()

Check if the stage is ready to run.

run(data, context)

Run all the passes in the stage on the data and context.

Parameters:

name (str) –

ready()#

Check if the stage is ready to run. A stage is ready if it has at least one pass defined.

Return type:

bool

add_passes(*pass_functions)#

Add multiple passes to the stage.

Parameters:

pass_functions (Callable[[Any, dict[str, Any]], tuple[Any, dict[str, Any]]]) – One or more pass functions to be added to the stage.

Return type:

None

run(data, context)#

Run all the passes in the stage on the data and context. The data and context are returned after all passes have been applied.

Parameters:
  • data (Any) – The data to be processed.

  • context (dict[str, Any]) – A dictionary containing any additional information that needs to be passed between the passes.

Returns:

The processed data and context.

Return type:

tuple[Any, dict[str, Any]]