1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibJS: Convert initialize_binding() to ThrowCompletionOr

Also add spec step comments to it while we're here.
This commit is contained in:
Linus Groh 2021-10-09 19:16:24 +01:00
parent 2691c65639
commit ae397541fb
12 changed files with 50 additions and 36 deletions

View file

@ -630,8 +630,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
} else {
if (!MUST(variable_environment->has_binding(function_name))) {
MUST(variable_environment->create_mutable_binding(global_object, function_name, true));
variable_environment->initialize_binding(global_object, function_name, js_undefined());
VERIFY(!vm.exception());
MUST(variable_environment->initialize_binding(global_object, function_name, js_undefined()));
}
}
@ -704,12 +703,12 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (!binding_exists) {
TRY(variable_environment->create_mutable_binding(global_object, declaration.name(), true));
variable_environment->initialize_binding(global_object, declaration.name(), function);
TRY(variable_environment->initialize_binding(global_object, declaration.name(), function));
} else {
variable_environment->set_mutable_binding(global_object, declaration.name(), function, false);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
}
if (auto* exception = vm.exception())
return throw_completion(exception->value());
}
}
@ -723,9 +722,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (!binding_exists) {
TRY(variable_environment->create_mutable_binding(global_object, var_name, true));
variable_environment->initialize_binding(global_object, var_name, js_undefined());
if (auto* exception = vm.exception())
return throw_completion(exception->value());
TRY(variable_environment->initialize_binding(global_object, var_name, js_undefined()));
}
}
}