mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:02:07 +00:00
LibJS: Convert get_binding_value() to ThrowCompletionOr
Also add spec step comments to it while we're here.
This commit is contained in:
parent
7652138ce0
commit
f35e268024
11 changed files with 43 additions and 27 deletions
|
@ -168,7 +168,7 @@ Value FunctionDeclaration::execute(Interpreter& interpreter, GlobalObject& globa
|
|||
// Perform special annexB steps see step 3 of: https://tc39.es/ecma262/#sec-web-compat-functiondeclarationinstantiation
|
||||
auto* variable_environment = interpreter.vm().running_execution_context().variable_environment;
|
||||
auto* lexical_environment = interpreter.vm().running_execution_context().lexical_environment;
|
||||
auto function_object = lexical_environment->get_binding_value(global_object, name(), false);
|
||||
auto function_object = MUST(lexical_environment->get_binding_value(global_object, name(), false));
|
||||
MUST(variable_environment->set_mutable_binding(global_object, name(), function_object, false));
|
||||
}
|
||||
|
||||
|
@ -573,9 +573,7 @@ Value ForStatement::execute(Interpreter& interpreter, GlobalObject& global_objec
|
|||
auto* this_iteration_env = new_declarative_environment(*outer);
|
||||
for (auto& name : let_declarations) {
|
||||
MUST(this_iteration_env->create_mutable_binding(global_object, name, false));
|
||||
auto last_value = last_iteration_env->get_binding_value(global_object, name, true);
|
||||
if (auto* exception = interpreter.exception())
|
||||
return throw_completion(exception->value());
|
||||
auto last_value = TRY(last_iteration_env->get_binding_value(global_object, name, true));
|
||||
VERIFY(!last_value.is_empty());
|
||||
MUST(this_iteration_env->initialize_binding(global_object, name, last_value));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue