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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 } | 1100 } |
1101 propertyNames.length = j; | 1101 propertyNames.length = j; |
1102 } | 1102 } |
1103 | 1103 |
1104 return propertyNames; | 1104 return propertyNames; |
1105 } | 1105 } |
1106 | 1106 |
1107 | 1107 |
1108 // ES5 section 15.2.3.4. | 1108 // ES5 section 15.2.3.4. |
1109 function ObjectGetOwnPropertyNames(obj) { | 1109 function ObjectGetOwnPropertyNames(obj) { |
1110 if (!IS_SPEC_OBJECT(obj)) { | 1110 obj = ToObject(obj); |
1111 throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyNames"]); | |
1112 } | |
1113 // Special handling for proxies. | 1111 // Special handling for proxies. |
1114 if (%IsJSProxy(obj)) { | 1112 if (%IsJSProxy(obj)) { |
1115 var handler = %GetHandler(obj); | 1113 var handler = %GetHandler(obj); |
1116 var names = CallTrap0(handler, "getOwnPropertyNames", UNDEFINED); | 1114 var names = CallTrap0(handler, "getOwnPropertyNames", UNDEFINED); |
1117 return ToNameArray(names, "getOwnPropertyNames", false); | 1115 return ToNameArray(names, "getOwnPropertyNames", false); |
1118 } | 1116 } |
1119 | 1117 |
1120 return ObjectGetOwnPropertyKeys(obj, false); | 1118 return ObjectGetOwnPropertyKeys(obj, false); |
1121 } | 1119 } |
1122 | 1120 |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 } | 1905 } |
1908 if (!IS_SPEC_FUNCTION(method)) { | 1906 if (!IS_SPEC_FUNCTION(method)) { |
1909 throw MakeTypeError('not_iterable', [obj]); | 1907 throw MakeTypeError('not_iterable', [obj]); |
1910 } | 1908 } |
1911 var iterator = %_CallFunction(obj, method); | 1909 var iterator = %_CallFunction(obj, method); |
1912 if (!IS_SPEC_OBJECT(iterator)) { | 1910 if (!IS_SPEC_OBJECT(iterator)) { |
1913 throw MakeTypeError('not_an_iterator', [iterator]); | 1911 throw MakeTypeError('not_an_iterator', [iterator]); |
1914 } | 1912 } |
1915 return iterator; | 1913 return iterator; |
1916 } | 1914 } |
OLD | NEW |