diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index a25b443cf1..22c64abebe 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -81,6 +81,7 @@ set(SOURCES Runtime/ErrorConstructor.cpp Runtime/ErrorPrototype.cpp Runtime/ErrorTypes.cpp + Runtime/ExecutionContext.cpp Runtime/FinalizationRegistry.cpp Runtime/FinalizationRegistryConstructor.cpp Runtime/FinalizationRegistryPrototype.cpp diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp new file mode 100644 index 0000000000..51a3ff21df --- /dev/null +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2020-2021, Linus Groh + * Copyright (c) 2022, Luke Wilde + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace JS { + +ExecutionContext::ExecutionContext(Heap& heap) + : arguments(heap) +{ +} + +ExecutionContext::ExecutionContext(MarkedVector existing_arguments) + : arguments(move(existing_arguments)) +{ +} + +ExecutionContext ExecutionContext::copy() const +{ + ExecutionContext copy { arguments }; + + copy.function = function; + copy.realm = realm; + copy.script_or_module = script_or_module; + copy.lexical_environment = lexical_environment; + copy.variable_environment = variable_environment; + copy.private_environment = private_environment; + copy.current_node = current_node; + copy.function_name = function_name; + copy.this_value = this_value; + copy.is_strict_mode = is_strict_mode; + + return copy; +} + +} diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h index cae575bdd1..3ac2f88521 100644 --- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h @@ -1,6 +1,7 @@ /* * Copyright (c) 2020-2021, Andreas Kling * Copyright (c) 2020-2021, Linus Groh + * Copyright (c) 2022, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause */ @@ -21,34 +22,12 @@ using ScriptOrModule = Variant, NonnullGCPtr // 9.4 Execution Contexts, https://tc39.es/ecma262/#sec-execution-contexts struct ExecutionContext { - explicit ExecutionContext(Heap& heap) - : arguments(heap) - { - } + explicit ExecutionContext(Heap& heap); - [[nodiscard]] ExecutionContext copy() const - { - ExecutionContext copy { arguments }; - - copy.function = function; - copy.realm = realm; - copy.script_or_module = script_or_module; - copy.lexical_environment = lexical_environment; - copy.variable_environment = variable_environment; - copy.private_environment = private_environment; - copy.current_node = current_node; - copy.function_name = function_name; - copy.this_value = this_value; - copy.is_strict_mode = is_strict_mode; - - return copy; - } + [[nodiscard]] ExecutionContext copy() const; private: - explicit ExecutionContext(MarkedVector existing_arguments) - : arguments(move(existing_arguments)) - { - } + explicit ExecutionContext(MarkedVector existing_arguments); public: FunctionObject* function { nullptr }; // [[Function]]