Skip to content

Commit c5d0985

Browse files
committed
incomplete work in progress
1 parent 3f74c9f commit c5d0985

File tree

5 files changed

+75
-418
lines changed

5 files changed

+75
-418
lines changed

src/clj/clojure/core_print.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
(defmethod print-dup java.lang.Double [o w] (print-method o w))
243243
(defmethod print-dup clojure.lang.Ratio [o w] (print-method o w))
244244
(defmethod print-dup java.math.BigDecimal [o w] (print-method o w))
245+
(defmethod print-dup java.math.BigInteger [o w] (print-method o w))
245246
(defmethod print-dup clojure.lang.PersistentHashMap [o w] (print-method o w))
246247
(defmethod print-dup clojure.lang.PersistentHashSet [o w] (print-method o w))
247248
(defmethod print-dup clojure.lang.PersistentVector [o w] (print-method o w))
@@ -278,6 +279,10 @@
278279
(.write w (str b))
279280
(.write w "M"))
280281

282+
(defmethod print-method java.math.BigInteger [b, ^Writer w]
283+
(.write w (str b))
284+
(.write w "N"))
285+
281286
(defmethod print-method java.util.regex.Pattern [p ^Writer w]
282287
(.write w "#\"")
283288
(loop [[^Character c & r :as s] (seq (.pattern ^java.util.regex.Pattern p))

src/jvm/clojure/lang/Compiler.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,7 +5391,10 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
53915391
{
53925392
if(!(arg instanceof MaybePrimitiveExpr && arg.hasJavaClass() && arg.getJavaClass() == primc))
53935393
throw new IllegalArgumentException("recur arg for primitive local: " +
5394-
lb.name + " must be matching primitive");
5394+
lb.name + " must be matching primitive, had: " +
5395+
arg.getJavaClass().getName() +
5396+
", needed: " +
5397+
primc.getName());
53955398
}
53965399
catch(Exception e)
53975400
{
@@ -7217,7 +7220,7 @@ public Expr parse(C context, Object frm) throws Exception{
72177220
for(Object o : ((Map)args.nth(6)).entrySet())
72187221
{
72197222
Map.Entry e = (Map.Entry) o;
7220-
Integer minhash = (Integer) e.getKey();
7223+
Integer minhash = ((Number)e.getKey()).intValue();
72217224
MapEntry me = (MapEntry) e.getValue();
72227225
Expr testExpr = new ConstantExpr(me.getKey());
72237226
tests.put(minhash, testExpr);
@@ -7243,12 +7246,12 @@ public Expr parse(C context, Object frm) throws Exception{
72437246
Var.popThreadBindings();
72447247
}
72457248

7246-
return new CaseExpr((Integer) LINE.deref(),
7249+
return new CaseExpr(((Number)LINE.deref()).intValue(),
72477250
testexpr,
7248-
(Integer)args.nth(1),
7249-
(Integer)args.nth(2),
7250-
(Integer)args.nth(3),
7251-
(Integer)args.nth(4),
7251+
((Number)args.nth(1)).intValue(),
7252+
((Number)args.nth(2)).intValue(),
7253+
((Number)args.nth(3)).intValue(),
7254+
((Number)args.nth(4)).intValue(),
72527255
defaultExpr,
72537256
tests,thens,args.nth(7) != RT.F);
72547257

src/jvm/clojure/lang/LispReader.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class LispReader{
4747
//static Pattern intPat = Pattern.compile("[-+]?[0-9]+\\.?");
4848
static Pattern intPat =
4949
Pattern.compile(
50-
"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)");
50+
"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?");
5151
static Pattern ratioPat = Pattern.compile("([-+]?[0-9]+)/([0-9]+)");
5252
static Pattern floatPat = Pattern.compile("([-+]?[0-9]+(\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?");
5353
static final Symbol SLASH = Symbol.create("/");
@@ -327,7 +327,11 @@ private static Object matchNumber(String s){
327327
if(m.matches())
328328
{
329329
if(m.group(2) != null)
330-
return 0;
330+
{
331+
if(m.group(8) != null)
332+
return BigInteger.ZERO;
333+
return new Long(0);
334+
}
331335
boolean negate = (m.group(1).equals("-"));
332336
String n;
333337
int radix = 10;
@@ -342,7 +346,9 @@ else if((n = m.group(7)) != null)
342346
if(n == null)
343347
return null;
344348
BigInteger bn = new BigInteger(n, radix);
345-
return Numbers.reduce(negate ? bn.negate() : bn);
349+
if(m.group(8) != null)
350+
return negate ? bn.negate() : bn;
351+
return Numbers.reduceBigInteger(negate ? bn.negate() : bn);
346352
}
347353
m = floatPat.matcher(s);
348354
if(m.matches())

0 commit comments

Comments
 (0)