| 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 18 matching lines...) Expand all Loading... |
| 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_SPEC_OBJECT(trap_result)) { |
| 39 throw MakeTypeError(kProxyTrapReturnedNonObject, handler, trap_result, | 39 throw MakeTypeError(kProxyEnumerateNonObject); |
| 40 "enumerate"); | |
| 41 } | 40 } |
| 42 // 9. Return trapResult. | 41 // 9. Return trapResult. |
| 43 var result = []; | 42 var result = []; |
| 44 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()) { |
| 45 var key = it.value; | 44 var key = it.value; |
| 46 // 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: |
| 47 // If the iterator returns a non-string value, throw a TypeError. | 46 // If the iterator returns a non-string value, throw a TypeError. |
| 48 if (!IS_STRING(key)) { | 47 if (!IS_STRING(key)) { |
| 49 throw MakeTypeError(kProxyTrapReturned, handler, "non-String", | 48 throw MakeTypeError(kProxyEnumerateNonString); |
| 50 "enumerate"); | |
| 51 } | 49 } |
| 52 result.push(key); | 50 result.push(key); |
| 53 } | 51 } |
| 54 return result; | 52 return result; |
| 55 } | 53 } |
| 56 | 54 |
| 57 //------------------------------------------------------------------- | 55 //------------------------------------------------------------------- |
| 58 | 56 |
| 59 //Set up non-enumerable properties of the Proxy object. | 57 //Set up non-enumerable properties of the Proxy object. |
| 60 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ | 58 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ |
| 61 "revocable", ProxyCreateRevocable | 59 "revocable", ProxyCreateRevocable |
| 62 ]); | 60 ]); |
| 63 | 61 |
| 64 // ------------------------------------------------------------------- | 62 // ------------------------------------------------------------------- |
| 65 // Exports | 63 // Exports |
| 66 | 64 |
| 67 %InstallToContext([ | 65 %InstallToContext([ |
| 68 "proxy_enumerate", ProxyEnumerate, | 66 "proxy_enumerate", ProxyEnumerate, |
| 69 ]); | 67 ]); |
| 70 | 68 |
| 71 }) | 69 }) |
| OLD | NEW |