Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 global.Proxy = new $Object(); | 28 global.Proxy = new $Object(); |
| 29 | 29 |
| 30 var $Proxy = global.Proxy | 30 var $Proxy = global.Proxy |
| 31 | 31 |
| 32 $Proxy.create = function(handler, proto) { | 32 $Proxy.create = function(handler, proto) { |
| 33 if (!IS_SPEC_OBJECT(handler)) | 33 if (!IS_SPEC_OBJECT(handler)) |
| 34 throw MakeTypeError("handler_non_object", ["create"]) | 34 throw MakeTypeError("handler_non_object", ["create"]) |
| 35 if (!IS_SPEC_OBJECT(proto)) proto = null // Mozilla does this... | 35 if (IS_UNDEFINED(proto)) |
| 36 proto = null | |
| 37 else if (!(IS_SPEC_OBJECT(proto) || proto === null)) | |
| 38 throw MakeTypeError("proto_non_object", ["create"]) | |
| 36 return %CreateJSProxy(handler, proto) | 39 return %CreateJSProxy(handler, proto) |
| 37 } | 40 } |
| 38 | 41 |
| 39 $Proxy.createFunction = function(handler, callTrap, constructTrap) { | 42 $Proxy.createFunction = function(handler, callTrap, constructTrap) { |
| 40 if (!IS_SPEC_OBJECT(handler)) | 43 if (!IS_SPEC_OBJECT(handler)) |
| 41 throw MakeTypeError("handler_non_object", ["create"]) | 44 throw MakeTypeError("handler_non_object", ["create"]) |
| 42 if (!IS_SPEC_FUNCTION(callTrap)) | 45 if (!IS_SPEC_FUNCTION(callTrap)) |
| 43 throw MakeTypeError("trap_function_expected", ["createFunction", "call"]) | 46 throw MakeTypeError("trap_function_expected", ["createFunction", "call"]) |
| 44 var construct | 47 var construct |
|
Michael Starzinger
2011/10/13 16:22:48
I think that "var" can be removed now.
rossberg
2011/10/24 15:59:49
Done.
| |
| 45 if (IS_UNDEFINED(constructTrap)) { | 48 if (IS_UNDEFINED(constructTrap)) { |
| 46 construct = DerivedConstructTrap(callTrap) | 49 constructTrap = DerivedConstructTrap(callTrap) |
| 47 } else if (IS_SPEC_FUNCTION(constructTrap)) { | 50 } else if (!IS_SPEC_FUNCTION(constructTrap)) { |
| 48 construct = function() { | |
| 49 // Make sure the trap receives 'undefined' as this. | |
| 50 return %Apply(constructTrap, void 0, arguments, 0, %_ArgumentsLength()); | |
| 51 } | |
| 52 } else { | |
| 53 throw MakeTypeError("trap_function_expected", | 51 throw MakeTypeError("trap_function_expected", |
| 54 ["createFunction", "construct"]) | 52 ["createFunction", "construct"]) |
| 55 } | 53 } |
| 56 return %CreateJSFunctionProxy( | 54 return %CreateJSFunctionProxy( |
| 57 handler, callTrap, construct, $Function.prototype) | 55 handler, callTrap, constructTrap, $Function.prototype) |
| 58 } | 56 } |
| 59 | 57 |
| 60 | 58 |
| 61 | 59 |
| 62 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
| 63 // Builtins | 61 // Builtins |
| 64 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 65 | 63 |
| 66 function DerivedConstructTrap(callTrap) { | 64 function DerivedConstructTrap(callTrap) { |
| 67 return function() { | 65 return function() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 var names = this.getOwnPropertyNames() | 150 var names = this.getOwnPropertyNames() |
| 153 var enumerableNames = [] | 151 var enumerableNames = [] |
| 154 for (var i = 0, count = 0; i < names.length; ++i) { | 152 for (var i = 0, count = 0; i < names.length; ++i) { |
| 155 var name = names[i] | 153 var name = names[i] |
| 156 if (this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)).enumerable) { | 154 if (this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)).enumerable) { |
| 157 enumerableNames[count++] = names[i] | 155 enumerableNames[count++] = names[i] |
| 158 } | 156 } |
| 159 } | 157 } |
| 160 return enumerableNames | 158 return enumerableNames |
| 161 } | 159 } |
| OLD | NEW |