From 98e3e776869842230f1b6ebf2e3447a25673122f Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Tue, 3 Aug 2021 17:53:44 +0200 Subject: [PATCH] add comments as base of Instruction --- src/instructions/Instruction.h | 5 +++-- src/instructions/virtual/Container.h | 11 ++++------- src/instructions/virtual/FastCall.h | 5 ----- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/instructions/Instruction.h b/src/instructions/Instruction.h index 2721cae..1a7042d 100644 --- a/src/instructions/Instruction.h +++ b/src/instructions/Instruction.h @@ -47,6 +47,7 @@ namespace Instruction { uint32_t _address{}; uint32_t _endAddress{}; public: + std::string comment; virtual ~Instruction()= default; @@ -83,8 +84,8 @@ namespace Instruction { virtual CommandOp getCommand() const = 0; - virtual std::string getComment() const { - return ""; + virtual const std::string& getComment() const { + return comment; }; void setAddress(uint32_t address){ diff --git a/src/instructions/virtual/Container.h b/src/instructions/virtual/Container.h index 299acf2..4988339 100644 --- a/src/instructions/virtual/Container.h +++ b/src/instructions/virtual/Container.h @@ -38,16 +38,13 @@ namespace Instruction { std::vector> instructions; public: - explicit Container() : instructions() { - + explicit Container(const std::string& c = ""){ + comment = c; } - explicit Container(std::vector> instructions) : instructions(std::move(instructions)) { - - } - - void addInstruction(std::unique_ptr instruction){ + void addInstruction(std::unique_ptr instruction, const std::string& c = ""){ instructions.emplace_back(std::move(instruction)); + instructions.back()->comment = c; } CommandOp getCommand() const override { diff --git a/src/instructions/virtual/FastCall.h b/src/instructions/virtual/FastCall.h index 1f7f45b..77708b4 100644 --- a/src/instructions/virtual/FastCall.h +++ b/src/instructions/virtual/FastCall.h @@ -33,7 +33,6 @@ namespace Instruction { //Akin to __fastcall, but the caller cleans up the stack class FastCall : public Instruction { private: - std::string comment; std::vector> instructions; void initData(const std::vector& data); void takedownData(const std::vector& data); @@ -48,10 +47,6 @@ namespace Instruction { std::vector toBytes() const override; - std::string getComment() const override { - return comment; - }; - size_t getByteSize() const override{ size_t s = 0; for(auto& i : instructions){