void Genesis::InstallExperimentalNativeFunctions() {
if (FLAG_harmony_proxies) {
- INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
- INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
- INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
- INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate);
}
#define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) InstallNativeFunctions_##id();
void Genesis::InstallNativeFunctions_harmony_proxies() {
if (FLAG_harmony_proxies) {
- INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
- INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
- INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
- INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap);
+ INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate);
}
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var $proxyDelegateCallAndConstruct;
+var $proxyDerivedGetTrap;
+var $proxyDerivedHasTrap;
+var $proxyDerivedHasOwnTrap;
+var $proxyDerivedKeysTrap;
+var $proxyDerivedSetTrap;
+var $proxyEnumerate;
+
+(function() {
+
"use strict";
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Object = global.Object;
+%CheckIsBootstrapping();
-var $Proxy = new $Object();
+var GlobalObject = global.Object;
// -------------------------------------------------------------------
handler, callTrap, constructTrap, $Function.prototype)
}
-
-// -------------------------------------------------------------------
-
-function SetUpProxy() {
- %CheckIsBootstrapping()
-
- var global_proxy = %GlobalProxy(global);
- global_proxy.Proxy = $Proxy;
-
- // Set up non-enumerable properties of the Proxy object.
- InstallFunctions($Proxy, DONT_ENUM, [
- "create", ProxyCreate,
- "createFunction", ProxyCreateFunction
- ])
-}
-
-SetUpProxy();
-
-
// -------------------------------------------------------------------
// Proxy Builtins
return ToNameArray(handler.enumerate(), "enumerate", false)
}
}
+
+//-------------------------------------------------------------------
+
+var Proxy = new GlobalObject();
+%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
+
+//Set up non-enumerable properties of the Proxy object.
+InstallFunctions(Proxy, DONT_ENUM, [
+ "create", ProxyCreate,
+ "createFunction", ProxyCreateFunction
+])
+
+$proxyDelegateCallAndConstruct = DelegateCallAndConstruct;
+$proxyDerivedGetTrap = DerivedGetTrap;
+$proxyDerivedHasTrap = DerivedHasTrap;
+$proxyDerivedHasOwnTrap = DerivedHasOwnTrap;
+$proxyDerivedKeysTrap = DerivedKeysTrap;
+$proxyDerivedSetTrap = DerivedSetTrap;
+$proxyEnumerate = ProxyEnumerate;
+
+})();
if (IS_SYMBOL(V)) return false;
var handler = %GetHandler(this);
- return CallTrap1(handler, "hasOwn", DerivedHasOwnTrap, ToName(V));
+ return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, ToName(V));
}
return %HasOwnProperty(TO_OBJECT_INLINE(this), ToName(V));
}
obj = TO_OBJECT_INLINE(obj);
if (%_IsJSProxy(obj)) {
var handler = %GetHandler(obj);
- var names = CallTrap0(handler, "keys", DerivedKeysTrap);
+ var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap);
return ToNameArray(names, "keys", false);
}
return %OwnKeys(obj);
if (%IsJSFunctionProxy(obj)) {
var callTrap = %GetCallTrap(obj);
var constructTrap = %GetConstructTrap(obj);
- var code = DelegateCallAndConstruct(callTrap, constructTrap);
+ var code = $proxyDelegateCallAndConstruct(callTrap, constructTrap);
%Fix(obj); // becomes a regular function
%SetCode(obj, code);
// TODO(rossberg): What about length and other properties? Not specified.