diff options
author | Andreas Kling <kling@serenityos.org> | 2020-09-29 21:15:06 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-29 21:15:06 +0200 |
commit | e4bda2e1e70efed986745431e132b6608586b991 (patch) | |
tree | 53766bacebe2def064214a32dc21be84416954f7 /Libraries/LibJS/Console.cpp | |
parent | a9335eea1c96d50140e46b8e0361e01b87c09ce2 (diff) | |
download | serenity-e4bda2e1e70efed986745431e132b6608586b991.zip |
LibJS: Move Console from Interpreter to GlobalObject
Each JS global object has its own "console", so it makes more sense to
store it in GlobalObject.
We'll need some smartness later to bundle up console messages from all
the different frames that make up a page later, but this works for now.
Diffstat (limited to 'Libraries/LibJS/Console.cpp')
-rw-r--r-- | Libraries/LibJS/Console.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Libraries/LibJS/Console.cpp b/Libraries/LibJS/Console.cpp index eff5bec2e9..4bddbcdfab 100644 --- a/Libraries/LibJS/Console.cpp +++ b/Libraries/LibJS/Console.cpp @@ -26,12 +26,12 @@ */ #include <LibJS/Console.h> -#include <LibJS/Interpreter.h> +#include <LibJS/Runtime/GlobalObject.h> namespace JS { -Console::Console(Interpreter& interpreter) - : m_interpreter(interpreter) +Console::Console(GlobalObject& global_object) + : m_global_object(global_object) { } @@ -120,10 +120,15 @@ bool Console::counter_reset(String label) return true; } +VM& ConsoleClient::vm() +{ + return global_object().vm(); +} + Vector<String> ConsoleClient::get_trace() const { Vector<String> trace; - auto& call_stack = m_console.interpreter().vm().call_stack(); + auto& call_stack = m_console.global_object().vm().call_stack(); // -2 to skip the console.trace() call frame for (ssize_t i = call_stack.size() - 2; i >= 0; --i) trace.append(call_stack[i].function_name); |