| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var $proxyDelegateCallAndConstruct; | |
| 6 var $proxyDerivedGetTrap; | 5 var $proxyDerivedGetTrap; |
| 7 var $proxyDerivedHasTrap; | 6 var $proxyDerivedHasTrap; |
| 8 var $proxyDerivedHasOwnTrap; | |
| 9 var $proxyDerivedKeysTrap; | |
| 10 var $proxyDerivedSetTrap; | 7 var $proxyDerivedSetTrap; |
| 11 var $proxyEnumerate; | 8 var $proxyEnumerate; |
| 12 | 9 |
| 13 (function(global, utils) { | 10 (function(global, utils) { |
| 14 | 11 |
| 15 "use strict"; | 12 "use strict"; |
| 16 | 13 |
| 17 %CheckIsBootstrapping(); | 14 %CheckIsBootstrapping(); |
| 18 | 15 |
| 16 // ---------------------------------------------------------------------------- |
| 17 // Imports |
| 18 |
| 19 var GlobalFunction = global.Function; | 19 var GlobalFunction = global.Function; |
| 20 var GlobalObject = global.Object; | 20 var GlobalObject = global.Object; |
| 21 | 21 |
| 22 // ------------------------------------------------------------------- | 22 var ToNameArray; |
| 23 |
| 24 utils.Import(function(from) { |
| 25 ToNameArray = from.ToNameArray; |
| 26 }); |
| 27 |
| 28 //---------------------------------------------------------------------------- |
| 23 | 29 |
| 24 function ProxyCreate(handler, proto) { | 30 function ProxyCreate(handler, proto) { |
| 25 if (!IS_SPEC_OBJECT(handler)) | 31 if (!IS_SPEC_OBJECT(handler)) |
| 26 throw MakeTypeError(kProxyHandlerNonObject, "create") | 32 throw MakeTypeError(kProxyHandlerNonObject, "create") |
| 27 if (IS_UNDEFINED(proto)) | 33 if (IS_UNDEFINED(proto)) |
| 28 proto = null | 34 proto = null |
| 29 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) | 35 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) |
| 30 throw MakeTypeError(kProxyProtoNonObject) | 36 throw MakeTypeError(kProxyProtoNonObject) |
| 31 return %CreateJSProxy(handler, proto) | 37 return %CreateJSProxy(handler, proto) |
| 32 } | 38 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 174 } |
| 169 } | 175 } |
| 170 return enumerableNames | 176 return enumerableNames |
| 171 } | 177 } |
| 172 | 178 |
| 173 function ProxyEnumerate(proxy) { | 179 function ProxyEnumerate(proxy) { |
| 174 var handler = %GetHandler(proxy) | 180 var handler = %GetHandler(proxy) |
| 175 if (IS_UNDEFINED(handler.enumerate)) { | 181 if (IS_UNDEFINED(handler.enumerate)) { |
| 176 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) | 182 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) |
| 177 } else { | 183 } else { |
| 178 return $toNameArray(handler.enumerate(), "enumerate", false) | 184 return ToNameArray(handler.enumerate(), "enumerate", false) |
| 179 } | 185 } |
| 180 } | 186 } |
| 181 | 187 |
| 182 //------------------------------------------------------------------- | 188 //------------------------------------------------------------------- |
| 183 | 189 |
| 184 var Proxy = new GlobalObject(); | 190 var Proxy = new GlobalObject(); |
| 185 %AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM); | 191 %AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM); |
| 186 | 192 |
| 187 //Set up non-enumerable properties of the Proxy object. | 193 //Set up non-enumerable properties of the Proxy object. |
| 188 $installFunctions(Proxy, DONT_ENUM, [ | 194 utils.InstallFunctions(Proxy, DONT_ENUM, [ |
| 189 "create", ProxyCreate, | 195 "create", ProxyCreate, |
| 190 "createFunction", ProxyCreateFunction | 196 "createFunction", ProxyCreateFunction |
| 191 ]) | 197 ]) |
| 192 | 198 |
| 193 $proxyDelegateCallAndConstruct = DelegateCallAndConstruct; | 199 // ------------------------------------------------------------------- |
| 200 // Exports |
| 201 |
| 194 $proxyDerivedGetTrap = DerivedGetTrap; | 202 $proxyDerivedGetTrap = DerivedGetTrap; |
| 195 $proxyDerivedHasTrap = DerivedHasTrap; | 203 $proxyDerivedHasTrap = DerivedHasTrap; |
| 196 $proxyDerivedHasOwnTrap = DerivedHasOwnTrap; | |
| 197 $proxyDerivedKeysTrap = DerivedKeysTrap; | |
| 198 $proxyDerivedSetTrap = DerivedSetTrap; | 204 $proxyDerivedSetTrap = DerivedSetTrap; |
| 199 $proxyEnumerate = ProxyEnumerate; | 205 $proxyEnumerate = ProxyEnumerate; |
| 200 | 206 |
| 207 utils.Export(function(to) { |
| 208 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; |
| 209 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; |
| 210 to.ProxyDerivedKeysTrap = DerivedKeysTrap; |
| 211 }); |
| 212 |
| 201 }) | 213 }) |
| OLD | NEW |