diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-11 20:55:11 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-12 11:10:20 +0100 |
commit | 332946ab4f77a16de6be7f9148817938c00e7ddd (patch) | |
tree | cf645fd8670b38f3d446846fcdbf8f534ade11e9 /Userland/Libraries/LibJS/Runtime | |
parent | 15c33477e4051196b199268c55f6c1d4fe098f1d (diff) | |
download | serenity-332946ab4f77a16de6be7f9148817938c00e7ddd.zip |
LibJS: Prepare ExecutionContext to store the current Realm Record
Also add VM::current_realm() to retrieve it, similar to all the other
getters (running_execution_context() et al.).
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/VM.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 3134bc7d02..8d5708f3da 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -42,6 +42,7 @@ struct ScopeFrame { bool pushed_environment { false }; }; +// 9.4 Execution Contexts, https://tc39.es/ecma262/#sec-execution-contexts struct ExecutionContext { explicit ExecutionContext(Heap& heap) : arguments(heap) @@ -56,6 +57,7 @@ struct ExecutionContext { Object* arguments_object { nullptr }; Environment* lexical_environment { nullptr }; Environment* variable_environment { nullptr }; + Realm* realm { nullptr }; bool is_strict_mode { false }; }; @@ -146,6 +148,11 @@ public: Environment const* variable_environment() const { return running_execution_context().variable_environment; } Environment* variable_environment() { return running_execution_context().variable_environment; } + // https://tc39.es/ecma262/#current-realm + // The value of the Realm component of the running execution context is also called the current Realm Record. + Realm const* current_realm() const { return running_execution_context().realm; } + Realm* current_realm() { return running_execution_context().realm; } + bool in_strict_mode() const; template<typename Callback> |