Skip to content

Commit

Permalink
Changed the std::string type to Token for function parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Sep 13, 2024
1 parent e7c6a03 commit 7359e14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/ast/expression/FunctionDeclarationExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@

#include <ast/ASTNode.hpp>
#include <ast/TerminativeSignal.hpp>
#include <parser/Token.hpp>

#include <memory>
#include <string>
#include <vector>

class FunctionDeclarationExpression : public ASTNode {
private:
std::vector<std::string> parameters;
std::vector<std::unique_ptr<Token>> parameters;
std::unique_ptr<ASTNode> body;

public:
explicit FunctionDeclarationExpression(
std::unique_ptr<Token> _address,
std::vector<std::string> _parameters,
std::vector<std::unique_ptr<Token>> _parameters,
std::unique_ptr<ASTNode> _body
) : parameters(std::move(_parameters)),
body(std::move(_body)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ast/expression/FunctionDeclarationExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DynamicObject FunctionDeclarationExpression::call(SymbolTable& symbols, const st
SymbolTable localSymbols(&symbols);
for(size_t i = 0; i < args.size(); ++i) {
auto obj = std::move(&std::move(args).at(i));
localSymbols.setSymbol(this->parameters[i], obj);
localSymbols.setSymbol(this->parameters[i]->getImage(), obj);
}

return std::move(this->body->visit(localSymbols));
Expand Down

0 comments on commit 7359e14

Please sign in to comment.