1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

LibJS: Convert new_declarative_environment() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-15 19:59:47 +00:00 committed by Andreas Kling
parent 4c732abed5
commit 107e06a396
6 changed files with 16 additions and 16 deletions

View file

@ -383,7 +383,7 @@ ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject
}
// 9.1.2.2 NewDeclarativeEnvironment ( E ), https://tc39.es/ecma262/#sec-newdeclarativeenvironment
DeclarativeEnvironment* new_declarative_environment(Environment& environment)
NonnullGCPtr<DeclarativeEnvironment> new_declarative_environment(Environment& environment)
{
auto& heap = environment.heap();

View file

@ -19,7 +19,7 @@
namespace JS {
DeclarativeEnvironment* new_declarative_environment(Environment&);
NonnullGCPtr<DeclarativeEnvironment> new_declarative_environment(Environment&);
ObjectEnvironment* new_object_environment(Object&, bool is_with_environment, Environment*);
FunctionEnvironment* new_function_environment(ECMAScriptFunctionObject&, Object* new_target);
PrivateEnvironment* new_private_environment(VM& vm, PrivateEnvironment* outer);

View file

@ -391,7 +391,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
arguments_object_needed = false;
}
Environment* environment;
GCPtr<Environment> environment;
if (is_strict_mode() || !has_parameter_expressions) {
environment = callee_context.lexical_environment;
@ -477,7 +477,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
}));
}
Environment* var_environment;
GCPtr<Environment> var_environment;
HashTable<FlyString> instantiated_var_names;
if (scope_body)
@ -531,7 +531,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
});
}
Environment* lex_environment;
GCPtr<Environment> lex_environment;
// 30. If strict is false, then
if (!is_strict_mode()) {
@ -578,9 +578,9 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
}
if (is<DeclarativeEnvironment>(*lex_environment))
static_cast<DeclarativeEnvironment*>(lex_environment)->shrink_to_fit();
static_cast<DeclarativeEnvironment*>(lex_environment.ptr())->shrink_to_fit();
if (is<DeclarativeEnvironment>(*var_environment))
static_cast<DeclarativeEnvironment*>(var_environment)->shrink_to_fit();
static_cast<DeclarativeEnvironment*>(var_environment.ptr())->shrink_to_fit();
return {};
}

View file

@ -127,7 +127,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
// NOTE: This would be unused due to step 11 and is omitted for that reason.
// 5. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]).
Environment* lexical_environment = new_declarative_environment(eval_realm.global_environment());
Environment* lexical_environment = new_declarative_environment(eval_realm.global_environment()).ptr();
// 6. Let varEnv be evalRealm.[[GlobalEnv]].
Environment* variable_environment = &eval_realm.global_environment();