OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 // ------------------------------------------------------------------- | 28 // ------------------------------------------------------------------- |
29 // Proxy Builtins | 29 // Proxy Builtins |
30 | 30 |
31 // Implements part of ES6 9.5.11 Proxy.[[Enumerate]]: | 31 // Implements part of ES6 9.5.11 Proxy.[[Enumerate]]: |
32 // Call the trap, which should return an iterator, exhaust the iterator, | 32 // Call the trap, which should return an iterator, exhaust the iterator, |
33 // and return an array containing the values. | 33 // and return an array containing the values. |
34 function ProxyEnumerate(trap, handler, target) { | 34 function ProxyEnumerate(trap, handler, target) { |
35 // 7. Let trapResult be ? Call(trap, handler, «target»). | 35 // 7. Let trapResult be ? Call(trap, handler, «target»). |
36 var trap_result = %_Call(trap, handler, target); | 36 var trap_result = %_Call(trap, handler, target); |
37 // 8. If Type(trapResult) is not Object, throw a TypeError exception. | 37 // 8. If Type(trapResult) is not Object, throw a TypeError exception. |
38 if (!IS_SPEC_OBJECT(trap_result)) { | 38 if (!IS_RECEIVER(trap_result)) { |
39 throw MakeTypeError(kProxyEnumerateNonObject); | 39 throw MakeTypeError(kProxyEnumerateNonObject); |
40 } | 40 } |
41 // 9. Return trapResult. | 41 // 9. Return trapResult. |
42 var result = []; | 42 var result = []; |
43 for (var it = trap_result.next(); !it.done; it = trap_result.next()) { | 43 for (var it = trap_result.next(); !it.done; it = trap_result.next()) { |
44 var key = it.value; | 44 var key = it.value; |
45 // Not yet spec'ed as of 2015-11-25, but will be spec'ed soon: | 45 // Not yet spec'ed as of 2015-11-25, but will be spec'ed soon: |
46 // If the iterator returns a non-string value, throw a TypeError. | 46 // If the iterator returns a non-string value, throw a TypeError. |
47 if (!IS_STRING(key)) { | 47 if (!IS_STRING(key)) { |
48 throw MakeTypeError(kProxyEnumerateNonString); | 48 throw MakeTypeError(kProxyEnumerateNonString); |
(...skipping 11 matching lines...) Expand all Loading... |
60 ]); | 60 ]); |
61 | 61 |
62 // ------------------------------------------------------------------- | 62 // ------------------------------------------------------------------- |
63 // Exports | 63 // Exports |
64 | 64 |
65 %InstallToContext([ | 65 %InstallToContext([ |
66 "proxy_enumerate", ProxyEnumerate, | 66 "proxy_enumerate", ProxyEnumerate, |
67 ]); | 67 ]); |
68 | 68 |
69 }) | 69 }) |
OLD | NEW |