Skip to content

Commit 40cc388

Browse files
Lubrsilinusg
authored andcommitted
LibJS: Move ExecutionContext function implementations out of line
1 parent 4311c21 commit 40cc388

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

Userland/Libraries/LibJS/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ set(SOURCES
8181
Runtime/ErrorConstructor.cpp
8282
Runtime/ErrorPrototype.cpp
8383
Runtime/ErrorTypes.cpp
84+
Runtime/ExecutionContext.cpp
8485
Runtime/FinalizationRegistry.cpp
8586
Runtime/FinalizationRegistryConstructor.cpp
8687
Runtime/FinalizationRegistryPrototype.cpp
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
3+
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
4+
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
5+
*
6+
* SPDX-License-Identifier: BSD-2-Clause
7+
*/
8+
9+
#include <LibJS/Runtime/ExecutionContext.h>
10+
11+
namespace JS {
12+
13+
ExecutionContext::ExecutionContext(Heap& heap)
14+
: arguments(heap)
15+
{
16+
}
17+
18+
ExecutionContext::ExecutionContext(MarkedVector<Value> existing_arguments)
19+
: arguments(move(existing_arguments))
20+
{
21+
}
22+
23+
ExecutionContext ExecutionContext::copy() const
24+
{
25+
ExecutionContext copy { arguments };
26+
27+
copy.function = function;
28+
copy.realm = realm;
29+
copy.script_or_module = script_or_module;
30+
copy.lexical_environment = lexical_environment;
31+
copy.variable_environment = variable_environment;
32+
copy.private_environment = private_environment;
33+
copy.current_node = current_node;
34+
copy.function_name = function_name;
35+
copy.this_value = this_value;
36+
copy.is_strict_mode = is_strict_mode;
37+
38+
return copy;
39+
}
40+
41+
}

Userland/Libraries/LibJS/Runtime/ExecutionContext.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
33
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
4+
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
45
*
56
* SPDX-License-Identifier: BSD-2-Clause
67
*/
@@ -21,34 +22,12 @@ using ScriptOrModule = Variant<Empty, NonnullGCPtr<Script>, NonnullGCPtr<Module>
2122

2223
// 9.4 Execution Contexts, https://tc39.es/ecma262/#sec-execution-contexts
2324
struct ExecutionContext {
24-
explicit ExecutionContext(Heap& heap)
25-
: arguments(heap)
26-
{
27-
}
25+
explicit ExecutionContext(Heap& heap);
2826

29-
[[nodiscard]] ExecutionContext copy() const
30-
{
31-
ExecutionContext copy { arguments };
32-
33-
copy.function = function;
34-
copy.realm = realm;
35-
copy.script_or_module = script_or_module;
36-
copy.lexical_environment = lexical_environment;
37-
copy.variable_environment = variable_environment;
38-
copy.private_environment = private_environment;
39-
copy.current_node = current_node;
40-
copy.function_name = function_name;
41-
copy.this_value = this_value;
42-
copy.is_strict_mode = is_strict_mode;
43-
44-
return copy;
45-
}
27+
[[nodiscard]] ExecutionContext copy() const;
4628

4729
private:
48-
explicit ExecutionContext(MarkedVector<Value> existing_arguments)
49-
: arguments(move(existing_arguments))
50-
{
51-
}
30+
explicit ExecutionContext(MarkedVector<Value> existing_arguments);
5231

5332
public:
5433
FunctionObject* function { nullptr }; // [[Function]]

0 commit comments

Comments
 (0)