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