proxy-revoke.tq 1.12 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include 'src/builtins/builtins-proxy-gen.h'

namespace proxy {

9 10 11
// Proxy Revocation Functions
// https://tc39.github.io/ecma262/#sec-proxy-revocation-functions
transitioning javascript builtin
12 13
ProxyRevoke(js-implicit context: Context)(): Undefined {
  const context = %RawDownCast<ProxyRevokeFunctionContext>(context);
14

15 16 17 18 19 20 21 22 23 24 25 26 27 28
  // 1. Let p be F.[[RevocableProxy]].
  const proxySlot:&(JSProxy | Null) =
      ContextSlot(context, ProxyRevokeFunctionContextSlot::kProxySlot);

  typeswitch (*proxySlot) {
    case (Null): {
      // 2. If p is null, return undefined
      return Undefined;
    }
    case (proxy: JSProxy): {
      // 3. Set F.[[RevocableProxy]] to null.
      *proxySlot = Null;

      // 4. Assert: p is a Proxy object.
29
      dcheck(Is<JSProxy>(proxy));
30 31 32 33 34 35 36 37 38 39

      // 5. Set p.[[ProxyTarget]] to null.
      proxy.target = Null;

      // 6. Set p.[[ProxyHandler]] to null.
      proxy.handler = Null;

      // 7. Return undefined.
      return Undefined;
    }
40 41
  }
}
42
}