mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
LibJS: Remove a bunch of gratuitous JS namespace qualifiers
This commit is contained in:
parent
f2c02077ba
commit
5b48912d35
17 changed files with 66 additions and 65 deletions
|
@ -580,13 +580,13 @@ ThrowCompletionOr<Value> perform_eval(Value x, GlobalObject& caller_realm, Calle
|
|||
Optional<Value> eval_result;
|
||||
|
||||
if (auto* bytecode_interpreter = Bytecode::Interpreter::current()) {
|
||||
auto executable_result = JS::Bytecode::Generator::generate(program);
|
||||
auto executable_result = Bytecode::Generator::generate(program);
|
||||
if (executable_result.is_error())
|
||||
return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string());
|
||||
|
||||
auto executable = executable_result.release_value();
|
||||
executable->name = "eval"sv;
|
||||
if (JS::Bytecode::g_dump_bytecode)
|
||||
if (Bytecode::g_dump_bytecode)
|
||||
executable->dump();
|
||||
eval_result = TRY(bytecode_interpreter->run(*executable));
|
||||
// Turn potentially empty JS::Value from the bytecode interpreter into an empty Optional
|
||||
|
@ -1009,7 +1009,7 @@ Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObje
|
|||
// 3. Perform map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]: false, [[Configurable]]: true }).
|
||||
object->parameter_map().define_native_accessor(
|
||||
PropertyKey { index },
|
||||
[&environment, name](VM&, GlobalObject& global_object_getter) -> JS::ThrowCompletionOr<Value> {
|
||||
[&environment, name](VM&, GlobalObject& global_object_getter) -> ThrowCompletionOr<Value> {
|
||||
return MUST(environment.get_binding_value(global_object_getter, name, false));
|
||||
},
|
||||
[&environment, name](VM& vm, GlobalObject& global_object_setter) {
|
||||
|
|
|
@ -777,19 +777,19 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
|||
if (bytecode_interpreter) {
|
||||
if (!m_bytecode_executable) {
|
||||
auto compile = [&](auto& node, auto kind, auto name) -> ThrowCompletionOr<NonnullOwnPtr<Bytecode::Executable>> {
|
||||
auto executable_result = JS::Bytecode::Generator::generate(node, kind);
|
||||
auto executable_result = Bytecode::Generator::generate(node, kind);
|
||||
if (executable_result.is_error())
|
||||
return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string());
|
||||
|
||||
auto bytecode_executable = executable_result.release_value();
|
||||
bytecode_executable->name = name;
|
||||
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline();
|
||||
auto& passes = Bytecode::Interpreter::optimization_pipeline();
|
||||
passes.perform(*bytecode_executable);
|
||||
if constexpr (JS_BYTECODE_DEBUG) {
|
||||
dbgln("Optimisation passes took {}us", passes.elapsed());
|
||||
dbgln("Compiled Bytecode::Block for function '{}':", m_name);
|
||||
}
|
||||
if (JS::Bytecode::g_dump_bytecode)
|
||||
if (Bytecode::g_dump_bytecode)
|
||||
bytecode_executable->dump();
|
||||
|
||||
return bytecode_executable;
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
FinalizationRegistry::FinalizationRegistry(Realm& realm, JS::JobCallback cleanup_callback, Object& prototype)
|
||||
FinalizationRegistry::FinalizationRegistry(Realm& realm, JobCallback cleanup_callback, Object& prototype)
|
||||
: Object(prototype)
|
||||
, WeakContainer(heap())
|
||||
, m_realm(JS::make_handle(realm))
|
||||
, m_realm(make_handle(realm))
|
||||
, m_cleanup_callback(move(cleanup_callback))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class FinalizationRegistry final
|
|||
JS_OBJECT(FinalizationRegistry, Object);
|
||||
|
||||
public:
|
||||
explicit FinalizationRegistry(Realm&, JS::JobCallback, Object& prototype);
|
||||
explicit FinalizationRegistry(Realm&, JobCallback, Object& prototype);
|
||||
virtual ~FinalizationRegistry() override = default;
|
||||
|
||||
void add_finalization_record(Cell& target, Value held_value, Object* unregister_token);
|
||||
|
@ -41,7 +41,7 @@ private:
|
|||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
Handle<Realm> m_realm;
|
||||
JS::JobCallback m_cleanup_callback;
|
||||
JobCallback m_cleanup_callback;
|
||||
|
||||
struct FinalizationRecord {
|
||||
Cell* target { nullptr };
|
||||
|
|
|
@ -72,10 +72,10 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
auto previous_generated_value = TRY(generated_value(m_previous_value));
|
||||
|
||||
auto result = Object::create(global_object, global_object.object_prototype());
|
||||
result->define_direct_property("value", previous_generated_value, JS::default_attributes);
|
||||
result->define_direct_property("value", previous_generated_value, default_attributes);
|
||||
|
||||
if (m_done) {
|
||||
result->define_direct_property("done", Value(true), JS::default_attributes);
|
||||
result->define_direct_property("done", Value(true), default_attributes);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
if (!next_block) {
|
||||
// The generator has terminated, now we can simply return done=true.
|
||||
m_done = true;
|
||||
result->define_direct_property("done", Value(true), JS::default_attributes);
|
||||
result->define_direct_property("done", Value(true), default_attributes);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
|
||||
m_previous_value = TRY(next_result);
|
||||
|
||||
result->define_direct_property("value", TRY(generated_value(m_previous_value)), JS::default_attributes);
|
||||
result->define_direct_property("done", Value(m_done), JS::default_attributes);
|
||||
result->define_direct_property("value", TRY(generated_value(m_previous_value)), default_attributes);
|
||||
result->define_direct_property("done", Value(m_done), default_attributes);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval)
|
|||
}
|
||||
|
||||
// 19.2.6.1.1 Encode ( string, unescapedSet ), https://tc39.es/ecma262/#sec-encode
|
||||
static ThrowCompletionOr<String> encode([[maybe_unused]] JS::GlobalObject& global_object, String const& string, StringView unescaped_set)
|
||||
static ThrowCompletionOr<String> encode(GlobalObject& global_object, String const& string, StringView unescaped_set)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto utf16_string = Utf16String(string);
|
||||
|
@ -544,7 +544,7 @@ static ThrowCompletionOr<String> encode([[maybe_unused]] JS::GlobalObject& globa
|
|||
}
|
||||
|
||||
// 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode
|
||||
static ThrowCompletionOr<String> decode(JS::GlobalObject& global_object, String const& string, StringView reserved_set)
|
||||
static ThrowCompletionOr<String> decode(GlobalObject& global_object, String const& string, StringView reserved_set)
|
||||
{
|
||||
StringBuilder decoded_builder;
|
||||
auto code_point_start_offset = 0u;
|
||||
|
|
|
@ -117,7 +117,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o
|
|||
return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidLanguageTag, code);
|
||||
|
||||
// c. Return ! CanonicalizeUnicodeLocaleId(code).
|
||||
auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
|
||||
auto canonicalized_tag = Intl::canonicalize_unicode_locale_id(*locale_id);
|
||||
return js_string(vm, move(canonicalized_tag));
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static ThrowCompletionOr<String> apply_options_to_tag(GlobalObject& global_objec
|
|||
auto region = TRY(get_string_option(global_object, options, vm.names.region, Unicode::is_unicode_region_subtag));
|
||||
|
||||
// 10. Set tag to ! CanonicalizeUnicodeLocaleId(tag).
|
||||
auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
|
||||
auto canonicalized_tag = Intl::canonicalize_unicode_locale_id(*locale_id);
|
||||
|
||||
// 11. Assert: tag matches the unicode_locale_id production.
|
||||
locale_id = Unicode::parse_unicode_locale_id(canonicalized_tag);
|
||||
|
|
|
@ -431,7 +431,7 @@ Object* JSONObject::parse_json_object(GlobalObject& global_object, JsonObject co
|
|||
{
|
||||
auto* object = Object::create(global_object, global_object.object_prototype());
|
||||
json_object.for_each_member([&](auto& key, auto& value) {
|
||||
object->define_direct_property(key, parse_json_value(global_object, value), JS::default_attributes);
|
||||
object->define_direct_property(key, parse_json_value(global_object, value), default_attributes);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ Array* JSONObject::parse_json_array(GlobalObject& global_object, JsonArray const
|
|||
auto* array = MUST(Array::create(global_object, 0));
|
||||
size_t index = 0;
|
||||
json_array.for_each([&](auto& value) {
|
||||
array->define_direct_property(index++, parse_json_value(global_object, value), JS::default_attributes);
|
||||
array->define_direct_property(index++, parse_json_value(global_object, value), default_attributes);
|
||||
});
|
||||
return array;
|
||||
}
|
||||
|
|
|
@ -77,14 +77,14 @@ static ThrowCompletionOr<Value> run_reaction_job(GlobalObject& global_object, Pr
|
|||
// i. Let status be Call(promiseCapability.[[Reject]], undefined, « handlerResult.[[Value]] »).
|
||||
auto* reject_function = promise_capability.value().reject;
|
||||
dbgln_if(PROMISE_DEBUG, "run_reaction_job: Calling PromiseCapability's reject function @ {}", reject_function);
|
||||
return JS::call(global_object, *reject_function, js_undefined(), *handler_result.value());
|
||||
return call(global_object, *reject_function, js_undefined(), *handler_result.value());
|
||||
}
|
||||
// i. Else,
|
||||
else {
|
||||
// i. Let status be Call(promiseCapability.[[Resolve]], undefined, « handlerResult.[[Value]] »).
|
||||
auto* resolve_function = promise_capability.value().resolve;
|
||||
dbgln_if(PROMISE_DEBUG, "[PromiseReactionJob]: Calling PromiseCapability's resolve function @ {}", resolve_function);
|
||||
return JS::call(global_object, *resolve_function, js_undefined(), *handler_result.value());
|
||||
return call(global_object, *resolve_function, js_undefined(), *handler_result.value());
|
||||
}
|
||||
|
||||
// j. Return Completion(status).
|
||||
|
@ -95,7 +95,7 @@ PromiseJob create_promise_reaction_job(GlobalObject& global_object, PromiseReact
|
|||
{
|
||||
// 1. Let job be a new Job Abstract Closure with no parameters that captures reaction and argument and performs the following steps when called:
|
||||
// See run_reaction_job for "the following steps".
|
||||
auto job = [global_object = JS::make_handle(&global_object), reaction = JS::make_handle(&reaction), argument = JS::make_handle(argument)]() mutable {
|
||||
auto job = [global_object = make_handle(&global_object), reaction = make_handle(&reaction), argument = make_handle(argument)]() mutable {
|
||||
return run_reaction_job(*global_object.cell(), *reaction.cell(), argument.value());
|
||||
};
|
||||
|
||||
|
@ -142,7 +142,7 @@ static ThrowCompletionOr<Value> run_resolve_thenable_job(GlobalObject& global_ob
|
|||
if (then_call_result.is_error()) {
|
||||
// i. Let status be Call(resolvingFunctions.[[Reject]], undefined, « thenCallResult.[[Value]] »).
|
||||
dbgln_if(PROMISE_DEBUG, "run_resolve_thenable_job: then_call_result is an abrupt completion, calling reject function with value {}", *then_call_result.throw_completion().value());
|
||||
auto status = JS::call(global_object, &reject_function, js_undefined(), *then_call_result.throw_completion().value());
|
||||
auto status = call(global_object, &reject_function, js_undefined(), *then_call_result.throw_completion().value());
|
||||
|
||||
// ii. Return Completion(status).
|
||||
return status;
|
||||
|
@ -174,7 +174,7 @@ PromiseJob create_promise_resolve_thenable_job(GlobalObject& global_object, Prom
|
|||
// 1. Let job be a new Job Abstract Closure with no parameters that captures promiseToResolve, thenable, and then and performs the following steps when called:
|
||||
// See PromiseResolveThenableJob::call() for "the following steps".
|
||||
// NOTE: This is done out of order, since `then` is moved into the lambda and `then` would be invalid if it was done at the start.
|
||||
auto job = [global_object = JS::make_handle(&global_object), promise_to_resolve = JS::make_handle(&promise_to_resolve), thenable = JS::make_handle(thenable), then = move(then)]() mutable {
|
||||
auto job = [global_object = make_handle(&global_object), promise_to_resolve = make_handle(&promise_to_resolve), thenable = make_handle(thenable), then = move(then)]() mutable {
|
||||
return run_resolve_thenable_job(*global_object.cell(), *promise_to_resolve.cell(), thenable.value(), then);
|
||||
};
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(GlobalObject& global_object,
|
|||
// b. If script is a List of errors, throw a SyntaxError exception.
|
||||
if (parser.has_errors()) {
|
||||
auto& error = parser.errors()[0];
|
||||
return vm.throw_completion<JS::SyntaxError>(global_object, error.to_string());
|
||||
return vm.throw_completion<SyntaxError>(global_object, error.to_string());
|
||||
}
|
||||
|
||||
// c. If script Contains ScriptBody is false, return undefined.
|
||||
|
|
|
@ -1598,7 +1598,7 @@ ThrowCompletionOr<TriState> is_less_than(GlobalObject& global_object, bool left_
|
|||
}
|
||||
|
||||
// 7.3.21 Invoke ( V, P [ , argumentsList ] ), https://tc39.es/ecma262/#sec-invoke
|
||||
ThrowCompletionOr<Value> Value::invoke_internal(GlobalObject& global_object, JS::PropertyKey const& property_key, Optional<MarkedVector<Value>> arguments)
|
||||
ThrowCompletionOr<Value> Value::invoke_internal(GlobalObject& global_object, PropertyKey const& property_key, Optional<MarkedVector<Value>> arguments)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto property = TRY(get(global_object, property_key));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue