Changeset 3887


Ignore:
Timestamp:
09/19/03 12:32:14 (20 years ago)
Author:
piso
Message:

Conditions: work in progress.

Location:
trunk/j/src/org/armedbear/lisp
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/BinaryInputStream.java

    r3883 r3887  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: BinaryInputStream.java,v 1.2 2003-09-19 01:46:39 piso Exp $
     5 * $Id: BinaryInputStream.java,v 1.3 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    4444        }
    4545        catch (IOException e) {
    46             throw new StreamError(e);
     46            throw new ConditionThrowable(new StreamError(e));
    4747        }
    4848        if (n < 0) {
    4949            if (eofError)
    50                 throw new EndOfFileException();
     50                throw new ConditionThrowable(new EndOfFileException());
    5151            else
    5252                return eofValue;
     
    5656
    5757    // Returns true if stream was open, otherwise implementation-dependent.
    58     public LispObject close(LispObject abort) throws StreamError
     58    public LispObject close(LispObject abort) throws ConditionThrowable
    5959    {
    6060        try {
     
    6363        }
    6464        catch (IOException e) {
    65             throw new StreamError(e);
     65            throw new ConditionThrowable(new StreamError(e));
    6666        }
    6767    }
  • trunk/j/src/org/armedbear/lisp/BinaryOutputStream.java

    r1598 r3887  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: BinaryOutputStream.java,v 1.2 2003-04-09 18:09:00 piso Exp $
     5 * $Id: BinaryOutputStream.java,v 1.3 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3535    }
    3636
    37     public void writeByte(int n) throws StreamError
     37    public void writeByte(int n) throws ConditionThrowable
    3838    {
    3939        try {
     
    4141        }
    4242        catch (IOException e) {
    43             throw new StreamError(e);
     43            throw new ConditionThrowable(new StreamError(e));
    4444        }
    4545    }
    4646
    47     public void finishOutput() throws StreamError
     47    public void finishOutput() throws ConditionThrowable
    4848    {
    4949        try {
     
    5151        }
    5252        catch (IOException e) {
    53             throw new StreamError(e);
     53            throw new ConditionThrowable(new StreamError(e));
    5454        }
    5555    }
    5656
    5757    // Returns true if stream was open, otherwise implementation-dependent.
    58     public LispObject close(LispObject abort) throws StreamError
     58    public LispObject close(LispObject abort) throws ConditionThrowable
    5959    {
    6060        try {
     
    6363        }
    6464        catch (IOException e) {
    65             throw new StreamError(e);
     65            throw new ConditionThrowable(new StreamError(e));
    6666        }
    6767    }
  • trunk/j/src/org/armedbear/lisp/CharacterInputStream.java

    r3886 r3887  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: CharacterInputStream.java,v 1.48 2003-09-19 12:20:34 piso Exp $
     5 * $Id: CharacterInputStream.java,v 1.49 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    7979        }
    8080        catch (IOException e) {
    81             throw new StreamError(e);
     81            throw new ConditionThrowable(new StreamError(e));
    8282        }
    8383    }
     
    9292            }
    9393            catch (IOException e) {
    94                 throw new StreamError(e);
     94                throw new ConditionThrowable(new StreamError(e));
    9595            }
    9696            if (n < 0) {
    9797                if (eofError)
    98                     throw new EndOfFileException();
     98                    throw new ConditionThrowable(new EndOfFileException());
    9999                else
    100100                    return eofValue;
     
    144144                int n = read();
    145145                if (n < 0)
    146                     throw new EndOfFileException();
     146                    throw new ConditionThrowable(new EndOfFileException());
    147147                char c = (char) n;
    148148                if (c == '\\') {
     
    150150                    n = read();
    151151                    if (n < 0)
    152                         throw new EndOfFileException();
     152                        throw new ConditionThrowable(new EndOfFileException());
    153153                    sb.append((char)n);
    154154                    continue;
     
    162162        }
    163163        catch (IOException e) {
    164             throw new StreamError(e);
     164            throw new ConditionThrowable(new StreamError(e));
    165165        }
    166166    }
     
    184184                    int n = read();
    185185                    if (n < 0)
    186                         throw new EndOfFileException();
     186                        throw new ConditionThrowable(new EndOfFileException());
    187187                    char nextChar = (char) n;
    188188                    if (isTokenDelimiter(nextChar)) {
     
    213213        }
    214214        catch (IOException e) {
    215             throw new StreamError(e);
     215            throw new ConditionThrowable(new StreamError(e));
    216216        }
    217217    }
     
    250250        }
    251251        catch (IOException e) {
    252             throw new StreamError(e);
     252            throw new ConditionThrowable(new StreamError(e));
    253253        }
    254254    }
     
    259259            int n = read();
    260260            if (n < 0)
    261                 throw new EndOfFileException();
     261                throw new ConditionThrowable(new EndOfFileException());
    262262            char c = (char) n;
    263263            switch (c) {
     
    275275        }
    276276        catch (IOException e) {
    277             throw new StreamError(e);
     277            throw new ConditionThrowable(new StreamError(e));
    278278        }
    279279    }
     
    292292                int n = read();
    293293                if (n < 0)
    294                     throw new EndOfFileException();
     294                    throw new ConditionThrowable(new EndOfFileException());
    295295                c = (char) n;
    296296                if (c < '0' || c > '9')
     
    354354        }
    355355        catch (IOException e) {
    356             throw new StreamError(e);
     356            throw new ConditionThrowable(new StreamError(e));
    357357        }
    358358    }
     
    363363            int n = read();
    364364            if (n < 0)
    365                 throw new EndOfFileException();
     365                throw new ConditionThrowable(new EndOfFileException());
    366366            char c = (char) n;
    367367            StringBuffer sb = new StringBuffer();
     
    389389        }
    390390        catch (IOException e) {
    391             throw new StreamError(e);
     391            throw new ConditionThrowable(new StreamError(e));
    392392        }
    393393    }
     
    419419            int n = read();
    420420            if (n < 0)
    421                 throw new EndOfFileException();
     421                throw new ConditionThrowable(new EndOfFileException());
    422422            char c = (char) n;
    423423            StringBuffer sb = new StringBuffer();
     
    426426                    n = read();
    427427                    if (n < 0)
    428                         throw new EndOfFileException();
     428                        throw new ConditionThrowable(new EndOfFileException());
    429429                    c = (char) n;
    430430                    if (c == '|')
     
    451451        }
    452452        catch (IOException e) {
    453             throw new StreamError(e);
    454         }
    455     }
    456 
    457     private void skipBalancedComment() throws StreamError
     453            throw new ConditionThrowable(new StreamError(e));
     454        }
     455    }
     456
     457    private void skipBalancedComment() throws ConditionThrowable
    458458    {
    459459        try {
     
    478478        }
    479479        catch (IOException e) {
    480             throw new StreamError(e);
     480            throw new ConditionThrowable(new StreamError(e));
    481481        }
    482482    }
     
    501501        }
    502502        catch (IOException e) {
    503             throw new StreamError(e);
     503            throw new ConditionThrowable(new StreamError(e));
    504504        }
    505505    }
     
    537537        }
    538538        catch (IOException e) {
    539             throw new StreamError(e);
     539            throw new ConditionThrowable(new StreamError(e));
    540540        }
    541541    }
     
    565565        }
    566566        catch (IOException e) {
    567             throw new StreamError(e);
     567            throw new ConditionThrowable(new StreamError(e));
    568568        }
    569569    }
     
    592592        }
    593593        catch (IOException e) {
    594             throw new StreamError(e);
     594            throw new ConditionThrowable(new StreamError(e));
    595595        }
    596596    }
     
    762762        }
    763763        catch (IOException e) {
    764             throw new StreamError(e);
     764            throw new ConditionThrowable(new StreamError(e));
    765765        }
    766766    }
     
    800800        }
    801801        catch (IOException e) {
    802             throw new StreamError(e);
     802            throw new ConditionThrowable(new StreamError(e));
    803803        }
    804804    }
     
    810810                int n = read();
    811811                if (n < 0)
    812                     throw new EndOfFileException();
     812                    throw new ConditionThrowable(new EndOfFileException());
    813813                char c = (char) n;
    814814                if (!Character.isWhitespace(c))
     
    817817        }
    818818        catch (IOException e) {
    819             throw new StreamError(e);
     819            throw new ConditionThrowable(new StreamError(e));
    820820        }
    821821    }
     
    834834                    if (sb.length() == 0) {
    835835                        if (eofError)
    836                             throw new EndOfFileException();
     836                            throw new ConditionThrowable(new EndOfFileException());
    837837                        return eofValue;
    838838                    }
     
    856856            }
    857857            catch (IOException e) {
    858                 throw new StreamError(e);
     858                throw new ConditionThrowable(new StreamError(e));
    859859            }
    860860        }
     
    871871        }
    872872        catch (IOException e) {
    873             throw new StreamError(e);
     873            throw new ConditionThrowable(new StreamError(e));
    874874        }
    875875        if (n < 0) {
    876876            if (eofError)
    877                 throw new EndOfFileException();
     877                throw new ConditionThrowable(new EndOfFileException());
    878878            else
    879879                return eofValue;
     
    889889        }
    890890        catch (IOException e) {
    891             throw new StreamError(e);
     891            throw new ConditionThrowable(new StreamError(e));
    892892        }
    893893        return NIL;
     
    902902        }
    903903        catch (IOException e) {
    904             throw new StreamError(e);
     904            throw new ConditionThrowable(new StreamError(e));
    905905        }
    906906        return NIL;
     
    909909    // close stream &key abort => result
    910910    // Must return true if stream was open, otherwise implementation-dependent.
    911     public LispObject close(LispObject abort) throws StreamError
     911    public LispObject close(LispObject abort) throws ConditionThrowable
    912912    {
    913913        try {
     
    916916        }
    917917        catch (IOException e) {
    918             throw new StreamError(e);
     918            throw new ConditionThrowable(new StreamError(e));
    919919        }
    920920    }
  • trunk/j/src/org/armedbear/lisp/CharacterOutputStream.java

    r3433 r3887  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: CharacterOutputStream.java,v 1.4 2003-08-16 16:53:39 piso Exp $
     5 * $Id: CharacterOutputStream.java,v 1.5 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    6363    }
    6464
    65     public LispObject terpri() throws StreamError
    66     {
    67         try {
    68             writer.write(lineSeparator);
    69             writer.flush();
    70             charPos = 0;
    71         }
    72         catch (IOException e) {
    73             throw new StreamError(e);
     65    public LispObject terpri() throws ConditionThrowable
     66    {
     67        try {
     68            writer.write(lineSeparator);
     69            writer.flush();
     70            charPos = 0;
     71        }
     72        catch (IOException e) {
     73            throw new ConditionThrowable(new StreamError(e));
    7474        }
    7575        return NIL;
    7676    }
    7777
    78     public LispObject freshLine() throws StreamError
     78    public LispObject freshLine() throws ConditionThrowable
    7979    {
    8080        if (charPos == 0)
     
    8686        }
    8787        catch (IOException e) {
    88             throw new StreamError(e);
     88            throw new ConditionThrowable(new StreamError(e));
    8989        }
    9090        return T;
    9191    }
    9292
    93     public void print(LispObject obj) throws StreamError
     93    public void print(LispObject obj) throws ConditionThrowable
    9494    {
    9595        try {
     
    9797        }
    9898        catch (IOException e) {
    99             throw new StreamError(e);
    100         }
    101     }
    102 
    103     public void print(char c) throws StreamError
     99            throw new ConditionThrowable(new StreamError(e));
     100        }
     101    }
     102
     103    public void print(char c) throws ConditionThrowable
    104104    {
    105105        try {
     
    112112        }
    113113        catch (IOException e) {
    114             throw new StreamError(e);
     114            throw new ConditionThrowable(new StreamError(e));
    115115        }
    116116    }
     
    121121    // good to people, while output from PRIN1 is intended to be acceptable to
    122122    // READ.
    123     public void princ(LispObject obj) throws StreamError
     123    public void princ(LispObject obj) throws ConditionThrowable
    124124    {
    125125        LispThread thread = LispThread.currentThread();
     
    137137        }
    138138        catch (IOException e) {
    139             throw new StreamError(e);
     139            throw new ConditionThrowable(new StreamError(e));
    140140        }
    141141    }
     
    143143    // PRIN1 produces output suitable for input to READ.
    144144    // Binds *PRINT-ESCAPE* to true.
    145     public void prin1(LispObject obj) throws StreamError
     145    public void prin1(LispObject obj) throws ConditionThrowable
    146146    {
    147147        String s = String.valueOf(obj);
     
    155155        }
    156156        catch (IOException e) {
    157             throw new StreamError(e);
    158         }
    159     }
    160 
    161     public void writeChar(char c) throws StreamError
     157            throw new ConditionThrowable(new StreamError(e));
     158        }
     159    }
     160
     161    public void writeChar(char c) throws ConditionThrowable
    162162    {
    163163        try {
     
    170170        }
    171171        catch (IOException e) {
    172             throw new StreamError(e);
    173         }
    174     }
    175 
    176     public void writeString(LispString string) throws StreamError
     172            throw new ConditionThrowable(new StreamError(e));
     173        }
     174    }
     175
     176    public void writeString(LispString string) throws ConditionThrowable
    177177    {
    178178        writeString(string.getValue());
    179179    }
    180180
    181     public void writeString(String s) throws StreamError
     181    public void writeString(String s) throws ConditionThrowable
    182182    {
    183183        try {
     
    190190        }
    191191        catch (IOException e) {
    192             throw new StreamError(e);
    193         }
    194     }
    195 
    196     public void writeLine(String s) throws StreamError
    197     {
    198         try {
    199             writer.write(s);
    200             writer.write(lineSeparator);
    201             writer.flush();
    202             charPos = 0;
    203         }
    204         catch (IOException e) {
    205             throw new StreamError(e);
    206         }
    207     }
    208 
    209     public void printStackTrace(Throwable t) throws StreamError
     192            throw new ConditionThrowable(new StreamError(e));
     193        }
     194    }
     195
     196    public void writeLine(String s) throws ConditionThrowable
     197    {
     198        try {
     199            writer.write(s);
     200            writer.write(lineSeparator);
     201            writer.flush();
     202            charPos = 0;
     203        }
     204        catch (IOException e) {
     205            throw new ConditionThrowable(new StreamError(e));
     206        }
     207    }
     208
     209    public void printStackTrace(Throwable t) throws ConditionThrowable
    210210    {
    211211        StringWriter sw = new StringWriter();
     
    219219        }
    220220        catch (IOException e) {
    221             throw new StreamError(e);
    222         }
    223     }
    224 
    225     public void finishOutput() throws StreamError
    226     {
    227         try {
    228             writer.flush();
    229         }
    230         catch (IOException e) {
    231             throw new StreamError(e);
     221            throw new ConditionThrowable(new StreamError(e));
     222        }
     223    }
     224
     225    public void finishOutput() throws ConditionThrowable
     226    {
     227        try {
     228            writer.flush();
     229        }
     230        catch (IOException e) {
     231            throw new ConditionThrowable(new StreamError(e));
    232232        }
    233233    }
    234234
    235235    // Returns true if stream was open, otherwise implementation-dependent.
    236     public LispObject close(LispObject abort) throws StreamError
     236    public LispObject close(LispObject abort) throws ConditionThrowable
    237237    {
    238238        try {
     
    241241        }
    242242        catch (IOException e) {
    243             throw new StreamError(e);
     243            throw new ConditionThrowable(new StreamError(e));
    244244        }
    245245    }
  • trunk/j/src/org/armedbear/lisp/Interpreter.java

    r3883 r3887  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Interpreter.java,v 1.32 2003-09-19 01:46:40 piso Exp $
     5 * $Id: Interpreter.java,v 1.33 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    374374                LispObject obj = stream.read(false, EOF, false);
    375375                if (obj == EOF)
    376                     throw new EndOfFileException();
     376                    throw new ConditionThrowable(new EndOfFileException());
    377377                eval(obj, new Environment(), LispThread.currentThread());
    378378                getStandardOutput().freshLine();
     
    388388                LispObject obj = stream.read(false, EOF, false);
    389389                if (obj == EOF)
    390                     throw new EndOfFileException();
     390                    throw new ConditionThrowable(new EndOfFileException());
    391391                eval(obj, new Environment(), LispThread.currentThread());
    392392                return true;
     
    531531        LispObject obj = stream.read(false, EOF, false);
    532532        if (obj == EOF)
    533             throw new EndOfFileException();
     533            throw new ConditionThrowable(new EndOfFileException());
    534534        return eval(obj, new Environment(), LispThread.currentThread());
    535535    }
  • trunk/j/src/org/armedbear/lisp/LispStream.java

    r3883 r3887  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispStream.java,v 1.4 2003-09-19 01:46:41 piso Exp $
     5 * $Id: LispStream.java,v 1.5 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3131    }
    3232
    33     public abstract LispObject close(LispObject abort) throws StreamError;
     33    public abstract LispObject close(LispObject abort) throws ConditionThrowable;
    3434}
  • trunk/j/src/org/armedbear/lisp/LispThread.java

    r3884 r3887  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: LispThread.java,v 1.12 2003-09-19 11:50:18 piso Exp $
     5 * $Id: LispThread.java,v 1.13 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    257257
    258258    private static void pprint(LispObject obj, int indentBy,
    259         CharacterOutputStream stream) throws StreamError
     259        CharacterOutputStream stream) throws ConditionThrowable
    260260    {
    261261        if (stream.getCharPos() == 0) {
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r3886 r3887  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.408 2003-09-19 12:20:34 piso Exp $
     5 * $Id: Primitives.java,v 1.409 2003-09-19 12:32:13 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    17901790    {
    17911791        if (type == Symbol.END_OF_FILE)
    1792             return c instanceof EndOfFileException;
     1792            return c.getCondition() instanceof EndOfFileException;
    17931793        if (type == Symbol.STREAM_ERROR)
    1794             return c instanceof StreamError;
     1794            return c.getCondition() instanceof StreamError;
    17951795        if (type == Symbol.UNDEFINED_FUNCTION)
    17961796            return c.getCondition() instanceof UndefinedFunctionError;
  • trunk/j/src/org/armedbear/lisp/StreamError.java

    r1605 r3887  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: StreamError.java,v 1.3 2003-04-09 23:54:47 piso Exp $
     5 * $Id: StreamError.java,v 1.4 2003-09-19 12:32:14 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
    24 public class StreamError extends LispError
     24public class StreamError extends Condition
    2525{
     26    private String message;
    2627    private Throwable cause;
    2728
    2829    public StreamError()
    2930    {
    30         super();
    3131    }
    3232
    3333    public StreamError(String message)
    3434    {
    35         super(message);
     35        this.message = message;
    3636    }
    3737
     
    4040        super();
    4141        this.cause = cause;
     42    }
     43
     44    public LispObject typep(LispObject type) throws ConditionThrowable
     45    {
     46        if (type == Symbol.ERROR)
     47            return T;
     48        if (type == Symbol.STREAM_ERROR)
     49            return T;
     50        return super.typep(type);
    4251    }
    4352
  • trunk/j/src/org/armedbear/lisp/TwoWayStream.java

    r3884 r3887  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: TwoWayStream.java,v 1.4 2003-09-19 11:50:19 piso Exp $
     5 * $Id: TwoWayStream.java,v 1.5 2003-09-19 12:32:14 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    5555    }
    5656
    57     public LispObject close(LispObject abort) throws StreamError
     57    public LispObject close(LispObject abort) throws ConditionThrowable
    5858    {
    5959        in.close(abort);
Note: See TracChangeset for help on using the changeset viewer.