From 4aa5af37f2219d5ea37c17bb89a7ff11a5640a52 Mon Sep 17 00:00:00 2001 From: dzaima Date: Mon, 2 Mar 2020 18:10:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=8E=95DR=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and increment app version --- AndroidIDE/AndroidManifest.xml | 2 +- src/APL/Scope.java | 8 ++++---- src/APL/types/BigValue.java | 4 ++++ src/APL/types/functions/builtins/dops/OverBuiltin.java | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/AndroidIDE/AndroidManifest.xml b/AndroidIDE/AndroidManifest.xml index a66c3b9..ef24066 100644 --- a/AndroidIDE/AndroidManifest.xml +++ b/AndroidIDE/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/src/APL/Scope.java b/src/APL/Scope.java index 2c3b88d..df8e689 100644 --- a/src/APL/Scope.java +++ b/src/APL/Scope.java @@ -723,26 +723,26 @@ public Obj call(Value a, Value w) { if (f==1) return OverBuiltin.on(this, new Fun() { public String repr() { return ""; } public Obj call(Value w) { - return new Num(Double.longBitsToDouble(((BigValue) UTackBuiltin.on(BigValue.TWO, w, DR.this)).i.longValueExact())); + return new Num(Double.longBitsToDouble(((BigValue) UTackBuiltin.on(BigValue.TWO, w, DR.this)).longValue())); } }, 1, w); if (f==5) return OverBuiltin.on(this, new Fun() { public String repr() { return ""; } public Obj call(Value w) { - return new Num(Double.longBitsToDouble(((BigValue) w).i.longValueExact())); + return new Num(Double.longBitsToDouble(((BigValue) w).longValue())); } }, 0, w); } else { if (t==1) return OverBuiltin.on(this, new Fun() { public String repr() { return ""; } public Obj call(Value w) { - return new BitArr(new long[]{Long.reverse(Double.doubleToLongBits(w.asDouble()))}, new int[]{64}); + return new BitArr(new long[]{Long.reverse(Double.doubleToRawLongBits(w.asDouble()))}, new int[]{64}); } }, 0, w); if (t==5) return OverBuiltin.on(this, new Fun() { public String repr() { return ""; } public Obj call(Value w) { - return new BigValue(Double.doubleToLongBits(w.asDouble())); + return new BigValue(Double.doubleToRawLongBits(w.asDouble())); } }, 0, w); } diff --git a/src/APL/types/BigValue.java b/src/APL/types/BigValue.java index 17ad7f6..b93c10e 100644 --- a/src/APL/types/BigValue.java +++ b/src/APL/types/BigValue.java @@ -83,4 +83,8 @@ public static int safeInt(BigInteger b) { } return b.intValue(); } + public long longValue() { + if (i.bitLength() > 64) throw new DomainError("using a bigint with more than 64 bits as long", this); + return i.longValue(); + } } diff --git a/src/APL/types/functions/builtins/dops/OverBuiltin.java b/src/APL/types/functions/builtins/dops/OverBuiltin.java index 7da0c8e..1f8f374 100644 --- a/src/APL/types/functions/builtins/dops/OverBuiltin.java +++ b/src/APL/types/functions/builtins/dops/OverBuiltin.java @@ -13,18 +13,18 @@ public class OverBuiltin extends Dop { public Obj call(Obj aa, Obj ww, Value w, DerivedDop derv) { isFn(aa, '⍶'); int d = ((Value) ww).asInt(); - return on(this, (Fun) aa, d, w); + return on(derv, (Fun) aa, d, w); } - public static Value on(Tokenable caller, Fun f, int d, Value w) { + public static Value on(Fun caller, Fun f, int d, Value w) { int ld = DepthBuiltin.lazy(w); if (ld==d || ld <= -d) { int fd = DepthBuiltin.full(w); - if (d>0 && d!=fd) throw new DomainError(caller.getToken().toRepr()+" can't match a depth " + fd + " array", caller, w); + if (d>0 && d!=fd) throw new DomainError(caller+" can't match a depth " + fd + " array", caller, w); if (d <= fd) { return (Value) f.call(w); } } - if (d>0 && ld < d) throw new DomainError(caller.getToken().toRepr()+" can't match a depth "+DepthBuiltin.full(w)+" array", caller, w); + if (d>0 && ld < d) throw new DomainError(caller+" can't match a depth "+DepthBuiltin.full(w)+" array", caller, w); Value[] res = new Value[w.ia]; for (int i = 0; i < res.length; i++) { res[i] = on(caller, f, d, w.get(i));