The base instruction
class includes a field for the destination
operand, even though not all instructions use it. The dst_op
method returns the value of this operand. If an instruction does not
produce a result, the destination operand should always be a null
operand. Moreover, the destination may be null even if an instruction
does produce a result. In that case, the result value is computed and
then discarded.
If the destination operand is a variable, its type must be compatible with the result type of the instruction.
If the result of an instruction is a temporary value, the destination operand is a pointer to the instruction where the value is used. Note that this is different than an instruction pointer in a source operand. The source operands of an instruction point to the children in an expression tree, while the destination operand points to the parent instruction.
The set_dst
method may be used to set the destination operand for
an instruction. However, there are some important restrictions on using
this method:
set_dst
. This allows the library to ensure
that the destination will always be a null operand (3).
Trying to use set_dst
for one of these instructions will cause an
error.
set_dst
to overwrite it. This also
causes a run-time error. As in the previous case, this is to prevent
inconsistent pointers. Instead, you must first call the instruction's
remove
method to clear the destination operand. See section Source Operands.