1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibJS/Bytecode: Leave for in and for of with right completion value

14 new passes on test262. :^)
This commit is contained in:
Andreas Kling 2023-07-05 14:07:20 +02:00
parent 7430dee5cf
commit b14032bbfa

View file

@ -2705,9 +2705,15 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
// 1. Assert: iterationKind is iterate.
// 2. Return ? IteratorClose(iteratorRecord, status).
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
// l. Let result be the result of evaluating stmt.
TRY(body.generate_bytecode(generator));
auto result_register = generator.allocate_register();
if (!generator.is_current_block_terminated())
generator.emit<Bytecode::Op::Store>(result_register);
// m. Set the running execution context's LexicalEnvironment to oldEnv.
if (has_lexical_binding)
generator.end_variable_scope();
@ -2730,6 +2736,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
generator.switch_to_basic_block(loop_end);
generator.emit<Bytecode::Op::Load>(result_register);
return {};
}