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

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

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removing unreachable code Created 5 years, 1 month 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 | « src/js/messages.js ('k') | src/messages.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
11 // ---------------------------------------------------------------------------- 11 // ----------------------------------------------------------------------------
12 // Imports 12 // Imports
13 13 //
14 var GlobalProxy = global.Proxy;
14 var GlobalFunction = global.Function; 15 var GlobalFunction = global.Function;
15 var GlobalObject = global.Object; 16 var GlobalObject = global.Object;
16 var MakeTypeError; 17 var MakeTypeError;
17 var ToNameArray; 18 var ToNameArray;
18 19
19 utils.Import(function(from) { 20 utils.Import(function(from) {
20 MakeTypeError = from.MakeTypeError; 21 MakeTypeError = from.MakeTypeError;
21 ToNameArray = from.ToNameArray; 22 ToNameArray = from.ToNameArray;
22 }); 23 });
23 24
24 //---------------------------------------------------------------------------- 25 //----------------------------------------------------------------------------
25 26
26 function ProxyCreate(handler, proto) { 27 function ProxyCreate(target, handler) {
27 if (!IS_SPEC_OBJECT(handler)) 28 if (!%_IsConstructCall()) {
28 throw MakeTypeError(kProxyHandlerNonObject, "create") 29 throw MakeTypeError(kConstructorNotFunction, "Proxy");
29 if (IS_UNDEFINED(proto)) 30 }
30 proto = null 31 // TODO(cbruni): Get the construct call right, this is just a prelimiary
31 else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) 32 // version to get started with tests.
32 throw MakeTypeError(kProxyProtoNonObject) 33 return %CreateJSProxy(this, target, handler);
33 return %CreateJSProxy({}, handler, proto)
34 } 34 }
35 35
36 function ProxyCreateFunction(handler, callTrap, constructTrap) { 36 function ProxyCreateFunction(handler, callTrap, constructTrap) {
37 if (!IS_SPEC_OBJECT(handler)) 37 if (!IS_SPEC_OBJECT(handler))
38 throw MakeTypeError(kProxyHandlerNonObject, "createFunction") 38 throw MakeTypeError(kProxyHandlerNonObject, "createFunction")
39 if (!IS_CALLABLE(callTrap)) 39 if (!IS_CALLABLE(callTrap))
40 throw MakeTypeError(kProxyTrapFunctionExpected, "call") 40 throw MakeTypeError(kProxyTrapFunctionExpected, "call")
41 if (IS_UNDEFINED(constructTrap)) { 41 if (IS_UNDEFINED(constructTrap)) {
42 constructTrap = DerivedConstructTrap(callTrap) 42 constructTrap = DerivedConstructTrap(callTrap)
43 } else if (IS_CALLABLE(constructTrap)) { 43 } else if (IS_CALLABLE(constructTrap)) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 function ProxyEnumerate(proxy) { 175 function ProxyEnumerate(proxy) {
176 var handler = %GetHandler(proxy) 176 var handler = %GetHandler(proxy)
177 if (IS_UNDEFINED(handler.enumerate)) { 177 if (IS_UNDEFINED(handler.enumerate)) {
178 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) 178 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
179 } else { 179 } else {
180 return ToNameArray(handler.enumerate(), "enumerate", false) 180 return ToNameArray(handler.enumerate(), "enumerate", false)
181 } 181 }
182 } 182 }
183 183
184 //------------------------------------------------------------------- 184 //-------------------------------------------------------------------
185 185 %SetCode(GlobalProxy, ProxyCreate);
186 var Proxy = new GlobalObject(); 186 %FunctionSetPrototype(GlobalProxy, new GlobalObject());
187 %AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
188 187
189 //Set up non-enumerable properties of the Proxy object. 188 //Set up non-enumerable properties of the Proxy object.
190 utils.InstallFunctions(Proxy, DONT_ENUM, [ 189 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
191 "create", ProxyCreate,
192 "createFunction", ProxyCreateFunction 190 "createFunction", ProxyCreateFunction
193 ]) 191 ]);
194 192
193 %AddNamedProperty(GlobalProxy.prototype, "constructor", GlobalProxy, DONT_ENUM);
195 // ------------------------------------------------------------------- 194 // -------------------------------------------------------------------
196 // Exports 195 // Exports
197 196
198 utils.Export(function(to) { 197 utils.Export(function(to) {
199 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 198 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
200 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 199 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
201 to.ProxyDerivedKeysTrap = DerivedKeysTrap; 200 to.ProxyDerivedKeysTrap = DerivedKeysTrap;
202 }); 201 });
203 202
204 %InstallToContext([ 203 %InstallToContext([
205 "derived_get_trap", DerivedGetTrap, 204 "derived_get_trap", DerivedGetTrap,
206 "derived_has_trap", DerivedHasTrap, 205 "derived_has_trap", DerivedHasTrap,
207 "derived_set_trap", DerivedSetTrap, 206 "derived_set_trap", DerivedSetTrap,
208 "proxy_enumerate", ProxyEnumerate, 207 "proxy_enumerate", ProxyEnumerate,
209 ]); 208 ]);
210 209
211 }) 210 })
OLDNEW
« no previous file with comments | « src/js/messages.js ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698