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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (IS_UNDEFINED(proto)) | 28 if (IS_UNDEFINED(proto)) |
29 proto = null | 29 proto = null |
30 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) | 30 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) |
31 throw MakeTypeError(kProxyProtoNonObject) | 31 throw MakeTypeError(kProxyProtoNonObject) |
32 return %CreateJSProxy(handler, proto) | 32 return %CreateJSProxy(handler, proto) |
33 } | 33 } |
34 | 34 |
35 function ProxyCreateFunction(handler, callTrap, constructTrap) { | 35 function ProxyCreateFunction(handler, callTrap, constructTrap) { |
36 if (!IS_SPEC_OBJECT(handler)) | 36 if (!IS_SPEC_OBJECT(handler)) |
37 throw MakeTypeError(kProxyHandlerNonObject, "createFunction") | 37 throw MakeTypeError(kProxyHandlerNonObject, "createFunction") |
38 if (!IS_SPEC_FUNCTION(callTrap)) | 38 if (!IS_CALLABLE(callTrap)) |
39 throw MakeTypeError(kProxyTrapFunctionExpected, "call") | 39 throw MakeTypeError(kProxyTrapFunctionExpected, "call") |
40 if (IS_UNDEFINED(constructTrap)) { | 40 if (IS_UNDEFINED(constructTrap)) { |
41 constructTrap = DerivedConstructTrap(callTrap) | 41 constructTrap = DerivedConstructTrap(callTrap) |
42 } else if (IS_SPEC_FUNCTION(constructTrap)) { | 42 } else if (IS_CALLABLE(constructTrap)) { |
43 // Make sure the trap receives 'undefined' as this. | 43 // Make sure the trap receives 'undefined' as this. |
44 var construct = constructTrap | 44 var construct = constructTrap |
45 constructTrap = function() { | 45 constructTrap = function() { |
46 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength()); | 46 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength()); |
47 } | 47 } |
48 } else { | 48 } else { |
49 throw MakeTypeError(kProxyTrapFunctionExpected, "construct") | 49 throw MakeTypeError(kProxyTrapFunctionExpected, "construct") |
50 } | 50 } |
51 return %CreateJSFunctionProxy( | 51 return %CreateJSFunctionProxy( |
52 handler, callTrap, constructTrap, GlobalFunction.prototype) | 52 handler, callTrap, constructTrap, GlobalFunction.prototype) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 }); | 201 }); |
202 | 202 |
203 %InstallToContext([ | 203 %InstallToContext([ |
204 "derived_get_trap", DerivedGetTrap, | 204 "derived_get_trap", DerivedGetTrap, |
205 "derived_has_trap", DerivedHasTrap, | 205 "derived_has_trap", DerivedHasTrap, |
206 "derived_set_trap", DerivedSetTrap, | 206 "derived_set_trap", DerivedSetTrap, |
207 "proxy_enumerate", ProxyEnumerate, | 207 "proxy_enumerate", ProxyEnumerate, |
208 ]); | 208 ]); |
209 | 209 |
210 }) | 210 }) |
OLD | NEW |