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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 i++; | 1131 i++; |
1132 break find_initial; | 1132 break find_initial; |
1133 } | 1133 } |
1134 } | 1134 } |
1135 throw MakeTypeError('reduce_no_initial', []); | 1135 throw MakeTypeError('reduce_no_initial', []); |
1136 } | 1136 } |
1137 | 1137 |
1138 for (; i < length; i++) { | 1138 for (; i < length; i++) { |
1139 var element = this[i]; | 1139 var element = this[i]; |
1140 if (!IS_UNDEFINED(element) || i in this) { | 1140 if (!IS_UNDEFINED(element) || i in this) { |
1141 current = %_CallFunction(null, current, element, i, this, callback); | 1141 current = callback.call(null, current, element, i, this); |
1142 } | 1142 } |
1143 } | 1143 } |
1144 return current; | 1144 return current; |
1145 } | 1145 } |
1146 | 1146 |
1147 function ArrayReduceRight(callback, current) { | 1147 function ArrayReduceRight(callback, current) { |
1148 if (!IS_FUNCTION(callback)) { | 1148 if (!IS_FUNCTION(callback)) { |
1149 throw MakeTypeError('called_non_callable', [callback]); | 1149 throw MakeTypeError('called_non_callable', [callback]); |
1150 } | 1150 } |
1151 var i = this.length - 1; | 1151 var i = this.length - 1; |
1152 | 1152 |
1153 find_initial: if (%_ArgumentsLength() < 2) { | 1153 find_initial: if (%_ArgumentsLength() < 2) { |
1154 for (; i >= 0; i--) { | 1154 for (; i >= 0; i--) { |
1155 current = this[i]; | 1155 current = this[i]; |
1156 if (!IS_UNDEFINED(current) || i in this) { | 1156 if (!IS_UNDEFINED(current) || i in this) { |
1157 i--; | 1157 i--; |
1158 break find_initial; | 1158 break find_initial; |
1159 } | 1159 } |
1160 } | 1160 } |
1161 throw MakeTypeError('reduce_no_initial', []); | 1161 throw MakeTypeError('reduce_no_initial', []); |
1162 } | 1162 } |
1163 | 1163 |
1164 for (; i >= 0; i--) { | 1164 for (; i >= 0; i--) { |
1165 var element = this[i]; | 1165 var element = this[i]; |
1166 if (!IS_UNDEFINED(element) || i in this) { | 1166 if (!IS_UNDEFINED(element) || i in this) { |
1167 current = %_CallFunction(null, current, element, i, this, callback); | 1167 current = callback.call(null, current, element, i, this); |
1168 } | 1168 } |
1169 } | 1169 } |
1170 return current; | 1170 return current; |
1171 } | 1171 } |
1172 | 1172 |
1173 // ES5, 15.4.3.2 | 1173 // ES5, 15.4.3.2 |
1174 function ArrayIsArray(obj) { | 1174 function ArrayIsArray(obj) { |
1175 return IS_ARRAY(obj); | 1175 return IS_ARRAY(obj); |
1176 } | 1176 } |
1177 | 1177 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 InternalArray.prototype.join = getFunction("join", ArrayJoin); | 1240 InternalArray.prototype.join = getFunction("join", ArrayJoin); |
1241 InternalArray.prototype.pop = getFunction("pop", ArrayPop); | 1241 InternalArray.prototype.pop = getFunction("pop", ArrayPop); |
1242 InternalArray.prototype.push = getFunction("push", ArrayPush); | 1242 InternalArray.prototype.push = getFunction("push", ArrayPush); |
1243 InternalArray.prototype.toString = function() { | 1243 InternalArray.prototype.toString = function() { |
1244 return "Internal Array, length " + this.length; | 1244 return "Internal Array, length " + this.length; |
1245 }; | 1245 }; |
1246 } | 1246 } |
1247 | 1247 |
1248 | 1248 |
1249 SetupArray(); | 1249 SetupArray(); |
OLD | NEW |