Changeset 3982


Ignore:
Timestamp:
09/21/03 23:06:29 (20 years ago)
Author:
piso
Message:

HANDLER-BIND, HANDLER-CASE: removed obsolete helper function isConditionOfType().

File:
1 edited

Legend:

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

    r3944 r3982  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.421 2003-09-21 01:40:57 piso Exp $
     5 * $Id: Primitives.java,v 1.422 2003-09-21 23:06:29 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    17071707    // ### handler-bind
    17081708    private static final SpecialOperator HANDLER_BIND =
    1709         new SpecialOperator("handler-bind") {
     1709        new SpecialOperator("handler-bind")
     1710    {
    17101711        public LispObject execute(LispObject args, Environment env)
    17111712            throws ConditionThrowable
     
    17211722            }
    17221723            catch (ConditionThrowable c) {
     1724                Condition condition = c.getCondition();
    17231725                while (bindings != NIL) {
    17241726                    Cons binding = checkCons(bindings.car());
    17251727                    LispObject type = binding.car();
    1726                     if (isConditionOfType(c, type)) {
     1728                    if (condition.typep(type) != NIL) {
    17271729                        LispObject obj = eval(binding.cadr(), env, thread);
    17281730                        LispObject handler;
     
    17341736                            handler = obj;
    17351737                        LispObject[] handlerArgs = new LispObject[1];
    1736                         handlerArgs[0] = c.getCondition();
     1738                        handlerArgs[0] = condition;
    17371739                         // Might not return.
    17381740                        funcall(handler, handlerArgs, thread);
     
    17401742                    bindings = bindings.cdr();
    17411743                }
    1742                 // Re-throw condition.
     1744                // Re-throw.
    17431745                throw c;
    17441746            }
     
    17621764            }
    17631765            catch (ConditionThrowable c) {
     1766                Condition condition = c.getCondition();
    17641767                thread.setStackDepth(depth);
    17651768                while (clauses != NIL) {
    17661769                    Cons clause = checkCons(clauses.car());
    17671770                    LispObject type = clause.car();
    1768                     if (isConditionOfType(c, type)) {
     1771                    if (condition.typep(type) != NIL) {
    17691772                        LispObject parameterList = clause.cadr();
    17701773                        LispObject body = clause.cdr().cdr();
     
    17731776                        if (numArgs == 1) {
    17741777                            LispObject[] handlerArgs = new LispObject[1];
    1775                             handlerArgs[0] = c.getCondition();
     1778                            handlerArgs[0] = condition;
    17761779                            return funcall(handler, handlerArgs, thread);
    17771780                        }
     
    17841787                    clauses = clauses.cdr();
    17851788                }
    1786                 // Re-throw condition.
     1789                // Re-throw.
    17871790                throw c;
    17881791            }
     
    18041807        }
    18051808    };
    1806 
    1807     private static boolean isConditionOfType(ConditionThrowable c, LispObject type)
    1808         throws ConditionThrowable
    1809     {
    1810         if (type == Symbol.END_OF_FILE)
    1811             return c.getCondition() instanceof EndOfFileException;
    1812         if (type == Symbol.STREAM_ERROR)
    1813             return c.getCondition() instanceof StreamError;
    1814         if (type == Symbol.UNDEFINED_FUNCTION)
    1815             return c.getCondition() instanceof UndefinedFunction;
    1816         if (type == Symbol.TYPE_ERROR)
    1817             return c.getCondition() instanceof TypeError;
    1818         if (type == Symbol.PACKAGE_ERROR)
    1819             return c.getCondition() instanceof PackageError;
    1820         if (type == Symbol.PARSE_ERROR)
    1821             return c.getCondition() instanceof ParseError;
    1822         if (type == Symbol.PROGRAM_ERROR)
    1823             return c.getCondition() instanceof ProgramError;
    1824         if (type == Symbol.CONTROL_ERROR)
    1825             return c.getCondition() instanceof ControlError;
    1826         if (type == Symbol.SIMPLE_ERROR)
    1827             return c.getCondition() instanceof SimpleError;
    1828         if (type == Symbol.CELL_ERROR)
    1829             return c.getCondition() instanceof CellError;
    1830         if (type == Symbol.ERROR || type == BuiltInClass.ERROR) {
    1831             Condition condition = c.getCondition();
    1832             if (condition.typep(Symbol.ERROR) == T)
    1833                 return true;
    1834             return false;
    1835         }
    1836         if (type == Symbol.CONDITION)
    1837             return true;
    1838         if (type == Symbol.SIMPLE_CONDITION)
    1839             return c.getCondition() instanceof SimpleCondition;
    1840         if (type == Symbol.DIVISION_BY_ZERO)
    1841             return c.getCondition() instanceof DivisionByZero;
    1842         if (type == Symbol.ARITHMETIC_ERROR)
    1843             return c.getCondition() instanceof ArithmeticError;
    1844 
    1845         return false;
    1846     }
    18471809
    18481810    // ### upgraded-array-element-type
Note: See TracChangeset for help on using the changeset viewer.