| 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; | 5 var $proxyDelegateCallAndConstruct; |
| 6 var $proxyDerivedGetTrap; | 6 var $proxyDerivedGetTrap; |
| 7 var $proxyDerivedHasTrap; | 7 var $proxyDerivedHasTrap; |
| 8 var $proxyDerivedHasOwnTrap; | 8 var $proxyDerivedHasOwnTrap; |
| 9 var $proxyDerivedKeysTrap; | 9 var $proxyDerivedKeysTrap; |
| 10 var $proxyDerivedSetTrap; | 10 var $proxyDerivedSetTrap; |
| 11 var $proxyEnumerate; | 11 var $proxyEnumerate; |
| 12 | 12 |
| 13 (function() { | 13 (function() { |
| 14 | 14 |
| 15 "use strict"; | 15 "use strict"; |
| 16 | 16 |
| 17 %CheckIsBootstrapping(); | 17 %CheckIsBootstrapping(); |
| 18 | 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 // ------------------------------------------------------------------- |
| 23 | 23 |
| 24 function ProxyCreate(handler, proto) { | 24 function ProxyCreate(handler, proto) { |
| 25 if (!IS_SPEC_OBJECT(handler)) | 25 if (!IS_SPEC_OBJECT(handler)) |
| 26 throw MakeTypeError("handler_non_object", ["create"]) | 26 throw MakeTypeError(kProxyHandlerNonObject, "create") |
| 27 if (IS_UNDEFINED(proto)) | 27 if (IS_UNDEFINED(proto)) |
| 28 proto = null | 28 proto = null |
| 29 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) | 29 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) |
| 30 throw MakeTypeError("proto_non_object", ["create"]) | 30 throw MakeTypeError(kProxyProtoNonObject) |
| 31 return %CreateJSProxy(handler, proto) | 31 return %CreateJSProxy(handler, proto) |
| 32 } | 32 } |
| 33 | 33 |
| 34 function ProxyCreateFunction(handler, callTrap, constructTrap) { | 34 function ProxyCreateFunction(handler, callTrap, constructTrap) { |
| 35 if (!IS_SPEC_OBJECT(handler)) | 35 if (!IS_SPEC_OBJECT(handler)) |
| 36 throw MakeTypeError("handler_non_object", ["create"]) | 36 throw MakeTypeError(kProxyHandlerNonObject, "createFunction") |
| 37 if (!IS_SPEC_FUNCTION(callTrap)) | 37 if (!IS_SPEC_FUNCTION(callTrap)) |
| 38 throw MakeTypeError("trap_function_expected", ["createFunction", "call"]) | 38 throw MakeTypeError(kProxyTrapFunctionExpected, "call") |
| 39 if (IS_UNDEFINED(constructTrap)) { | 39 if (IS_UNDEFINED(constructTrap)) { |
| 40 constructTrap = DerivedConstructTrap(callTrap) | 40 constructTrap = DerivedConstructTrap(callTrap) |
| 41 } else if (IS_SPEC_FUNCTION(constructTrap)) { | 41 } else if (IS_SPEC_FUNCTION(constructTrap)) { |
| 42 // Make sure the trap receives 'undefined' as this. | 42 // Make sure the trap receives 'undefined' as this. |
| 43 var construct = constructTrap | 43 var construct = constructTrap |
| 44 constructTrap = function() { | 44 constructTrap = function() { |
| 45 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength()); | 45 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength()); |
| 46 } | 46 } |
| 47 } else { | 47 } else { |
| 48 throw MakeTypeError("trap_function_expected", | 48 throw MakeTypeError(kProxyTrapFunctionExpected, "construct") |
| 49 ["createFunction", "construct"]) | |
| 50 } | 49 } |
| 51 return %CreateJSFunctionProxy( | 50 return %CreateJSFunctionProxy( |
| 52 handler, callTrap, constructTrap, GlobalFunction.prototype) | 51 handler, callTrap, constructTrap, GlobalFunction.prototype) |
| 53 } | 52 } |
| 54 | 53 |
| 55 // ------------------------------------------------------------------- | 54 // ------------------------------------------------------------------- |
| 56 // Proxy Builtins | 55 // Proxy Builtins |
| 57 | 56 |
| 58 function DerivedConstructTrap(callTrap) { | 57 function DerivedConstructTrap(callTrap) { |
| 59 return function() { | 58 return function() { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 192 |
| 194 $proxyDelegateCallAndConstruct = DelegateCallAndConstruct; | 193 $proxyDelegateCallAndConstruct = DelegateCallAndConstruct; |
| 195 $proxyDerivedGetTrap = DerivedGetTrap; | 194 $proxyDerivedGetTrap = DerivedGetTrap; |
| 196 $proxyDerivedHasTrap = DerivedHasTrap; | 195 $proxyDerivedHasTrap = DerivedHasTrap; |
| 197 $proxyDerivedHasOwnTrap = DerivedHasOwnTrap; | 196 $proxyDerivedHasOwnTrap = DerivedHasOwnTrap; |
| 198 $proxyDerivedKeysTrap = DerivedKeysTrap; | 197 $proxyDerivedKeysTrap = DerivedKeysTrap; |
| 199 $proxyDerivedSetTrap = DerivedSetTrap; | 198 $proxyDerivedSetTrap = DerivedSetTrap; |
| 200 $proxyEnumerate = ProxyEnumerate; | 199 $proxyEnumerate = ProxyEnumerate; |
| 201 | 200 |
| 202 })(); | 201 })(); |
| OLD | NEW |