| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 if (x === y) return 0; | 735 if (x === y) return 0; |
| 736 if (%_IsSmi(x) && %_IsSmi(y)) { | 736 if (%_IsSmi(x) && %_IsSmi(y)) { |
| 737 return %SmiLexicographicCompare(x, y); | 737 return %SmiLexicographicCompare(x, y); |
| 738 } | 738 } |
| 739 x = ToString(x); | 739 x = ToString(x); |
| 740 y = ToString(y); | 740 y = ToString(y); |
| 741 if (x == y) return 0; | 741 if (x == y) return 0; |
| 742 else return x < y ? -1 : 1; | 742 else return x < y ? -1 : 1; |
| 743 }; | 743 }; |
| 744 } | 744 } |
| 745 var receiver = | 745 var receiver = %GetDefaultReceiver(comparefn); |
| 746 %_IsNativeOrStrictMode(comparefn) ? void 0 : %GetGlobalReceiver(); | |
| 747 | 746 |
| 748 function InsertionSort(a, from, to) { | 747 function InsertionSort(a, from, to) { |
| 749 for (var i = from + 1; i < to; i++) { | 748 for (var i = from + 1; i < to; i++) { |
| 750 var element = a[i]; | 749 var element = a[i]; |
| 751 for (var j = i - 1; j >= from; j--) { | 750 for (var j = i - 1; j >= from; j--) { |
| 752 var tmp = a[j]; | 751 var tmp = a[j]; |
| 753 var order = %_CallFunction(receiver, tmp, element, comparefn); | 752 var order = %_CallFunction(receiver, tmp, element, comparefn); |
| 754 if (order > 0) { | 753 if (order > 0) { |
| 755 a[j + 1] = tmp; | 754 a[j + 1] = tmp; |
| 756 } else { | 755 } else { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 // or delete elements from the array. | 989 // or delete elements from the array. |
| 991 function ArrayFilter(f, receiver) { | 990 function ArrayFilter(f, receiver) { |
| 992 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 991 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 993 throw MakeTypeError("called_on_null_or_undefined", | 992 throw MakeTypeError("called_on_null_or_undefined", |
| 994 ["Array.prototype.filter"]); | 993 ["Array.prototype.filter"]); |
| 995 } | 994 } |
| 996 | 995 |
| 997 if (!IS_FUNCTION(f)) { | 996 if (!IS_FUNCTION(f)) { |
| 998 throw MakeTypeError('called_non_callable', [ f ]); | 997 throw MakeTypeError('called_non_callable', [ f ]); |
| 999 } | 998 } |
| 999 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 1000 receiver = %GetDefaultReceiver(f) || receiver; |
| 1001 } |
| 1000 // Pull out the length so that modifications to the length in the | 1002 // Pull out the length so that modifications to the length in the |
| 1001 // loop will not affect the looping. | 1003 // loop will not affect the looping. |
| 1002 var length = ToUint32(this.length); | 1004 var length = ToUint32(this.length); |
| 1003 var result = []; | 1005 var result = []; |
| 1004 var result_length = 0; | 1006 var result_length = 0; |
| 1005 for (var i = 0; i < length; i++) { | 1007 for (var i = 0; i < length; i++) { |
| 1006 var current = this[i]; | 1008 var current = this[i]; |
| 1007 if (!IS_UNDEFINED(current) || i in this) { | 1009 if (!IS_UNDEFINED(current) || i in this) { |
| 1008 if (f.call(receiver, current, i, this)) { | 1010 if (%_CallFunction(receiver, current, i, this, f)) { |
| 1009 result[result_length++] = current; | 1011 result[result_length++] = current; |
| 1010 } | 1012 } |
| 1011 } | 1013 } |
| 1012 } | 1014 } |
| 1013 return result; | 1015 return result; |
| 1014 } | 1016 } |
| 1015 | 1017 |
| 1016 | 1018 |
| 1017 function ArrayForEach(f, receiver) { | 1019 function ArrayForEach(f, receiver) { |
| 1018 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1020 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1019 throw MakeTypeError("called_on_null_or_undefined", | 1021 throw MakeTypeError("called_on_null_or_undefined", |
| 1020 ["Array.prototype.forEach"]); | 1022 ["Array.prototype.forEach"]); |
| 1021 } | 1023 } |
| 1022 | 1024 |
| 1023 if (!IS_FUNCTION(f)) { | 1025 if (!IS_FUNCTION(f)) { |
| 1024 throw MakeTypeError('called_non_callable', [ f ]); | 1026 throw MakeTypeError('called_non_callable', [ f ]); |
| 1025 } | 1027 } |
| 1028 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 1029 receiver = %GetDefaultReceiver(f) || receiver; |
| 1030 } |
| 1026 // Pull out the length so that modifications to the length in the | 1031 // Pull out the length so that modifications to the length in the |
| 1027 // loop will not affect the looping. | 1032 // loop will not affect the looping. |
| 1028 var length = TO_UINT32(this.length); | 1033 var length = TO_UINT32(this.length); |
| 1029 for (var i = 0; i < length; i++) { | 1034 for (var i = 0; i < length; i++) { |
| 1030 var current = this[i]; | 1035 var current = this[i]; |
| 1031 if (!IS_UNDEFINED(current) || i in this) { | 1036 if (!IS_UNDEFINED(current) || i in this) { |
| 1032 f.call(receiver, current, i, this); | 1037 %_CallFunction(receiver, current, i, this, f); |
| 1033 } | 1038 } |
| 1034 } | 1039 } |
| 1035 } | 1040 } |
| 1036 | 1041 |
| 1037 | 1042 |
| 1038 // Executes the function once for each element present in the | 1043 // Executes the function once for each element present in the |
| 1039 // array until it finds one where callback returns true. | 1044 // array until it finds one where callback returns true. |
| 1040 function ArraySome(f, receiver) { | 1045 function ArraySome(f, receiver) { |
| 1041 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1046 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1042 throw MakeTypeError("called_on_null_or_undefined", | 1047 throw MakeTypeError("called_on_null_or_undefined", |
| 1043 ["Array.prototype.some"]); | 1048 ["Array.prototype.some"]); |
| 1044 } | 1049 } |
| 1045 | 1050 |
| 1046 if (!IS_FUNCTION(f)) { | 1051 if (!IS_FUNCTION(f)) { |
| 1047 throw MakeTypeError('called_non_callable', [ f ]); | 1052 throw MakeTypeError('called_non_callable', [ f ]); |
| 1048 } | 1053 } |
| 1054 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 1055 receiver = %GetDefaultReceiver(f) || receiver; |
| 1056 } |
| 1049 // Pull out the length so that modifications to the length in the | 1057 // Pull out the length so that modifications to the length in the |
| 1050 // loop will not affect the looping. | 1058 // loop will not affect the looping. |
| 1051 var length = TO_UINT32(this.length); | 1059 var length = TO_UINT32(this.length); |
| 1052 for (var i = 0; i < length; i++) { | 1060 for (var i = 0; i < length; i++) { |
| 1053 var current = this[i]; | 1061 var current = this[i]; |
| 1054 if (!IS_UNDEFINED(current) || i in this) { | 1062 if (!IS_UNDEFINED(current) || i in this) { |
| 1055 if (f.call(receiver, current, i, this)) return true; | 1063 if (%_CallFunction(receiver, current, i, this, f)) return true; |
| 1056 } | 1064 } |
| 1057 } | 1065 } |
| 1058 return false; | 1066 return false; |
| 1059 } | 1067 } |
| 1060 | 1068 |
| 1061 | 1069 |
| 1062 function ArrayEvery(f, receiver) { | 1070 function ArrayEvery(f, receiver) { |
| 1063 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1071 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1064 throw MakeTypeError("called_on_null_or_undefined", | 1072 throw MakeTypeError("called_on_null_or_undefined", |
| 1065 ["Array.prototype.every"]); | 1073 ["Array.prototype.every"]); |
| 1066 } | 1074 } |
| 1067 | 1075 |
| 1068 if (!IS_FUNCTION(f)) { | 1076 if (!IS_FUNCTION(f)) { |
| 1069 throw MakeTypeError('called_non_callable', [ f ]); | 1077 throw MakeTypeError('called_non_callable', [ f ]); |
| 1070 } | 1078 } |
| 1079 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 1080 receiver = %GetDefaultReceiver(f) || receiver; |
| 1081 } |
| 1071 // Pull out the length so that modifications to the length in the | 1082 // Pull out the length so that modifications to the length in the |
| 1072 // loop will not affect the looping. | 1083 // loop will not affect the looping. |
| 1073 var length = TO_UINT32(this.length); | 1084 var length = TO_UINT32(this.length); |
| 1074 for (var i = 0; i < length; i++) { | 1085 for (var i = 0; i < length; i++) { |
| 1075 var current = this[i]; | 1086 var current = this[i]; |
| 1076 if (!IS_UNDEFINED(current) || i in this) { | 1087 if (!IS_UNDEFINED(current) || i in this) { |
| 1077 if (!f.call(receiver, current, i, this)) return false; | 1088 if (!%_CallFunction(receiver, current, i, this, f)) return false; |
| 1078 } | 1089 } |
| 1079 } | 1090 } |
| 1080 return true; | 1091 return true; |
| 1081 } | 1092 } |
| 1082 | 1093 |
| 1083 function ArrayMap(f, receiver) { | 1094 function ArrayMap(f, receiver) { |
| 1084 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1095 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1085 throw MakeTypeError("called_on_null_or_undefined", | 1096 throw MakeTypeError("called_on_null_or_undefined", |
| 1086 ["Array.prototype.map"]); | 1097 ["Array.prototype.map"]); |
| 1087 } | 1098 } |
| 1088 | 1099 |
| 1089 if (!IS_FUNCTION(f)) { | 1100 if (!IS_FUNCTION(f)) { |
| 1090 throw MakeTypeError('called_non_callable', [ f ]); | 1101 throw MakeTypeError('called_non_callable', [ f ]); |
| 1091 } | 1102 } |
| 1103 if (IS_NULL_OR_UNDEFINED(receiver)) { |
| 1104 receiver = %GetDefaultReceiver(f) || receiver; |
| 1105 } |
| 1092 // Pull out the length so that modifications to the length in the | 1106 // Pull out the length so that modifications to the length in the |
| 1093 // loop will not affect the looping. | 1107 // loop will not affect the looping. |
| 1094 var length = TO_UINT32(this.length); | 1108 var length = TO_UINT32(this.length); |
| 1095 var result = new $Array(); | 1109 var result = new $Array(); |
| 1096 var accumulator = new InternalArray(length); | 1110 var accumulator = new InternalArray(length); |
| 1097 for (var i = 0; i < length; i++) { | 1111 for (var i = 0; i < length; i++) { |
| 1098 var current = this[i]; | 1112 var current = this[i]; |
| 1099 if (!IS_UNDEFINED(current) || i in this) { | 1113 if (!IS_UNDEFINED(current) || i in this) { |
| 1100 accumulator[i] = f.call(receiver, current, i, this); | 1114 accumulator[i] = %_CallFunction(receiver, current, i, this, f); |
| 1101 } | 1115 } |
| 1102 } | 1116 } |
| 1103 %MoveArrayContents(accumulator, result); | 1117 %MoveArrayContents(accumulator, result); |
| 1104 return result; | 1118 return result; |
| 1105 } | 1119 } |
| 1106 | 1120 |
| 1107 | 1121 |
| 1108 function ArrayIndexOf(element, index) { | 1122 function ArrayIndexOf(element, index) { |
| 1109 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1123 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1110 throw MakeTypeError("called_on_null_or_undefined", | 1124 throw MakeTypeError("called_on_null_or_undefined", |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 | 1241 |
| 1228 function ArrayReduce(callback, current) { | 1242 function ArrayReduce(callback, current) { |
| 1229 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1243 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1230 throw MakeTypeError("called_on_null_or_undefined", | 1244 throw MakeTypeError("called_on_null_or_undefined", |
| 1231 ["Array.prototype.reduce"]); | 1245 ["Array.prototype.reduce"]); |
| 1232 } | 1246 } |
| 1233 | 1247 |
| 1234 if (!IS_FUNCTION(callback)) { | 1248 if (!IS_FUNCTION(callback)) { |
| 1235 throw MakeTypeError('called_non_callable', [callback]); | 1249 throw MakeTypeError('called_non_callable', [callback]); |
| 1236 } | 1250 } |
| 1251 |
| 1237 // Pull out the length so that modifications to the length in the | 1252 // Pull out the length so that modifications to the length in the |
| 1238 // loop will not affect the looping. | 1253 // loop will not affect the looping. |
| 1239 var length = ToUint32(this.length); | 1254 var length = ToUint32(this.length); |
| 1240 var i = 0; | 1255 var i = 0; |
| 1241 | 1256 |
| 1242 find_initial: if (%_ArgumentsLength() < 2) { | 1257 find_initial: if (%_ArgumentsLength() < 2) { |
| 1243 for (; i < length; i++) { | 1258 for (; i < length; i++) { |
| 1244 current = this[i]; | 1259 current = this[i]; |
| 1245 if (!IS_UNDEFINED(current) || i in this) { | 1260 if (!IS_UNDEFINED(current) || i in this) { |
| 1246 i++; | 1261 i++; |
| 1247 break find_initial; | 1262 break find_initial; |
| 1248 } | 1263 } |
| 1249 } | 1264 } |
| 1250 throw MakeTypeError('reduce_no_initial', []); | 1265 throw MakeTypeError('reduce_no_initial', []); |
| 1251 } | 1266 } |
| 1252 | 1267 |
| 1268 var receiver = %GetDefaultReceiver(callback); |
| 1253 for (; i < length; i++) { | 1269 for (; i < length; i++) { |
| 1254 var element = this[i]; | 1270 var element = this[i]; |
| 1255 if (!IS_UNDEFINED(element) || i in this) { | 1271 if (!IS_UNDEFINED(element) || i in this) { |
| 1256 current = callback.call(void 0, current, element, i, this); | 1272 current = %_CallFunction(receiver, current, element, i, this, callback); |
| 1257 } | 1273 } |
| 1258 } | 1274 } |
| 1259 return current; | 1275 return current; |
| 1260 } | 1276 } |
| 1261 | 1277 |
| 1262 function ArrayReduceRight(callback, current) { | 1278 function ArrayReduceRight(callback, current) { |
| 1263 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1279 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 1264 throw MakeTypeError("called_on_null_or_undefined", | 1280 throw MakeTypeError("called_on_null_or_undefined", |
| 1265 ["Array.prototype.reduceRight"]); | 1281 ["Array.prototype.reduceRight"]); |
| 1266 } | 1282 } |
| 1267 | 1283 |
| 1268 if (!IS_FUNCTION(callback)) { | 1284 if (!IS_FUNCTION(callback)) { |
| 1269 throw MakeTypeError('called_non_callable', [callback]); | 1285 throw MakeTypeError('called_non_callable', [callback]); |
| 1270 } | 1286 } |
| 1271 var i = ToUint32(this.length) - 1; | 1287 var i = ToUint32(this.length) - 1; |
| 1272 | 1288 |
| 1273 find_initial: if (%_ArgumentsLength() < 2) { | 1289 find_initial: if (%_ArgumentsLength() < 2) { |
| 1274 for (; i >= 0; i--) { | 1290 for (; i >= 0; i--) { |
| 1275 current = this[i]; | 1291 current = this[i]; |
| 1276 if (!IS_UNDEFINED(current) || i in this) { | 1292 if (!IS_UNDEFINED(current) || i in this) { |
| 1277 i--; | 1293 i--; |
| 1278 break find_initial; | 1294 break find_initial; |
| 1279 } | 1295 } |
| 1280 } | 1296 } |
| 1281 throw MakeTypeError('reduce_no_initial', []); | 1297 throw MakeTypeError('reduce_no_initial', []); |
| 1282 } | 1298 } |
| 1283 | 1299 |
| 1300 var receiver = %GetDefaultReceiver(callback); |
| 1284 for (; i >= 0; i--) { | 1301 for (; i >= 0; i--) { |
| 1285 var element = this[i]; | 1302 var element = this[i]; |
| 1286 if (!IS_UNDEFINED(element) || i in this) { | 1303 if (!IS_UNDEFINED(element) || i in this) { |
| 1287 current = callback.call(void 0, current, element, i, this); | 1304 current = %_CallFunction(receiver, current, element, i, this, callback); |
| 1288 } | 1305 } |
| 1289 } | 1306 } |
| 1290 return current; | 1307 return current; |
| 1291 } | 1308 } |
| 1292 | 1309 |
| 1293 // ES5, 15.4.3.2 | 1310 // ES5, 15.4.3.2 |
| 1294 function ArrayIsArray(obj) { | 1311 function ArrayIsArray(obj) { |
| 1295 return IS_ARRAY(obj); | 1312 return IS_ARRAY(obj); |
| 1296 } | 1313 } |
| 1297 | 1314 |
| 1298 | 1315 |
| 1299 // ------------------------------------------------------------------- | 1316 // ------------------------------------------------------------------- |
| 1300 function SetupArray() { | 1317 function SetUpArray() { |
| 1301 // Setup non-enumerable constructor property on the Array.prototype | 1318 %CheckIsBootstrapping(); |
| 1319 // Set up non-enumerable constructor property on the Array.prototype |
| 1302 // object. | 1320 // object. |
| 1303 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); | 1321 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); |
| 1304 | 1322 |
| 1305 // Setup non-enumerable functions on the Array object. | 1323 // Set up non-enumerable functions on the Array object. |
| 1306 InstallFunctions($Array, DONT_ENUM, $Array( | 1324 InstallFunctions($Array, DONT_ENUM, $Array( |
| 1307 "isArray", ArrayIsArray | 1325 "isArray", ArrayIsArray |
| 1308 )); | 1326 )); |
| 1309 | 1327 |
| 1310 var specialFunctions = %SpecialArrayFunctions({}); | 1328 var specialFunctions = %SpecialArrayFunctions({}); |
| 1311 | 1329 |
| 1312 function getFunction(name, jsBuiltin, len) { | 1330 function getFunction(name, jsBuiltin, len) { |
| 1313 var f = jsBuiltin; | 1331 var f = jsBuiltin; |
| 1314 if (specialFunctions.hasOwnProperty(name)) { | 1332 if (specialFunctions.hasOwnProperty(name)) { |
| 1315 f = specialFunctions[name]; | 1333 f = specialFunctions[name]; |
| 1316 } | 1334 } |
| 1317 if (!IS_UNDEFINED(len)) { | 1335 if (!IS_UNDEFINED(len)) { |
| 1318 %FunctionSetLength(f, len); | 1336 %FunctionSetLength(f, len); |
| 1319 } | 1337 } |
| 1320 return f; | 1338 return f; |
| 1321 } | 1339 } |
| 1322 | 1340 |
| 1323 // Setup non-enumerable functions of the Array.prototype object and | 1341 // Set up non-enumerable functions of the Array.prototype object and |
| 1324 // set their names. | 1342 // set their names. |
| 1325 // Manipulate the length of some of the functions to meet | 1343 // Manipulate the length of some of the functions to meet |
| 1326 // expectations set by ECMA-262 or Mozilla. | 1344 // expectations set by ECMA-262 or Mozilla. |
| 1327 InstallFunctionsOnHiddenPrototype($Array.prototype, DONT_ENUM, $Array( | 1345 InstallFunctionsOnHiddenPrototype($Array.prototype, DONT_ENUM, $Array( |
| 1328 "toString", getFunction("toString", ArrayToString), | 1346 "toString", getFunction("toString", ArrayToString), |
| 1329 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), | 1347 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), |
| 1330 "join", getFunction("join", ArrayJoin), | 1348 "join", getFunction("join", ArrayJoin), |
| 1331 "pop", getFunction("pop", ArrayPop), | 1349 "pop", getFunction("pop", ArrayPop), |
| 1332 "push", getFunction("push", ArrayPush, 1), | 1350 "push", getFunction("push", ArrayPush, 1), |
| 1333 "concat", getFunction("concat", ArrayConcat, 1), | 1351 "concat", getFunction("concat", ArrayConcat, 1), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1344 "map", getFunction("map", ArrayMap, 1), | 1362 "map", getFunction("map", ArrayMap, 1), |
| 1345 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), | 1363 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), |
| 1346 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1364 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
| 1347 "reduce", getFunction("reduce", ArrayReduce, 1), | 1365 "reduce", getFunction("reduce", ArrayReduce, 1), |
| 1348 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) | 1366 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) |
| 1349 )); | 1367 )); |
| 1350 | 1368 |
| 1351 %FinishArrayPrototypeSetup($Array.prototype); | 1369 %FinishArrayPrototypeSetup($Array.prototype); |
| 1352 | 1370 |
| 1353 // The internal Array prototype doesn't need to be fancy, since it's never | 1371 // The internal Array prototype doesn't need to be fancy, since it's never |
| 1354 // exposed to user code, so no hidden prototypes or DONT_ENUM attributes | 1372 // exposed to user code. |
| 1355 // are necessary. | 1373 // Adding only the functions that are actually used. |
| 1356 // The null __proto__ ensures that we never inherit any user created | 1374 SetUpLockedPrototype(InternalArray, $Array(), $Array( |
| 1357 // getters or setters from, e.g., Object.prototype. | 1375 "join", getFunction("join", ArrayJoin), |
| 1358 InternalArray.prototype.__proto__ = null; | 1376 "pop", getFunction("pop", ArrayPop), |
| 1359 // Adding only the functions that are actually used, and a toString. | 1377 "push", getFunction("push", ArrayPush) |
| 1360 InternalArray.prototype.join = getFunction("join", ArrayJoin); | 1378 )); |
| 1361 InternalArray.prototype.pop = getFunction("pop", ArrayPop); | |
| 1362 InternalArray.prototype.push = getFunction("push", ArrayPush); | |
| 1363 InternalArray.prototype.toString = function() { | |
| 1364 return "Internal Array, length " + this.length; | |
| 1365 }; | |
| 1366 } | 1379 } |
| 1367 | 1380 |
| 1368 | 1381 SetUpArray(); |
| 1369 SetupArray(); | |
| OLD | NEW |