mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibJS: Add spec comments to get_this_environment()
This commit is contained in:
parent
c6638f53c0
commit
19ea0d8dcf
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
|
// 9.4.3 GetThisEnvironment ( ), https://tc39.es/ecma262/#sec-getthisenvironment
|
||||||
Environment& get_this_environment(VM& vm)
|
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()) {
|
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())
|
if (env->has_this_binding())
|
||||||
return *env;
|
return *env;
|
||||||
|
|
||||||
|
// c. Let outer be env.[[OuterEnv]].
|
||||||
|
// d. Assert: outer is not null.
|
||||||
|
// e. Set env to outer.
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue