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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 function ObjectLookupSetter(name) { | 318 function ObjectLookupSetter(name) { |
319 var receiver = this; | 319 var receiver = this; |
320 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 320 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
321 receiver = %GlobalProxy(global); | 321 receiver = %GlobalProxy(global); |
322 } | 322 } |
323 return %LookupAccessor(ToObject(receiver), ToName(name), SETTER); | 323 return %LookupAccessor(ToObject(receiver), ToName(name), SETTER); |
324 } | 324 } |
325 | 325 |
326 | 326 |
327 function ObjectKeys(obj) { | 327 function ObjectKeys(obj) { |
328 obj = ToObject(obj); | 328 if (!IS_SPEC_OBJECT(obj)) { |
| 329 throw MakeTypeError("called_on_non_object", ["Object.keys"]); |
| 330 } |
329 if (%IsJSProxy(obj)) { | 331 if (%IsJSProxy(obj)) { |
330 var handler = %GetHandler(obj); | 332 var handler = %GetHandler(obj); |
331 var names = CallTrap0(handler, "keys", DerivedKeysTrap); | 333 var names = CallTrap0(handler, "keys", DerivedKeysTrap); |
332 return ToNameArray(names, "keys", false); | 334 return ToNameArray(names, "keys", false); |
333 } | 335 } |
334 return %OwnKeys(obj); | 336 return %OwnKeys(obj); |
335 } | 337 } |
336 | 338 |
337 | 339 |
338 // ES5 8.10.1. | 340 // ES5 8.10.1. |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 } | 1903 } |
1902 if (!IS_SPEC_FUNCTION(method)) { | 1904 if (!IS_SPEC_FUNCTION(method)) { |
1903 throw MakeTypeError('not_iterable', [obj]); | 1905 throw MakeTypeError('not_iterable', [obj]); |
1904 } | 1906 } |
1905 var iterator = %_CallFunction(obj, method); | 1907 var iterator = %_CallFunction(obj, method); |
1906 if (!IS_SPEC_OBJECT(iterator)) { | 1908 if (!IS_SPEC_OBJECT(iterator)) { |
1907 throw MakeTypeError('not_an_iterator', [iterator]); | 1909 throw MakeTypeError('not_an_iterator', [iterator]); |
1908 } | 1910 } |
1909 return iterator; | 1911 return iterator; |
1910 } | 1912 } |
OLD | NEW |