source: branches/1.0.x/abcl/src/org/armedbear/lisp/LispObject.java

Last change on this file was 13521, checked in by ehuelsmann, 14 years ago

Revert r13509 because it breaks cl-ppcre compilation and the ANSI tests.

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