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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 from = high_start; | 878 from = high_start; |
879 } | 879 } |
880 } | 880 } |
881 }; | 881 }; |
882 | 882 |
883 // Copy elements in the range 0..length from obj's prototype chain | 883 // Copy elements in the range 0..length from obj's prototype chain |
884 // to obj itself, if obj has holes. Return one more than the maximal index | 884 // to obj itself, if obj has holes. Return one more than the maximal index |
885 // of a prototype property. | 885 // of a prototype property. |
886 var CopyFromPrototype = function CopyFromPrototype(obj, length) { | 886 var CopyFromPrototype = function CopyFromPrototype(obj, length) { |
887 var max = 0; | 887 var max = 0; |
888 for (var proto = obj.__proto__; proto; proto = proto.__proto__) { | 888 for (var proto = %GetPrototype(obj); proto; proto = %GetPrototype(proto)) { |
889 var indices = %GetArrayKeys(proto, length); | 889 var indices = %GetArrayKeys(proto, length); |
890 if (indices.length > 0) { | 890 if (indices.length > 0) { |
891 if (indices[0] == -1) { | 891 if (indices[0] == -1) { |
892 // It's an interval. | 892 // It's an interval. |
893 var proto_length = indices[1]; | 893 var proto_length = indices[1]; |
894 for (var i = 0; i < proto_length; i++) { | 894 for (var i = 0; i < proto_length; i++) { |
895 if (!obj.hasOwnProperty(i) && proto.hasOwnProperty(i)) { | 895 if (!obj.hasOwnProperty(i) && proto.hasOwnProperty(i)) { |
896 obj[i] = proto[i]; | 896 obj[i] = proto[i]; |
897 if (i >= max) { max = i + 1; } | 897 if (i >= max) { max = i + 1; } |
898 } | 898 } |
(...skipping 10 matching lines...) Expand all Loading... |
909 } | 909 } |
910 } | 910 } |
911 } | 911 } |
912 return max; | 912 return max; |
913 }; | 913 }; |
914 | 914 |
915 // Set a value of "undefined" on all indices in the range from..to | 915 // Set a value of "undefined" on all indices in the range from..to |
916 // where a prototype of obj has an element. I.e., shadow all prototype | 916 // where a prototype of obj has an element. I.e., shadow all prototype |
917 // elements in that range. | 917 // elements in that range. |
918 var ShadowPrototypeElements = function(obj, from, to) { | 918 var ShadowPrototypeElements = function(obj, from, to) { |
919 for (var proto = obj.__proto__; proto; proto = proto.__proto__) { | 919 for (var proto = %GetPrototype(obj); proto; proto = %GetPrototype(proto)) { |
920 var indices = %GetArrayKeys(proto, to); | 920 var indices = %GetArrayKeys(proto, to); |
921 if (indices.length > 0) { | 921 if (indices.length > 0) { |
922 if (indices[0] == -1) { | 922 if (indices[0] == -1) { |
923 // It's an interval. | 923 // It's an interval. |
924 var proto_length = indices[1]; | 924 var proto_length = indices[1]; |
925 for (var i = from; i < proto_length; i++) { | 925 for (var i = from; i < proto_length; i++) { |
926 if (proto.hasOwnProperty(i)) { | 926 if (proto.hasOwnProperty(i)) { |
927 obj[i] = void 0; | 927 obj[i] = void 0; |
928 } | 928 } |
929 } | 929 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // of defined elements. | 979 // of defined elements. |
980 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; | 980 if (!IS_UNDEFINED(obj[first_undefined])) first_undefined++; |
981 // Fill in the undefineds and the holes. There may be a hole where | 981 // Fill in the undefineds and the holes. There may be a hole where |
982 // an undefined should be and vice versa. | 982 // an undefined should be and vice versa. |
983 var i; | 983 var i; |
984 for (i = first_undefined; i < length - num_holes; i++) { | 984 for (i = first_undefined; i < length - num_holes; i++) { |
985 obj[i] = void 0; | 985 obj[i] = void 0; |
986 } | 986 } |
987 for (i = length - num_holes; i < length; i++) { | 987 for (i = length - num_holes; i < length; i++) { |
988 // For compatability with Webkit, do not expose elements in the prototype. | 988 // For compatability with Webkit, do not expose elements in the prototype. |
989 if (i in obj.__proto__) { | 989 if (i in %GetPrototype(obj)) { |
990 obj[i] = void 0; | 990 obj[i] = void 0; |
991 } else { | 991 } else { |
992 delete obj[i]; | 992 delete obj[i]; |
993 } | 993 } |
994 } | 994 } |
995 | 995 |
996 // Return the number of defined elements. | 996 // Return the number of defined elements. |
997 return first_undefined; | 997 return first_undefined; |
998 }; | 998 }; |
999 | 999 |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 )); | 1561 )); |
1562 | 1562 |
1563 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1563 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1564 "join", getFunction("join", ArrayJoin), | 1564 "join", getFunction("join", ArrayJoin), |
1565 "pop", getFunction("pop", ArrayPop), | 1565 "pop", getFunction("pop", ArrayPop), |
1566 "push", getFunction("push", ArrayPush) | 1566 "push", getFunction("push", ArrayPush) |
1567 )); | 1567 )); |
1568 } | 1568 } |
1569 | 1569 |
1570 SetUpArray(); | 1570 SetUpArray(); |
OLD | NEW |