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

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: doh 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
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 //----------------------------------------------------------------------------
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 // ------------------------------------------------------------------- 23 // -------------------------------------------------------------------
46 // Proxy Builtins 24 // Proxy Builtins
47 25
48 function DerivedConstructTrap(callTrap) { 26 function DerivedConstructTrap(callTrap) {
49 return function() { 27 return function() {
50 var proto = this.prototype 28 var proto = this.prototype
51 if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype 29 if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype
52 var obj = { __proto__: proto }; 30 var obj = { __proto__: proto };
53 var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength()); 31 var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength());
54 return IS_SPEC_OBJECT(result) ? result : obj 32 return IS_SPEC_OBJECT(result) ? result : obj
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // If the iterator returns a non-string value, throw a TypeError. 111 // If the iterator returns a non-string value, throw a TypeError.
134 if (!IS_STRING(key)) { 112 if (!IS_STRING(key)) {
135 throw MakeTypeError(kProxyHandlerReturned, handler, "non-String", 113 throw MakeTypeError(kProxyHandlerReturned, handler, "non-String",
136 "enumerate-iterator"); 114 "enumerate-iterator");
137 } 115 }
138 result.push(key); 116 result.push(key);
139 } 117 }
140 return result; 118 return result;
141 } 119 }
142 120
143 //-------------------------------------------------------------------
144
145 //Set up non-enumerable properties of the Proxy object.
146 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
147 "createFunction", ProxyCreateFunction
148 ]);
149
150 // ------------------------------------------------------------------- 121 // -------------------------------------------------------------------
151 // Exports 122 // Exports
152 123
153 utils.Export(function(to) { 124 utils.Export(function(to) {
154 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 125 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
155 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 126 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
156 }); 127 });
157 128
158 %InstallToContext([ 129 %InstallToContext([
159 "proxy_enumerate", ProxyEnumerate, 130 "proxy_enumerate", ProxyEnumerate,
160 ]); 131 ]);
161 132
162 }) 133 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698