From ff4d0a9c3e272bae0d46b002469cca70c70d1b0e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 17 Dec 2025 15:53:24 +0300 Subject: [PATCH] Rename 'interpreter.hpp' -> 'exec.hpp' --- apps/interpreter/source/main.cpp | 4 +- .../interpreter/{interpreter.hpp => exec.hpp} | 2 +- libs/interpreter/source/eval.cpp | 4 +- .../source/{interpreter.cpp => exec.cpp} | 40 +++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) rename libs/interpreter/include/pslang/interpreter/{interpreter.hpp => exec.hpp} (63%) rename libs/interpreter/source/{interpreter.cpp => exec.cpp} (79%) diff --git a/apps/interpreter/source/main.cpp b/apps/interpreter/source/main.cpp index 7d63da0..f9c7668 100644 --- a/apps/interpreter/source/main.cpp +++ b/apps/interpreter/source/main.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -54,7 +54,7 @@ int main(int argc, char ** argv) try std::cout << std::flush; } - interpreter::execute(context, ast); + interpreter::exec(context, ast); if (dump) interpreter::dump(std::cout, context); diff --git a/libs/interpreter/include/pslang/interpreter/interpreter.hpp b/libs/interpreter/include/pslang/interpreter/exec.hpp similarity index 63% rename from libs/interpreter/include/pslang/interpreter/interpreter.hpp rename to libs/interpreter/include/pslang/interpreter/exec.hpp index 88e7e18..1c1af4c 100644 --- a/libs/interpreter/include/pslang/interpreter/interpreter.hpp +++ b/libs/interpreter/include/pslang/interpreter/exec.hpp @@ -6,6 +6,6 @@ namespace pslang::interpreter { - void execute(context & context, ast::statement_list_ptr const & statements); + void exec(context & context, ast::statement_list_ptr const & statements); } diff --git a/libs/interpreter/source/eval.cpp b/libs/interpreter/source/eval.cpp index e392380..d7ffd6d 100644 --- a/libs/interpreter/source/eval.cpp +++ b/libs/interpreter/source/eval.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -413,7 +413,7 @@ namespace pslang::interpreter auto expected_return_type = jt->second.return_type; - execute(context, jt->second.statements); + exec(context, jt->second.statements); auto actual_return_type = type_of(context.scope_stack.back().return_value); if (!type::equal(actual_return_type, *expected_return_type)) diff --git a/libs/interpreter/source/interpreter.cpp b/libs/interpreter/source/exec.cpp similarity index 79% rename from libs/interpreter/source/interpreter.cpp rename to libs/interpreter/source/exec.cpp index 18a27ad..786b545 100644 --- a/libs/interpreter/source/interpreter.cpp +++ b/libs/interpreter/source/exec.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -30,12 +30,12 @@ namespace pslang::interpreter context & context_; }; - void execute_impl(context & context, ast::expression_ptr const & expression) + void exec_impl(context & context, ast::expression_ptr const & expression) { eval(context, expression); } - void execute_impl(context & context, ast::assignment const & assignment) + void exec_impl(context & context, ast::assignment const & assignment) { std::string name; if (auto identifier = std::get_if(assignment.lhs.get())) @@ -70,7 +70,7 @@ namespace pslang::interpreter throw std::runtime_error("Identifier \"" + name + "\" is not defined"); } - void execute_impl(context & context, ast::variable_declaration const & variable_declaration) + void exec_impl(context & context, ast::variable_declaration const & variable_declaration) { auto & scope = context.scope_stack.back(); if (scope.variables.count(variable_declaration.name) > 0) @@ -93,26 +93,26 @@ namespace pslang::interpreter context.scope_stack.back().variables[variable_declaration.name] = {.category = variable_declaration.category, .value = value}; } - void execute_impl(context & context, ast::if_block const &) + void exec_impl(context & context, ast::if_block const &) { throw std::runtime_error("Internal interpreter error: if blocks cannot be present in the final AST"); } - void execute_impl(context & context, ast::else_block const &) + void exec_impl(context & context, ast::else_block const &) { throw std::runtime_error("Internal interpreter error: else blocks cannot be present in the final AST"); } - void execute_impl(context & context, ast::else_if_block const &) + void exec_impl(context & context, ast::else_if_block const &) { throw std::runtime_error("Internal interpreter error: else if blocks cannot be present in the final AST"); } - void execute_impl(context & context, ast::if_chain const & if_chain) + void exec_impl(context & context, ast::if_chain const & if_chain) { for (auto const & block : if_chain.blocks) { - bool do_execute = true; + bool do_exec = true; if (block.condition) { @@ -127,20 +127,20 @@ namespace pslang::interpreter throw std::runtime_error(os.str()); } - do_execute = std::get(std::get(value)).value; + do_exec = std::get(std::get(value)).value; } - if (!do_execute) + if (!do_exec) continue; context.scope_stack.emplace_back(); stack_pop_guard guard(context); - execute(context, block.statements); + exec(context, block.statements); break; } } - void execute_impl(context & context, ast::while_block const & while_block) + void exec_impl(context & context, ast::while_block const & while_block) { while (true) { @@ -159,14 +159,14 @@ namespace pslang::interpreter { context.scope_stack.emplace_back(); stack_pop_guard guard(context); - execute(context, while_block.statements); + exec(context, while_block.statements); } else break; } } - void execute_impl(context & context, ast::function_definition const & function_definition) + void exec_impl(context & context, ast::function_definition const & function_definition) { auto & scope = context.scope_stack.back(); if (scope.functions.count(function_definition.name) > 0) @@ -178,7 +178,7 @@ namespace pslang::interpreter function.statements = function_definition.statements; } - void execute_impl(context & context, ast::return_statement const & return_statement) + void exec_impl(context & context, ast::return_statement const & return_statement) { auto value = return_statement.value ? eval(context, return_statement.value) : unit_value{}; for (auto it = context.scope_stack.rbegin(); it != context.scope_stack.rend(); ++it) @@ -193,13 +193,13 @@ namespace pslang::interpreter throw std::runtime_error("Cannot return outside of a function"); } - void execute_impl(context & context, ast::statement_list_ptr const & statements) + void exec_impl(context & context, ast::statement_list_ptr const & statements) { for (auto const & statement : statements->statements) { try { - std::visit([&](auto const & statement){ execute_impl(context, statement); }, *statement); + std::visit([&](auto const & statement){ exec_impl(context, statement); }, *statement); } catch (return_exception const &) { @@ -213,9 +213,9 @@ namespace pslang::interpreter } - void execute(context & context, ast::statement_list_ptr const & statements) + void exec(context & context, ast::statement_list_ptr const & statements) { - execute_impl(context, statements); + exec_impl(context, statements); } }