Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: src/array.js

Issue 669061: First take on custom call generators. (Closed)
Patch Set: Ultimate version Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 } 1081 }
1082 } 1082 }
1083 return current; 1083 return current;
1084 } 1084 }
1085 1085
1086 // ES5, 15.4.3.2 1086 // ES5, 15.4.3.2
1087 function ArrayIsArray(obj) { 1087 function ArrayIsArray(obj) {
1088 return IS_ARRAY(obj); 1088 return IS_ARRAY(obj);
1089 } 1089 }
1090 1090
1091 // -------------------------------------------------------------------
1092
1093
1094 function UpdateFunctionLengths(lengths) {
1095 for (var key in lengths) {
1096 %FunctionSetLength(this[key], lengths[key]);
1097 }
1098 }
1099
1100 1091
1101 // ------------------------------------------------------------------- 1092 // -------------------------------------------------------------------
1102 function SetupArray() { 1093 function SetupArray() {
1103 // Setup non-enumerable constructor property on the Array.prototype 1094 // Setup non-enumerable constructor property on the Array.prototype
1104 // object. 1095 // object.
1105 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM); 1096 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
1106 1097
1107 // Setup non-enumerable functions on the Array object. 1098 // Setup non-enumerable functions on the Array object.
1108 InstallFunctions($Array, DONT_ENUM, $Array( 1099 InstallFunctions($Array, DONT_ENUM, $Array(
1109 "isArray", ArrayIsArray 1100 "isArray", ArrayIsArray
1110 )); 1101 ));
1111 1102
1103 var specialFunctions = %SpecialArrayFunctions({});
1104
1105 function getFunction(name, jsBuiltin, len) {
1106 var f = jsBuiltin;
1107 if (specialFunctions.hasOwnProperty(name)) {
1108 f = specialFunctions[name];
1109 }
1110 if (arguments.length == 3) {
1111 %FunctionSetLength(f, len);
1112 }
1113 return f;
1114 }
1115
1112 // Setup non-enumerable functions of the Array.prototype object and 1116 // Setup non-enumerable functions of the Array.prototype object and
1113 // set their names. 1117 // set their names.
1118 // Manipulate the length of some of the functions to meet
1119 // expectations set by ECMA-262 or Mozilla.
1114 InstallFunctionsOnHiddenPrototype($Array.prototype, DONT_ENUM, $Array( 1120 InstallFunctionsOnHiddenPrototype($Array.prototype, DONT_ENUM, $Array(
1115 "toString", ArrayToString, 1121 "toString", getFunction("toString", ArrayToString),
1116 "toLocaleString", ArrayToLocaleString, 1122 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
1117 "join", ArrayJoin, 1123 "join", getFunction("join", ArrayJoin),
1118 "pop", ArrayPop, 1124 "pop", getFunction("pop", ArrayPop),
1119 "push", ArrayPush, 1125 "push", getFunction("push", ArrayPush, 1),
1120 "concat", ArrayConcat, 1126 "concat", getFunction("concat", ArrayConcat),
1121 "reverse", ArrayReverse, 1127 "reverse", getFunction("reverse", ArrayReverse),
1122 "shift", ArrayShift, 1128 "shift", getFunction("shift", ArrayShift),
1123 "unshift", ArrayUnshift, 1129 "unshift", getFunction("unshift", ArrayUnshift, 1),
1124 "slice", ArraySlice, 1130 "slice", getFunction("slice", ArraySlice, 2),
1125 "splice", ArraySplice, 1131 "splice", getFunction("splice", ArraySplice, 2),
1126 "sort", ArraySort, 1132 "sort", getFunction("sort", ArraySort),
1127 "filter", ArrayFilter, 1133 "filter", getFunction("filter", ArrayFilter, 1),
1128 "forEach", ArrayForEach, 1134 "forEach", getFunction("forEach", ArrayForEach, 1),
1129 "some", ArraySome, 1135 "some", getFunction("some", ArraySome, 1),
1130 "every", ArrayEvery, 1136 "every", getFunction("every", ArrayEvery, 1),
1131 "map", ArrayMap, 1137 "map", getFunction("map", ArrayMap, 1),
1132 "indexOf", ArrayIndexOf, 1138 "indexOf", getFunction("indexOf", ArrayIndexOf, 1),
1133 "lastIndexOf", ArrayLastIndexOf, 1139 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
1134 "reduce", ArrayReduce, 1140 "reduce", getFunction("reduce", ArrayReduce, 1),
1135 "reduceRight", ArrayReduceRight 1141 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
1136 )); 1142 ));
1137 1143
1138 // Manipulate the length of some of the functions to meet
1139 // expectations set by ECMA-262 or Mozilla.
1140 UpdateFunctionLengths({
1141 ArrayFilter: 1,
1142 ArrayForEach: 1,
1143 ArraySome: 1,
1144 ArrayEvery: 1,
1145 ArrayMap: 1,
1146 ArrayIndexOf: 1,
1147 ArrayLastIndexOf: 1,
1148 ArrayPush: 1,
1149 ArrayReduce: 1,
1150 ArrayReduceRight: 1
1151 });
1152
1153 %FinishArrayPrototypeSetup($Array.prototype); 1144 %FinishArrayPrototypeSetup($Array.prototype);
1154 } 1145 }
1155 1146
1156 1147
1157 SetupArray(); 1148 SetupArray();
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698