Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index 0c4985ed86aed8e22a9ee3b7fa055da761778743..94775cd6334c492c9449e2755ac8f35da0e0409d 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -395,7 +395,7 @@ function ArrayToString() { |
function InnerArrayToLocaleString(array, length) { |
- var len = TO_UINT32(length); |
+ var len = TO_LENGTH_OR_UINT32(length); |
if (len === 0) return ""; |
return Join(array, len, ',', ConvertToLocaleString); |
} |
@@ -434,7 +434,7 @@ function ArrayJoin(separator) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join"); |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArrayJoin(separator, array, length); |
} |
@@ -463,7 +463,7 @@ function ArrayPop() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.pop"); |
var array = TO_OBJECT(this); |
- var n = TO_UINT32(array.length); |
+ var n = TO_LENGTH_OR_UINT32(array.length); |
if (n == 0) { |
array.length = n; |
return; |
@@ -481,7 +481,7 @@ function ArrayPop() { |
function ObservedArrayPush() { |
- var n = TO_UINT32(this.length); |
+ var n = TO_LENGTH_OR_UINT32(this.length); |
var m = %_ArgumentsLength(); |
try { |
@@ -509,7 +509,7 @@ function ArrayPush() { |
return ObservedArrayPush.apply(this, arguments); |
var array = TO_OBJECT(this); |
- var n = TO_UINT32(array.length); |
+ var n = TO_LENGTH_OR_UINT32(array.length); |
var m = %_ArgumentsLength(); |
for (var i = 0; i < m; i++) { |
@@ -606,7 +606,7 @@ function ArrayReverse() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse"); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = TO_LENGTH_OR_UINT32(array.length); |
var isArray = IS_ARRAY(array); |
if (UseSparseVariant(array, len, isArray, len)) { |
@@ -641,7 +641,7 @@ function ArrayShift() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift"); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = TO_LENGTH_OR_UINT32(array.length); |
if (len === 0) { |
array.length = 0; |
@@ -668,7 +668,7 @@ function ArrayShift() { |
function ObservedArrayUnshift() { |
- var len = TO_UINT32(this.length); |
+ var len = TO_LENGTH_OR_UINT32(this.length); |
var num_arguments = %_ArgumentsLength(); |
try { |
@@ -695,7 +695,7 @@ function ArrayUnshift(arg1) { // length == 1 |
return ObservedArrayUnshift.apply(this, arguments); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = TO_LENGTH_OR_UINT32(array.length); |
var num_arguments = %_ArgumentsLength(); |
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) && |
@@ -719,7 +719,7 @@ function ArraySlice(start, end) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.slice"); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = TO_LENGTH_OR_UINT32(array.length); |
var start_i = TO_INTEGER(start); |
var end_i = len; |
@@ -790,7 +790,7 @@ function ComputeSpliceDeleteCount(delete_count, num_arguments, len, start_i) { |
function ObservedArraySplice(start, delete_count) { |
var num_arguments = %_ArgumentsLength(); |
- var len = TO_UINT32(this.length); |
+ var len = TO_LENGTH_OR_UINT32(this.length); |
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len); |
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len, |
start_i); |
@@ -837,7 +837,7 @@ function ArraySplice(start, delete_count) { |
var num_arguments = %_ArgumentsLength(); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = TO_LENGTH_OR_UINT32(array.length); |
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len); |
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len, |
start_i); |
@@ -1173,7 +1173,7 @@ function ArraySort(comparefn) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort"); |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArraySort(array, length, comparefn); |
} |
@@ -1207,7 +1207,7 @@ function ArrayFilter(f, receiver) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
var accumulator = InnerArrayFilter(f, receiver, array, length); |
var result = new GlobalArray(); |
%MoveArrayContents(accumulator, result); |
@@ -1235,7 +1235,7 @@ function ArrayForEach(f, receiver) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
InnerArrayForEach(f, receiver, array, length); |
} |
@@ -1265,7 +1265,7 @@ function ArraySome(f, receiver) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArraySome(f, receiver, array, length); |
} |
@@ -1292,7 +1292,7 @@ function ArrayEvery(f, receiver) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArrayEvery(f, receiver, array, length); |
} |
@@ -1321,7 +1321,7 @@ function ArrayMap(f, receiver) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
var accumulator = InnerArrayMap(f, receiver, array, length); |
var result = new GlobalArray(); |
%MoveArrayContents(accumulator, result); |
@@ -1390,7 +1390,7 @@ function InnerArrayIndexOf(array, element, index, length) { |
function ArrayIndexOf(element, index) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); |
- var length = TO_UINT32(this.length); |
+ var length = TO_LENGTH_OR_UINT32(this.length); |
return InnerArrayIndexOf(this, element, index, length); |
} |
@@ -1448,7 +1448,7 @@ function InnerArrayLastIndexOf(array, element, index, length, argumentsLength) { |
function ArrayLastIndexOf(element, index) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf"); |
- var length = TO_UINT32(this.length); |
+ var length = TO_LENGTH_OR_UINT32(this.length); |
return InnerArrayLastIndexOf(this, element, index, length, |
%_ArgumentsLength()); |
} |
@@ -1490,7 +1490,7 @@ function ArrayReduce(callback, current) { |
// Pull out the length so that modifications to the length in the |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArrayReduce(callback, current, array, length, |
%_ArgumentsLength()); |
} |
@@ -1533,7 +1533,7 @@ function ArrayReduceRight(callback, current) { |
// Pull out the length so that side effects are visible before the |
// callback function is checked. |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = TO_LENGTH_OR_UINT32(array.length); |
return InnerArrayReduceRight(callback, current, array, length, |
%_ArgumentsLength()); |
} |