Fix stoi -> stoul
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2021-01-02 15:43:48 +01:00
parent ffc243d528
commit 8793c64f1c
2 changed files with 148 additions and 142 deletions

View file

@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <iostream>
#include "Parser.h"
void Parser::parse() {
@ -61,6 +62,7 @@ void Parser::parse() {
Declaration currentDeclaration;
while (true) {
try{
c = getByte();
if (c == '\n' || c == '\0' || (!isComment && (c == ' ' || c == '\t' || c == ',' || c == ';'))) {
//End token
@ -97,7 +99,7 @@ void Parser::parse() {
if (isRegisterLocation(currentValue)) {
currentDeclaration.tokens.emplace_back(
Token(t.first, currentValue.substr(1, std::string::npos),
std::stoi(currentValue.substr(1, std::string::npos), nullptr, 0)));
std::stoul(currentValue.substr(1, std::string::npos), nullptr, 0)));
foundToken = true;
}
break;
@ -112,14 +114,14 @@ void Parser::parse() {
if (isCodeLocation(currentValue)) {
currentDeclaration.tokens.emplace_back(
Token(t.first, currentValue.substr(1, std::string::npos),
std::stoi(currentValue.substr(1, std::string::npos), nullptr, 0)));
std::stoul(currentValue.substr(1, std::string::npos), nullptr, 0)));
foundToken = true;
}
break;
case Token::Type::Immediate:
if (isImmediate(currentValue)) {
currentDeclaration.tokens.emplace_back(
Token(t.first, currentValue, std::stoi(currentValue, nullptr, 0)));
Token(t.first, currentValue, std::stoul(currentValue, nullptr, 0)));
foundToken = true;
}
break;
@ -218,6 +220,10 @@ void Parser::parse() {
} else if (!isComment) {
currentValue += c;
}
}catch (const std::exception& e){
std::cerr << "Exception: " << e.what() << " on " << currentFunction.label << "\n";
throw e;
}
}
}

View file

@ -173,8 +173,8 @@ namespace Instruction {
segments.push_back(segment);
}
uint8_t offset1 = segments.size() > 1 ? std::stoi(segments.at(1).substr(0, 1), nullptr, 10) : 0;
uint8_t offset2 = (segments.size() > 1 && segments.at(1).size() > 1) ? std::stoi(
uint8_t offset1 = segments.size() > 1 ? std::stoul(segments.at(1).substr(0, 1), nullptr, 10) : 0;
uint8_t offset2 = (segments.size() > 1 && segments.at(1).size() > 1) ? std::stoul(
segments.at(1).substr(1, 1), nullptr, 10) : 0;
return Instruction::parseOperatorResult{