GEGELATI
|
This abstract class is the base class for any instruction to be used in a Program. More...
#include <instruction.h>
Public Member Functions | |
virtual bool | isPrintable () const |
function saying if an Instruction can be printed in a C file during the code gen. More... | |
virtual const std::string & | getPrintTemplate () const |
This function return the printTemplate of the line of code used to represent the instruction. More... | |
virtual std::string | getPrintablePrimitiveOperandType (const uint64_t &opIdx) const |
Retrieve the primitive data type of the operand. More... | |
virtual | ~Instruction ()=default |
Default virtual destructor for polyphormism. | |
const std::vector< std::reference_wrapper< const std::type_info > > & | getOperandTypes () const |
Get the list of operand types needed by the Instruction. More... | |
unsigned int | getNbOperands () const |
Get the number of operands required to execute the Instruction. More... | |
virtual bool | checkOperandTypes (const std::vector< Data::UntypedSharedPtr > &arguments) const |
Check if a given vector contains elements whose types corresponds to the types of the Instruction operands. More... | |
virtual double | execute (const std::vector< Data::UntypedSharedPtr > &args) const =0 |
Execute the Instruction for the given arguments. More... | |
Protected Member Functions | |
Instruction (std::string printTemplate) | |
Protected constructor to force the class abstract nature. More... | |
Protected Attributes | |
std::string | printTemplate |
std::vector< std::reference_wrapper< const std::type_info > > | operandTypes |
List of the types of the operands needed to execute the instruction. | |
This abstract class is the base class for any instruction to be used in a Program.
An Instruction declares a list of operands it needs to be executed. This information will be used to fetch the required operands from any ProgramLine, and to ensure the compatibility of the type of the fetched operands with the instruction before executing it.
|
protected |
Protected constructor to force the class abstract nature.
The definition of this constructor initialize the string printTemplate with the format given as parameter.
[in] | printTemplate | of the line used to represent the instruction in the C files generated. |
|
virtual |
Check if a given vector contains elements whose types corresponds to the types of the Instruction operands.
[in] | arguments | a const list of shared pointers to any type of object. (not doable at compile time) |
Reimplemented in Instructions::LambdaInstruction< First, Rest >.
|
pure virtual |
Execute the Instruction for the given arguments.
Derived class should implement their own behavior for this method. In case of invalid arguments, for type or number or value reason, this method should always return 0.0.
[in] | args | the vector of UntypedSharedPtr passed to the Instruction. |
Implemented in Instructions::AddPrimitiveType< T >, Instructions::LambdaInstruction< First, Rest >, and Instructions::MultByConstant< T >.
unsigned int Instructions::Instruction::getNbOperands | ( | ) | const |
Get the number of operands required to execute the Instruction.
const std::vector< std::reference_wrapper< const std::type_info > > & Instruction::getOperandTypes | ( | ) | const |
Get the list of operand types needed by the Instruction.
|
virtual |
Retrieve the primitive data type of the operand.
[in] | opIdx | const uint64_t reference to the index of the operand of the instruction |
|
virtual |
This function return the printTemplate of the line of code used to represent the instruction.
|
virtual |
function saying if an Instruction can be printed in a C file during the code gen.
|
protected |
printTemplate of the instruction used to generate the code. The result of the function is represented with $0. The first parameter correspond to $1 the second to $2...