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

Erik Huelsmann ehuelsmann at common-lisp.net
Sun May 2 18:30:48 UTC 2010


Author: ehuelsmann
Date: Sun May  2 14:30:47 2010
New Revision: 12648

Log:
Add (and use) more wrappers for the lisp ERROR function, using
different return types: ierror returns an int, etc.

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

Modified: trunk/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Lisp.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Lisp.java	Sun May  2 14:30:47 2010
@@ -351,19 +351,44 @@
 
 
   public static final LispObject error(LispObject condition)
-
   {
     pushJavaStackFrames();
     return Symbol.ERROR.execute(condition);
   }
 
-  public static final LispObject error(LispObject condition, LispObject message)
+  public static final int ierror(LispObject condition)
+  {
+    error(condition);
+    return 0; // Not reached
+  }
 
+  public static final String serror(LispObject condition)
+  {
+    error(condition);
+    return ""; // Not reached
+  }
+
+
+  public static final LispObject error(LispObject condition, LispObject message)
   {
     pushJavaStackFrames();
     return Symbol.ERROR.execute(condition, Keyword.FORMAT_CONTROL, message);
   }
 
+  public static final int ierror(LispObject condition, LispObject message)
+  {
+    error(condition, message);
+    return 0; // Not reached
+  }
+
+  public static final String serror(LispObject condition, LispObject message)
+  {
+    error(condition, message);
+    return ""; // Not reached
+  }
+
+
+
   public static final LispObject type_error(LispObject datum,
                                             LispObject expectedType)
 

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	Sun May  2 14:30:47 2010
@@ -604,20 +604,16 @@
       {
         while (true) {
           int n = _readChar();
-          if (n < 0) {
-            error(new EndOfFile(this));
-            // Not reached.
-            return null;
-          }
+          if (n < 0)
+            return error(new EndOfFile(this));
+
           char c = (char) n; // ### BUG: Codepoint conversion
           if (rt.getSyntaxType(c) == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
             // Single escape.
             n = _readChar();
-            if (n < 0) {
-              error(new EndOfFile(this));
-              // Not reached.
-              return null;
-            }
+            if (n < 0)
+              return error(new EndOfFile(this));
+
             sb.append((char)n); // ### BUG: Codepoint conversion
             continue;
           }
@@ -970,20 +966,16 @@
         try {
             while (true) {
                 int n = _readChar();
-                if (n < 0) {
-                    error(new EndOfFile(this));
-                    // Not reached.
-                    return null;
-                }
+                if (n < 0)
+                    return serror(new EndOfFile(this));
+
                 char c = (char) n; // ### BUG: Codepoint conversion
                 byte syntaxType = rt.getSyntaxType(c);
                 if (syntaxType == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
                     n = _readChar();
-                    if (n < 0) {
-                        error(new EndOfFile(this));
-                        // Not reached.
-                        return null;
-                    }
+                    if (n < 0)
+                        return serror(new EndOfFile(this));
+
                     sb.append((char)n); // ### BUG: Codepoint conversion
                     continue;
                 }
@@ -992,7 +984,7 @@
                 sb.append(c);
             }
         } catch (IOException e) {
-            error(new StreamError(this, e));
+            return serror(new StreamError(this, e));
         }
         return sb.toString();
     }
@@ -1136,9 +1128,9 @@
                 }
                 if (n < 0) {
                     error(new EndOfFile(this));
-                    // Not reached.
-                    return flags;
+                    return null; // Not reached
                 }
+
                 sb.setCharAt(0, (char) n); // ### BUG: Codepoint conversion
                 flags = new BitSet(1);
                 flags.set(0);
@@ -1252,22 +1244,19 @@
         final LispObject readBaseObject = Symbol.READ_BASE.symbolValue(thread);
         if (readBaseObject instanceof Fixnum) {
             readBase = ((Fixnum)readBaseObject).value;
-        } else {
+        } else
             // The value of *READ-BASE* is not a Fixnum.
-            error(new LispError("The value of *READ-BASE* is not of type '(INTEGER 2 36)."));
-            // Not reached.
-            return 10;
-        }
-        if (readBase < 2 || readBase > 36) {
-            error(new LispError("The value of *READ-BASE* is not of type '(INTEGER 2 36)."));
-            // Not reached.
-            return 10;
-        }
+            return ierror(new LispError("The value of *READ-BASE* is not " +
+                                        "of type '(INTEGER 2 36)."));
+
+        if (readBase < 2 || readBase > 36)
+            return ierror(new LispError("The value of *READ-BASE* is not " +
+                                        "of type '(INTEGER 2 36)."));
+
         return readBase;
     }
 
     private final LispObject makeNumber(String token, int length, int radix)
-
     {
         if (length == 0)
             return null;
@@ -1436,11 +1425,9 @@
         try {
             while (true) {
                 int n = _readChar();
-                if (n < 0) {
-                    error(new EndOfFile(this));
-                    // Not reached.
-                    return 0;
-                }
+                if (n < 0)
+                    return (char)ierror(new EndOfFile(this));
+
                 char c = (char) n; // ### BUG: Codepoint conversion
                 if (!rt.isWhitespace(c))
                     return c;
@@ -1862,9 +1849,7 @@
 
             return n; // Reads an 8-bit byte.
         } catch (IOException e) {
-            error(new StreamError(this, e));
-            // Not reached.
-            return -1;
+            return ierror(new StreamError(this, e));
         }
     }
 




More information about the armedbear-cvs mailing list