From df361ede5e694c41095d7be4eabf86d0ee6a1162 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 09:53:43 +0000
Subject: [PATCH] fix function parameter parser
---
src/Interpreter/OperationsFactory.hpp | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/Interpreter/OperationsFactory.hpp b/src/Interpreter/OperationsFactory.hpp
index 2034a72..f69bb14 100644
--- a/src/Interpreter/OperationsFactory.hpp
+++ b/src/Interpreter/OperationsFactory.hpp
@@ -14,6 +14,7 @@
#include "Parser/ParsedExpression.hpp"
#include "Symbols/ParameterContainer.hpp"
#include "Symbols/Value.hpp"
+#include "Interpreter/ReturnStatementNode.hpp"
namespace Interpreter {
@@ -81,6 +82,24 @@
ns,
Operations::Operation{Operations::Type::FunctionCall, functionName, std::move(stmt)});
}
+ /**
+ * @brief Record a return statement operation inside a function.
+ * @param pexpr Parsed expression for return value, or nullptr for void return.
+ * @param ns Current namespace (function scope).
+ * @param fileName Source filename.
+ * @param line Line number of return.
+ * @param column Column number of return.
+ */
+ static void callReturn(const Parser::ParsedExpressionPtr &pexpr,
+ const std::string & ns,
+ const std::string & fileName,
+ int line,
+ size_t column) {
+ std::unique_ptr<ExpressionNode> expr = pexpr ? buildExpressionFromParsed(pexpr) : nullptr;
+ auto stmt = std::make_unique<ReturnStatementNode>(std::move(expr), fileName, line, column);
+ Operations::Container::instance()->add(ns,
+ Operations::Operation{Operations::Type::Return, std::string(), std::move(stmt)});
+ }
};
} // namespace Interpreter
--
Gitblit v1.9.3