From acb1c33ab258dc14dcc51b405b44cc5923b34324 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 08:52:16 +0000
Subject: [PATCH] add function call
---
src/Interpreter/OperationsFactory.hpp | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Interpreter/OperationsFactory.hpp b/src/Interpreter/OperationsFactory.hpp
index 2dc39af..2034a72 100644
--- a/src/Interpreter/OperationsFactory.hpp
+++ b/src/Interpreter/OperationsFactory.hpp
@@ -8,6 +8,7 @@
#include "Interpreter/DeclareVariableStatementNode.hpp"
#include "Interpreter/ExpressionBuilder.hpp"
#include "Interpreter/LiteralExpressionNode.hpp"
+#include "Interpreter/CallStatementNode.hpp"
#include "Interpreter/Operation.hpp"
#include "Interpreter/OperationContainer.hpp"
#include "Parser/ParsedExpression.hpp"
@@ -54,22 +55,31 @@
}
/**
- * @brief Record a function call operation for later detection.
+ * @brief Record a function call operation with argument expressions.
* @param functionName Name of the function being called.
- * @param ns Current namespace scope.
+ * @param parsedArgs Vector of parsed argument expressions.
+ * @param ns Current namespace scope for operations.
* @param fileName Source filename.
* @param line Line number of call.
* @param column Column number of call.
*/
static void callFunction(const std::string & functionName,
+ std::vector<Parser::ParsedExpressionPtr> &&parsedArgs,
const std::string & ns,
const std::string & fileName,
int line,
size_t column) {
- // No associated StatementNode; this is for detection only
+ // Build argument ExpressionNode list
+ std::vector<std::unique_ptr<ExpressionNode>> exprs;
+ exprs.reserve(parsedArgs.size());
+ for (auto &pexpr : parsedArgs) {
+ exprs.push_back(buildExpressionFromParsed(pexpr));
+ }
+ // Create call statement node
+ auto stmt = std::make_unique<CallStatementNode>(functionName, std::move(exprs), fileName, line, column);
Operations::Container::instance()->add(
ns,
- Operations::Operation{Operations::Type::FunctionCall, functionName, nullptr});
+ Operations::Operation{Operations::Type::FunctionCall, functionName, std::move(stmt)});
}
};
--
Gitblit v1.9.3