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