summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ExecutionContext.h
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-11-09 20:39:22 +0200
committerLinus Groh <mail@linusgroh.de>2021-11-10 08:48:27 +0000
commit681787de7656a31f4f010f93b8319e444b7014fa (patch)
tree0f4b2fdb817ee1213413498b655054c34bc11c99 /Userland/Libraries/LibJS/Runtime/ExecutionContext.h
parent05c3320da366ba27560e77c010feffdc9afc4b72 (diff)
downloadserenity-681787de7656a31f4f010f93b8319e444b7014fa.zip
LibJS: Add support for async functions
This commit adds support for the most bare bones version of async functions, support for async generator functions, async arrow functions and await expressions are TODO.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ExecutionContext.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ExecutionContext.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h
index 344205b917..5e0ce04953 100644
--- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h
+++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h
@@ -22,6 +22,30 @@ struct ExecutionContext {
{
}
+ [[nodiscard]] ExecutionContext copy() const
+ {
+ ExecutionContext copy { arguments.copy() };
+
+ copy.function = function;
+ copy.realm = realm;
+ 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;
+ }
+
+private:
+ explicit ExecutionContext(MarkedValueList existing_arguments)
+ : arguments(move(existing_arguments))
+ {
+ }
+
+public:
FunctionObject* function { nullptr }; // [[Function]]
Realm* realm { nullptr }; // [[Realm]]
Environment* lexical_environment { nullptr }; // [[LexicalEnvironment]]