OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 | 260 |
261 | 261 |
262 // ECMA-262 - 15.2.4.5 | 262 // ECMA-262 - 15.2.4.5 |
263 function ObjectHasOwnProperty(V) { | 263 function ObjectHasOwnProperty(V) { |
264 if (%_IsJSProxy(this)) { | 264 if (%_IsJSProxy(this)) { |
265 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 265 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
266 if (IS_SYMBOL(V)) return false; | 266 if (IS_SYMBOL(V)) return false; |
267 | 267 |
268 var handler = %GetHandler(this); | 268 var handler = %GetHandler(this); |
269 return CallTrap1(handler, "hasOwn", DerivedHasOwnTrap, ToName(V)); | 269 return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, ToName(V)); |
270 } | 270 } |
271 return %HasOwnProperty(TO_OBJECT_INLINE(this), ToName(V)); | 271 return %HasOwnProperty(TO_OBJECT_INLINE(this), ToName(V)); |
272 } | 272 } |
273 | 273 |
274 | 274 |
275 // ECMA-262 - 15.2.4.6 | 275 // ECMA-262 - 15.2.4.6 |
276 function ObjectIsPrototypeOf(V) { | 276 function ObjectIsPrototypeOf(V) { |
277 if (!IS_SPEC_OBJECT(V)) return false; | 277 if (!IS_SPEC_OBJECT(V)) return false; |
278 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); | 278 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); |
279 return %IsInPrototypeChain(this, V); | 279 return %IsInPrototypeChain(this, V); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 receiver = %GlobalProxy(global); | 344 receiver = %GlobalProxy(global); |
345 } | 345 } |
346 return %LookupAccessor(TO_OBJECT_INLINE(receiver), ToName(name), SETTER); | 346 return %LookupAccessor(TO_OBJECT_INLINE(receiver), ToName(name), SETTER); |
347 } | 347 } |
348 | 348 |
349 | 349 |
350 function ObjectKeys(obj) { | 350 function ObjectKeys(obj) { |
351 obj = TO_OBJECT_INLINE(obj); | 351 obj = TO_OBJECT_INLINE(obj); |
352 if (%_IsJSProxy(obj)) { | 352 if (%_IsJSProxy(obj)) { |
353 var handler = %GetHandler(obj); | 353 var handler = %GetHandler(obj); |
354 var names = CallTrap0(handler, "keys", DerivedKeysTrap); | 354 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap); |
355 return ToNameArray(names, "keys", false); | 355 return ToNameArray(names, "keys", false); |
356 } | 356 } |
357 return %OwnKeys(obj); | 357 return %OwnKeys(obj); |
358 } | 358 } |
359 | 359 |
360 | 360 |
361 // ES5 8.10.1. | 361 // ES5 8.10.1. |
362 function IsAccessorDescriptor(desc) { | 362 function IsAccessorDescriptor(desc) { |
363 if (IS_UNDEFINED(desc)) return false; | 363 if (IS_UNDEFINED(desc)) return false; |
364 return desc.hasGetter() || desc.hasSetter(); | 364 return desc.hasGetter() || desc.hasSetter(); |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 function ProxyFix(obj) { | 1231 function ProxyFix(obj) { |
1232 var handler = %GetHandler(obj); | 1232 var handler = %GetHandler(obj); |
1233 var props = CallTrap0(handler, "fix", UNDEFINED); | 1233 var props = CallTrap0(handler, "fix", UNDEFINED); |
1234 if (IS_UNDEFINED(props)) { | 1234 if (IS_UNDEFINED(props)) { |
1235 throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); | 1235 throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); |
1236 } | 1236 } |
1237 | 1237 |
1238 if (%IsJSFunctionProxy(obj)) { | 1238 if (%IsJSFunctionProxy(obj)) { |
1239 var callTrap = %GetCallTrap(obj); | 1239 var callTrap = %GetCallTrap(obj); |
1240 var constructTrap = %GetConstructTrap(obj); | 1240 var constructTrap = %GetConstructTrap(obj); |
1241 var code = DelegateCallAndConstruct(callTrap, constructTrap); | 1241 var code = $proxyDelegateCallAndConstruct(callTrap, constructTrap); |
1242 %Fix(obj); // becomes a regular function | 1242 %Fix(obj); // becomes a regular function |
1243 %SetCode(obj, code); | 1243 %SetCode(obj, code); |
1244 // TODO(rossberg): What about length and other properties? Not specified. | 1244 // TODO(rossberg): What about length and other properties? Not specified. |
1245 // We just put in some half-reasonable defaults for now. | 1245 // We just put in some half-reasonable defaults for now. |
1246 var prototype = new $Object(); | 1246 var prototype = new $Object(); |
1247 $Object.defineProperty(prototype, "constructor", | 1247 $Object.defineProperty(prototype, "constructor", |
1248 {value: obj, writable: true, enumerable: false, configurable: true}); | 1248 {value: obj, writable: true, enumerable: false, configurable: true}); |
1249 // TODO(v8:1530): defineProperty does not handle prototype and length. | 1249 // TODO(v8:1530): defineProperty does not handle prototype and length. |
1250 %FunctionSetPrototype(obj, prototype); | 1250 %FunctionSetPrototype(obj, prototype); |
1251 obj.length = 0; | 1251 obj.length = 0; |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 } | 1914 } |
1915 if (!IS_SPEC_FUNCTION(method)) { | 1915 if (!IS_SPEC_FUNCTION(method)) { |
1916 throw MakeTypeError('not_iterable', [obj]); | 1916 throw MakeTypeError('not_iterable', [obj]); |
1917 } | 1917 } |
1918 var iterator = %_CallFunction(obj, method); | 1918 var iterator = %_CallFunction(obj, method); |
1919 if (!IS_SPEC_OBJECT(iterator)) { | 1919 if (!IS_SPEC_OBJECT(iterator)) { |
1920 throw MakeTypeError('not_an_iterator', [iterator]); | 1920 throw MakeTypeError('not_an_iterator', [iterator]); |
1921 } | 1921 } |
1922 return iterator; | 1922 return iterator; |
1923 } | 1923 } |
OLD | NEW |