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

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

Issue 1496503002: [runtime] [proxy] removing JSFunctionProxy and related code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixing merge artifacts 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 | « src/ia32/builtins-ia32.cc ('k') | src/js/v8natives.js » ('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 GlobalProxy = global.Proxy;
15 var GlobalFunction = global.Function; 15 var GlobalFunction = global.Function;
16 var GlobalObject = global.Object; 16 var GlobalObject = global.Object;
17 var MakeTypeError; 17 var MakeTypeError;
18 18
19 utils.Import(function(from) { 19 utils.Import(function(from) {
20 MakeTypeError = from.MakeTypeError; 20 MakeTypeError = from.MakeTypeError;
21 }); 21 });
22 22
23 //---------------------------------------------------------------------------- 23 //----------------------------------------------------------------------------
24 24
25 function ProxyCreateFunction(handler, callTrap, constructTrap) {
26 if (!IS_SPEC_OBJECT(handler))
27 throw MakeTypeError(kProxyHandlerNonObject, "createFunction")
28 if (!IS_CALLABLE(callTrap))
29 throw MakeTypeError(kProxyTrapFunctionExpected, "call")
30 if (IS_UNDEFINED(constructTrap)) {
31 constructTrap = DerivedConstructTrap(callTrap)
32 } else if (IS_CALLABLE(constructTrap)) {
33 // Make sure the trap receives 'undefined' as this.
34 var construct = constructTrap
35 constructTrap = function() {
36 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength());
37 }
38 } else {
39 throw MakeTypeError(kProxyTrapFunctionExpected, "construct")
40 }
41 return %CreateJSFunctionProxy(
42 {}, handler, callTrap, constructTrap, GlobalFunction.prototype)
43 }
44
45 function ProxyCreateRevocable(target, handler) { 25 function ProxyCreateRevocable(target, handler) {
46 var p = new GlobalProxy(target, handler); 26 var p = new GlobalProxy(target, handler);
47 return {proxy: p, revoke: () => %RevokeProxy(p)}; 27 return {proxy: p, revoke: () => %RevokeProxy(p)};
48 } 28 }
49 29
50 // ------------------------------------------------------------------- 30 // -------------------------------------------------------------------
51 // Proxy Builtins 31 // Proxy Builtins
52 32
53 function DerivedConstructTrap(callTrap) { 33 function DerivedConstructTrap(callTrap) {
54 return function() { 34 return function() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 122 }
143 result.push(key); 123 result.push(key);
144 } 124 }
145 return result; 125 return result;
146 } 126 }
147 127
148 //------------------------------------------------------------------- 128 //-------------------------------------------------------------------
149 129
150 //Set up non-enumerable properties of the Proxy object. 130 //Set up non-enumerable properties of the Proxy object.
151 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ 131 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
152 "revocable", ProxyCreateRevocable, 132 "revocable", ProxyCreateRevocable
153 "createFunction", ProxyCreateFunction
154 ]); 133 ]);
155 134
156 // ------------------------------------------------------------------- 135 // -------------------------------------------------------------------
157 // Exports 136 // Exports
158 137
159 utils.Export(function(to) { 138 utils.Export(function(to) {
160 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 139 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
161 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 140 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
162 }); 141 });
163 142
164 %InstallToContext([ 143 %InstallToContext([
165 "proxy_enumerate", ProxyEnumerate, 144 "proxy_enumerate", ProxyEnumerate,
166 ]); 145 ]);
167 146
168 }) 147 })
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/js/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698