From 375607d9969896c894fa2642ce4a0b8b519a2adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 2 Sep 2017 15:34:07 +0200 Subject: Use QString and QVector instead of std ones and more --- qtmips_machine/instruction.cpp | 44 ++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'qtmips_machine/instruction.cpp') diff --git a/qtmips_machine/instruction.cpp b/qtmips_machine/instruction.cpp index c5d5345..e03f794 100644 --- a/qtmips_machine/instruction.cpp +++ b/qtmips_machine/instruction.cpp @@ -1,7 +1,4 @@ #include "instruction.h" -#include -#include -#include "utils.h" InstructionR::InstructionR(std::uint8_t rs, std::uint8_t rd, std::uint8_t rt, std::uint8_t sa) { this->rs = rs; @@ -12,20 +9,18 @@ InstructionR::InstructionR(std::uint8_t rs, std::uint8_t rd, std::uint8_t rt, st // TODO for registers output as register ($0)! -std::vector InstructionR::to_strs() { - std::vector str; +QVector InstructionR::to_strs() { + QVector str; // Instruction name - str.push_back("unknown"); // unknown instruction, should be replaced by child - + str << "unknown"; // unknown instruction, should be replaced by child // Source register - str.push_back(to_string_hex((unsigned)this->rs)); + str << QString::number((unsigned)this->rs, 16); // Target register - str.push_back(to_string_hex((unsigned)this->rt)); + str << QString::number((unsigned)this->rt, 16); // Destination register - str.push_back(to_string_hex((unsigned)this->rd)); + str << QString::number((unsigned)this->rd, 16); // Shift amount - str.push_back(to_string_hex((unsigned)this->sa)); - + str << QString::number((unsigned)this->sa, 16); return str; } @@ -35,18 +30,16 @@ InstructionI::InstructionI(std::uint8_t rs, std::uint8_t rt, std::uint16_t immed this->immediate = immediate; } -std::vector InstructionI::to_strs() { - std::vector str; +QVector InstructionI::to_strs() { + QVector str; // Instruction name - str.push_back("unknown"); // unknown instruction, should be replaced by child - + str << "unknown"; // unknown instruction, should be replaced by child // Source register - str.push_back(to_string_hex((unsigned)this->rs)); + str << QString::number((unsigned)this->rs, 16); // Target register - str.push_back(to_string_hex((unsigned)this->rt)); + str << QString::number((unsigned)this->rt, 16); // Immediate value - str.push_back(to_string_hex((unsigned)this->immediate)); - + str << QString::number((unsigned)this->immediate, 16); return str; } @@ -54,14 +47,11 @@ InstructionJ::InstructionJ(std::uint32_t address) { this->address = address; } -std::vector InstructionJ::to_strs() { - std::vector str; +QVector InstructionJ::to_strs() { + QVector str; // Instruction name - str.push_back("unknown"); // unknown instruction, should be replaced by child - - std::stringstream ss; + str << "unknown"; // unknown instruction, should be replaced by child // Source register - str.push_back(to_string_hex((unsigned)this->address)); - + str << QString::number((unsigned)this->address, 16); return str; } -- cgit v1.2.3