mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibJS: Replace GlobalObject with VM in remaining AOs [Part 19/19]
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 07:53:23 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/56b2ae5ac0 Pull-request: https://github.com/SerenityOS/serenity/pull/14973 Reviewed-by: https://github.com/davidot ✅
@@ -14,10 +14,9 @@
|
||||
namespace JS {
|
||||
|
||||
// 10.5.14 ProxyCreate ( target, handler ), https://tc39.es/ecma262/#sec-proxycreate
|
||||
static ThrowCompletionOr<ProxyObject*> proxy_create(GlobalObject& global_object, Value target, Value handler)
|
||||
static ThrowCompletionOr<ProxyObject*> proxy_create(VM& vm, Value target, Value handler)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects());
|
||||
if (!handler.is_object())
|
||||
@@ -51,16 +50,16 @@ ThrowCompletionOr<Value> ProxyConstructor::call()
|
||||
ThrowCompletionOr<Object*> ProxyConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
return TRY(proxy_create(global_object(), vm.argument(0), vm.argument(1)));
|
||||
return TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
|
||||
}
|
||||
|
||||
// 28.2.2.1 Proxy.revocable ( target, handler ), https://tc39.es/ecma262/#sec-proxy.revocable
|
||||
JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let p be ? ProxyCreate(target, handler).
|
||||
auto* proxy = TRY(proxy_create(global_object, vm.argument(0), vm.argument(1)));
|
||||
auto* proxy = TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
|
||||
|
||||
// 2. Let revokerClosure be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
|
||||
auto revoker_closure = [proxy_handle = make_handle(proxy)](auto&, auto&) -> ThrowCompletionOr<Value> {
|
||||
|
||||
Reference in New Issue
Block a user