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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 function DelegateCallAndConstruct(callTrap, constructTrap) { | 67 function DelegateCallAndConstruct(callTrap, constructTrap) { |
68 return function() { | 68 return function() { |
69 return %Apply(IS_UNDEFINED(new.target) ? callTrap : constructTrap, | 69 return %Apply(IS_UNDEFINED(new.target) ? callTrap : constructTrap, |
70 this, arguments, 0, %_ArgumentsLength()) | 70 this, arguments, 0, %_ArgumentsLength()) |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 function DerivedGetTrap(receiver, name) { | |
75 var desc = this.getPropertyDescriptor(name) | |
76 if (IS_UNDEFINED(desc)) { return desc } | |
77 if ('value' in desc) { | |
78 return desc.value | |
79 } else { | |
80 if (IS_UNDEFINED(desc.get)) { return desc.get } | |
81 // The proposal says: desc.get.call(receiver) | |
82 return %_Call(desc.get, receiver) | |
83 } | |
84 } | |
85 | |
86 function DerivedSetTrap(receiver, name, val) { | 74 function DerivedSetTrap(receiver, name, val) { |
87 var desc = this.getOwnPropertyDescriptor(name) | 75 var desc = this.getOwnPropertyDescriptor(name) |
88 if (desc) { | 76 if (desc) { |
89 if ('writable' in desc) { | 77 if ('writable' in desc) { |
90 if (desc.writable) { | 78 if (desc.writable) { |
91 desc.value = val | 79 desc.value = val |
92 this.defineProperty(name, desc) | 80 this.defineProperty(name, desc) |
93 return true | 81 return true |
94 } else { | 82 } else { |
95 return false | 83 return false |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // ------------------------------------------------------------------- | 173 // ------------------------------------------------------------------- |
186 // Exports | 174 // Exports |
187 | 175 |
188 utils.Export(function(to) { | 176 utils.Export(function(to) { |
189 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; | 177 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; |
190 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; | 178 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; |
191 to.ProxyDerivedKeysTrap = DerivedKeysTrap; | 179 to.ProxyDerivedKeysTrap = DerivedKeysTrap; |
192 }); | 180 }); |
193 | 181 |
194 %InstallToContext([ | 182 %InstallToContext([ |
195 "derived_get_trap", DerivedGetTrap, | |
196 "proxy_enumerate", ProxyEnumerate, | 183 "proxy_enumerate", ProxyEnumerate, |
197 ]); | 184 ]); |
198 | 185 |
199 }) | 186 }) |
OLD | NEW |