OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 if (!IS_SPEC_OBJECT(obj)) { | 1007 if (!IS_SPEC_OBJECT(obj)) { |
1008 throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyNames"]); | 1008 throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyNames"]); |
1009 } | 1009 } |
1010 // Special handling for proxies. | 1010 // Special handling for proxies. |
1011 if (%IsJSProxy(obj)) { | 1011 if (%IsJSProxy(obj)) { |
1012 var handler = %GetHandler(obj); | 1012 var handler = %GetHandler(obj); |
1013 var names = CallTrap0(handler, "getOwnPropertyNames", void 0); | 1013 var names = CallTrap0(handler, "getOwnPropertyNames", void 0); |
1014 return ToNameArray(names, "getOwnPropertyNames", true); | 1014 return ToNameArray(names, "getOwnPropertyNames", true); |
1015 } | 1015 } |
1016 | 1016 |
| 1017 var nameArrays = new InternalArray(); |
| 1018 |
1017 // Find all the indexed properties. | 1019 // Find all the indexed properties. |
1018 | 1020 |
1019 // Get the local element names. | 1021 // Get the local element names. |
1020 var propertyNames = %GetLocalElementNames(obj); | 1022 var localElementNames = %GetLocalElementNames(obj); |
1021 for (var i = 0; i < propertyNames.length; ++i) { | 1023 for (var i = 0; i < localElementNames.length; ++i) { |
1022 propertyNames[i] = %_NumberToString(propertyNames[i]); | 1024 localElementNames[i] = %_NumberToString(localElementNames[i]); |
1023 } | 1025 } |
| 1026 nameArrays.push(localElementNames); |
1024 | 1027 |
1025 // Get names for indexed interceptor properties. | 1028 // Get names for indexed interceptor properties. |
1026 var interceptorInfo = %GetInterceptorInfo(obj); | 1029 var interceptorInfo = %GetInterceptorInfo(obj); |
1027 if ((interceptorInfo & 1) != 0) { | 1030 if ((interceptorInfo & 1) != 0) { |
1028 var indexedInterceptorNames = | 1031 var indexedInterceptorNames = %GetIndexedInterceptorElementNames(obj); |
1029 %GetIndexedInterceptorElementNames(obj); | 1032 if (!IS_UNDEFINED(indexedInterceptorNames)) { |
1030 if (indexedInterceptorNames) { | 1033 nameArrays.push(indexedInterceptorNames); |
1031 propertyNames = propertyNames.concat(indexedInterceptorNames); | |
1032 } | 1034 } |
1033 } | 1035 } |
1034 | 1036 |
1035 // Find all the named properties. | 1037 // Find all the named properties. |
1036 | 1038 |
1037 // Get the local property names. | 1039 // Get the local property names. |
1038 propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj)); | 1040 nameArrays.push(%GetLocalPropertyNames(obj)); |
1039 | 1041 |
1040 // Get names for named interceptor properties if any. | 1042 // Get names for named interceptor properties if any. |
1041 if ((interceptorInfo & 2) != 0) { | 1043 if ((interceptorInfo & 2) != 0) { |
1042 var namedInterceptorNames = | 1044 var namedInterceptorNames = %GetNamedInterceptorPropertyNames(obj); |
1043 %GetNamedInterceptorPropertyNames(obj); | 1045 if (!IS_UNDEFINED(namedInterceptorNames)) { |
1044 if (namedInterceptorNames) { | 1046 nameArrays.push(namedInterceptorNames); |
1045 propertyNames = propertyNames.concat(namedInterceptorNames); | |
1046 } | 1047 } |
1047 } | 1048 } |
1048 | 1049 |
1049 // Property names are expected to be unique names, | 1050 var propertyNames = |
| 1051 %Apply(InternalArray.prototype.concat, |
| 1052 nameArrays[0], nameArrays, 1, nameArrays.length - 1); |
| 1053 |
| 1054 // Property names are expected to be unique strings, |
1050 // but interceptors can interfere with that assumption. | 1055 // but interceptors can interfere with that assumption. |
1051 if (interceptorInfo != 0) { | 1056 if (interceptorInfo != 0) { |
1052 var propertySet = { __proto__: null }; | 1057 var propertySet = { __proto__: null }; |
1053 var j = 0; | 1058 var j = 0; |
1054 for (var i = 0; i < propertyNames.length; ++i) { | 1059 for (var i = 0; i < propertyNames.length; ++i) { |
1055 var name = ToName(propertyNames[i]); | 1060 var name = ToName(propertyNames[i]); |
1056 // We need to check for the exact property value since for intrinsic | 1061 // We need to check for the exact property value since for intrinsic |
1057 // properties like toString if(propertySet["toString"]) will always | 1062 // properties like toString if(propertySet["toString"]) will always |
1058 // succeed. | 1063 // succeed. |
1059 if (propertySet[name] === true) { | 1064 if (propertySet[name] === true) { |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 | 1732 |
1728 function SetUpFunction() { | 1733 function SetUpFunction() { |
1729 %CheckIsBootstrapping(); | 1734 %CheckIsBootstrapping(); |
1730 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1735 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1731 "bind", FunctionBind, | 1736 "bind", FunctionBind, |
1732 "toString", FunctionToString | 1737 "toString", FunctionToString |
1733 )); | 1738 )); |
1734 } | 1739 } |
1735 | 1740 |
1736 SetUpFunction(); | 1741 SetUpFunction(); |
OLD | NEW |