diff --git a/src/language/PugsParser.cpp b/src/language/PugsParser.cpp index fbf7b60a21d0ea6aed9e9609d2b4c733a56fbcbc..74c35b827552d5d042ae43948e1a836e0d48bfd8 100644 --- a/src/language/PugsParser.cpp +++ b/src/language/PugsParser.cpp @@ -1,8 +1,8 @@ #include <language/PugsParser.hpp> #include <language/PEGGrammar.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNode.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> @@ -20,6 +20,7 @@ #include <language/utils/OperatorRepository.hpp> #include <language/utils/SymbolTable.hpp> #include <utils/ConsoleManager.hpp> +#include <utils/Messenger.hpp> #include <utils/PugsAssert.hpp> #include <utils/PugsUtils.hpp> #include <utils/SignalManager.hpp> @@ -53,9 +54,10 @@ parser(const std::string& filename) << rang::style::reset << " ...\n"; } - auto parse_and_execute = [](auto& input) { + auto parse_and_execute = [](auto& input, const std::string& file_content) { OperatorRepository::create(); - ASTBacktrace::create(input); + + ASTExecutionStack::create(input, file_content); std::unique_ptr<ASTNode> root_node = ASTBuilder::build(*input); ASTModulesImporter module_importer{*root_node}; @@ -96,10 +98,18 @@ parser(const std::string& filename) OperatorRepository::destroy(); }; - auto input = std::make_shared<TAO_PEGTL_NAMESPACE::file_input<>>(filename); + std::string file_content; + if (parallel::rank() == 0) { + std::ifstream file{filename}; + file_content = std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()}; + } + parallel::broadcast(file_content, 0); + + auto input = std::make_shared<TAO_PEGTL_NAMESPACE::string_input<>>(file_content, filename); + if (not SignalManager::pauseOnError()) { try { - parse_and_execute(input); + parse_and_execute(input, file_content); } catch (const ParseError& e) { const auto p = e.positions().front(); @@ -127,12 +137,12 @@ parser(const std::string& filename) std::exit(1); } catch (const IExitError& e) { - std::cerr << ASTBacktrace::getInstance().errorMessageAt(e.what()) << '\n'; + std::cerr << ASTExecutionStack::getInstance().errorMessageAt(e.what()) << '\n'; finalize(); std::exit(1); } } else { - parse_and_execute(input); + parse_and_execute(input, file_content); } } diff --git a/src/language/ast/ASTBacktrace.cpp b/src/language/ast/ASTBacktrace.cpp deleted file mode 100644 index 18442ec439194924fe83a5080b5bee2016eab4da..0000000000000000000000000000000000000000 --- a/src/language/ast/ASTBacktrace.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include <language/ast/ASTBacktrace.hpp> - -#include <language/ast/ASTNode.hpp> - -ASTBacktrace* ASTBacktrace::m_instance = nullptr; - -ASTBacktrace::ASTBacktrace(const std::shared_ptr<TAO_PEGTL_NAMESPACE::file_input<>>& file_input) - : m_file_input(file_input) -{} - -std::string -ASTBacktrace::errorMessageAt(const std::string& message) const -{ - auto& stack = ASTBacktrace::getInstance().m_stack; - std::ostringstream error_msg; - - auto p = stack[stack.size() - 1]->begin(); - error_msg << rang::style::bold << p.source << ':' << p.line << ':' << p.column << ": " << rang::style::reset - << message << rang::fg::reset << '\n'; - - if (m_file_input.use_count() > 0) { - error_msg << m_file_input->line_at(p) << '\n' - << std::string(p.column - 1, ' ') << rang::fgB::yellow << '^' << rang::fg::reset << '\n'; - } - - return error_msg.str(); -} - -SourceLocation -ASTBacktrace::sourceLocation() const -{ - auto& stack = ASTBacktrace::getInstance().m_stack; - - auto p = stack[stack.size() - 1]->begin(); - return SourceLocation(p.source, p.line, p.column); -} - -void -ASTBacktrace::create() -{ - if (m_instance == nullptr) { - m_instance = new ASTBacktrace(); - } else { - throw UnexpectedError("ASTBackTrace was already created!"); - } -} - -void -ASTBacktrace::create(const std::shared_ptr<TAO_PEGTL_NAMESPACE::file_input<>>& file_input) -{ - if (m_instance == nullptr) { - m_instance = new ASTBacktrace(file_input); - } else { - throw UnexpectedError("ASTBackTrace was already created!"); - } -} - -void -ASTBacktrace::destroy() -{ - delete m_instance; - m_instance = nullptr; -} diff --git a/src/language/ast/ASTBacktrace.hpp b/src/language/ast/ASTBacktrace.hpp deleted file mode 100644 index 6ea9a53645ea4c4fda5c35585a80e44392254b5f..0000000000000000000000000000000000000000 --- a/src/language/ast/ASTBacktrace.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef AST_BACTRACE_HPP -#define AST_BACTRACE_HPP - -#include <utils/PugsAssert.hpp> -#include <utils/SourceLocation.hpp> - -#include <pegtl/file_input.hpp> -#include <string> -#include <vector> - -class ASTNode; -class ASTBacktrace -{ - private: - std::vector<const ASTNode*> m_stack; - - std::shared_ptr<TAO_PEGTL_NAMESPACE::file_input<>> m_file_input; - - static ASTBacktrace* m_instance; - - ASTBacktrace() = default; - ASTBacktrace(const std::shared_ptr<TAO_PEGTL_NAMESPACE::file_input<>>& file_input); - ~ASTBacktrace() = default; - - public: - std::string errorMessageAt(const std::string& error_msg) const; - - SourceLocation sourceLocation() const; - - void - push(const ASTNode* node) - { - m_stack.push_back(node); - } - - void - pop() - { - m_stack.pop_back(); - } - - static void create(); // for unit tests only - static void create(const std::shared_ptr<TAO_PEGTL_NAMESPACE::file_input<>>& file_input); - static void destroy(); - - static ASTBacktrace& - getInstance() - { - Assert(m_instance != nullptr); - return *m_instance; - } - - ASTBacktrace(const ASTBacktrace&) = delete; - ASTBacktrace(ASTBacktrace&&) = delete; -}; - -#endif // AST_BACTRACE_HPP diff --git a/src/language/ast/ASTBuilder.cpp b/src/language/ast/ASTBuilder.cpp index d7d8dbc1fe9936a734a395695570d982a9b10779..b15b79a04fc301a06a166a36e447a98df64599bb 100644 --- a/src/language/ast/ASTBuilder.cpp +++ b/src/language/ast/ASTBuilder.cpp @@ -312,5 +312,4 @@ ASTBuilder::build(InputT& input) return root_node; } -template std::unique_ptr<ASTNode> ASTBuilder::build(TAO_PEGTL_NAMESPACE::file_input<>& input); template std::unique_ptr<ASTNode> ASTBuilder::build(TAO_PEGTL_NAMESPACE::string_input<>& input); diff --git a/src/language/ast/ASTExecutionStack.cpp b/src/language/ast/ASTExecutionStack.cpp new file mode 100644 index 0000000000000000000000000000000000000000..922e40e32bd8901b226561426b7b42976babae7a --- /dev/null +++ b/src/language/ast/ASTExecutionStack.cpp @@ -0,0 +1,75 @@ +#include <language/ast/ASTExecutionStack.hpp> + +#include <language/ast/ASTNode.hpp> + +ASTExecutionStack* ASTExecutionStack::m_instance = nullptr; + +ASTExecutionStack::ASTExecutionStack(const std::shared_ptr<TAO_PEGTL_NAMESPACE::string_input<>>& file_input, + const std::string& file_content) + : m_file_input(file_input), m_file_content{file_content} +{} + +std::string +ASTExecutionStack::errorMessageAt(const std::string& message) const +{ + auto& stack = ASTExecutionStack::getInstance().m_stack; + std::ostringstream error_msg; + + auto p = stack[stack.size() - 1]->begin(); + error_msg << rang::style::bold << p.source << ':' << p.line << ':' << p.column << ": " << rang::style::reset + << message << rang::fg::reset << '\n'; + + if (m_file_input.use_count() > 0) { + error_msg << m_file_input->line_at(p) << '\n' + << std::string(p.column - 1, ' ') << rang::fgB::yellow << '^' << rang::fg::reset << '\n'; + } + + return error_msg.str(); +} + +const ASTNode& +ASTExecutionStack::currentNode() const +{ + auto& stack = ASTExecutionStack::getInstance().m_stack; + Assert(stack.size() > 0); + + return *stack[stack.size() - 1]; +} + +SourceLocation +ASTExecutionStack::sourceLocation() const +{ + auto& stack = ASTExecutionStack::getInstance().m_stack; + Assert(stack.size() > 0); + + auto p = stack[stack.size() - 1]->begin(); + return SourceLocation(p.source, p.line, p.column); +} + +void +ASTExecutionStack::create() +{ + if (m_instance == nullptr) { + m_instance = new ASTExecutionStack(); + } else { + throw UnexpectedError("ASTExecutionStack was already created!"); + } +} + +void +ASTExecutionStack::create(const std::shared_ptr<TAO_PEGTL_NAMESPACE::string_input<>>& file_input, + const std::string& file_content) +{ + if (m_instance == nullptr) { + m_instance = new ASTExecutionStack(file_input, file_content); + } else { + throw UnexpectedError("ASTExecutionStack was already created!"); + } +} + +void +ASTExecutionStack::destroy() +{ + delete m_instance; + m_instance = nullptr; +} diff --git a/src/language/ast/ASTExecutionStack.hpp b/src/language/ast/ASTExecutionStack.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3fe6fbece629477e75be352d64f1be7120ae1745 --- /dev/null +++ b/src/language/ast/ASTExecutionStack.hpp @@ -0,0 +1,68 @@ +#ifndef AST_EXECUTION_STACK_HPP +#define AST_EXECUTION_STACK_HPP + +#include <utils/PugsAssert.hpp> +#include <utils/SourceLocation.hpp> + +#include <pegtl/string_input.hpp> +#include <string> +#include <vector> + +class ASTNode; +class ASTExecutionStack +{ + private: + std::vector<const ASTNode*> m_stack; + + std::shared_ptr<TAO_PEGTL_NAMESPACE::string_input<>> m_file_input; + std::string m_file_content; + + static ASTExecutionStack* m_instance; + + ASTExecutionStack() = default; + ASTExecutionStack(const std::shared_ptr<TAO_PEGTL_NAMESPACE::string_input<>>& file_input, + const std::string& file_content); + ~ASTExecutionStack() = default; + + public: + std::string errorMessageAt(const std::string& error_msg) const; + + const std::string& + fileContent() const + { + return m_file_content; + } + + SourceLocation sourceLocation() const; + + const ASTNode& currentNode() const; + + void + push(const ASTNode* node) + { + m_stack.push_back(node); + } + + void + pop() + { + m_stack.pop_back(); + } + + static void create(); // for unit tests only + static void create(const std::shared_ptr<TAO_PEGTL_NAMESPACE::string_input<>>& file_input, + const std::string& file_content); + static void destroy(); + + static ASTExecutionStack& + getInstance() + { + Assert(m_instance != nullptr); + return *m_instance; + } + + ASTExecutionStack(const ASTExecutionStack&) = delete; + ASTExecutionStack(ASTExecutionStack&&) = delete; +}; + +#endif // AST_EXECUTION_STACK_HPP diff --git a/src/language/ast/ASTNode.hpp b/src/language/ast/ASTNode.hpp index 19b43a9272229d97bef9c96a8210506e23513a40..612b4d0c46b0790bf5406e085469a4afca53d4df 100644 --- a/src/language/ast/ASTNode.hpp +++ b/src/language/ast/ASTNode.hpp @@ -1,7 +1,7 @@ #ifndef AST_NODE_HPP #define AST_NODE_HPP -#include <language/ast/ASTBacktrace.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/node_processor/ExecutionPolicy.hpp> #include <language/node_processor/INodeProcessor.hpp> #include <language/utils/ASTNodeDataType.hpp> @@ -110,19 +110,19 @@ class ASTNode : public TAO_PEGTL_NAMESPACE::parse_tree::basic_node<ASTNode> if (exec_policy.exec()) { if (m_stack_details) { if (m_node_processor->type() == INodeProcessor::Type::builtin_function_processor) { - ASTBacktrace::getInstance().push(this); + ASTExecutionStack::getInstance().push(this); m_stack_details = false; auto result = m_node_processor->execute(exec_policy); m_stack_details = true; - ASTBacktrace::getInstance().pop(); + ASTExecutionStack::getInstance().pop(); return result; } else { - ASTBacktrace::getInstance().push(this); + ASTExecutionStack::getInstance().push(this); auto result = m_node_processor->execute(exec_policy); - ASTBacktrace::getInstance().pop(); + ASTExecutionStack::getInstance().pop(); return result; } diff --git a/src/language/ast/CMakeLists.txt b/src/language/ast/CMakeLists.txt index 63e208c2b153b7f05318ee15066f5da0f7e2cb8c..cd2f89636ffd8255af1a077118b44c64147fd18c 100644 --- a/src/language/ast/CMakeLists.txt +++ b/src/language/ast/CMakeLists.txt @@ -1,8 +1,8 @@ # ------------------- Source files -------------------- add_library(PugsLanguageAST - ASTBacktrace.cpp ASTBuilder.cpp + ASTExecutionStack.cpp ASTModulesImporter.cpp ASTNode.cpp ASTNodeAffectationExpressionBuilder.cpp diff --git a/src/language/modules/DevUtilsModule.cpp b/src/language/modules/DevUtilsModule.cpp index 7685443b081fb2c8f71e65c8eed8aae16273100b..7df6e847e157a68e073642dd50ee87383788d98a 100644 --- a/src/language/modules/DevUtilsModule.cpp +++ b/src/language/modules/DevUtilsModule.cpp @@ -95,7 +95,8 @@ DevUtilsModule::DevUtilsModule() [](const std::shared_ptr<const DiscreteFunctionVariant>& discrete_function, const std::string& name) { - parallel_check(*discrete_function, name, ASTBacktrace::getInstance().sourceLocation()); + parallel_check(*discrete_function, name, + ASTExecutionStack::getInstance().sourceLocation()); } )); @@ -104,7 +105,7 @@ DevUtilsModule::DevUtilsModule() std::function( [](const std::shared_ptr<const ItemValueVariant>& item_value, const std::string& name) { - parallel_check(*item_value, name, ASTBacktrace::getInstance().sourceLocation()); + parallel_check(*item_value, name, ASTExecutionStack::getInstance().sourceLocation()); } )); @@ -113,7 +114,7 @@ DevUtilsModule::DevUtilsModule() std::function( [](const std::shared_ptr<const ItemArrayVariant>& item_array, const std::string& name) { - parallel_check(*item_array, name, ASTBacktrace::getInstance().sourceLocation()); + parallel_check(*item_array, name, ASTExecutionStack::getInstance().sourceLocation()); } )); @@ -124,7 +125,7 @@ DevUtilsModule::DevUtilsModule() [](const std::shared_ptr<const SubItemValuePerItemVariant>& subitem_value_per_item, const std::string& name) { parallel_check(*subitem_value_per_item, name, - ASTBacktrace::getInstance().sourceLocation()); + ASTExecutionStack::getInstance().sourceLocation()); } )); @@ -135,7 +136,7 @@ DevUtilsModule::DevUtilsModule() [](const std::shared_ptr<const SubItemArrayPerItemVariant>& subitem_array_per_item, const std::string& name) { parallel_check(*subitem_array_per_item, name, - ASTBacktrace::getInstance().sourceLocation()); + ASTExecutionStack::getInstance().sourceLocation()); } )); diff --git a/src/utils/SignalManager.cpp b/src/utils/SignalManager.cpp index 62505d7b4d171ff3ff9bf207f9e357aada060fda..4b2046a98796fc72cef406f77e7498930089f533 100644 --- a/src/utils/SignalManager.cpp +++ b/src/utils/SignalManager.cpp @@ -1,6 +1,6 @@ #include <utils/SignalManager.hpp> -#include <language/ast/ASTBacktrace.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/utils/ParseError.hpp> #include <utils/BacktraceManager.hpp> #include <utils/ConsoleManager.hpp> @@ -93,7 +93,7 @@ SignalManager::handler(int signal) } else { std::ostringstream error_msg; error_msg << "received " << signalName(signal); - std::cerr << ASTBacktrace::getInstance().errorMessageAt(error_msg.str()) << '\n'; + std::cerr << ASTExecutionStack::getInstance().errorMessageAt(error_msg.str()) << '\n'; } } catch (const IBacktraceError& backtrace_error) { @@ -101,7 +101,7 @@ SignalManager::handler(int signal) std::cerr << rang::fgB::cyan << source_location.file_name() << ':' << source_location.line() << ':' << source_location.column() << ':' << rang::fg::reset << rang::fgB::yellow << " threw the following exception" << rang::fg::reset << "\n\n"; - std::cerr << ASTBacktrace::getInstance().errorMessageAt(backtrace_error.what()) << '\n'; + std::cerr << ASTExecutionStack::getInstance().errorMessageAt(backtrace_error.what()) << '\n'; } catch (const ParseError& parse_error) { auto p = parse_error.positions().front(); @@ -110,7 +110,7 @@ SignalManager::handler(int signal) << rang::style::reset << '\n'; } catch (const IExitError& exit_error) { - std::cerr << ASTBacktrace::getInstance().errorMessageAt(exit_error.what()) << '\n'; + std::cerr << ASTExecutionStack::getInstance().errorMessageAt(exit_error.what()) << '\n'; } catch (const AssertError& assert_error) { std::cerr << assert_error << '\n'; diff --git a/tests/test_ASTModulesImporter.cpp b/tests/test_ASTModulesImporter.cpp index f70fa9b2bc118c4498072de10414d346b17717b4..24557c449ca495b92598ea5bd0140b55c381b15c 100644 --- a/tests/test_ASTModulesImporter.cpp +++ b/tests/test_ASTModulesImporter.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeExpressionBuilder.hpp> #include <language/ast/ASTNodeTypeCleaner.hpp> @@ -38,9 +38,9 @@ test_ASTExecutionInfo(const ASTNode& root_node, const ModuleRepository& module_r test_ASTExecutionInfo(*ast, module_repository); \ \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ std::stringstream ast_output; \ ast_output << '\n' << ASTPrinter{*ast, ASTPrinter::Format::raw, {ASTPrinter::Info::data_type}}; \ diff --git a/tests/test_ASTNode.cpp b/tests/test_ASTNode.cpp index cda39283b3848f893a8bae7955d9ef57efc70839..1a2e5911898ac7d859ecd732916ea6bbf532d5fb 100644 --- a/tests/test_ASTNode.cpp +++ b/tests/test_ASTNode.cpp @@ -2,7 +2,7 @@ #include <catch2/matchers/catch_matchers_all.hpp> #include <language/PEGGrammar.hpp> -#include <language/ast/ASTBacktrace.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTNode.hpp> #include <language/node_processor/FakeProcessor.hpp> #include <utils/Demangle.hpp> @@ -18,16 +18,16 @@ TEST_CASE("ASTNode", "[language]") ExecutionPolicy exec_policy; #ifndef NDEBUG - ASTBacktrace::create(); + ASTExecutionStack::create(); REQUIRE_THROWS(ast_node.execute(exec_policy)); - ASTBacktrace::destroy(); + ASTExecutionStack::destroy(); #endif // NDEBUG ast_node.m_node_processor = std::make_unique<FakeProcessor>(); - ASTBacktrace::create(); + ASTExecutionStack::create(); REQUIRE_NOTHROW(ast_node.execute(exec_policy)); - ASTBacktrace::destroy(); + ASTExecutionStack::destroy(); } SECTION("name") diff --git a/tests/test_ASTNodeListProcessor.cpp b/tests/test_ASTNodeListProcessor.cpp index d858b313aa695d39912953712858bf1bbb5e257e..1cc41cb341301d109743387821021e24c731a1cb 100644 --- a/tests/test_ASTNodeListProcessor.cpp +++ b/tests/test_ASTNodeListProcessor.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> #include <language/ast/ASTNodeDeclarationToAffectationConverter.hpp> #include <language/ast/ASTNodeExpressionBuilder.hpp> @@ -36,9 +36,9 @@ true; ASTNodeExpressionBuilder{*ast}; ExecutionPolicy exec_policy; - ASTBacktrace::create(); + ASTExecutionStack::create(); ast->execute(exec_policy); - ASTBacktrace::destroy(); + ASTExecutionStack::destroy(); REQUIRE(ast->children[0]->is_type<language::integer>()); REQUIRE(ast->children[1]->is_type<language::true_kw>()); diff --git a/tests/test_AffectationProcessor.cpp b/tests/test_AffectationProcessor.cpp index 599a9457f4cb940f08409d47ebb7ef2c792e7478..20b2c215f12ff75ae60a28c47304e1603048c364 100644 --- a/tests/test_AffectationProcessor.cpp +++ b/tests/test_AffectationProcessor.cpp @@ -16,7 +16,7 @@ #include <utils/Stringify.hpp> #include <FixturesForBuiltinT.hpp> -#include <language/ast/ASTBacktrace.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/utils/BasicAffectationRegistrerFor.hpp> #include <pegtl/string_input.hpp> @@ -38,9 +38,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ @@ -100,9 +100,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ using namespace TAO_PEGTL_NAMESPACE; \ position use_position{10000, 1000, 10, "fixture"}; \ @@ -153,9 +153,9 @@ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ REQUIRE_THROWS_WITH(ast->execute(exec_policy), error_message); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ } // clazy:excludeall=non-pod-global-static diff --git a/tests/test_AffectationToStringProcessor.cpp b/tests/test_AffectationToStringProcessor.cpp index 68f97dfedd38da47c31a3aef9e64364e31e29a97..13e9485436f6889bf32f141f7a4b8c52e2c6ead8 100644 --- a/tests/test_AffectationToStringProcessor.cpp +++ b/tests/test_AffectationToStringProcessor.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeAffectationExpressionBuilder.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> @@ -33,9 +33,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ diff --git a/tests/test_AffectationToTupleProcessor.cpp b/tests/test_AffectationToTupleProcessor.cpp index b8e7010c9bcd748b168f048163619b7c61622edc..d77cd1dc62403be24a2b4908c2dd38c03b56ba60 100644 --- a/tests/test_AffectationToTupleProcessor.cpp +++ b/tests/test_AffectationToTupleProcessor.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeAffectationExpressionBuilder.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> @@ -33,9 +33,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ @@ -65,9 +65,9 @@ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ REQUIRE_THROWS_WITH(ast->execute(exec_policy), error_message); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ } // clazy:excludeall=non-pod-global-static diff --git a/tests/test_ArraySubscriptProcessor.cpp b/tests/test_ArraySubscriptProcessor.cpp index 48998c7d39999b5c45590a80054377d5057c4355..423d63aae8670a8170e338f02d20f1e54baf2813 100644 --- a/tests/test_ArraySubscriptProcessor.cpp +++ b/tests/test_ArraySubscriptProcessor.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeAffectationExpressionBuilder.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> @@ -34,9 +34,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ @@ -68,9 +68,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ }; \ \ REQUIRE_THROWS_WITH(eval(), error_message); \ diff --git a/tests/test_BinaryExpressionProcessor_arithmetic.cpp b/tests/test_BinaryExpressionProcessor_arithmetic.cpp index c1ce3de0e03f5d9b0b14e43ba71cc06fd4c70359..84be64a40d447d88612b106a7184ec7e242ebbd9 100644 --- a/tests/test_BinaryExpressionProcessor_arithmetic.cpp +++ b/tests/test_BinaryExpressionProcessor_arithmetic.cpp @@ -76,9 +76,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ using namespace TAO_PEGTL_NAMESPACE; \ position use_position{10000, 1000, 10, "fixture"}; \ @@ -154,9 +154,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ REQUIRE_THROWS_WITH(ast->execute(exec_policy), error_msg); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ } TEST_CASE("BinaryExpressionProcessor arithmetic", "[language]") diff --git a/tests/test_BinaryExpressionProcessor_shift.cpp b/tests/test_BinaryExpressionProcessor_shift.cpp index 190b9f2b26d39d831550b70fef528a06f2c4503e..b324735f26d5892c2164f393012abe930c8b06b1 100644 --- a/tests/test_BinaryExpressionProcessor_shift.cpp +++ b/tests/test_BinaryExpressionProcessor_shift.cpp @@ -64,9 +64,9 @@ fout << createSocketServer(0) << "\n";)"; ASTNodeExpressionBuilder{*ast}; ExecutionPolicy exec_policy; - ASTBacktrace::create(); + ASTExecutionStack::create(); ast->execute(exec_policy); - ASTBacktrace::destroy(); + ASTExecutionStack::destroy(); } REQUIRE(std::filesystem::exists(filename)); diff --git a/tests/test_BinaryExpressionProcessor_utils.hpp b/tests/test_BinaryExpressionProcessor_utils.hpp index 4b5deff94b6cab09ccdb72e6113dd5c2cc83d2e5..5a98115c387e885a893119bab7703f48cc4bbb08 100644 --- a/tests/test_BinaryExpressionProcessor_utils.hpp +++ b/tests/test_BinaryExpressionProcessor_utils.hpp @@ -1,8 +1,8 @@ #ifndef TEST_BINARY_EXPRESSION_PROCESSOR_UTILS_HPP #define TEST_BINARY_EXPRESSION_PROCESSOR_UTILS_HPP -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> #include <language/ast/ASTNodeDeclarationToAffectationConverter.hpp> @@ -31,9 +31,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ diff --git a/tests/test_BuiltinFunctionProcessor.cpp b/tests/test_BuiltinFunctionProcessor.cpp index de04b76016ad02a78130574129b74d95ca38ba94..c92fff9459b566ddb0a0b28fb615bbae1839ec86 100644 --- a/tests/test_BuiltinFunctionProcessor.cpp +++ b/tests/test_BuiltinFunctionProcessor.cpp @@ -1,8 +1,8 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_predicate.hpp> -#include <language/ast/ASTBacktrace.hpp> #include <language/ast/ASTBuilder.hpp> +#include <language/ast/ASTExecutionStack.hpp> #include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTNodeDataTypeBuilder.hpp> #include <language/ast/ASTNodeDeclarationToAffectationConverter.hpp> @@ -32,9 +32,9 @@ \ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ ast->execute(exec_policy); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ \ auto symbol_table = ast->m_symbol_table; \ \ @@ -71,9 +71,9 @@ ASTNodeExpressionBuilder{*ast}; \ ExecutionPolicy exec_policy; \ using namespace Catch::Matchers; \ - ASTBacktrace::create(); \ + ASTExecutionStack::create(); \ REQUIRE_THROWS_WITH(ast->execute(exec_policy), expected_error); \ - ASTBacktrace::destroy(); \ + ASTExecutionStack::destroy(); \ } // clazy:excludeall=non-pod-global-static