LibJS: Add spec comments to get_this_environment()
This commit is contained in:
parent
c6638f53c0
commit
19ea0d8dcf
Notes:
sideshowbarker
2024-07-17 11:29:41 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/19ea0d8dcf Pull-request: https://github.com/SerenityOS/serenity/pull/16455
1 changed files with 8 additions and 0 deletions
|
@ -445,9 +445,17 @@ PrivateEnvironment* new_private_environment(VM& vm, PrivateEnvironment* outer)
|
|||
// 9.4.3 GetThisEnvironment ( ), https://tc39.es/ecma262/#sec-getthisenvironment
|
||||
Environment& get_this_environment(VM& vm)
|
||||
{
|
||||
// 1. Let env be the running execution context's LexicalEnvironment.
|
||||
// 2. Repeat,
|
||||
for (auto* env = vm.lexical_environment(); env; env = env->outer_environment()) {
|
||||
// a. Let exists be env.HasThisBinding().
|
||||
// b. If exists is true, return env.
|
||||
if (env->has_this_binding())
|
||||
return *env;
|
||||
|
||||
// c. Let outer be env.[[OuterEnv]].
|
||||
// d. Assert: outer is not null.
|
||||
// e. Set env to outer.
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue