OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 desc = descObj; | 1008 desc = descObj; |
1009 */ | 1009 */ |
1010 } else { | 1010 } else { |
1011 var desc = ToPropertyDescriptor(attributes); | 1011 var desc = ToPropertyDescriptor(attributes); |
1012 DefineOwnProperty(obj, name, desc, true); | 1012 DefineOwnProperty(obj, name, desc, true); |
1013 } | 1013 } |
1014 return obj; | 1014 return obj; |
1015 } | 1015 } |
1016 | 1016 |
1017 | 1017 |
1018 function GetOwnPropertyNames(properties) { | |
Lasse Reichstein
2011/08/18 08:35:22
Put "Enuerable" in the name somewhere.
| |
1019 var names = new InternalArray(); | |
1020 for (var key in properties) { | |
Lasse Reichstein
2011/08/18 08:35:22
I was hoping there would be a way to get the own p
| |
1021 global.print("key: " + key); | |
Lasse Reichstein
2011/08/18 08:35:22
Without the prints? :)
| |
1022 if (%HasLocalProperty(properties, key)) { | |
1023 global.print("key: " + key); | |
1024 names.push(key); | |
1025 } | |
1026 } | |
1027 return names; | |
1028 } | |
1029 | |
1030 | |
1018 // ES5 section 15.2.3.7. | 1031 // ES5 section 15.2.3.7. |
1019 function ObjectDefineProperties(obj, properties) { | 1032 function ObjectDefineProperties(obj, properties) { |
1020 if (!IS_SPEC_OBJECT(obj)) | 1033 if (!IS_SPEC_OBJECT(obj)) |
1021 throw MakeTypeError("obj_ctor_property_non_object", ["defineProperties"]); | 1034 throw MakeTypeError("obj_ctor_property_non_object", ["defineProperties"]); |
1022 var props = ToObject(properties); | 1035 var props = ToObject(properties); |
1023 var key_values = []; | 1036 var names = GetOwnPropertyNames(props); |
1024 for (var key in props) { | 1037 for (var i = 0; i < names.length; i++) { |
1025 if (%HasLocalProperty(props, key)) { | 1038 var name = names[i]; |
1026 key_values.push(key); | 1039 var desc = ToPropertyDescriptor(props[name]); |
1027 var value = props[key]; | 1040 DefineOwnProperty(obj, name, desc, true); |
1028 var desc = ToPropertyDescriptor(value); | |
1029 key_values.push(desc); | |
1030 } | |
1031 } | |
1032 for (var i = 0; i < key_values.length; i += 2) { | |
1033 var key = key_values[i]; | |
1034 var desc = key_values[i + 1]; | |
1035 DefineOwnProperty(obj, key, desc, true); | |
1036 } | 1041 } |
1037 return obj; | 1042 return obj; |
1038 } | 1043 } |
1039 | 1044 |
1040 | 1045 |
1041 // Harmony proxies. | 1046 // Harmony proxies. |
1042 function ProxyFix(obj) { | 1047 function ProxyFix(obj) { |
1043 var handler = %GetHandler(obj); | 1048 var handler = %GetHandler(obj); |
1044 var props = CallTrap0(handler, "fix", void 0); | 1049 var props = CallTrap0(handler, "fix", void 0); |
1045 if (IS_UNDEFINED(props)) { | 1050 if (IS_UNDEFINED(props)) { |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1534 // ---------------------------------------------------------------------------- | 1539 // ---------------------------------------------------------------------------- |
1535 | 1540 |
1536 function SetupFunction() { | 1541 function SetupFunction() { |
1537 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1542 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1538 "bind", FunctionBind, | 1543 "bind", FunctionBind, |
1539 "toString", FunctionToString | 1544 "toString", FunctionToString |
1540 )); | 1545 )); |
1541 } | 1546 } |
1542 | 1547 |
1543 SetupFunction(); | 1548 SetupFunction(); |
OLD | NEW |