diff --git a/src/org/mozilla/javascript/NativeArray.java b/src/org/mozilla/javascript/NativeArray.java index f5862cd992..feea67c9a2 100644 --- a/src/org/mozilla/javascript/NativeArray.java +++ b/src/org/mozilla/javascript/NativeArray.java @@ -455,7 +455,7 @@ public Object execIdCall( return js_flatMap(cx, scope, thisObj, args); case Id_toReversed: - return js_toReversed(cx, scope, thisObj, args); + return js_toReversed(cx, scope, thisObj); case Id_every: case Id_filter: @@ -2262,15 +2262,14 @@ private static boolean js_isArray(Object o) { } private static Scriptable js_toReversed( - Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { + Context cx, Scriptable scope, Scriptable thisObj) { Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj); - int len = (getLengthProperty(cx, o) > Integer.MAX_VALUE) ? 0 :(int) getLengthProperty(cx, o); - - Scriptable result = cx.newArray(scope, len); + long len = (getLengthProperty(cx, o) > Integer.MAX_VALUE) ? 0 : getLengthProperty(cx, o); - for(int k = len-1; k >= 0; k--){ + Scriptable result = cx.newArray(scope, (int)len); + for(long k = len-1; k >= 0; k--){ Object temp1 = getRawElem(o, k); - setRawElem(cx, result, k, temp1); + defineElemOrThrow(cx, result, len-k-1, temp1); } return result; } @@ -2754,8 +2753,8 @@ protected int findPrototypeId(String s) { Id_at = 32, Id_flat = 33, Id_flatMap = 34, - SymbolId_iterator = 35, Id_toReversed =36, + SymbolId_iterator = 37, MAX_PROTOTYPE_ID = SymbolId_iterator; private static final int ConstructorId_join = -Id_join, ConstructorId_reverse = -Id_reverse,