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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1308 } | 1308 } |
1309 | 1309 |
1310 // ES5, 15.4.3.2 | 1310 // ES5, 15.4.3.2 |
1311 function ArrayIsArray(obj) { | 1311 function ArrayIsArray(obj) { |
1312 return IS_ARRAY(obj); | 1312 return IS_ARRAY(obj); |
1313 } | 1313 } |
1314 | 1314 |
1315 | 1315 |
1316 // ------------------------------------------------------------------- | 1316 // ------------------------------------------------------------------- |
1317 function SetupArray() { | 1317 function SetupArray() { |
1318 %AssertIsBootstrapping(); | |
1318 // Setup non-enumerable constructor property on the Array.prototype | 1319 // Setup non-enumerable constructor property on the Array.prototype |
Erik Corry
2011/08/31 05:46:04
While we are here: "Set up", the verb, is two wor
Lasse Reichstein
2011/09/01 13:30:42
Fixed in comments.
| |
1319 // object. | 1320 // object. |
1320 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); | 1321 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); |
1321 | 1322 |
1322 // Setup non-enumerable functions on the Array object. | 1323 // Setup non-enumerable functions on the Array object. |
1323 InstallFunctions($Array, DONT_ENUM, $Array( | 1324 InstallFunctions($Array, DONT_ENUM, $Array( |
1324 "isArray", ArrayIsArray | 1325 "isArray", ArrayIsArray |
1325 )); | 1326 )); |
1326 | 1327 |
1327 var specialFunctions = %SpecialArrayFunctions({}); | 1328 var specialFunctions = %SpecialArrayFunctions({}); |
1328 | 1329 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1361 "map", getFunction("map", ArrayMap, 1), | 1362 "map", getFunction("map", ArrayMap, 1), |
1362 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), | 1363 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), |
1363 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1364 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
1364 "reduce", getFunction("reduce", ArrayReduce, 1), | 1365 "reduce", getFunction("reduce", ArrayReduce, 1), |
1365 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) | 1366 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) |
1366 )); | 1367 )); |
1367 | 1368 |
1368 %FinishArrayPrototypeSetup($Array.prototype); | 1369 %FinishArrayPrototypeSetup($Array.prototype); |
1369 | 1370 |
1370 // 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 |
1371 // exposed to user code, so no hidden prototypes or DONT_ENUM attributes | 1372 // exposed to user code. |
1372 // are necessary. | 1373 // Adding only the functions that are actually used. |
1373 // The null __proto__ ensures that we never inherit any user created | 1374 SetupLockedPrototype(InternalArray, $Array(), $Array( |
Lasse Reichstein
2011/09/01 13:30:42
Changed to SetUp....
| |
1374 // getters or setters from, e.g., Object.prototype. | 1375 "join", getFunction("join", ArrayJoin), |
1375 InternalArray.prototype.__proto__ = null; | 1376 "pop", getFunction("pop", ArrayPop), |
1376 // Adding only the functions that are actually used, and a toString. | 1377 "push", getFunction("push", ArrayPush) |
1377 InternalArray.prototype.join = getFunction("join", ArrayJoin); | 1378 )); |
1378 InternalArray.prototype.pop = getFunction("pop", ArrayPop); | |
1379 InternalArray.prototype.push = getFunction("push", ArrayPush); | |
1380 InternalArray.prototype.toString = function() { | |
1381 return "Internal Array, length " + this.length; | |
1382 }; | |
1383 } | 1379 } |
1384 | 1380 |
1385 | 1381 |
1386 SetupArray(); | 1382 SetupArray(); |
OLD | NEW |