LibJS: Rename some variables from "script body" to "script"

This is an editorial change in the ECMA-262 spec.

See: https://github.com/tc39/ecma262/commit/38a2584
This commit is contained in:
Linus Groh 2022-05-01 01:13:33 +02:00
parent acda12597a
commit 7767f9be37
Notes: sideshowbarker 2024-07-17 11:24:31 +09:00
2 changed files with 11 additions and 11 deletions

View file

@ -77,17 +77,17 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record)
// 10. Push scriptContext onto the execution context stack; scriptContext is now the running execution context.
TRY(vm.push_execution_context(script_context, global_object));
// 11. Let scriptBody be scriptRecord.[[ECMAScriptCode]].
auto& script_body = script_record.parse_node();
// 11. Let script be scriptRecord.[[ECMAScriptCode]].
auto& script = script_record.parse_node();
// 12. Let result be GlobalDeclarationInstantiation(scriptBody, globalEnv).
auto instantiation_result = script_body.global_declaration_instantiation(*this, global_object, global_environment);
// 12. Let result be GlobalDeclarationInstantiation(script, globalEnv).
auto instantiation_result = script.global_declaration_instantiation(*this, global_object, global_environment);
Completion result = instantiation_result.is_throw_completion() ? instantiation_result.throw_completion() : normal_completion({});
// 13. If result.[[Type]] is normal, then
if (result.type() == Completion::Type::Normal) {
// a. Set result to the result of evaluating scriptBody.
result = script_body.execute(*this, global_object);
// a. Set result to the result of evaluating script.
result = script.execute(*this, global_object);
}
// 14. If result.[[Type]] is normal and result.[[Value]] is empty, then

View file

@ -15,16 +15,16 @@ namespace JS {
// 16.1.5 ParseScript ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parse-script
Result<NonnullRefPtr<Script>, Vector<Parser::Error>> Script::parse(StringView source_text, Realm& realm, StringView filename, HostDefined* host_defined, size_t line_number_offset)
{
// 1. Let body be ParseText(sourceText, Script).
// 1. Let script be ParseText(sourceText, Script).
auto parser = Parser(Lexer(source_text, filename, line_number_offset));
auto body = parser.parse_program();
auto script = parser.parse_program();
// 2. If body is a List of errors, return body.
// 2. If script is a List of errors, return body.
if (parser.has_errors())
return parser.errors();
// 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: body, [[HostDefined]]: hostDefined }.
return adopt_ref(*new Script(realm, filename, move(body), host_defined));
// 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }.
return adopt_ref(*new Script(realm, filename, move(script), host_defined));
}
Script::Script(Realm& realm, StringView filename, NonnullRefPtr<Program> parse_node, HostDefined* host_defined)