A simple scripting language in C++
Ferenc Szontágh
2025-04-18 df361ede5e694c41095d7be4eabf86d0ee6a1162
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