From 7767f9be370974ac192ba1d208aace00e8422cd5 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 1 May 2022 01:13:33 +0200 Subject: [PATCH] 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 --- Userland/Libraries/LibJS/Interpreter.cpp | 12 ++++++------ Userland/Libraries/LibJS/Script.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp index 19ffcca15e..3e91438b25 100644 --- a/Userland/Libraries/LibJS/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Interpreter.cpp @@ -77,17 +77,17 @@ ThrowCompletionOr 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 diff --git a/Userland/Libraries/LibJS/Script.cpp b/Userland/Libraries/LibJS/Script.cpp index c9104cc7c4..d5a76c4def 100644 --- a/Userland/Libraries/LibJS/Script.cpp +++ b/Userland/Libraries/LibJS/Script.cpp @@ -15,16 +15,16 @@ namespace JS { // 16.1.5 ParseScript ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parse-script Result, Vector> 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 parse_node, HostDefined* host_defined)