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 /Userland/js.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 'Userland/js.cpp')
-rw-r--r-- | Userland/js.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp index c455ead699..97605d10f1 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -470,32 +470,32 @@ public: virtual JS::Value log() override { - puts(interpreter().vm().join_arguments().characters()); + puts(vm().join_arguments().characters()); return JS::js_undefined(); } virtual JS::Value info() override { - printf("(i) %s\n", interpreter().vm().join_arguments().characters()); + printf("(i) %s\n", vm().join_arguments().characters()); return JS::js_undefined(); } virtual JS::Value debug() override { printf("\033[36;1m"); - puts(interpreter().vm().join_arguments().characters()); + puts(vm().join_arguments().characters()); printf("\033[0m"); return JS::js_undefined(); } virtual JS::Value warn() override { printf("\033[33;1m"); - puts(interpreter().vm().join_arguments().characters()); + puts(vm().join_arguments().characters()); printf("\033[0m"); return JS::js_undefined(); } virtual JS::Value error() override { printf("\033[31;1m"); - puts(interpreter().vm().join_arguments().characters()); + puts(vm().join_arguments().characters()); printf("\033[0m"); return JS::js_undefined(); } @@ -507,7 +507,7 @@ public: } virtual JS::Value trace() override { - puts(interpreter().vm().join_arguments().characters()); + puts(vm().join_arguments().characters()); auto trace = get_trace(); for (auto& function_name : trace) { if (function_name.is_empty()) @@ -518,14 +518,14 @@ public: } virtual JS::Value count() override { - auto label = interpreter().argument_count() ? interpreter().argument(0).to_string_without_side_effects() : "default"; + auto label = vm().argument_count() ? vm().argument(0).to_string_without_side_effects() : "default"; auto counter_value = m_console.counter_increment(label); printf("%s: %u\n", label.characters(), counter_value); return JS::js_undefined(); } virtual JS::Value count_reset() override { - auto label = interpreter().argument_count() ? interpreter().argument(0).to_string_without_side_effects() : "default"; + auto label = vm().argument_count() ? vm().argument(0).to_string_without_side_effects() : "default"; if (m_console.counter_reset(label)) { printf("%s: 0\n", label.characters()); } else { @@ -564,8 +564,8 @@ int main(int argc, char** argv) if (script_path == nullptr) { s_print_last_result = true; interpreter = JS::Interpreter::create<ReplObject>(*vm); - ReplConsoleClient console_client(interpreter->console()); - interpreter->console().set_client(console_client); + ReplConsoleClient console_client(interpreter->global_object().console()); + interpreter->global_object().console().set_client(console_client); interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation); interpreter->vm().set_underscore_is_last_value(true); @@ -846,8 +846,8 @@ int main(int argc, char** argv) repl(*interpreter); } else { interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm); - ReplConsoleClient console_client(interpreter->console()); - interpreter->console().set_client(console_client); + ReplConsoleClient console_client(interpreter->global_object().console()); + interpreter->global_object().console().set_client(console_client); interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation); signal(SIGINT, [](int) { |