proxy-revoke.tq 1.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
// 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 {

  // Proxy Revocation Functions
  // https://tc39.github.io/ecma262/#sec-proxy-revocation-functions
  // TODO(v8:9007) remove receiver in argument since we don't use it
  transitioning javascript builtin
  ProxyRevoke(context: Context, receiver: Object): Undefined {
    // 1. Let p be F.[[RevocableProxy]].
    const proxyObject: Object = context[PROXY_SLOT];

    // 2. If p is null, return undefined
    if (proxyObject == Null) {
      return Undefined;
    }

    // 3. Set F.[[RevocableProxy]] to null.
    context[PROXY_SLOT] = Null;

    // 4. Assert: p is a Proxy object.
    const proxy: JSProxy = UnsafeCast<JSProxy>(proxyObject);

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

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

    // 7. Return undefined.
    return Undefined;
  }
}