1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

LibJS: Move AST node stack from VM to Interpreter

This commit is contained in:
Andreas Kling 2021-03-21 12:18:56 +01:00
parent b3b8c01ebf
commit 1603623772
7 changed files with 29 additions and 19 deletions

View file

@ -26,6 +26,7 @@
#include <AK/String.h>
#include <LibJS/AST.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Exception.h>
#include <LibJS/Runtime/VM.h>
@ -34,7 +35,8 @@ namespace JS {
Exception::Exception(Value value)
: m_value(value)
{
auto& call_stack = vm().call_stack();
auto& vm = this->vm();
auto& call_stack = vm.call_stack();
for (ssize_t i = call_stack.size() - 1; i >= 0; --i) {
String function_name = call_stack[i]->function_name;
if (function_name.is_empty())
@ -42,11 +44,13 @@ Exception::Exception(Value value)
m_trace.append(function_name);
}
auto& node_stack = vm().node_stack();
for (ssize_t i = node_stack.size() - 1; i >= 0; --i) {
auto* node = node_stack[i];
VERIFY(node);
m_source_ranges.append(node->source_range());
if (auto* interpreter = vm.interpreter_if_exists()) {
auto& node_stack = interpreter->node_stack();
for (ssize_t i = node_stack.size() - 1; i >= 0; --i) {
auto* node = node_stack[i];
VERIFY(node);
m_source_ranges.append(node->source_range());
}
}
}