Operand

An Operand is a qualifier to an instruction.   It might hold a numeric or string value, or a reference to some other CIL entity such as a Type, a FieldName, or a Local reference.   It is usually specified for use in the constructor for an Instruction.


Literal values need to have a size specified.

        enum OpSize { any, i8, u8, i16, u16, i32, u32, i64, u64, inative, r4, r8 };

An operand may be constructed either directly or through an Allocator object.   There are several constructors to create different types of Operands.

Constructor for a null operand

        Operand::Operand() ;

Constructor for an operand with a value that derives from Value, for example a Local or Param

        Operand::Operand(Value *V) :

Various constructors for integer values

        Operand::Operand(longlong Value, OpSize Size)
        Operand::Operand(int Value, OpSize Size)
        Operand::Operand(unsigned Value, OpSize Size)

Constructor for a floating point value.

        Operand::Operand(double Value, OpSize Size)

Constructor for a string value.  The operand is there purely to distinguish between this and the 'label' constructor.
 
        Operand(std::string Value, bool)

Constructor for a label.

        Operand(std::string Value)

Various getters to get operand values.

        OpType OperandType() const { return type_; }
        Value * GetValue() const { return type_ == t_value ? refValue_ : nullptr; }
        longlong IntValue() const { return intValue_; }
        std::string StringValue() const { return stringValue_; }
        double FloatValue() const { return floatValue_; }