Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: src/js/proxy.js

Issue 1482113002: Revert of [proxies] Implement [[Enumerate]] and [[OwnPropertyKeys]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/key-accumulator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 var name = names[i] 145 var name = names[i]
146 if (IS_SYMBOL(name)) continue 146 if (IS_SYMBOL(name)) continue
147 var desc = this.getOwnPropertyDescriptor(TO_STRING(name)) 147 var desc = this.getOwnPropertyDescriptor(TO_STRING(name))
148 if (!IS_UNDEFINED(desc) && desc.enumerable) { 148 if (!IS_UNDEFINED(desc) && desc.enumerable) {
149 enumerableNames[count++] = names[i] 149 enumerableNames[count++] = names[i]
150 } 150 }
151 } 151 }
152 return enumerableNames 152 return enumerableNames
153 } 153 }
154 154
155 // Implements part of ES6 9.5.11 Proxy.[[Enumerate]]: 155 function DerivedEnumerateTrap() {
156 // Call the trap, which should return an iterator, exhaust the iterator, 156 var names = this.getPropertyNames()
157 // and return an array containing the values. 157 var enumerableNames = []
158 function ProxyEnumerate(trap, handler, target) { 158 for (var i = 0, count = 0; i < names.length; ++i) {
159 // 7. Let trapResult be ? Call(trap, handler, «target»). 159 var name = names[i]
160 var trap_result = %_Call(trap, handler, target); 160 if (IS_SYMBOL(name)) continue
161 // 8. If Type(trapResult) is not Object, throw a TypeError exception. 161 var desc = this.getPropertyDescriptor(TO_STRING(name))
162 if (!IS_SPEC_OBJECT(trap_result)) { 162 if (!IS_UNDEFINED(desc)) {
163 throw MakeTypeError(kProxyHandlerReturned, handler, "non-Object", 163 if (!desc.configurable) {
164 "enumerate"); 164 throw MakeTypeError(kProxyPropNotConfigurable,
165 this, name, "getPropertyDescriptor")
166 }
167 if (desc.enumerable) enumerableNames[count++] = names[i]
168 }
165 } 169 }
166 // 9. Return trapResult. 170 return enumerableNames
167 var result = []; 171 }
168 for (var it = trap_result.next(); !it.done; it = trap_result.next()) { 172
169 var key = it.value; 173 function ProxyEnumerate(proxy) {
170 // Not yet spec'ed as of 2015-11-25, but will be spec'ed soon: 174 var handler = %GetHandler(proxy)
171 // If the iterator returns a non-string value, throw a TypeError. 175 if (IS_UNDEFINED(handler.enumerate)) {
172 if (!IS_STRING(key)) { 176 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
173 throw MakeTypeError(kProxyHandlerReturned, handler, "non-String", 177 } else {
174 "enumerate-iterator"); 178 return ToNameArray(handler.enumerate(), "enumerate", false)
175 }
176 result.push(key);
177 } 179 }
178 return result;
179 } 180 }
180 181
181 //------------------------------------------------------------------- 182 //-------------------------------------------------------------------
182 %SetCode(GlobalProxy, ProxyCreate); 183 %SetCode(GlobalProxy, ProxyCreate);
183 184
184 //Set up non-enumerable properties of the Proxy object. 185 //Set up non-enumerable properties of the Proxy object.
185 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ 186 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
186 "createFunction", ProxyCreateFunction 187 "createFunction", ProxyCreateFunction
187 ]); 188 ]);
188 189
189 // ------------------------------------------------------------------- 190 // -------------------------------------------------------------------
190 // Exports 191 // Exports
191 192
192 utils.Export(function(to) { 193 utils.Export(function(to) {
193 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 194 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
194 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 195 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
195 to.ProxyDerivedKeysTrap = DerivedKeysTrap; 196 to.ProxyDerivedKeysTrap = DerivedKeysTrap;
196 }); 197 });
197 198
198 %InstallToContext([ 199 %InstallToContext([
199 "derived_get_trap", DerivedGetTrap, 200 "derived_get_trap", DerivedGetTrap,
200 "derived_has_trap", DerivedHasTrap, 201 "derived_has_trap", DerivedHasTrap,
201 "derived_set_trap", DerivedSetTrap, 202 "derived_set_trap", DerivedSetTrap,
202 "proxy_enumerate", ProxyEnumerate, 203 "proxy_enumerate", ProxyEnumerate,
203 ]); 204 ]);
204 205
205 }) 206 })
OLDNEW
« no previous file with comments | « no previous file | src/key-accumulator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698