Skip to content

Consistent management of "operations" in InstructionBlock

We should think about encapsulating the "operations" of an InstructionBlock in another object. An InstructionBlock is basically a collection of "Instructions". So we might work with a class Instruction. The class MPI_Call should inherit from the Instruction class.

The main reason for that is that we do not run in the following problem of overloading the functions of InstructionBlock with different types, e.g.

block.register_operation(mpi_call) <- Type is MPI_Call
block.register_operation("printf(...)") <- Type is string

It would be better to have both as Instruction. This class could also have the method set_has_error to have a unified method that we can use to set the markers. To avoid the overhead of always writing something like block.register_operation(Instruction(...)) for simple statements, we could define additional wrapper functions such as block.register_string_operation("printf(...)").

And with that change we could also rename register_operation to register_instruction etc. to have that consistent. 🙂

Edited by Simon Schwitanski