Creating a new type of IInstructionArgument

An instance of an instruction argument represents some type of argument to an operation in an instruction. Examples (already implemented) include features, ephemeral constants and read-write registers.

virtual T Value(const FitnessEnvironment& fe) const = 0

This method returns the value of this instruction, which may depend on the current values of some registers or the current fitness case (hence fe as a parameter).


virtual IInstructionArgument* Clone() const = 0

This method works as a virtualised copy constructor. Internally, implementations should just return appropriately cast results of calls to new.


virtual std::string ToString() const = 0

This method returns a string representation of this instruction argument.


ArgumentType and ArgumentIndex

These methods are coded for using enums defined in the file "baseSrc/IInstructionArgument.h". They are used in the IProgram::MarkIntrons method, which needs to have some semantic insight into the meaning of the instructions (as opposed to just blindly executing them).


static InstructionArgument* Generate(Config* conf) = 0;

This method works as a virtualised constructor. Internally, implementations should just return appropriately cast results of calls to new.



Christopher Fogelberg
fogelbchri@mcs.vuw.ac.nz or cgf.unimail@syntilect.com