add comments as base of Instruction
This commit is contained in:
parent
1cce604661
commit
98e3e77686
|
@ -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){
|
||||
|
|
|
@ -38,16 +38,13 @@ namespace Instruction {
|
|||
std::vector<std::unique_ptr<Instruction>> instructions;
|
||||
public:
|
||||
|
||||
explicit Container() : instructions() {
|
||||
|
||||
explicit Container(const std::string& c = ""){
|
||||
comment = c;
|
||||
}
|
||||
|
||||
explicit Container(std::vector<std::unique_ptr<Instruction>> instructions) : instructions(std::move(instructions)) {
|
||||
|
||||
}
|
||||
|
||||
void addInstruction(std::unique_ptr<Instruction> instruction){
|
||||
void addInstruction(std::unique_ptr<Instruction> instruction, const std::string& c = ""){
|
||||
instructions.emplace_back(std::move(instruction));
|
||||
instructions.back()->comment = c;
|
||||
}
|
||||
|
||||
CommandOp getCommand() const override {
|
||||
|
|
|
@ -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<std::unique_ptr<Instruction>> instructions;
|
||||
void initData(const std::vector<Token>& data);
|
||||
void takedownData(const std::vector<Token>& data);
|
||||
|
@ -48,10 +47,6 @@ namespace Instruction {
|
|||
|
||||
std::vector<uint8_t> toBytes() const override;
|
||||
|
||||
std::string getComment() const override {
|
||||
return comment;
|
||||
};
|
||||
|
||||
size_t getByteSize() const override{
|
||||
size_t s = 0;
|
||||
for(auto& i : instructions){
|
||||
|
|
Loading…
Reference in a new issue