Skip to content

Commit

Permalink
Fixed vector element/item insertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Dec 5, 2024
1 parent f72a0b6 commit 8f080dc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/n8/core/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool Runtime::hasLoadedLibrary(std::string libName) {
}

void Runtime::addFileHash(std::string hash) {
Runtime::fileHashes.emplace_back(hash);
Runtime::fileHashes.push_back(hash);
}

bool Runtime::hasFileHash(std::string hash) {
Expand Down
2 changes: 1 addition & 1 deletion src/n8/core/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool SymbolTable::hasSymbol(const std::string& name) {
}

void SymbolTable::addParallelism(std::thread par) {
this->threads.emplace_back(std::move(par));
this->threads.push_back(std::move(par));
}

void SymbolTable::waitForThreads() {
Expand Down
10 changes: 5 additions & 5 deletions src/n8/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ std::shared_ptr<ASTNode> Parser::exprBlock() {
std::vector<std::shared_ptr<ASTNode>> body;

while(!this->isNext("}", TokenType::OPERATOR))
body.emplace_back(this->expression());
body.push_back(this->expression());

return std::make_shared<BlockExpression>(
std::make_shared<Token>(address),
Expand Down Expand Up @@ -236,7 +236,7 @@ std::shared_ptr<ASTNode> Parser::exprFunctionDecl() {
if(!parameters.empty())
this->consume(",");

parameters.emplace_back(
parameters.push_back(
std::make_shared<Token>(
this->consume(TokenType::IDENTIFIER)
)
Expand Down Expand Up @@ -502,7 +502,7 @@ std::shared_ptr<ASTNode> Parser::exprWhen() {
this->consume(")");

std::shared_ptr<ASTNode> thenBlock = this->expression();
cases.emplace_back(std::make_pair(
cases.push_back(std::make_pair(
std::move(caseExpr),
std::move(thenBlock)
));
Expand Down Expand Up @@ -576,7 +576,7 @@ std::shared_ptr<ASTNode> Parser::exprPrimary() {

while(!this->isNext("}", TokenType::OPERATOR)) {
std::shared_ptr<ASTNode> stmt = this->statement();
statements.emplace_back(std::move(stmt));
statements.push_back(std::move(stmt));
}
this->consume("}");

Expand Down Expand Up @@ -652,7 +652,7 @@ std::shared_ptr<ASTNode> Parser::exprPrimary() {
if(!arguments.empty())
this->consume(",");

arguments.emplace_back(this->expression());
arguments.push_back(this->expression());
}

this->consume(")");
Expand Down
20 changes: 10 additions & 10 deletions src/n8/parser/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ void Tokenizer::scan() {
column++;

str = N8Util::replaceEscapeSequences(std::move(str));
this->tokens.emplace_back(
this->tokens.push_back(Token(
str,
fileName,
line,
startColumn,
TokenType::STRING
);
));
}
else if(currentChar == '`') {
std::string str;
Expand Down Expand Up @@ -129,13 +129,13 @@ void Tokenizer::scan() {
column++;

str = N8Util::replaceEscapeSequences(std::move(str));
this->tokens.emplace_back(
this->tokens.push_back(Token(
str,
fileName,
line,
startColumn,
TokenType::REGEX
);
));
}
else {
std::string op(1, currentChar);
Expand All @@ -150,13 +150,13 @@ void Tokenizer::scan() {
column++;
}

this->tokens.emplace_back(
this->tokens.push_back(Token(
op,
fileName,
line,
startColumn,
TokenType::OPERATOR
);
));
}
}
else if(this->isDigit(currentChar)) {
Expand Down Expand Up @@ -298,13 +298,13 @@ void Tokenizer::scan() {
}
}

this->tokens.emplace_back(
this->tokens.push_back(Token(
digit,
fileName,
line,
startColumn,
TokenType::DIGIT
);
));
}
else if(this->isAlphabet(currentChar)) {
std::string token(1, currentChar);
Expand All @@ -320,13 +320,13 @@ void Tokenizer::scan() {

TokenType type = this->isKeyword(token) ?
TokenType::KEYWORD : TokenType::IDENTIFIER;
this->tokens.emplace_back(
this->tokens.push_back(Token(
token,
fileName,
line,
startColumn,
type
);
));
}
}
}
Expand Down

0 comments on commit 8f080dc

Please sign in to comment.