diff --git a/include/private-include/dollop.h b/include/private-include/dollop.h index 0dc77b5b311ac4d2a7f34f5ef2c7f13a4ee35b8c..0903bf33e06b0a8dd06e4c486e9927b8f7cb553f 100644 --- a/include/private-include/dollop.h +++ b/include/private-include/dollop.h @@ -11,116 +11,88 @@ namespace Zipr_SDK class Placeable_t { - public: - Placeable_t() : m_is_placed(false), m_placed_address(0) {} - void Place(RangeAddress_t place) { - assert(!m_is_placed); - m_is_placed = true; - m_placed_address = place; - }; - RangeAddress_t getPlace() { return m_placed_address; } - bool isPlaced() const { return m_is_placed; } protected: - bool m_is_placed; - RangeAddress_t m_placed_address; + Placeable_t() {} + Placeable_t(const Placeable_t& copy) = delete; + public: + virtual void Place(RangeAddress_t place) = 0; + virtual RangeAddress_t getPlace() const = 0; + virtual bool isPlaced() const = 0; friend ostream &operator<<(ostream &, const Placeable_t &); }; - class DollopPatch_t : public Placeable_t + class DollopPatch_t : virtual public Placeable_t { + protected: + DollopPatch_t() { } + DollopPatch_t(const DollopPatch_t& copy) = delete; public: - DollopPatch_t(Dollop_t *target) : m_target(target) {}; - DollopPatch_t() : m_target(NULL) { }; - Dollop_t *getTarget() const { return m_target; } - void setTarget(Dollop_t *target) { m_target = target; } + virtual Dollop_t* getTarget() const = 0 ; + virtual void setTarget(Dollop_t *target) = 0 ; friend ostream &operator<<(ostream &, const DollopPatch_t &); - private: - Dollop_t *m_target; }; - class DollopEntry_t : public Placeable_t + class DollopEntry_t : virtual public Placeable_t { + protected: + DollopEntry_t() { } + DollopEntry_t(const DollopEntry_t& copy) = delete; public: - DollopEntry_t(IRDB_SDK::Instruction_t *insn, Dollop_t *member_of); - IRDB_SDK::Instruction_t *getInstruction() const { return m_instruction; } - void setTargetDollop(Dollop_t *target) { m_target_dollop = target; } - Dollop_t *getTargetDollop() const { return m_target_dollop; } - Dollop_t *getMemberOfDollop() const { return m_member_of_dollop; } - void MemberOfDollop(Dollop_t *member_of) { m_member_of_dollop = member_of; } - - bool operator==(const DollopEntry_t &); - bool operator!=(const DollopEntry_t &); - private: - IRDB_SDK::Instruction_t *m_instruction; - Dollop_t *m_target_dollop, *m_member_of_dollop; + virtual Instruction_t *getInstruction() const = 0 ; + virtual void setTargetDollop(Dollop_t *target) = 0 ; + virtual Dollop_t *getTargetDollop() const = 0 ; + virtual Dollop_t *getMemberOfDollop() const = 0 ; + virtual void MemberOfDollop(Dollop_t *member_of) = 0 ; + + virtual bool operator==(const DollopEntry_t &); + virtual bool operator!=(const DollopEntry_t &); friend ostream &operator<<(ostream &, const DollopEntry_t &); }; - class Dollop_t : public Placeable_t, public list<DollopEntry_t*> + using DollopEntryList_t = list<DollopEntry_t*>; + + class Dollop_t : virtual public Placeable_t, virtual public DollopEntryList_t { + protected: + Dollop_t() {} + Dollop_t(const Dollop_t& copy) = delete; + public: - static Dollop_t *createNewDollop(IRDB_SDK::Instruction_t *start, - DollopManager_t *mgr = NULL); - - Dollop_t(IRDB_SDK::Instruction_t *start, DollopManager_t *); - Dollop_t() : - m_size(0), - m_fallthrough_dollop(NULL), - m_fallback_dollop(NULL), - m_fallthrough_patched(false), - m_coalesced(false), - m_was_truncated(false), - m_dollop_mgr(NULL) {} - - void setDollopManager(DollopManager_t *mgr) { m_dollop_mgr = mgr; } - - size_t getSize() const { - return m_size; - } - void setSize(size_t size) { - m_size = size; - } - - size_t getDollopEntryCount() const { - return size(); - } - - Dollop_t *split(IRDB_SDK::Instruction_t *split_point); - void removeDollopEntries(list<DollopEntry_t*>::iterator, - list<DollopEntry_t*>::iterator); - - - void setFallbackDollop(Dollop_t *fallback) { m_fallback_dollop = fallback; } - Dollop_t *getFallbackDollop(void) const { return m_fallback_dollop; } - - void setFallthroughDollop(Dollop_t *fallthrough) { m_fallthrough_dollop = fallthrough; } - Dollop_t *getFallthroughDollop(void) const { return m_fallthrough_dollop; } - - bool isFallthroughPatched(void) const { return m_fallthrough_patched; } - void setFallthroughPatched(bool patched); - - DollopEntry_t *setFallthroughDollopEntry(DollopEntry_t *) const; - - void wasTruncated(bool truncated) { m_was_truncated = truncated; } - bool wasTruncated(void) const { return m_was_truncated; } - - void setCoalesced(bool coalesced); - bool wasCoalesced(void) const { return m_coalesced; } - - void reCalculateSize(); - private: - size_t CalculateSize(); - size_t m_size; - Dollop_t *m_fallthrough_dollop, *m_fallback_dollop; - bool m_fallthrough_patched; - bool m_coalesced; - bool m_was_truncated; - DollopManager_t *m_dollop_mgr; + static Dollop_t *createNewDollop(IRDB_SDK::Instruction_t *start, DollopManager_t *mgr = NULL); + + virtual void setDollopManager(DollopManager_t *mgr) = 0 ; + + virtual size_t getSize() const = 0; + virtual void setSize(size_t size) = 0; + virtual size_t getDollopEntryCount() const = 0; + + virtual Dollop_t *split(IRDB_SDK::Instruction_t *split_point) = 0 ; + virtual void removeDollopEntries(list<DollopEntry_t*>::iterator, list<DollopEntry_t*>::iterator) = 0; + + + virtual void setFallbackDollop(Dollop_t *fallback) = 0 ; + virtual Dollop_t *getFallbackDollop(void) const = 0; + + virtual void setFallthroughDollop(Dollop_t *fallthrough) = 0; + virtual Dollop_t *getFallthroughDollop(void) const = 0; + + virtual bool isFallthroughPatched(void) const = 0; + virtual void setFallthroughPatched(bool patched) = 0 ; + + virtual DollopEntry_t *setFallthroughDollopEntry(DollopEntry_t *) const = 0 ; + + virtual void wasTruncated(bool truncated) = 0; + virtual bool wasTruncated(void) const = 0; + + virtual void setCoalesced(bool coalesced) = 0 ; + virtual bool wasCoalesced(void) const = 0; + + virtual void reCalculateSize() = 0 ; friend ostream &operator<<(ostream &, const Dollop_t &); };