Ignore:
Timestamp:
05/02/10 18:30:47 (13 years ago)
Author:
ehuelsmann
Message:

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

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Lisp.java

    r12607 r12648  
    352352
    353353  public static final LispObject error(LispObject condition)
    354 
    355354  {
    356355    pushJavaStackFrames();
     
    358357  }
    359358
     359  public static final int ierror(LispObject condition)
     360  {
     361    error(condition);
     362    return 0; // Not reached
     363  }
     364
     365  public static final String serror(LispObject condition)
     366  {
     367    error(condition);
     368    return ""; // Not reached
     369  }
     370
     371
    360372  public static final LispObject error(LispObject condition, LispObject message)
    361 
    362373  {
    363374    pushJavaStackFrames();
    364375    return Symbol.ERROR.execute(condition, Keyword.FORMAT_CONTROL, message);
    365376  }
     377
     378  public static final int ierror(LispObject condition, LispObject message)
     379  {
     380    error(condition, message);
     381    return 0; // Not reached
     382  }
     383
     384  public static final String serror(LispObject condition, LispObject message)
     385  {
     386    error(condition, message);
     387    return ""; // Not reached
     388  }
     389
     390
    366391
    367392  public static final LispObject type_error(LispObject datum,
  • trunk/abcl/src/org/armedbear/lisp/Stream.java

    r12646 r12648  
    605605        while (true) {
    606606          int n = _readChar();
    607           if (n < 0) {
    608             error(new EndOfFile(this));
    609             // Not reached.
    610             return null;
    611           }
     607          if (n < 0)
     608            return error(new EndOfFile(this));
     609
    612610          char c = (char) n; // ### BUG: Codepoint conversion
    613611          if (rt.getSyntaxType(c) == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
    614612            // Single escape.
    615613            n = _readChar();
    616             if (n < 0) {
    617               error(new EndOfFile(this));
    618               // Not reached.
    619               return null;
    620             }
     614            if (n < 0)
     615              return error(new EndOfFile(this));
     616
    621617            sb.append((char)n); // ### BUG: Codepoint conversion
    622618            continue;
     
    971967            while (true) {
    972968                int n = _readChar();
    973                 if (n < 0) {
    974                     error(new EndOfFile(this));
    975                     // Not reached.
    976                     return null;
    977                 }
     969                if (n < 0)
     970                    return serror(new EndOfFile(this));
     971
    978972                char c = (char) n; // ### BUG: Codepoint conversion
    979973                byte syntaxType = rt.getSyntaxType(c);
    980974                if (syntaxType == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
    981975                    n = _readChar();
    982                     if (n < 0) {
    983                         error(new EndOfFile(this));
    984                         // Not reached.
    985                         return null;
    986                     }
     976                    if (n < 0)
     977                        return serror(new EndOfFile(this));
     978
    987979                    sb.append((char)n); // ### BUG: Codepoint conversion
    988980                    continue;
     
    993985            }
    994986        } catch (IOException e) {
    995             error(new StreamError(this, e));
     987            return serror(new StreamError(this, e));
    996988        }
    997989        return sb.toString();
     
    11371129                if (n < 0) {
    11381130                    error(new EndOfFile(this));
    1139                     // Not reached.
    1140                     return flags;
    1141                 }
     1131                    return null; // Not reached
     1132                }
     1133
    11421134                sb.setCharAt(0, (char) n); // ### BUG: Codepoint conversion
    11431135                flags = new BitSet(1);
     
    12531245        if (readBaseObject instanceof Fixnum) {
    12541246            readBase = ((Fixnum)readBaseObject).value;
    1255         } else {
     1247        } else
    12561248            // The value of *READ-BASE* is not a Fixnum.
    1257             error(new LispError("The value of *READ-BASE* is not of type '(INTEGER 2 36)."));
    1258             // Not reached.
    1259             return 10;
    1260         }
    1261         if (readBase < 2 || readBase > 36) {
    1262             error(new LispError("The value of *READ-BASE* is not of type '(INTEGER 2 36)."));
    1263             // Not reached.
    1264             return 10;
    1265         }
     1249            return ierror(new LispError("The value of *READ-BASE* is not " +
     1250                                        "of type '(INTEGER 2 36)."));
     1251
     1252        if (readBase < 2 || readBase > 36)
     1253            return ierror(new LispError("The value of *READ-BASE* is not " +
     1254                                        "of type '(INTEGER 2 36)."));
     1255
    12661256        return readBase;
    12671257    }
    12681258
    12691259    private final LispObject makeNumber(String token, int length, int radix)
    1270 
    12711260    {
    12721261        if (length == 0)
     
    14371426            while (true) {
    14381427                int n = _readChar();
    1439                 if (n < 0) {
    1440                     error(new EndOfFile(this));
    1441                     // Not reached.
    1442                     return 0;
    1443                 }
     1428                if (n < 0)
     1429                    return (char)ierror(new EndOfFile(this));
     1430
    14441431                char c = (char) n; // ### BUG: Codepoint conversion
    14451432                if (!rt.isWhitespace(c))
     
    18631850            return n; // Reads an 8-bit byte.
    18641851        } catch (IOException e) {
    1865             error(new StreamError(this, e));
    1866             // Not reached.
    1867             return -1;
     1852            return ierror(new StreamError(this, e));
    18681853        }
    18691854    }
Note: See TracChangeset for help on using the changeset viewer.