Chromium Code Reviews| 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 } | 963 } |
| 964 | 964 |
| 965 | 965 |
| 966 // For Harmony proxies | 966 // For Harmony proxies |
| 967 function ToStringArray(obj, trap) { | 967 function ToStringArray(obj, trap) { |
| 968 if (!IS_SPEC_OBJECT(obj)) { | 968 if (!IS_SPEC_OBJECT(obj)) { |
| 969 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); | 969 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); |
| 970 } | 970 } |
| 971 var n = ToUint32(obj.length); | 971 var n = ToUint32(obj.length); |
| 972 var array = new $Array(n); | 972 var array = new $Array(n); |
| 973 var names = {}; // TODO(rossberg): use sets once they are ready. | 973 var names = { __proto__: null }; // TODO(rossberg): use sets once they are re ady. |
|
rossberg
2012/11/15 15:39:37
Actually, this case was correct. ;) But cannot ha
| |
| 974 for (var index = 0; index < n; index++) { | 974 for (var index = 0; index < n; index++) { |
| 975 var s = ToString(obj[index]); | 975 var s = ToString(obj[index]); |
| 976 if (%HasLocalProperty(names, s)) { | 976 if (%HasLocalProperty(names, s)) { |
| 977 throw MakeTypeError("proxy_repeated_prop_name", [obj, trap, s]); | 977 throw MakeTypeError("proxy_repeated_prop_name", [obj, trap, s]); |
| 978 } | 978 } |
| 979 array[index] = s; | 979 array[index] = s; |
| 980 names[s] = 0; | 980 names[s] = 0; |
| 981 } | 981 } |
| 982 return array; | 982 return array; |
| 983 } | 983 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 | 1018 |
| 1019 if (%GetInterceptorInfo(obj) & 2) { | 1019 if (%GetInterceptorInfo(obj) & 2) { |
| 1020 var namedInterceptorNames = | 1020 var namedInterceptorNames = |
| 1021 %GetNamedInterceptorPropertyNames(obj); | 1021 %GetNamedInterceptorPropertyNames(obj); |
| 1022 if (namedInterceptorNames) { | 1022 if (namedInterceptorNames) { |
| 1023 propertyNames = propertyNames.concat(namedInterceptorNames); | 1023 propertyNames = propertyNames.concat(namedInterceptorNames); |
| 1024 } | 1024 } |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 // Property names are expected to be unique strings. | 1027 // Property names are expected to be unique strings. |
| 1028 var propertySet = {}; | 1028 var propertySet = { __proto__: null }; |
| 1029 var j = 0; | 1029 var j = 0; |
| 1030 for (var i = 0; i < propertyNames.length; ++i) { | 1030 for (var i = 0; i < propertyNames.length; ++i) { |
| 1031 var name = ToString(propertyNames[i]); | 1031 var name = ToString(propertyNames[i]); |
| 1032 // We need to check for the exact property value since for intrinsic | 1032 // We need to check for the exact property value since for intrinsic |
| 1033 // properties like toString if(propertySet["toString"]) will always | 1033 // properties like toString if(propertySet["toString"]) will always |
| 1034 // succeed. | 1034 // succeed. |
| 1035 if (propertySet[name] === true) { | 1035 if (propertySet[name] === true) { |
| 1036 continue; | 1036 continue; |
| 1037 } | 1037 } |
| 1038 propertySet[name] = true; | 1038 propertySet[name] = true; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1059 // ES5 section 15.2.3.6. | 1059 // ES5 section 15.2.3.6. |
| 1060 function ObjectDefineProperty(obj, p, attributes) { | 1060 function ObjectDefineProperty(obj, p, attributes) { |
| 1061 if (!IS_SPEC_OBJECT(obj)) { | 1061 if (!IS_SPEC_OBJECT(obj)) { |
| 1062 throw MakeTypeError("called_on_non_object", ["Object.defineProperty"]); | 1062 throw MakeTypeError("called_on_non_object", ["Object.defineProperty"]); |
| 1063 } | 1063 } |
| 1064 var name = ToString(p); | 1064 var name = ToString(p); |
| 1065 if (%IsJSProxy(obj)) { | 1065 if (%IsJSProxy(obj)) { |
| 1066 // Clone the attributes object for protection. | 1066 // Clone the attributes object for protection. |
| 1067 // TODO(rossberg): not spec'ed yet, so not sure if this should involve | 1067 // TODO(rossberg): not spec'ed yet, so not sure if this should involve |
| 1068 // non-own properties as it does (or non-enumerable ones, as it doesn't?). | 1068 // non-own properties as it does (or non-enumerable ones, as it doesn't?). |
| 1069 var attributesClone = {}; | 1069 var attributesClone = { __proto__: null }; |
| 1070 for (var a in attributes) { | 1070 for (var a in attributes) { |
| 1071 attributesClone[a] = attributes[a]; | 1071 attributesClone[a] = attributes[a]; |
| 1072 } | 1072 } |
| 1073 DefineProxyProperty(obj, name, attributesClone, true); | 1073 DefineProxyProperty(obj, name, attributesClone, true); |
| 1074 // The following would implement the spec as in the current proposal, | 1074 // The following would implement the spec as in the current proposal, |
| 1075 // but after recent comments on es-discuss, is most likely obsolete. | 1075 // but after recent comments on es-discuss, is most likely obsolete. |
| 1076 /* | 1076 /* |
| 1077 var defineObj = FromGenericPropertyDescriptor(desc); | 1077 var defineObj = FromGenericPropertyDescriptor(desc); |
| 1078 var names = ObjectGetOwnPropertyNames(attributes); | 1078 var names = ObjectGetOwnPropertyNames(attributes); |
| 1079 var standardNames = | 1079 var standardNames = |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1677 | 1677 |
| 1678 function SetUpFunction() { | 1678 function SetUpFunction() { |
| 1679 %CheckIsBootstrapping(); | 1679 %CheckIsBootstrapping(); |
| 1680 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1680 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1681 "bind", FunctionBind, | 1681 "bind", FunctionBind, |
| 1682 "toString", FunctionToString | 1682 "toString", FunctionToString |
| 1683 )); | 1683 )); |
| 1684 } | 1684 } |
| 1685 | 1685 |
| 1686 SetUpFunction(); | 1686 SetUpFunction(); |
| OLD | NEW |