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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 writable: true, | 127 writable: true, |
128 enumerable: true, | 128 enumerable: true, |
129 configurable: true}); | 129 configurable: true}); |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 function DerivedHasOwnTrap(name) { | 133 function DerivedHasOwnTrap(name) { |
134 return !!this.getOwnPropertyDescriptor(name) | 134 return !!this.getOwnPropertyDescriptor(name) |
135 } | 135 } |
136 | 136 |
137 function DerivedKeysTrap() { | |
138 var names = this.getOwnPropertyNames() | |
139 var enumerableNames = [] | |
140 for (var i = 0, count = 0; i < names.length; ++i) { | |
141 var name = names[i] | |
142 if (IS_SYMBOL(name)) continue | |
143 var desc = this.getOwnPropertyDescriptor(TO_STRING(name)) | |
144 if (!IS_UNDEFINED(desc) && desc.enumerable) { | |
145 enumerableNames[count++] = names[i] | |
146 } | |
147 } | |
148 return enumerableNames | |
149 } | |
150 | 137 |
151 // Implements part of ES6 9.5.11 Proxy.[[Enumerate]]: | 138 // Implements part of ES6 9.5.11 Proxy.[[Enumerate]]: |
152 // Call the trap, which should return an iterator, exhaust the iterator, | 139 // Call the trap, which should return an iterator, exhaust the iterator, |
153 // and return an array containing the values. | 140 // and return an array containing the values. |
154 function ProxyEnumerate(trap, handler, target) { | 141 function ProxyEnumerate(trap, handler, target) { |
155 // 7. Let trapResult be ? Call(trap, handler, «target»). | 142 // 7. Let trapResult be ? Call(trap, handler, «target»). |
156 var trap_result = %_Call(trap, handler, target); | 143 var trap_result = %_Call(trap, handler, target); |
157 // 8. If Type(trapResult) is not Object, throw a TypeError exception. | 144 // 8. If Type(trapResult) is not Object, throw a TypeError exception. |
158 if (!IS_SPEC_OBJECT(trap_result)) { | 145 if (!IS_SPEC_OBJECT(trap_result)) { |
159 throw MakeTypeError(kProxyHandlerReturned, handler, "non-Object", | 146 throw MakeTypeError(kProxyHandlerReturned, handler, "non-Object", |
(...skipping 21 matching lines...) Expand all Loading... |
181 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ | 168 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ |
182 "createFunction", ProxyCreateFunction | 169 "createFunction", ProxyCreateFunction |
183 ]); | 170 ]); |
184 | 171 |
185 // ------------------------------------------------------------------- | 172 // ------------------------------------------------------------------- |
186 // Exports | 173 // Exports |
187 | 174 |
188 utils.Export(function(to) { | 175 utils.Export(function(to) { |
189 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; | 176 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; |
190 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; | 177 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; |
191 to.ProxyDerivedKeysTrap = DerivedKeysTrap; | |
192 }); | 178 }); |
193 | 179 |
194 %InstallToContext([ | 180 %InstallToContext([ |
195 "derived_get_trap", DerivedGetTrap, | 181 "derived_get_trap", DerivedGetTrap, |
196 "derived_set_trap", DerivedSetTrap, | 182 "derived_set_trap", DerivedSetTrap, |
197 "proxy_enumerate", ProxyEnumerate, | 183 "proxy_enumerate", ProxyEnumerate, |
198 ]); | 184 ]); |
199 | 185 |
200 }) | 186 }) |
OLD | NEW |