/* * File: MOperand.h * Author: rick * * Created on November 19, 2008, 1:17 AM */ #ifndef _MOPERAND_H #define _MOPERAND_H #include #include "IOperand.h" #include "globals.h" #include #define NO_OFFSET INT_MIN using namespace std; // The type of an operand typedef enum __moperandtype { MT_UNKNOWN, // Unknown (yet) MT_INT, // Integer immediate MT_REAL, // Real immediate MT_LABEL, // Label name e.k.a. string MT_REGISTER, // Integer Register MT_ADDRESS, // Address operand MT_OFFSET // Register + offset address } MOperandType; /* Do not use virtuals, just one mapping will do */ class MOperand { public: // Constructor/destructor MOperand(MOperandType mtype, int value); MOperand(MOperandType mtype, float value); MOperand(MOperandType mtype, MRegisterType value); MOperand(MOperandType mtype, string newLabel); MOperand(MOperandType mtype, MRegisterType reg, int offset); ~MOperand(); // Set operand type handling void SetOperandType(MOperandType type); MOperandType GetOperandType() const; // constant value based int GetIntValue() const; void SetIntValue(int value); float GetRealValue() const; void SetRealValue(float value); // register entries void SetRegisterNumber(int value); int GetRegisterNumber() const; void SetRegisterType(MRegisterType value); MRegisterType GetRegisterType() const; void SetOffset(int value); int GetOffset() const; void SetAddress(int value); void SetAddress(MRegisterType value); int GetAddress() const; void SetLabel(string newLabel); string GetLabel() const; // Dump void Dump(FILE *file); private: int iValue; float rValue; int registerNumber; string label; int offset; int address; MOperandType mType; }; #endif /* _MOPERAND_H */