Changeset 3885


Ignore:
Timestamp:
09/19/03 12:10:28 (19 years ago)
Author:
piso
Message:

Conditions: work in progress.

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

Legend:

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

    r3884 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Lisp.java,v 1.135 2003-09-19 11:50:18 piso Exp $
     5 * $Id: Lisp.java,v 1.136 2003-09-19 12:10:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    275275                result = obj.getSymbolValue();
    276276                if (result == null)
    277                     throw new UnboundVariableException(obj.getName());
     277                    throw new ConditionThrowable(new UnboundVariableException(obj.getName()));
    278278            }
    279279            return result;
     
    283283                LispObject fun = env.lookupFunctional(first);
    284284                if (fun == null)
    285                     throw new UndefinedFunctionError(first);
     285                    throw new ConditionThrowable(new UndefinedFunctionError(first));
    286286                switch (fun.getFunctionalType()) {
    287287                    case FTYPE_SPECIAL_OPERATOR: {
     
    759759        } else if (obj instanceof Cons && obj.car() == Symbol.LAMBDA)
    760760            return new Closure(obj.cadr(), obj.cddr(), new Environment());
    761         throw new UndefinedFunctionError(obj);
     761        throw new ConditionThrowable(new UndefinedFunctionError(obj));
    762762    }
    763763
  • trunk/j/src/org/armedbear/lisp/ParseError.java

    r3880 r3885  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: ParseError.java,v 1.2 2003-09-19 01:07:46 piso Exp $
     5 * $Id: ParseError.java,v 1.3 2003-09-19 12:10:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3030        this.message = message;
    3131    }
     32
     33    public LispObject typep(LispObject type) throws ConditionThrowable
     34    {
     35        if (type == Symbol.PARSE_ERROR)
     36            return T;
     37        if (type == Symbol.ERROR)
     38            return T;
     39        return super.typep(type);
     40    }
    3241}
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r3884 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.406 2003-09-19 11:50:19 piso Exp $
     5 * $Id: Primitives.java,v 1.407 2003-09-19 12:10:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    306306                if (function != null)
    307307                    return function;
    308                 throw new UndefinedFunctionError(arg);
     308                throw new ConditionThrowable(new UndefinedFunctionError(arg));
    309309            }
    310310            case SYMBOL_PLIST:                  // ### symbol-plist
     
    17281728                            handler = obj.getSymbolFunction();
    17291729                            if (handler == null)
    1730                                 throw new UndefinedFunctionError(obj);
     1730                                throw new ConditionThrowable(new UndefinedFunctionError(obj));
    17311731                        } else
    17321732                            handler = obj;
     
    17871787
    17881788    private static boolean isConditionOfType(ConditionThrowable c, LispObject type)
     1789        throws ConditionThrowable
    17891790    {
    17901791        if (type == Symbol.END_OF_FILE)
     
    17931794            return c instanceof StreamError;
    17941795        if (type == Symbol.UNDEFINED_FUNCTION)
    1795             return c instanceof UndefinedFunctionError;
     1796            return c.getCondition() instanceof UndefinedFunctionError;
    17961797        if (type == Symbol.TYPE_ERROR)
    17971798            return c.getCondition() instanceof TypeError;
     
    18101811                return true;
    18111812            Condition condition = c.getCondition();
    1812             if (condition instanceof ParseError)
    1813                 return true;
    1814             if (condition instanceof ProgramError)
    1815                 return true;
    1816             if (condition instanceof TypeError)
     1813            if (condition.typep(Symbol.ERROR) == T)
    18171814                return true;
    18181815            return false;
     
    22312228            if (fun instanceof Function)
    22322229                return funcall0(fun, LispThread.currentThread());
    2233             throw new UndefinedFunctionError(arg);
     2230            throw new ConditionThrowable(new UndefinedFunctionError(arg));
    22342231        }
    22352232        public LispObject execute(LispObject first, LispObject second)
     
    22432240            if (fun instanceof Function)
    22442241                return funcall1(fun, second, LispThread.currentThread());
    2245             throw new UndefinedFunctionError(first);
     2242            throw new ConditionThrowable(new UndefinedFunctionError(first));
    22462243        }
    22472244        public LispObject execute(LispObject first, LispObject second,
     
    22562253            if (fun instanceof Function)
    22572254                return funcall2(fun, second, third, LispThread.currentThread());
    2258             throw new UndefinedFunctionError(first);
     2255            throw new ConditionThrowable(new UndefinedFunctionError(first));
    22592256        }
    22602257        public LispObject execute(LispObject[] args) throws ConditionThrowable
     
    22782275                }
    22792276            }
    2280             throw new UndefinedFunctionError(args[0]);
     2277            throw new ConditionThrowable(new UndefinedFunctionError(args[0]));
    22812278        }
    22822279    };
     
    23502347                fun = fun.getSymbolFunction();
    23512348            if (!(fun instanceof Function))
    2352                 throw new UndefinedFunctionError(first);
     2349                throw new ConditionThrowable(new UndefinedFunctionError(first));
    23532350            // Second argument must be a list.
    23542351            LispObject list = checkList(second);
     
    23782375                fun = fun.getSymbolFunction();
    23792376            if (!(fun instanceof Function))
    2380                 throw new UndefinedFunctionError(first);
     2377                throw new ConditionThrowable(new UndefinedFunctionError(first));
    23812378            // Remaining arguments must be lists.
    23822379            LispObject list1 = checkList(second);
     
    24112408                fun = fun.getSymbolFunction();
    24122409            if (!(fun instanceof Function))
    2413                 throw new UndefinedFunctionError(args[0]);
     2410                throw new ConditionThrowable(new UndefinedFunctionError(args[0]));
    24142411            // Remaining arguments must be lists.
    24152412            int commonLength = -1;
     
    33493346                if (functional instanceof Function)
    33503347                    return functional;
    3351                 throw new UndefinedFunctionError(arg);
     3348                throw new ConditionThrowable(new UndefinedFunctionError(arg));
    33523349            }
    33533350            if (arg instanceof Cons) {
     
    33553352                    return new Closure(arg.cadr(), arg.cddr(), env);
    33563353            }
    3357             throw new UndefinedFunctionError(String.valueOf(arg));
     3354            throw new ConditionThrowable(new UndefinedFunctionError(String.valueOf(arg)));
    33583355        }
    33593356    };
     
    35273524                function = obj.getSymbolFunction();
    35283525                if (function == null)
    3529                     throw new UndefinedFunctionError(obj);
     3526                    throw new ConditionThrowable(new UndefinedFunctionError(obj));
    35303527            } else if (obj instanceof Function) {
    35313528                function = obj;
     
    44694466                    key = key.getSymbolFunction();
    44704467                if (!(key instanceof Function))
    4471                     throw new UndefinedFunctionError(args[2]);
     4468                    throw new ConditionThrowable(new UndefinedFunctionError(args[2]));
    44724469            }
    44734470            LispObject test = args[3];
     
    44814478                    test = test.getSymbolFunction();
    44824479                if (!(test instanceof Function))
    4483                     throw new UndefinedFunctionError(args[3]);
     4480                    throw new ConditionThrowable(new UndefinedFunctionError(args[3]));
    44844481            } else if (testNot != NIL) {
    44854482                if (testNot instanceof Symbol)
    44864483                    testNot = testNot.getSymbolFunction();
    44874484                if (!(testNot instanceof Function))
    4488                     throw new UndefinedFunctionError(args[3]);
     4485                    throw new ConditionThrowable(new UndefinedFunctionError(args[3]));
    44894486            }
    44904487            if (key == NIL && test == EQL) {
  • trunk/j/src/org/armedbear/lisp/ProgramError.java

    r3883 r3885  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: ProgramError.java,v 1.4 2003-09-19 01:46:42 piso Exp $
     5 * $Id: ProgramError.java,v 1.5 2003-09-19 12:10:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3434        this.message = message;
    3535    }
     36
     37    public LispObject typep(LispObject type) throws ConditionThrowable
     38    {
     39        if (type == Symbol.PROGRAM_ERROR)
     40            return T;
     41        if (type == Symbol.ERROR)
     42            return T;
     43        return super.typep(type);
     44    }
    3645}
  • trunk/j/src/org/armedbear/lisp/Symbol.java

    r3883 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Symbol.java,v 1.77 2003-09-19 01:46:42 piso Exp $
     5 * $Id: Symbol.java,v 1.78 2003-09-19 12:10:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    124124    public static final Symbol STREAM_ERROR         = PACKAGE_CL.addExternalSymbol("STREAM-ERROR");
    125125    public static final Symbol TYPE_ERROR           = PACKAGE_CL.addExternalSymbol("TYPE-ERROR");
     126    public static final Symbol UNBOUND_VARIABLE     = PACKAGE_CL.addExternalSymbol("UNBOUND-VARIABLE");
    126127    public static final Symbol UNDEFINED_FUNCTION   = PACKAGE_CL.addExternalSymbol("UNDEFINED-FUNCTION");
    127128
     
    317318    {
    318319        if (function == null)
    319             throw new UndefinedFunctionError(this);
     320            throw new ConditionThrowable(new UndefinedFunctionError(this));
    320321        return function;
    321322    }
  • trunk/j/src/org/armedbear/lisp/TypeError.java

    r3884 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: TypeError.java,v 1.3 2003-09-19 11:50:19 piso Exp $
     5 * $Id: TypeError.java,v 1.4 2003-09-19 12:10:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    5252    }
    5353
     54    public LispObject typep(LispObject type) throws ConditionThrowable
     55    {
     56        if (type == Symbol.TYPE_ERROR)
     57            return T;
     58        if (type == Symbol.ERROR)
     59            return T;
     60        return super.typep(type);
     61    }
     62
    5463    public String getMessage()
    5564    {
  • trunk/j/src/org/armedbear/lisp/UnboundVariableException.java

    r743 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: UnboundVariableException.java,v 1.2 2003-02-15 16:48:17 piso Exp $
     5 * $Id: UnboundVariableException.java,v 1.3 2003-09-19 12:10:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
    24 public final class UnboundVariableException extends LispError
     24public final class UnboundVariableException extends Condition
    2525{
    2626    private final String name;
     
    3737        return "the variable " + name + " has no value";
    3838    }
     39
     40    public LispObject typep(LispObject type) throws ConditionThrowable
     41    {
     42        if (type == Symbol.UNBOUND_VARIABLE)
     43            return T;
     44        if (type == Symbol.ERROR)
     45            return T;
     46        return super.typep(type);
     47    }
    3948}
  • trunk/j/src/org/armedbear/lisp/UndefinedFunctionError.java

    r2572 r3885  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: UndefinedFunctionError.java,v 1.2 2003-06-24 18:21:40 piso Exp $
     5 * $Id: UndefinedFunctionError.java,v 1.3 2003-09-19 12:10:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
    24 public final class UndefinedFunctionError extends LispError
     24public final class UndefinedFunctionError extends Condition
    2525{
    2626    private final LispObject object;
     
    4545    }
    4646
     47    public LispObject typep(LispObject type) throws ConditionThrowable
     48    {
     49        if (type == Symbol.UNDEFINED_FUNCTION)
     50            return T;
     51        if (type == Symbol.ERROR)
     52            return T;
     53        return super.typep(type);
     54    }
     55
    4756    public String getMessage()
    4857    {
Note: See TracChangeset for help on using the changeset viewer.