Changeset 3982
- Timestamp:
- 09/21/03 23:06:29 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Primitives.java
r3944 r3982 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Primitives.java,v 1.42 1 2003-09-21 01:40:57piso Exp $5 * $Id: Primitives.java,v 1.422 2003-09-21 23:06:29 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 1707 1707 // ### handler-bind 1708 1708 private static final SpecialOperator HANDLER_BIND = 1709 new SpecialOperator("handler-bind") { 1709 new SpecialOperator("handler-bind") 1710 { 1710 1711 public LispObject execute(LispObject args, Environment env) 1711 1712 throws ConditionThrowable … … 1721 1722 } 1722 1723 catch (ConditionThrowable c) { 1724 Condition condition = c.getCondition(); 1723 1725 while (bindings != NIL) { 1724 1726 Cons binding = checkCons(bindings.car()); 1725 1727 LispObject type = binding.car(); 1726 if ( isConditionOfType(c, type)) {1728 if (condition.typep(type) != NIL) { 1727 1729 LispObject obj = eval(binding.cadr(), env, thread); 1728 1730 LispObject handler; … … 1734 1736 handler = obj; 1735 1737 LispObject[] handlerArgs = new LispObject[1]; 1736 handlerArgs[0] = c .getCondition();1738 handlerArgs[0] = condition; 1737 1739 // Might not return. 1738 1740 funcall(handler, handlerArgs, thread); … … 1740 1742 bindings = bindings.cdr(); 1741 1743 } 1742 // Re-throw condition.1744 // Re-throw. 1743 1745 throw c; 1744 1746 } … … 1762 1764 } 1763 1765 catch (ConditionThrowable c) { 1766 Condition condition = c.getCondition(); 1764 1767 thread.setStackDepth(depth); 1765 1768 while (clauses != NIL) { 1766 1769 Cons clause = checkCons(clauses.car()); 1767 1770 LispObject type = clause.car(); 1768 if ( isConditionOfType(c, type)) {1771 if (condition.typep(type) != NIL) { 1769 1772 LispObject parameterList = clause.cadr(); 1770 1773 LispObject body = clause.cdr().cdr(); … … 1773 1776 if (numArgs == 1) { 1774 1777 LispObject[] handlerArgs = new LispObject[1]; 1775 handlerArgs[0] = c .getCondition();1778 handlerArgs[0] = condition; 1776 1779 return funcall(handler, handlerArgs, thread); 1777 1780 } … … 1784 1787 clauses = clauses.cdr(); 1785 1788 } 1786 // Re-throw condition.1789 // Re-throw. 1787 1790 throw c; 1788 1791 } … … 1804 1807 } 1805 1808 }; 1806 1807 private static boolean isConditionOfType(ConditionThrowable c, LispObject type)1808 throws ConditionThrowable1809 {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 }1847 1809 1848 1810 // ### upgraded-array-element-type
Note: See TracChangeset
for help on using the changeset viewer.