diff --git a/include/interfaces/abstract/STARSOp.h b/include/interfaces/abstract/STARSOp.h index 4e38766b2acd4fc6d943746c5ad9ae9fcc266e99..8d856da5b575c0d4b0c99810e2210d56e8d16182 100644 --- a/include/interfaces/abstract/STARSOp.h +++ b/include/interfaces/abstract/STARSOp.h @@ -10,10 +10,13 @@ class STARS_op_t public: // Constructors - STARS_op_t(); + STARS_op_t() = default; + + // Clone method (deep copy). + virtual STARSOpndTypePtr clone(void) const = 0; // Operators - virtual bool operator<(const STARS_op_t &rOp) const = 0; + virtual bool operator<(const STARS_op_t &rOp) const = 0; // Less-than operator for use in STL ordered containers, e.g. sets. // Get methods virtual uintptr_t GetAddr(void) const = 0; diff --git a/include/interfaces/idapro/STARSOp.h b/include/interfaces/idapro/STARSOp.h index 5a32bb7b47c11eedfd97d9853e401b3e044feea4..5ac876f172cad01f5da5abc550e10e01f0ee7cd0 100644 --- a/include/interfaces/idapro/STARSOp.h +++ b/include/interfaces/idapro/STARSOp.h @@ -12,8 +12,11 @@ class STARS_IDA_op_t : public STARS_op_t // Constructors STARS_IDA_op_t(op_t IDAOp) : m_Opnd(IDAOp) {}; + // Clone method (deep copy). + STARSOpndTypePtr clone(void) const; + // Operators - bool operator<(const STARS_op_t &rOp) const; + bool operator<(const STARS_op_t &rOp) const; // Less-than operator for use in STL ordered containers, e.g. sets. // Get methods uintptr_t GetAddr(void) const { return m_Opnd.addr; }; diff --git a/src/interfaces/idapro/STARSIDAOp.cpp b/src/interfaces/idapro/STARSIDAOp.cpp index 438ade08da0b2fe258c6ec908bb99e8570f29245..e951696cc6d604b5a9fbf1506bec1ec84d1bbac1 100644 --- a/src/interfaces/idapro/STARSIDAOp.cpp +++ b/src/interfaces/idapro/STARSIDAOp.cpp @@ -7,7 +7,13 @@ #include "interfaces/abstract/all.h" #include "interfaces/idapro/all.h" +// Clone method (deep copy). +STARSOpndTypePtr STARS_IDA_op_t::clone(void) const { + STARS_IDA_op_t *TempOpPtr = new STARS_IDA_op_t(this->m_Opnd); + return dynamic_cast<STARSOpndTypePtr>(TempOpPtr); +} // end of STARS_IDA_op_t::clone() +// Less-than operator for use in STL ordered containers, e.g. sets. bool STARS_IDA_op_t::operator<(const STARS_op_t &rOp) const { unsigned char Type1 = this->GetType(); unsigned char Type2 = rOp.GetType();