LibJS: Track source positions all the way down to exceptions

This makes exceptions have a trace of source positions too, which could
probably be helpful in making fancier error tracebacks.
This commit is contained in:
AnotherTest 2020-12-28 20:45:22 +03:30 committed by Andreas Kling
commit b34b681811
Notes: sideshowbarker 2024-07-19 00:28:37 +09:00
10 changed files with 647 additions and 245 deletions

View file

@ -25,6 +25,7 @@
*/
#include <AK/String.h>
#include <LibJS/AST.h>
#include <LibJS/Runtime/Exception.h>
#include <LibJS/Runtime/VM.h>
@ -40,6 +41,13 @@ Exception::Exception(Value value)
function_name = "<anonymous>";
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];
ASSERT(node);
m_source_ranges.append(node->source_range());
}
}
Exception::~Exception()