From d4d80bc9a9c3595651002cc4a9905a55cd1df0a3 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Sun, 10 Dec 2023 23:00:25 +0100
Subject: [PATCH] Rename ASTBacktrace to ASTExecutionStack

- add access to the current execution node
- store data file to a string
---
 src/language/PugsParser.cpp                   | 24 ++++--
 src/language/ast/ASTBacktrace.cpp             | 63 ----------------
 src/language/ast/ASTBacktrace.hpp             | 57 --------------
 src/language/ast/ASTBuilder.cpp               |  1 -
 src/language/ast/ASTExecutionStack.cpp        | 75 +++++++++++++++++++
 src/language/ast/ASTExecutionStack.hpp        | 68 +++++++++++++++++
 src/language/ast/ASTNode.hpp                  | 10 +--
 src/language/ast/CMakeLists.txt               |  2 +-
 src/language/modules/DevUtilsModule.cpp       | 11 +--
 src/utils/SignalManager.cpp                   |  8 +-
 tests/test_ASTModulesImporter.cpp             |  6 +-
 tests/test_ASTNode.cpp                        | 10 +--
 tests/test_ASTNodeListProcessor.cpp           |  6 +-
 tests/test_AffectationProcessor.cpp           | 14 ++--
 tests/test_AffectationToStringProcessor.cpp   |  6 +-
 tests/test_AffectationToTupleProcessor.cpp    | 10 +--
 tests/test_ArraySubscriptProcessor.cpp        | 10 +--
 ...t_BinaryExpressionProcessor_arithmetic.cpp |  8 +-
 .../test_BinaryExpressionProcessor_shift.cpp  |  4 +-
 .../test_BinaryExpressionProcessor_utils.hpp  |  6 +-
 tests/test_BuiltinFunctionProcessor.cpp       | 10 +--
 21 files changed, 221 insertions(+), 188 deletions(-)
 delete mode 100644 src/language/ast/ASTBacktrace.cpp
 delete mode 100644 src/language/ast/ASTBacktrace.hpp
 create mode 100644 src/language/ast/ASTExecutionStack.cpp
 create mode 100644 src/language/ast/ASTExecutionStack.hpp

diff --git a/src/language/PugsParser.cpp b/src/language/PugsParser.cpp
index fbf7b60a2..74c35b827 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 18442ec43..000000000
--- 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 6ea9a5364..000000000
--- 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 d7d8dbc1f..b15b79a04 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 000000000..922e40e32
--- /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 000000000..3fe6fbece
--- /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 19b43a927..612b4d0c4 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 63e208c2b..cd2f89636 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 7685443b0..7df6e847e 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 62505d7b4..4b2046a98 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 f70fa9b2b..24557c449 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 cda39283b..1a2e59118 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 d858b313a..1cc41cb34 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 599a9457f..20b2c215f 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 68f97dfed..13e948543 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 b8e7010c9..d77cd1dc6 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 48998c7d3..423d63aae 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 c1ce3de0e..84be64a40 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 190b9f2b2..b324735f2 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 4b5deff94..5a98115c3 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 de04b7601..c92fff945 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
-- 
GitLab