Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index af3dbd701ebac2f756dde8ff379af2c5efc9370c..056321bbc7a7a5b636343e569b6be6a5250b6955 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -22,6 +22,7 @@ var ObjectIsSealed; |
var ObjectToString; |
var ToNumber; |
var ToString; |
+var ToLengthFlagged; |
utils.Import(function(from) { |
Delete = from.Delete; |
@@ -32,6 +33,7 @@ utils.Import(function(from) { |
ObjectToString = from.ObjectToString; |
ToNumber = from.ToNumber; |
ToString = from.ToString; |
+ ToLengthFlagged = from.ToLengthFlagged; |
}); |
// ------------------------------------------------------------------- |
@@ -394,7 +396,7 @@ function ArrayToString() { |
function InnerArrayToLocaleString(array, length) { |
- var len = TO_UINT32(length); |
+ var len = ToLengthFlagged(length); |
if (len === 0) return ""; |
return Join(array, len, ',', ConvertToLocaleString); |
} |
@@ -433,7 +435,7 @@ function ArrayJoin(separator) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join"); |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = ToLengthFlagged(array.length); |
return InnerArrayJoin(separator, array, length); |
} |
@@ -462,7 +464,7 @@ function ArrayPop() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.pop"); |
var array = TO_OBJECT(this); |
- var n = TO_UINT32(array.length); |
+ var n = ToLengthFlagged(array.length); |
if (n == 0) { |
array.length = n; |
return; |
@@ -480,7 +482,7 @@ function ArrayPop() { |
function ObservedArrayPush() { |
- var n = TO_UINT32(this.length); |
+ var n = ToLengthFlagged(this.length); |
var m = %_ArgumentsLength(); |
try { |
@@ -508,7 +510,7 @@ function ArrayPush() { |
return ObservedArrayPush.apply(this, arguments); |
var array = TO_OBJECT(this); |
- var n = TO_UINT32(array.length); |
+ var n = ToLengthFlagged(array.length); |
var m = %_ArgumentsLength(); |
for (var i = 0; i < m; i++) { |
@@ -623,7 +625,7 @@ function ArrayReverse() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse"); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = ToLengthFlagged(array.length); |
var isArray = IS_ARRAY(array); |
if (UseSparseVariant(array, len, isArray, len)) { |
@@ -658,7 +660,7 @@ function ArrayShift() { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.shift"); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = ToLengthFlagged(array.length); |
if (len === 0) { |
array.length = 0; |
@@ -685,7 +687,7 @@ function ArrayShift() { |
function ObservedArrayUnshift() { |
- var len = TO_UINT32(this.length); |
+ var len = ToLengthFlagged(this.length); |
var num_arguments = %_ArgumentsLength(); |
try { |
@@ -712,7 +714,7 @@ function ArrayUnshift(arg1) { // length == 1 |
return ObservedArrayUnshift.apply(this, arguments); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = ToLengthFlagged(array.length); |
var num_arguments = %_ArgumentsLength(); |
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) && |
@@ -736,7 +738,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 = ToLengthFlagged(array.length); |
var start_i = TO_INTEGER(start); |
var end_i = len; |
@@ -807,7 +809,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 = ToLengthFlagged(this.length); |
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len); |
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len, |
start_i); |
@@ -854,7 +856,7 @@ function ArraySplice(start, delete_count) { |
var num_arguments = %_ArgumentsLength(); |
var array = TO_OBJECT(this); |
- var len = TO_UINT32(array.length); |
+ var len = ToLengthFlagged(array.length); |
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len); |
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len, |
start_i); |
@@ -1186,7 +1188,7 @@ function ArraySort(comparefn) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort"); |
var array = TO_OBJECT(this); |
- var length = TO_UINT32(array.length); |
+ var length = ToLengthFlagged(array.length); |
return %_CallFunction(array, length, comparefn, InnerArraySort); |
} |
@@ -1227,7 +1229,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 = ToLengthFlagged(array.length); |
var accumulator = InnerArrayFilter(f, receiver, array, length); |
var result = new GlobalArray(); |
%MoveArrayContents(accumulator, result); |
@@ -1262,7 +1264,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 = ToLengthFlagged(array.length); |
InnerArrayForEach(f, receiver, array, length); |
} |
@@ -1299,7 +1301,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 = ToLengthFlagged(array.length); |
return InnerArraySome(f, receiver, array, length); |
} |
@@ -1333,7 +1335,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 = ToLengthFlagged(array.length); |
return InnerArrayEvery(f, receiver, array, length); |
} |
@@ -1369,7 +1371,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 = ToLengthFlagged(array.length); |
var accumulator = InnerArrayMap(f, receiver, array, length); |
var result = new GlobalArray(); |
%MoveArrayContents(accumulator, result); |
@@ -1438,7 +1440,7 @@ function InnerArrayIndexOf(element, index, length) { |
function ArrayIndexOf(element, index) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); |
- var length = TO_UINT32(this.length); |
+ var length = ToLengthFlagged(this.length); |
return %_CallFunction(this, element, index, length, InnerArrayIndexOf); |
} |
@@ -1496,7 +1498,7 @@ function InnerArrayLastIndexOf(element, index, length, argumentsLength) { |
function ArrayLastIndexOf(element, index) { |
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf"); |
- var length = TO_UINT32(this.length); |
+ var length = ToLengthFlagged(this.length); |
return %_CallFunction(this, element, index, length, |
%_ArgumentsLength(), InnerArrayLastIndexOf); |
} |
@@ -1538,7 +1540,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 = ToLengthFlagged(array.length); |
return InnerArrayReduce(callback, current, array, length, |
%_ArgumentsLength()); |
} |
@@ -1581,7 +1583,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 = ToLengthFlagged(array.length); |
return InnerArrayReduceRight(callback, current, array, length, |
%_ArgumentsLength()); |
} |