KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > lisp > UndefinedFunction


1 /*
2  * UndefinedFunction.java
3  *
4  * Copyright (C) 2002-2004 Peter Graves
5  * $Id: UndefinedFunction.java,v 1.10 2004/06/29 15:15:26 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.lisp;
23
24 public final class UndefinedFunction extends CellError
25 {
26     // obj is either the undefined function itself or an initArgs list.
27
public UndefinedFunction(LispObject obj) throws ConditionThrowable
28     {
29         super(obj instanceof Cons ? obj : list2(Keyword.NAME, obj));
30     }
31
32     public LispObject typeOf()
33     {
34         return Symbol.UNDEFINED_FUNCTION;
35     }
36
37     public LispClass classOf()
38     {
39         return BuiltInClass.UNDEFINED_FUNCTION;
40     }
41
42     public LispObject typep(LispObject type) throws ConditionThrowable
43     {
44         if (type == Symbol.UNDEFINED_FUNCTION)
45             return T;
46         if (type == BuiltInClass.UNDEFINED_FUNCTION)
47             return T;
48         return super.typep(type);
49     }
50
51     public String JavaDoc getMessage()
52     {
53         LispObject cellName = getCellName();
54         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("The function ");
55         // FIXME
56
try {
57             sb.append(cellName.writeToString());
58         }
59         catch (Throwable JavaDoc t) {}
60         sb.append(" is undefined.");
61         return sb.toString();
62     }
63
64     public String JavaDoc writeToString() throws ConditionThrowable
65     {
66         if (_PRINT_ESCAPE_.symbolValue() == NIL)
67             return super.writeToString();
68         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("UNDEFINED-FUNCTION ");
69         sb.append(getCellName().writeToString());
70         return unreadableString(sb.toString());
71     }
72 }
73
Popular Tags