• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include 'src/builtins/builtins-proxy-gen.h'
6
7namespace proxy {
8
9// Proxy Revocation Functions
10// https://tc39.github.io/ecma262/#sec-proxy-revocation-functions
11transitioning javascript builtin
12ProxyRevoke(js-implicit context: Context)(): Undefined {
13  const context = %RawDownCast<ProxyRevokeFunctionContext>(context);
14
15  // 1. Let p be F.[[RevocableProxy]].
16  const proxySlot:&(JSProxy | Null) =
17      ContextSlot(context, ProxyRevokeFunctionContextSlot::kProxySlot);
18
19  typeswitch (*proxySlot) {
20    case (Null): {
21      // 2. If p is null, return undefined
22      return Undefined;
23    }
24    case (proxy: JSProxy): {
25      // 3. Set F.[[RevocableProxy]] to null.
26      *proxySlot = Null;
27
28      // 4. Assert: p is a Proxy object.
29      dcheck(Is<JSProxy>(proxy));
30
31      // 5. Set p.[[ProxyTarget]] to null.
32      proxy.target = Null;
33
34      // 6. Set p.[[ProxyHandler]] to null.
35      proxy.handler = Null;
36
37      // 7. Return undefined.
38      return Undefined;
39    }
40  }
41}
42}
43