1 | /* |
---|
2 | * LispObject.java |
---|
3 | * |
---|
4 | * Copyright (C) 2002-2007 Peter Graves |
---|
5 | * $Id: LispObject.java 12150 2009-09-18 06:31:06Z mevenson $ |
---|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | * |
---|
21 | * As a special exception, the copyright holders of this library give you |
---|
22 | * permission to link this library with independent modules to produce an |
---|
23 | * executable, regardless of the license terms of these independent |
---|
24 | * modules, and to copy and distribute the resulting executable under |
---|
25 | * terms of your choice, provided that you also meet, for each linked |
---|
26 | * independent module, the terms and conditions of the license of that |
---|
27 | * module. An independent module is a module which is not derived from |
---|
28 | * or based on this library. If you modify this library, you may extend |
---|
29 | * this exception to your version of the library, but you are not |
---|
30 | * obligated to do so. If you do not wish to do so, delete this |
---|
31 | * exception statement from your version. |
---|
32 | */ |
---|
33 | |
---|
34 | package org.armedbear.lisp; |
---|
35 | |
---|
36 | public class LispObject extends Lisp |
---|
37 | { |
---|
38 | public LispObject typeOf() |
---|
39 | { |
---|
40 | return T; |
---|
41 | } |
---|
42 | |
---|
43 | static public LispObject getInstance(boolean b) { |
---|
44 | return b ? T : NIL; |
---|
45 | } |
---|
46 | |
---|
47 | public LispObject classOf() |
---|
48 | { |
---|
49 | return BuiltInClass.CLASS_T; |
---|
50 | } |
---|
51 | |
---|
52 | public LispObject getDescription() throws ConditionThrowable |
---|
53 | { |
---|
54 | FastStringBuffer sb = new FastStringBuffer("An object of type "); |
---|
55 | sb.append(typeOf().writeToString()); |
---|
56 | sb.append(" at #x"); |
---|
57 | sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase()); |
---|
58 | return new SimpleString(sb); |
---|
59 | } |
---|
60 | |
---|
61 | public LispObject getParts() throws ConditionThrowable |
---|
62 | { |
---|
63 | return NIL; |
---|
64 | } |
---|
65 | |
---|
66 | public boolean getBooleanValue() |
---|
67 | { |
---|
68 | return true; |
---|
69 | } |
---|
70 | |
---|
71 | public LispObject typep(LispObject typeSpecifier) throws ConditionThrowable |
---|
72 | { |
---|
73 | if (typeSpecifier == T) |
---|
74 | return T; |
---|
75 | if (typeSpecifier == BuiltInClass.CLASS_T) |
---|
76 | return T; |
---|
77 | if (typeSpecifier == Symbol.ATOM) |
---|
78 | return T; |
---|
79 | return NIL; |
---|
80 | } |
---|
81 | |
---|
82 | public boolean constantp() |
---|
83 | { |
---|
84 | return true; |
---|
85 | } |
---|
86 | |
---|
87 | public LispObject CONSTANTP() |
---|
88 | { |
---|
89 | return constantp() ? T : NIL; |
---|
90 | } |
---|
91 | |
---|
92 | public LispObject ATOM() |
---|
93 | { |
---|
94 | return T; |
---|
95 | } |
---|
96 | |
---|
97 | public boolean atom() |
---|
98 | { |
---|
99 | return true; |
---|
100 | } |
---|
101 | |
---|
102 | public Object javaInstance() throws ConditionThrowable |
---|
103 | { |
---|
104 | return this; |
---|
105 | } |
---|
106 | |
---|
107 | public Object javaInstance(Class<?> c) throws ConditionThrowable |
---|
108 | { |
---|
109 | if (c.isAssignableFrom(getClass())) |
---|
110 | return this; |
---|
111 | return error(new LispError("The value " + writeToString() + |
---|
112 | " is not of class " + c.getName())); |
---|
113 | } |
---|
114 | |
---|
115 | /** This method returns 'this' by default, but allows |
---|
116 | * objects to return different values to increase Java |
---|
117 | * interoperability |
---|
118 | * |
---|
119 | * @return An object to be used with synchronized, wait, notify, etc |
---|
120 | * @throws org.armedbear.lisp.ConditionThrowable |
---|
121 | */ |
---|
122 | public Object lockableInstance() throws ConditionThrowable |
---|
123 | { |
---|
124 | return this; |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | public LispObject car() throws ConditionThrowable |
---|
129 | { |
---|
130 | return type_error(this, Symbol.LIST); |
---|
131 | } |
---|
132 | |
---|
133 | public void setCar(LispObject obj) throws ConditionThrowable |
---|
134 | { |
---|
135 | type_error(this, Symbol.CONS); |
---|
136 | } |
---|
137 | |
---|
138 | public LispObject RPLACA(LispObject obj) throws ConditionThrowable |
---|
139 | { |
---|
140 | return type_error(this, Symbol.CONS); |
---|
141 | } |
---|
142 | |
---|
143 | public LispObject cdr() throws ConditionThrowable |
---|
144 | { |
---|
145 | return type_error(this, Symbol.LIST); |
---|
146 | } |
---|
147 | |
---|
148 | public void setCdr(LispObject obj) throws ConditionThrowable |
---|
149 | { |
---|
150 | type_error(this, Symbol.CONS); |
---|
151 | } |
---|
152 | |
---|
153 | public LispObject RPLACD(LispObject obj) throws ConditionThrowable |
---|
154 | { |
---|
155 | return type_error(this, Symbol.CONS); |
---|
156 | } |
---|
157 | |
---|
158 | public LispObject cadr() throws ConditionThrowable |
---|
159 | { |
---|
160 | return type_error(this, Symbol.LIST); |
---|
161 | } |
---|
162 | |
---|
163 | public LispObject cddr() throws ConditionThrowable |
---|
164 | { |
---|
165 | return type_error(this, Symbol.LIST); |
---|
166 | } |
---|
167 | |
---|
168 | public LispObject caddr() throws ConditionThrowable |
---|
169 | { |
---|
170 | return type_error(this, Symbol.LIST); |
---|
171 | } |
---|
172 | |
---|
173 | public LispObject nthcdr(int n) throws ConditionThrowable |
---|
174 | { |
---|
175 | if (n < 0) |
---|
176 | return type_error(Fixnum.getInstance(n), |
---|
177 | list(Symbol.INTEGER, Fixnum.ZERO)); |
---|
178 | return type_error(this, Symbol.LIST); |
---|
179 | } |
---|
180 | |
---|
181 | public LispObject push(LispObject obj) throws ConditionThrowable |
---|
182 | { |
---|
183 | return type_error(this, Symbol.LIST); |
---|
184 | } |
---|
185 | |
---|
186 | public LispObject EQ(LispObject obj) |
---|
187 | { |
---|
188 | return this == obj ? T : NIL; |
---|
189 | } |
---|
190 | |
---|
191 | public boolean eql(char c) |
---|
192 | { |
---|
193 | return false; |
---|
194 | } |
---|
195 | |
---|
196 | public boolean eql(int n) |
---|
197 | { |
---|
198 | return false; |
---|
199 | } |
---|
200 | |
---|
201 | public boolean eql(LispObject obj) |
---|
202 | { |
---|
203 | return this == obj; |
---|
204 | } |
---|
205 | |
---|
206 | public final LispObject EQL(LispObject obj) |
---|
207 | { |
---|
208 | return eql(obj) ? T : NIL; |
---|
209 | } |
---|
210 | |
---|
211 | public final LispObject EQUAL(LispObject obj) throws ConditionThrowable |
---|
212 | { |
---|
213 | return equal(obj) ? T : NIL; |
---|
214 | } |
---|
215 | |
---|
216 | public boolean equal(int n) |
---|
217 | { |
---|
218 | return false; |
---|
219 | } |
---|
220 | |
---|
221 | public boolean equal(LispObject obj) throws ConditionThrowable |
---|
222 | { |
---|
223 | return this == obj; |
---|
224 | } |
---|
225 | |
---|
226 | public boolean equalp(int n) |
---|
227 | { |
---|
228 | return false; |
---|
229 | } |
---|
230 | |
---|
231 | public boolean equalp(LispObject obj) throws ConditionThrowable |
---|
232 | { |
---|
233 | return this == obj; |
---|
234 | } |
---|
235 | |
---|
236 | public LispObject ABS() throws ConditionThrowable |
---|
237 | { |
---|
238 | return type_error(this, Symbol.NUMBER); |
---|
239 | } |
---|
240 | |
---|
241 | public LispObject NUMERATOR() throws ConditionThrowable |
---|
242 | { |
---|
243 | return type_error(this, Symbol.RATIONAL); |
---|
244 | } |
---|
245 | |
---|
246 | public LispObject DENOMINATOR() throws ConditionThrowable |
---|
247 | { |
---|
248 | return type_error(this, Symbol.RATIONAL); |
---|
249 | } |
---|
250 | |
---|
251 | public LispObject EVENP() throws ConditionThrowable |
---|
252 | { |
---|
253 | return evenp() ? T : NIL; |
---|
254 | } |
---|
255 | |
---|
256 | public boolean evenp() throws ConditionThrowable |
---|
257 | { |
---|
258 | type_error(this, Symbol.INTEGER); |
---|
259 | // Not reached. |
---|
260 | return false; |
---|
261 | } |
---|
262 | |
---|
263 | public LispObject ODDP() throws ConditionThrowable |
---|
264 | { |
---|
265 | return oddp() ? T : NIL; |
---|
266 | } |
---|
267 | |
---|
268 | public boolean oddp() throws ConditionThrowable |
---|
269 | { |
---|
270 | type_error(this, Symbol.INTEGER); |
---|
271 | // Not reached. |
---|
272 | return false; |
---|
273 | } |
---|
274 | |
---|
275 | public LispObject PLUSP() throws ConditionThrowable |
---|
276 | { |
---|
277 | return plusp() ? T : NIL; |
---|
278 | } |
---|
279 | |
---|
280 | public boolean plusp() throws ConditionThrowable |
---|
281 | { |
---|
282 | type_error(this, Symbol.REAL); |
---|
283 | // Not reached. |
---|
284 | return false; |
---|
285 | } |
---|
286 | |
---|
287 | public LispObject MINUSP() throws ConditionThrowable |
---|
288 | { |
---|
289 | return minusp() ? T : NIL; |
---|
290 | } |
---|
291 | |
---|
292 | public boolean minusp() throws ConditionThrowable |
---|
293 | { |
---|
294 | type_error(this, Symbol.REAL); |
---|
295 | // Not reached. |
---|
296 | return false; |
---|
297 | } |
---|
298 | |
---|
299 | public LispObject NUMBERP() |
---|
300 | { |
---|
301 | return NIL; |
---|
302 | } |
---|
303 | |
---|
304 | public boolean numberp() |
---|
305 | { |
---|
306 | return false; |
---|
307 | } |
---|
308 | |
---|
309 | public LispObject ZEROP() throws ConditionThrowable |
---|
310 | { |
---|
311 | return zerop() ? T : NIL; |
---|
312 | } |
---|
313 | |
---|
314 | public boolean zerop() throws ConditionThrowable |
---|
315 | { |
---|
316 | type_error(this, Symbol.NUMBER); |
---|
317 | // Not reached. |
---|
318 | return false; |
---|
319 | } |
---|
320 | |
---|
321 | public LispObject COMPLEXP() |
---|
322 | { |
---|
323 | return NIL; |
---|
324 | } |
---|
325 | |
---|
326 | public LispObject FLOATP() |
---|
327 | { |
---|
328 | return NIL; |
---|
329 | } |
---|
330 | |
---|
331 | public boolean floatp() |
---|
332 | { |
---|
333 | return false; |
---|
334 | } |
---|
335 | |
---|
336 | public LispObject INTEGERP() |
---|
337 | { |
---|
338 | return NIL; |
---|
339 | } |
---|
340 | |
---|
341 | public boolean integerp() |
---|
342 | { |
---|
343 | return false; |
---|
344 | } |
---|
345 | |
---|
346 | public LispObject RATIONALP() |
---|
347 | { |
---|
348 | return rationalp() ? T : NIL; |
---|
349 | } |
---|
350 | |
---|
351 | public boolean rationalp() |
---|
352 | { |
---|
353 | return false; |
---|
354 | } |
---|
355 | |
---|
356 | public LispObject REALP() |
---|
357 | { |
---|
358 | return realp() ? T : NIL; |
---|
359 | } |
---|
360 | |
---|
361 | public boolean realp() |
---|
362 | { |
---|
363 | return false; |
---|
364 | } |
---|
365 | |
---|
366 | public LispObject STRINGP() |
---|
367 | { |
---|
368 | return NIL; |
---|
369 | } |
---|
370 | |
---|
371 | public boolean stringp() |
---|
372 | { |
---|
373 | return false; |
---|
374 | } |
---|
375 | |
---|
376 | public LispObject SIMPLE_STRING_P() |
---|
377 | { |
---|
378 | return NIL; |
---|
379 | } |
---|
380 | |
---|
381 | public LispObject VECTORP() |
---|
382 | { |
---|
383 | return NIL; |
---|
384 | } |
---|
385 | |
---|
386 | public boolean vectorp() |
---|
387 | { |
---|
388 | return false; |
---|
389 | } |
---|
390 | |
---|
391 | public LispObject CHARACTERP() |
---|
392 | { |
---|
393 | return NIL; |
---|
394 | } |
---|
395 | |
---|
396 | public boolean characterp() |
---|
397 | { |
---|
398 | return false; |
---|
399 | } |
---|
400 | |
---|
401 | public int length() throws ConditionThrowable |
---|
402 | { |
---|
403 | type_error(this, Symbol.SEQUENCE); |
---|
404 | // Not reached. |
---|
405 | return 0; |
---|
406 | } |
---|
407 | |
---|
408 | public final LispObject LENGTH() throws ConditionThrowable |
---|
409 | { |
---|
410 | return Fixnum.getInstance(length()); |
---|
411 | } |
---|
412 | |
---|
413 | public LispObject CHAR(int index) throws ConditionThrowable |
---|
414 | { |
---|
415 | return type_error(this, Symbol.STRING); |
---|
416 | } |
---|
417 | |
---|
418 | public LispObject SCHAR(int index) throws ConditionThrowable |
---|
419 | { |
---|
420 | return type_error(this, Symbol.SIMPLE_STRING); |
---|
421 | } |
---|
422 | |
---|
423 | public LispObject NTH(int index) throws ConditionThrowable |
---|
424 | { |
---|
425 | return type_error(this, Symbol.LIST); |
---|
426 | } |
---|
427 | |
---|
428 | public LispObject NTH(LispObject arg) throws ConditionThrowable |
---|
429 | { |
---|
430 | return type_error(this, Symbol.LIST); |
---|
431 | } |
---|
432 | |
---|
433 | public LispObject elt(int index) throws ConditionThrowable |
---|
434 | { |
---|
435 | return type_error(this, Symbol.SEQUENCE); |
---|
436 | } |
---|
437 | |
---|
438 | public LispObject reverse() throws ConditionThrowable |
---|
439 | { |
---|
440 | return type_error(this, Symbol.SEQUENCE); |
---|
441 | } |
---|
442 | |
---|
443 | public LispObject nreverse() throws ConditionThrowable |
---|
444 | { |
---|
445 | return type_error(this, Symbol.SEQUENCE); |
---|
446 | } |
---|
447 | |
---|
448 | public long aref_long(int index) throws ConditionThrowable |
---|
449 | { |
---|
450 | return AREF(index).longValue(); |
---|
451 | } |
---|
452 | |
---|
453 | public int aref(int index) throws ConditionThrowable |
---|
454 | { |
---|
455 | return AREF(index).intValue(); |
---|
456 | } |
---|
457 | |
---|
458 | public LispObject AREF(int index) throws ConditionThrowable |
---|
459 | { |
---|
460 | return type_error(this, Symbol.ARRAY); |
---|
461 | } |
---|
462 | |
---|
463 | public LispObject AREF(LispObject index) throws ConditionThrowable |
---|
464 | { |
---|
465 | return AREF(Fixnum.getValue(index)); |
---|
466 | } |
---|
467 | |
---|
468 | public void aset(int index, int n) |
---|
469 | throws ConditionThrowable |
---|
470 | { |
---|
471 | aset(index, Fixnum.getInstance(n)); |
---|
472 | } |
---|
473 | |
---|
474 | public void aset(int index, LispObject newValue) |
---|
475 | throws ConditionThrowable |
---|
476 | { |
---|
477 | type_error(this, Symbol.ARRAY); |
---|
478 | } |
---|
479 | |
---|
480 | public void aset(LispObject index, LispObject newValue) |
---|
481 | throws ConditionThrowable |
---|
482 | { |
---|
483 | aset(Fixnum.getValue(index), newValue); |
---|
484 | } |
---|
485 | |
---|
486 | public LispObject SVREF(int index) throws ConditionThrowable |
---|
487 | { |
---|
488 | return type_error(this, Symbol.SIMPLE_VECTOR); |
---|
489 | } |
---|
490 | |
---|
491 | public void svset(int index, LispObject newValue) throws ConditionThrowable |
---|
492 | { |
---|
493 | type_error(this, Symbol.SIMPLE_VECTOR); |
---|
494 | } |
---|
495 | |
---|
496 | public void vectorPushExtend(LispObject element) |
---|
497 | throws ConditionThrowable |
---|
498 | { |
---|
499 | noFillPointer(); |
---|
500 | } |
---|
501 | |
---|
502 | public LispObject VECTOR_PUSH_EXTEND(LispObject element) |
---|
503 | throws ConditionThrowable |
---|
504 | { |
---|
505 | return noFillPointer(); |
---|
506 | } |
---|
507 | |
---|
508 | public LispObject VECTOR_PUSH_EXTEND(LispObject element, LispObject extension) |
---|
509 | throws ConditionThrowable |
---|
510 | { |
---|
511 | return noFillPointer(); |
---|
512 | } |
---|
513 | |
---|
514 | public final LispObject noFillPointer() throws ConditionThrowable |
---|
515 | { |
---|
516 | return type_error(this, list(Symbol.AND, Symbol.VECTOR, |
---|
517 | list(Symbol.SATISFIES, |
---|
518 | Symbol.ARRAY_HAS_FILL_POINTER_P))); |
---|
519 | } |
---|
520 | |
---|
521 | public LispObject[] copyToArray() throws ConditionThrowable |
---|
522 | { |
---|
523 | type_error(this, Symbol.LIST); |
---|
524 | // Not reached. |
---|
525 | return null; |
---|
526 | } |
---|
527 | |
---|
528 | public LispObject SYMBOLP() |
---|
529 | { |
---|
530 | return NIL; |
---|
531 | } |
---|
532 | |
---|
533 | public boolean listp() |
---|
534 | { |
---|
535 | return false; |
---|
536 | } |
---|
537 | |
---|
538 | public LispObject LISTP() |
---|
539 | { |
---|
540 | return NIL; |
---|
541 | } |
---|
542 | |
---|
543 | public boolean endp() throws ConditionThrowable |
---|
544 | { |
---|
545 | type_error(this, Symbol.LIST); |
---|
546 | // Not reached. |
---|
547 | return false; |
---|
548 | } |
---|
549 | |
---|
550 | public LispObject ENDP() throws ConditionThrowable |
---|
551 | { |
---|
552 | return type_error(this, Symbol.LIST); |
---|
553 | } |
---|
554 | |
---|
555 | public LispObject NOT() |
---|
556 | { |
---|
557 | return NIL; |
---|
558 | } |
---|
559 | |
---|
560 | public boolean isSpecialOperator() throws ConditionThrowable |
---|
561 | { |
---|
562 | type_error(this, Symbol.SYMBOL); |
---|
563 | // Not reached. |
---|
564 | return false; |
---|
565 | } |
---|
566 | |
---|
567 | public boolean isSpecialVariable() |
---|
568 | { |
---|
569 | return false; |
---|
570 | } |
---|
571 | |
---|
572 | private static final EqHashTable documentationHashTable = |
---|
573 | new EqHashTable(11, NIL, NIL); |
---|
574 | |
---|
575 | public LispObject getDocumentation(LispObject docType) |
---|
576 | throws ConditionThrowable |
---|
577 | { |
---|
578 | LispObject alist = documentationHashTable.get(this); |
---|
579 | if (alist != null) |
---|
580 | { |
---|
581 | LispObject entry = assq(docType, alist); |
---|
582 | if (entry instanceof Cons) |
---|
583 | return ((Cons)entry).cdr; |
---|
584 | } |
---|
585 | return NIL; |
---|
586 | } |
---|
587 | |
---|
588 | public void setDocumentation(LispObject docType, LispObject documentation) |
---|
589 | throws ConditionThrowable |
---|
590 | { |
---|
591 | LispObject alist = documentationHashTable.get(this); |
---|
592 | if (alist == null) |
---|
593 | alist = NIL; |
---|
594 | LispObject entry = assq(docType, alist); |
---|
595 | if (entry instanceof Cons) |
---|
596 | { |
---|
597 | ((Cons)entry).cdr = documentation; |
---|
598 | } |
---|
599 | else |
---|
600 | { |
---|
601 | alist = alist.push(new Cons(docType, documentation)); |
---|
602 | documentationHashTable.put(this, alist); |
---|
603 | } |
---|
604 | } |
---|
605 | |
---|
606 | public LispObject getPropertyList() |
---|
607 | { |
---|
608 | return null; |
---|
609 | } |
---|
610 | |
---|
611 | public void setPropertyList(LispObject obj) |
---|
612 | { |
---|
613 | } |
---|
614 | |
---|
615 | public LispObject getSymbolValue() throws ConditionThrowable |
---|
616 | { |
---|
617 | return type_error(this, Symbol.SYMBOL); |
---|
618 | } |
---|
619 | |
---|
620 | public LispObject getSymbolFunction() throws ConditionThrowable |
---|
621 | { |
---|
622 | return type_error(this, Symbol.SYMBOL); |
---|
623 | } |
---|
624 | |
---|
625 | public LispObject getSymbolFunctionOrDie() throws ConditionThrowable |
---|
626 | { |
---|
627 | return type_error(this, Symbol.SYMBOL); |
---|
628 | } |
---|
629 | |
---|
630 | public String writeToString() throws ConditionThrowable |
---|
631 | { |
---|
632 | return toString(); |
---|
633 | } |
---|
634 | |
---|
635 | public String unreadableString(String s) { |
---|
636 | return unreadableString(s, true); |
---|
637 | } |
---|
638 | public String unreadableString(Symbol sym) throws ConditionThrowable { |
---|
639 | return unreadableString(sym, true); |
---|
640 | } |
---|
641 | |
---|
642 | public String unreadableString(String s, boolean identity) |
---|
643 | { |
---|
644 | FastStringBuffer sb = new FastStringBuffer("#<"); |
---|
645 | sb.append(s); |
---|
646 | if (identity) { |
---|
647 | sb.append(" {"); |
---|
648 | sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase()); |
---|
649 | sb.append("}"); |
---|
650 | } |
---|
651 | sb.append(">"); |
---|
652 | return sb.toString(); |
---|
653 | } |
---|
654 | |
---|
655 | public String unreadableString(Symbol symbol, boolean identity) |
---|
656 | throws ConditionThrowable |
---|
657 | { |
---|
658 | return unreadableString(symbol.writeToString(), identity); |
---|
659 | } |
---|
660 | |
---|
661 | // Special operator |
---|
662 | public LispObject execute(LispObject args, Environment env) |
---|
663 | throws ConditionThrowable |
---|
664 | { |
---|
665 | return error(new LispError()); |
---|
666 | } |
---|
667 | |
---|
668 | public LispObject execute() throws ConditionThrowable |
---|
669 | { |
---|
670 | return type_error(this, Symbol.FUNCTION); |
---|
671 | } |
---|
672 | |
---|
673 | public LispObject execute(LispObject arg) throws ConditionThrowable |
---|
674 | { |
---|
675 | return type_error(this, Symbol.FUNCTION); |
---|
676 | } |
---|
677 | |
---|
678 | public LispObject execute(LispObject first, LispObject second) |
---|
679 | throws ConditionThrowable |
---|
680 | { |
---|
681 | return type_error(this, Symbol.FUNCTION); |
---|
682 | } |
---|
683 | |
---|
684 | public LispObject execute(LispObject first, LispObject second, |
---|
685 | LispObject third) |
---|
686 | throws ConditionThrowable |
---|
687 | { |
---|
688 | return type_error(this, Symbol.FUNCTION); |
---|
689 | } |
---|
690 | |
---|
691 | public LispObject execute(LispObject first, LispObject second, |
---|
692 | LispObject third, LispObject fourth) |
---|
693 | throws ConditionThrowable |
---|
694 | { |
---|
695 | return type_error(this, Symbol.FUNCTION); |
---|
696 | } |
---|
697 | |
---|
698 | public LispObject execute(LispObject first, LispObject second, |
---|
699 | LispObject third, LispObject fourth, |
---|
700 | LispObject fifth) |
---|
701 | throws ConditionThrowable |
---|
702 | { |
---|
703 | return type_error(this, Symbol.FUNCTION); |
---|
704 | } |
---|
705 | |
---|
706 | public LispObject execute(LispObject first, LispObject second, |
---|
707 | LispObject third, LispObject fourth, |
---|
708 | LispObject fifth, LispObject sixth) |
---|
709 | throws ConditionThrowable |
---|
710 | { |
---|
711 | return type_error(this, Symbol.FUNCTION); |
---|
712 | } |
---|
713 | |
---|
714 | public LispObject execute(LispObject first, LispObject second, |
---|
715 | LispObject third, LispObject fourth, |
---|
716 | LispObject fifth, LispObject sixth, |
---|
717 | LispObject seventh) |
---|
718 | throws ConditionThrowable |
---|
719 | { |
---|
720 | return type_error(this, Symbol.FUNCTION); |
---|
721 | } |
---|
722 | |
---|
723 | public LispObject execute(LispObject first, LispObject second, |
---|
724 | LispObject third, LispObject fourth, |
---|
725 | LispObject fifth, LispObject sixth, |
---|
726 | LispObject seventh, LispObject eighth) |
---|
727 | throws ConditionThrowable |
---|
728 | { |
---|
729 | return type_error(this, Symbol.FUNCTION); |
---|
730 | } |
---|
731 | |
---|
732 | public LispObject execute(LispObject[] args) throws ConditionThrowable |
---|
733 | { |
---|
734 | return type_error(this, Symbol.FUNCTION); |
---|
735 | } |
---|
736 | |
---|
737 | // Used by COMPILE-MULTIPLE-VALUE-CALL. |
---|
738 | public LispObject dispatch(LispObject[] args) throws ConditionThrowable |
---|
739 | { |
---|
740 | switch (args.length) |
---|
741 | { |
---|
742 | case 0: |
---|
743 | return execute(); |
---|
744 | case 1: |
---|
745 | return execute(args[0]); |
---|
746 | case 2: |
---|
747 | return execute(args[0], args[1]); |
---|
748 | case 3: |
---|
749 | return execute(args[0], args[1], args[2]); |
---|
750 | case 4: |
---|
751 | return execute(args[0], args[1], args[2], args[3]); |
---|
752 | case 5: |
---|
753 | return execute(args[0], args[1], args[2], args[3], args[4]); |
---|
754 | case 6: |
---|
755 | return execute(args[0], args[1], args[2], args[3], args[4], |
---|
756 | args[5]); |
---|
757 | case 7: |
---|
758 | return execute(args[0], args[1], args[2], args[3], args[4], |
---|
759 | args[5], args[6]); |
---|
760 | case 8: |
---|
761 | return execute(args[0], args[1], args[2], args[3], args[4], |
---|
762 | args[5], args[6], args[7]); |
---|
763 | default: |
---|
764 | return type_error(this, Symbol.FUNCTION); |
---|
765 | } |
---|
766 | } |
---|
767 | |
---|
768 | public int intValue() throws ConditionThrowable |
---|
769 | { |
---|
770 | type_error(this, Symbol.INTEGER); |
---|
771 | // Not reached. |
---|
772 | return 0; |
---|
773 | } |
---|
774 | |
---|
775 | public long longValue() throws ConditionThrowable |
---|
776 | { |
---|
777 | type_error(this, Symbol.INTEGER); |
---|
778 | // Not reached. |
---|
779 | return 0; |
---|
780 | } |
---|
781 | |
---|
782 | public float floatValue() throws ConditionThrowable |
---|
783 | { |
---|
784 | type_error(this, Symbol.SINGLE_FLOAT); |
---|
785 | // Not reached |
---|
786 | return 0; |
---|
787 | } |
---|
788 | |
---|
789 | public double doubleValue() throws ConditionThrowable |
---|
790 | { |
---|
791 | type_error(this, Symbol.DOUBLE_FLOAT); |
---|
792 | // Not reached |
---|
793 | return 0; |
---|
794 | } |
---|
795 | |
---|
796 | public LispObject incr() throws ConditionThrowable |
---|
797 | { |
---|
798 | return type_error(this, Symbol.NUMBER); |
---|
799 | } |
---|
800 | |
---|
801 | public LispObject decr() throws ConditionThrowable |
---|
802 | { |
---|
803 | return type_error(this, Symbol.NUMBER); |
---|
804 | } |
---|
805 | |
---|
806 | public LispObject negate() throws ConditionThrowable |
---|
807 | { |
---|
808 | return Fixnum.ZERO.subtract(this); |
---|
809 | } |
---|
810 | |
---|
811 | public LispObject add(int n) throws ConditionThrowable |
---|
812 | { |
---|
813 | return add(Fixnum.getInstance(n)); |
---|
814 | } |
---|
815 | |
---|
816 | public LispObject add(LispObject obj) throws ConditionThrowable |
---|
817 | { |
---|
818 | return type_error(this, Symbol.NUMBER); |
---|
819 | } |
---|
820 | |
---|
821 | public LispObject subtract(int n) throws ConditionThrowable |
---|
822 | { |
---|
823 | return subtract(Fixnum.getInstance(n)); |
---|
824 | } |
---|
825 | |
---|
826 | public LispObject subtract(LispObject obj) throws ConditionThrowable |
---|
827 | { |
---|
828 | return type_error(this, Symbol.NUMBER); |
---|
829 | } |
---|
830 | |
---|
831 | public LispObject multiplyBy(int n) throws ConditionThrowable |
---|
832 | { |
---|
833 | return multiplyBy(Fixnum.getInstance(n)); |
---|
834 | } |
---|
835 | |
---|
836 | public LispObject multiplyBy(LispObject obj) throws ConditionThrowable |
---|
837 | { |
---|
838 | return type_error(this, Symbol.NUMBER); |
---|
839 | } |
---|
840 | |
---|
841 | public LispObject divideBy(LispObject obj) throws ConditionThrowable |
---|
842 | { |
---|
843 | return type_error(this, Symbol.NUMBER); |
---|
844 | } |
---|
845 | |
---|
846 | public boolean isEqualTo(int n) throws ConditionThrowable |
---|
847 | { |
---|
848 | return isEqualTo(Fixnum.getInstance(n)); |
---|
849 | } |
---|
850 | |
---|
851 | public boolean isEqualTo(LispObject obj) throws ConditionThrowable |
---|
852 | { |
---|
853 | type_error(this, Symbol.NUMBER); |
---|
854 | // Not reached. |
---|
855 | return false; |
---|
856 | } |
---|
857 | |
---|
858 | public LispObject IS_E(LispObject obj) throws ConditionThrowable |
---|
859 | { |
---|
860 | return isEqualTo(obj) ? T : NIL; |
---|
861 | } |
---|
862 | |
---|
863 | public boolean isNotEqualTo(int n) throws ConditionThrowable |
---|
864 | { |
---|
865 | return isNotEqualTo(Fixnum.getInstance(n)); |
---|
866 | } |
---|
867 | |
---|
868 | public boolean isNotEqualTo(LispObject obj) throws ConditionThrowable |
---|
869 | { |
---|
870 | type_error(this, Symbol.NUMBER); |
---|
871 | // Not reached. |
---|
872 | return false; |
---|
873 | } |
---|
874 | |
---|
875 | public LispObject IS_NE(LispObject obj) throws ConditionThrowable |
---|
876 | { |
---|
877 | return isNotEqualTo(obj) ? T : NIL; |
---|
878 | } |
---|
879 | |
---|
880 | public boolean isLessThan(int n) throws ConditionThrowable |
---|
881 | { |
---|
882 | return isLessThan(Fixnum.getInstance(n)); |
---|
883 | } |
---|
884 | |
---|
885 | public boolean isLessThan(LispObject obj) throws ConditionThrowable |
---|
886 | { |
---|
887 | type_error(this, Symbol.REAL); |
---|
888 | // Not reached. |
---|
889 | return false; |
---|
890 | } |
---|
891 | |
---|
892 | public LispObject IS_LT(LispObject obj) throws ConditionThrowable |
---|
893 | { |
---|
894 | return isLessThan(obj) ? T : NIL; |
---|
895 | } |
---|
896 | |
---|
897 | public boolean isGreaterThan(int n) throws ConditionThrowable |
---|
898 | { |
---|
899 | return isGreaterThan(Fixnum.getInstance(n)); |
---|
900 | } |
---|
901 | |
---|
902 | public boolean isGreaterThan(LispObject obj) throws ConditionThrowable |
---|
903 | { |
---|
904 | type_error(this, Symbol.REAL); |
---|
905 | // Not reached. |
---|
906 | return false; |
---|
907 | } |
---|
908 | |
---|
909 | public LispObject IS_GT(LispObject obj) throws ConditionThrowable |
---|
910 | { |
---|
911 | return isGreaterThan(obj) ? T : NIL; |
---|
912 | } |
---|
913 | |
---|
914 | public boolean isLessThanOrEqualTo(int n) throws ConditionThrowable |
---|
915 | { |
---|
916 | return isLessThanOrEqualTo(Fixnum.getInstance(n)); |
---|
917 | } |
---|
918 | |
---|
919 | public boolean isLessThanOrEqualTo(LispObject obj) throws ConditionThrowable |
---|
920 | { |
---|
921 | type_error(this, Symbol.REAL); |
---|
922 | // Not reached. |
---|
923 | return false; |
---|
924 | } |
---|
925 | |
---|
926 | public LispObject IS_LE(LispObject obj) throws ConditionThrowable |
---|
927 | { |
---|
928 | return isLessThanOrEqualTo(obj) ? T : NIL; |
---|
929 | } |
---|
930 | |
---|
931 | public boolean isGreaterThanOrEqualTo(int n) throws ConditionThrowable |
---|
932 | { |
---|
933 | return isGreaterThanOrEqualTo(Fixnum.getInstance(n)); |
---|
934 | } |
---|
935 | |
---|
936 | public boolean isGreaterThanOrEqualTo(LispObject obj) throws ConditionThrowable |
---|
937 | { |
---|
938 | type_error(this, Symbol.REAL); |
---|
939 | // Not reached. |
---|
940 | return false; |
---|
941 | } |
---|
942 | |
---|
943 | public LispObject IS_GE(LispObject obj) throws ConditionThrowable |
---|
944 | { |
---|
945 | return isGreaterThanOrEqualTo(obj) ? T : NIL; |
---|
946 | } |
---|
947 | |
---|
948 | public LispObject truncate(LispObject obj) throws ConditionThrowable |
---|
949 | { |
---|
950 | return type_error(this, Symbol.REAL); |
---|
951 | } |
---|
952 | |
---|
953 | public LispObject MOD(LispObject divisor) throws ConditionThrowable |
---|
954 | { |
---|
955 | truncate(divisor); |
---|
956 | final LispThread thread = LispThread.currentThread(); |
---|
957 | LispObject remainder = thread._values[1]; |
---|
958 | thread.clearValues(); |
---|
959 | if (!remainder.zerop()) |
---|
960 | { |
---|
961 | if (divisor.minusp()) |
---|
962 | { |
---|
963 | if (plusp()) |
---|
964 | return remainder.add(divisor); |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | if (minusp()) |
---|
969 | return remainder.add(divisor); |
---|
970 | } |
---|
971 | } |
---|
972 | return remainder; |
---|
973 | } |
---|
974 | |
---|
975 | public LispObject MOD(int divisor) throws ConditionThrowable |
---|
976 | { |
---|
977 | return MOD(Fixnum.getInstance(divisor)); |
---|
978 | } |
---|
979 | |
---|
980 | public LispObject ash(int shift) throws ConditionThrowable |
---|
981 | { |
---|
982 | return ash(Fixnum.getInstance(shift)); |
---|
983 | } |
---|
984 | |
---|
985 | public LispObject ash(LispObject obj) throws ConditionThrowable |
---|
986 | { |
---|
987 | return type_error(this, Symbol.INTEGER); |
---|
988 | } |
---|
989 | |
---|
990 | public LispObject LOGNOT() throws ConditionThrowable |
---|
991 | { |
---|
992 | return type_error(this, Symbol.INTEGER); |
---|
993 | } |
---|
994 | |
---|
995 | public LispObject LOGAND(int n) throws ConditionThrowable |
---|
996 | { |
---|
997 | return LOGAND(Fixnum.getInstance(n)); |
---|
998 | } |
---|
999 | |
---|
1000 | public LispObject LOGAND(LispObject obj) throws ConditionThrowable |
---|
1001 | { |
---|
1002 | return type_error(this, Symbol.INTEGER); |
---|
1003 | } |
---|
1004 | |
---|
1005 | public LispObject LOGIOR(int n) throws ConditionThrowable |
---|
1006 | { |
---|
1007 | return LOGIOR(Fixnum.getInstance(n)); |
---|
1008 | } |
---|
1009 | |
---|
1010 | public LispObject LOGIOR(LispObject obj) throws ConditionThrowable |
---|
1011 | { |
---|
1012 | return type_error(this, Symbol.INTEGER); |
---|
1013 | } |
---|
1014 | |
---|
1015 | public LispObject LOGXOR(int n) throws ConditionThrowable |
---|
1016 | { |
---|
1017 | return LOGXOR(Fixnum.getInstance(n)); |
---|
1018 | } |
---|
1019 | |
---|
1020 | public LispObject LOGXOR(LispObject obj) throws ConditionThrowable |
---|
1021 | { |
---|
1022 | return type_error(this, Symbol.INTEGER); |
---|
1023 | } |
---|
1024 | |
---|
1025 | public LispObject LDB(int size, int position) throws ConditionThrowable |
---|
1026 | { |
---|
1027 | return type_error(this, Symbol.INTEGER); |
---|
1028 | } |
---|
1029 | |
---|
1030 | public int sxhash() |
---|
1031 | { |
---|
1032 | return hashCode() & 0x7fffffff; |
---|
1033 | } |
---|
1034 | |
---|
1035 | // For EQUALP hash tables. |
---|
1036 | public int psxhash() |
---|
1037 | { |
---|
1038 | return sxhash(); |
---|
1039 | } |
---|
1040 | |
---|
1041 | public int psxhash(int depth) |
---|
1042 | { |
---|
1043 | return psxhash(); |
---|
1044 | } |
---|
1045 | |
---|
1046 | public LispObject STRING() throws ConditionThrowable |
---|
1047 | { |
---|
1048 | return error(new TypeError(writeToString() + " cannot be coerced to a string.")); |
---|
1049 | } |
---|
1050 | |
---|
1051 | public char[] chars() throws ConditionThrowable |
---|
1052 | { |
---|
1053 | type_error(this, Symbol.STRING); |
---|
1054 | // Not reached. |
---|
1055 | return null; |
---|
1056 | } |
---|
1057 | |
---|
1058 | public char[] getStringChars() throws ConditionThrowable |
---|
1059 | { |
---|
1060 | type_error(this, Symbol.STRING); |
---|
1061 | // Not reached. |
---|
1062 | return null; |
---|
1063 | } |
---|
1064 | |
---|
1065 | public String getStringValue() throws ConditionThrowable |
---|
1066 | { |
---|
1067 | type_error(this, Symbol.STRING); |
---|
1068 | // Not reached. |
---|
1069 | return null; |
---|
1070 | } |
---|
1071 | |
---|
1072 | public LispObject getSlotValue_0() throws ConditionThrowable |
---|
1073 | { |
---|
1074 | return type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1075 | } |
---|
1076 | |
---|
1077 | public LispObject getSlotValue_1() throws ConditionThrowable |
---|
1078 | { |
---|
1079 | return type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1080 | } |
---|
1081 | |
---|
1082 | public LispObject getSlotValue_2() throws ConditionThrowable |
---|
1083 | { |
---|
1084 | return type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1085 | } |
---|
1086 | |
---|
1087 | public LispObject getSlotValue_3() throws ConditionThrowable |
---|
1088 | { |
---|
1089 | return type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1090 | } |
---|
1091 | |
---|
1092 | public LispObject getSlotValue(int index) throws ConditionThrowable |
---|
1093 | { |
---|
1094 | return type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1095 | } |
---|
1096 | |
---|
1097 | public int getFixnumSlotValue(int index) throws ConditionThrowable |
---|
1098 | { |
---|
1099 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1100 | // Not reached. |
---|
1101 | return 0; |
---|
1102 | } |
---|
1103 | |
---|
1104 | public boolean getSlotValueAsBoolean(int index) throws ConditionThrowable |
---|
1105 | { |
---|
1106 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1107 | // Not reached. |
---|
1108 | return false; |
---|
1109 | } |
---|
1110 | |
---|
1111 | public void setSlotValue_0(LispObject value) |
---|
1112 | throws ConditionThrowable |
---|
1113 | { |
---|
1114 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1115 | } |
---|
1116 | |
---|
1117 | public void setSlotValue_1(LispObject value) |
---|
1118 | throws ConditionThrowable |
---|
1119 | { |
---|
1120 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1121 | } |
---|
1122 | |
---|
1123 | public void setSlotValue_2(LispObject value) |
---|
1124 | throws ConditionThrowable |
---|
1125 | { |
---|
1126 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1127 | } |
---|
1128 | |
---|
1129 | public void setSlotValue_3(LispObject value) |
---|
1130 | throws ConditionThrowable |
---|
1131 | { |
---|
1132 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1133 | } |
---|
1134 | |
---|
1135 | public void setSlotValue(int index, LispObject value) |
---|
1136 | throws ConditionThrowable |
---|
1137 | { |
---|
1138 | type_error(this, Symbol.STRUCTURE_OBJECT); |
---|
1139 | } |
---|
1140 | |
---|
1141 | public LispObject SLOT_VALUE(LispObject slotName) throws ConditionThrowable |
---|
1142 | { |
---|
1143 | return type_error(this, Symbol.STANDARD_OBJECT); |
---|
1144 | } |
---|
1145 | |
---|
1146 | public void setSlotValue(LispObject slotName, LispObject newValue) |
---|
1147 | throws ConditionThrowable |
---|
1148 | { |
---|
1149 | type_error(this, Symbol.STANDARD_OBJECT); |
---|
1150 | } |
---|
1151 | |
---|
1152 | // Profiling. |
---|
1153 | public int getCallCount() |
---|
1154 | { |
---|
1155 | return 0; |
---|
1156 | } |
---|
1157 | |
---|
1158 | public void setCallCount(int n) |
---|
1159 | { |
---|
1160 | } |
---|
1161 | |
---|
1162 | public void incrementCallCount() |
---|
1163 | { |
---|
1164 | } |
---|
1165 | |
---|
1166 | public int getHotCount() |
---|
1167 | { |
---|
1168 | return 0; |
---|
1169 | } |
---|
1170 | |
---|
1171 | public void setHotCount(int n) |
---|
1172 | { |
---|
1173 | } |
---|
1174 | |
---|
1175 | public void incrementHotCount() |
---|
1176 | { |
---|
1177 | } |
---|
1178 | } |
---|