Skip to content

Commit

Permalink
Update NativeArray.java
Browse files Browse the repository at this point in the history
  • Loading branch information
pkkht committed Nov 5, 2023
1 parent 9d06be8 commit c6c116a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/org/mozilla/javascript/NativeArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c6c116a

Please sign in to comment.