001: /*
002: * LispObject.java
003: *
004: * Copyright (C) 2002-2003 Peter Graves
005: * $Id: LispObject.java,v 1.7 2003/11/15 11:03:30 beedlem Exp $
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021:
022: package org.armedbear.lisp;
023:
024: public class LispObject extends Lisp {
025: public int getFunctionalType() {
026: return 0;
027: }
028:
029: public LispObject typeOf() {
030: return T;
031: }
032:
033: public LispClass classOf() {
034: return BuiltInClass.CLASS_T;
035: }
036:
037: public LispObject typep(LispObject typeSpecifier)
038: throws ConditionThrowable {
039: if (typeSpecifier == T)
040: return T;
041: if (typeSpecifier == BuiltInClass.CLASS_T)
042: return T;
043: if (typeSpecifier == Symbol.ATOM)
044: return T;
045: return NIL;
046: }
047:
048: public LispObject CONSTANTP() {
049: return T;
050: }
051:
052: public LispObject ATOM() {
053: return T;
054: }
055:
056: public boolean atom() {
057: return true;
058: }
059:
060: public String getName() {
061: return null;
062: }
063:
064: public Object javaInstance() throws ConditionThrowable {
065: throw new ConditionThrowable(new TypeError(this ,
066: "primitive type"));
067: }
068:
069: public LispObject car() throws ConditionThrowable {
070: throw new ConditionThrowable(new TypeError(this , "list"));
071: }
072:
073: public void setCar(LispObject obj) throws ConditionThrowable {
074: throw new ConditionThrowable(new TypeError(this , "cons"));
075: }
076:
077: public LispObject cdr() throws ConditionThrowable {
078: throw new ConditionThrowable(new TypeError(this , "list"));
079: }
080:
081: public void setCdr(LispObject obj) throws ConditionThrowable {
082: throw new ConditionThrowable(new TypeError(this , "cons"));
083: }
084:
085: public LispObject cadr() throws ConditionThrowable {
086: throw new ConditionThrowable(new TypeError(this , "list"));
087: }
088:
089: public LispObject cddr() throws ConditionThrowable {
090: throw new ConditionThrowable(new TypeError(this , "list"));
091: }
092:
093: public LispObject EQ(LispObject obj) {
094: return this == obj ? T : NIL;
095: }
096:
097: public boolean eql(LispObject obj) {
098: return this == obj;
099: }
100:
101: public LispObject EQL(LispObject obj) {
102: return eql(obj) ? T : NIL;
103: }
104:
105: public boolean equal(LispObject obj) throws ConditionThrowable {
106: return this == obj;
107: }
108:
109: public boolean equalp(LispObject obj) throws ConditionThrowable {
110: return this == obj;
111: }
112:
113: public LispObject ABS() throws ConditionThrowable {
114: throw new ConditionThrowable(new TypeError(this , "number"));
115: }
116:
117: public LispObject NUMERATOR() throws ConditionThrowable {
118: throw new ConditionThrowable(new TypeError(this ,
119: "rational number"));
120: }
121:
122: public LispObject DENOMINATOR() throws ConditionThrowable {
123: throw new ConditionThrowable(new TypeError(this ,
124: "rational number"));
125: }
126:
127: public LispObject EVENP() throws ConditionThrowable {
128: return evenp() ? T : NIL;
129: }
130:
131: public boolean evenp() throws ConditionThrowable {
132: throw new ConditionThrowable(new TypeError(this , "integer"));
133: }
134:
135: public LispObject ODDP() throws ConditionThrowable {
136: return oddp() ? T : NIL;
137: }
138:
139: public boolean oddp() throws ConditionThrowable {
140: throw new ConditionThrowable(new TypeError(this , "integer"));
141: }
142:
143: public LispObject PLUSP() throws ConditionThrowable {
144: return plusp() ? T : NIL;
145: }
146:
147: public boolean plusp() throws ConditionThrowable {
148: throw new ConditionThrowable(new TypeError(this , "real number"));
149: }
150:
151: public LispObject MINUSP() throws ConditionThrowable {
152: return minusp() ? T : NIL;
153: }
154:
155: public boolean minusp() throws ConditionThrowable {
156: throw new ConditionThrowable(new TypeError(this , "real number"));
157: }
158:
159: public LispObject NUMBERP() {
160: return NIL;
161: }
162:
163: public boolean numberp() {
164: return false;
165: }
166:
167: public LispObject ZEROP() throws ConditionThrowable {
168: return zerop() ? T : NIL;
169: }
170:
171: public boolean zerop() throws ConditionThrowable {
172: throw new ConditionThrowable(new TypeError(this , "number"));
173: }
174:
175: public LispObject BIT_VECTOR_P() {
176: return NIL;
177: }
178:
179: public LispObject COMPLEXP() {
180: return NIL;
181: }
182:
183: public LispObject FLOATP() {
184: return NIL;
185: }
186:
187: public boolean floatp() {
188: return false;
189: }
190:
191: public LispObject INTEGERP() {
192: return integerp() ? T : NIL;
193: }
194:
195: public boolean integerp() {
196: return false;
197: }
198:
199: public LispObject RATIONALP() {
200: return rationalp() ? T : NIL;
201: }
202:
203: public boolean rationalp() {
204: return false;
205: }
206:
207: public LispObject REALP() {
208: return realp() ? T : NIL;
209: }
210:
211: public boolean realp() {
212: return false;
213: }
214:
215: public LispObject STRINGP() {
216: return NIL;
217: }
218:
219: public LispObject SIMPLE_STRING_P() {
220: return NIL;
221: }
222:
223: public LispObject VECTORP() {
224: return vectorp() ? T : NIL;
225: }
226:
227: public boolean vectorp() {
228: return false;
229: }
230:
231: public int length() throws ConditionThrowable {
232: throw new ConditionThrowable(new TypeError(this , "sequence"));
233: }
234:
235: public final LispObject LENGTH() throws ConditionThrowable {
236: return new Fixnum(length());
237: }
238:
239: public LispObject elt(int index) throws ConditionThrowable {
240: throw new ConditionThrowable(new TypeError(this , "sequence"));
241: }
242:
243: public LispObject nreverse() throws ConditionThrowable {
244: throw new ConditionThrowable(new TypeError(this , "sequence"));
245: }
246:
247: public LispObject AREF(LispObject index) throws ConditionThrowable {
248: throw new ConditionThrowable(new TypeError(this , "array"));
249: }
250:
251: public LispObject[] copyToArray() throws ConditionThrowable {
252: throw new ConditionThrowable(new TypeError(this , "list"));
253: }
254:
255: public LispObject SYMBOLP() {
256: return NIL;
257: }
258:
259: public boolean listp() {
260: return false;
261: }
262:
263: public LispObject LISTP() {
264: return NIL;
265: }
266:
267: public LispObject ENDP() throws ConditionThrowable {
268: throw new ConditionThrowable(new TypeError(this , "list"));
269: }
270:
271: public LispObject NOT() {
272: return NIL;
273: }
274:
275: public boolean isSpecialVariable() {
276: return false;
277: }
278:
279: public LispObject getSymbolValue() throws ConditionThrowable {
280: throw new ConditionThrowable(new TypeError(this , "symbol"));
281: }
282:
283: public LispObject getSymbolFunction() throws ConditionThrowable {
284: throw new ConditionThrowable(new TypeError(this , "symbol"));
285: }
286:
287: public LispObject getSymbolFunctionOrDie()
288: throws ConditionThrowable {
289: throw new ConditionThrowable(new TypeError(this , "symbol"));
290: }
291:
292: public String toString() {
293: return super .toString();
294: }
295:
296: public String unreadableString(String s) {
297: StringBuffer sb = new StringBuffer("#<");
298: sb.append(s);
299: sb.append(" @ #x");
300: sb.append(Integer.toHexString(System.identityHashCode(this )));
301: sb.append(">");
302: return sb.toString();
303: }
304:
305: // Special operator
306: public LispObject execute(LispObject args, Environment env)
307: throws ConditionThrowable {
308: throw new ConditionThrowable(new LispError());
309: }
310:
311: // Primitive
312: public LispObject execute(LispObject[] args)
313: throws ConditionThrowable {
314: throw new ConditionThrowable(new LispError());
315: }
316:
317: // Primitive0
318: public LispObject execute() throws ConditionThrowable {
319: throw new ConditionThrowable(new LispError());
320: }
321:
322: // Primitive1
323: public LispObject execute(LispObject arg) throws ConditionThrowable {
324: throw new ConditionThrowable(new LispError());
325: }
326:
327: // Primitive2
328: public LispObject execute(LispObject first, LispObject second)
329: throws ConditionThrowable {
330: throw new ConditionThrowable(new LispError());
331: }
332:
333: // Primitive3
334: public LispObject execute(LispObject first, LispObject second,
335: LispObject third) throws ConditionThrowable {
336: throw new ConditionThrowable(new LispError());
337: }
338:
339: public LispObject incr() throws ConditionThrowable {
340: throw new ConditionThrowable(new TypeError(this , "number"));
341: }
342:
343: public LispObject decr() throws ConditionThrowable {
344: throw new ConditionThrowable(new TypeError(this , "number"));
345: }
346:
347: public LispObject add(LispObject obj) throws ConditionThrowable {
348: throw new ConditionThrowable(new TypeError(this , "number"));
349: }
350:
351: public LispObject subtract(LispObject obj)
352: throws ConditionThrowable {
353: throw new ConditionThrowable(new TypeError(this , "number"));
354: }
355:
356: public LispObject multiplyBy(LispObject obj)
357: throws ConditionThrowable {
358: throw new ConditionThrowable(new TypeError(this , "number"));
359: }
360:
361: public LispObject divideBy(LispObject obj)
362: throws ConditionThrowable {
363: throw new ConditionThrowable(new TypeError(this , "number"));
364: }
365:
366: public boolean isEqualTo(LispObject obj) throws ConditionThrowable {
367: throw new ConditionThrowable(new TypeError(this , "number"));
368: }
369:
370: public LispObject IS_E(LispObject obj) throws ConditionThrowable {
371: return isEqualTo(obj) ? T : NIL;
372: }
373:
374: public boolean isNotEqualTo(LispObject obj)
375: throws ConditionThrowable {
376: throw new ConditionThrowable(new TypeError(this , "number"));
377: }
378:
379: public LispObject IS_NE(LispObject obj) throws ConditionThrowable {
380: return isNotEqualTo(obj) ? T : NIL;
381: }
382:
383: public boolean isLessThan(LispObject obj) throws ConditionThrowable {
384: throw new ConditionThrowable(new TypeError(this , "number"));
385: }
386:
387: public LispObject IS_LT(LispObject obj) throws ConditionThrowable {
388: return isLessThan(obj) ? T : NIL;
389: }
390:
391: public boolean isGreaterThan(LispObject obj)
392: throws ConditionThrowable {
393: throw new ConditionThrowable(new TypeError(this , "number"));
394: }
395:
396: public LispObject IS_GT(LispObject obj) throws ConditionThrowable {
397: return isGreaterThan(obj) ? T : NIL;
398: }
399:
400: public boolean isLessThanOrEqualTo(LispObject obj)
401: throws ConditionThrowable {
402: throw new ConditionThrowable(new TypeError(this , "number"));
403: }
404:
405: public LispObject IS_LE(LispObject obj) throws ConditionThrowable {
406: return isLessThanOrEqualTo(obj) ? T : NIL;
407: }
408:
409: public boolean isGreaterThanOrEqualTo(LispObject obj)
410: throws ConditionThrowable {
411: throw new ConditionThrowable(new TypeError(this , "number"));
412: }
413:
414: public LispObject IS_GE(LispObject obj) throws ConditionThrowable {
415: return isGreaterThanOrEqualTo(obj) ? T : NIL;
416: }
417:
418: public LispObject truncate(LispObject obj)
419: throws ConditionThrowable {
420: throw new ConditionThrowable(new TypeError(this , "real number"));
421: }
422:
423: // Profiling.
424: public int getCallCount() {
425: return 0;
426: }
427:
428: public void setCallCount(int n) {
429: }
430:
431: public void incrementCallCount() {
432: }
433: }
|