[armedbear-cvs] r12600 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sat Apr 10 21:10:29 UTC 2010


Author: ehuelsmann
Date: Sat Apr 10 17:10:28 2010
New Revision: 12600

Log:
Consolidate faslReadRadix with readRadix.

Modified:
   trunk/abcl/src/org/armedbear/lisp/FaslReader.java
   trunk/abcl/src/org/armedbear/lisp/LispReader.java
   trunk/abcl/src/org/armedbear/lisp/Stream.java

Modified: trunk/abcl/src/org/armedbear/lisp/FaslReader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/FaslReader.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/FaslReader.java	Sat Apr 10 17:10:28 2010
@@ -303,7 +303,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.faslReadRadix(2);
+            return stream.readRadix(2, Stream.faslReadtable);
         }
     };
 
@@ -329,7 +329,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.faslReadRadix(8);
+            return stream.readRadix(8, Stream.faslReadtable);
         }
     };
 
@@ -355,7 +355,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.faslReadRadix(n);
+            return stream.readRadix(n, Stream.faslReadtable);
         }
     };
 
@@ -381,7 +381,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.faslReadRadix(16);
+            return stream.readRadix(16, Stream.faslReadtable);
         }
     };
 

Modified: trunk/abcl/src/org/armedbear/lisp/LispReader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispReader.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispReader.java	Sat Apr 10 17:10:28 2010
@@ -334,7 +334,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.readRadix(2);
+            return stream.readRadix(2, Stream.currentReadtable);
         }
     };
 
@@ -360,7 +360,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.readRadix(8);
+            return stream.readRadix(8, Stream.currentReadtable);
         }
     };
 
@@ -386,7 +386,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.readRadix(n);
+            return stream.readRadix(n, Stream.currentReadtable);
         }
     };
 
@@ -412,7 +412,7 @@
         public LispObject execute(Stream stream, char c, int n)
 
         {
-            return stream.readRadix(16);
+            return stream.readRadix(16, Stream.currentReadtable);
         }
     };
 

Modified: trunk/abcl/src/org/armedbear/lisp/Stream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Stream.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Stream.java	Sat Apr 10 17:10:28 2010
@@ -1243,11 +1243,10 @@
         }
     }
 
-    public LispObject readRadix(int radix) {
+    public LispObject readRadix(int radix, ReadtableAccessor rta) {
         StringBuilder sb = new StringBuilder();
         final LispThread thread = LispThread.currentThread();
-        final Readtable rt =
-            (Readtable) Symbol.CURRENT_READTABLE.symbolValue(thread);
+        final Readtable rt = rta.rt(thread);
         boolean escaped = (_readToken(sb, rt) != null);
         if (Symbol.READ_SUPPRESS.symbolValue(thread) != NIL)
             return NIL;
@@ -1272,30 +1271,6 @@
         return error(new LispError());
     }
 
-    public LispObject faslReadRadix(int radix) {
-        StringBuilder sb = new StringBuilder();
-        final LispThread thread = LispThread.currentThread();
-        final Readtable rt = FaslReadtable.getInstance();
-        boolean escaped = (_readToken(sb, rt) != null);
-        if (Symbol.READ_SUPPRESS.symbolValue(thread) != NIL)
-            return NIL;
-        if (escaped)
-            return error(new ReaderError("Illegal syntax for number.", this));
-        String s = sb.toString();
-        if (s.indexOf('/') >= 0)
-            return makeRatio(s, radix);
-        try {
-            int n = Integer.parseInt(s, radix);
-            return (n >= 0 && n <= 255) ? Fixnum.constants[n] : Fixnum.getInstance(n);
-        } catch (NumberFormatException e) {}
-        // parseInt() failed.
-        try {
-            return Bignum.getInstance(s, radix);
-        } catch (NumberFormatException e) {}
-        // Not a number.
-        return error(new LispError());
-    }
-
     private char flushWhitespace(Readtable rt) {
         try {
             while (true) {




More information about the armedbear-cvs mailing list