source: branches/1.1.x/src/org/armedbear/lisp/BuiltInClass.java

Last change on this file was 13769, checked in by rschlatte, 13 years ago

Remove spurious built-in class definition for method-combination

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.7 KB
Line 
1/*
2 * BuiltInClass.java
3 *
4 * Copyright (C) 2003-2007 Peter Graves
5 * $Id: BuiltInClass.java 13769 2012-01-12 19:22:42Z rschlatte $
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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.*;
37
38public class BuiltInClass extends LispClass
39{
40  private BuiltInClass(Symbol symbol)
41  {
42    super(symbol);
43  }
44
45  @Override
46  public LispObject typeOf()
47  {
48    return Symbol.BUILT_IN_CLASS;
49  }
50
51  @Override
52  public LispObject classOf()
53  {
54    return StandardClass.BUILT_IN_CLASS;
55  }
56
57  @Override
58  public boolean isFinalized()
59  {
60    return true;
61  }
62
63  @Override
64  public LispObject typep(LispObject type)
65  {
66    if (type == Symbol.BUILT_IN_CLASS)
67      return T;
68    if (type == StandardClass.BUILT_IN_CLASS)
69      return T;
70    return super.typep(type);
71  }
72
73  @Override
74  public LispObject getDescription()
75  {
76    return new SimpleString(princToString());
77  }
78
79  @Override
80  public String printObject()
81  {
82    return unreadableString(getName().princToString());
83  }
84
85  private static BuiltInClass addClass(Symbol symbol)
86  {
87    BuiltInClass c = new BuiltInClass(symbol);
88    addClass(symbol, c);
89    return c;
90  }
91
92  public static final BuiltInClass CLASS_T              = addClass(T);
93
94  public static final BuiltInClass ARRAY                = addClass(Symbol.ARRAY);
95  public static final BuiltInClass BIGNUM               = addClass(Symbol.BIGNUM);
96  public static final BuiltInClass BASE_STRING          = addClass(Symbol.BASE_STRING);
97  public static final BuiltInClass BIT_VECTOR           = addClass(Symbol.BIT_VECTOR);
98  public static final BuiltInClass CHARACTER            = addClass(Symbol.CHARACTER);
99  public static final BuiltInClass COMPLEX              = addClass(Symbol.COMPLEX);
100  public static final BuiltInClass CONS                 = addClass(Symbol.CONS);
101  public static final BuiltInClass DOUBLE_FLOAT         = addClass(Symbol.DOUBLE_FLOAT);
102  public static final BuiltInClass ENVIRONMENT          = addClass(Symbol.ENVIRONMENT);
103  public static final BuiltInClass FIXNUM               = addClass(Symbol.FIXNUM);
104  public static final BuiltInClass FLOAT                = addClass(Symbol.FLOAT);
105  public static final BuiltInClass FUNCTION             = addClass(Symbol.FUNCTION);
106  public static final BuiltInClass HASH_TABLE           = addClass(Symbol.HASH_TABLE);
107  public static final BuiltInClass INTEGER              = addClass(Symbol.INTEGER);
108  public static final BuiltInClass JAVA_OBJECT          = addClass(Symbol.JAVA_OBJECT);
109  public static final BuiltInClass LIST                 = addClass(Symbol.LIST);
110  public static final BuiltInClass LOGICAL_PATHNAME     = addClass(Symbol.LOGICAL_PATHNAME);
111  public static final BuiltInClass MAILBOX              = addClass(Symbol.MAILBOX);
112  public static final BuiltInClass MUTEX                = addClass(Symbol.MUTEX);
113  public static final BuiltInClass NIL_VECTOR           = addClass(Symbol.NIL_VECTOR);
114  public static final BuiltInClass NULL                 = addClass(Symbol.NULL);
115  public static final BuiltInClass NUMBER               = addClass(Symbol.NUMBER);
116  public static final BuiltInClass PACKAGE              = addClass(Symbol.PACKAGE);
117  public static final BuiltInClass PATHNAME             = addClass(Symbol.PATHNAME);
118  public static final BuiltInClass JAR_PATHNAME         = addClass(Symbol.JAR_PATHNAME);
119  public static final BuiltInClass URL_PATHNAME         = addClass(Symbol.URL_PATHNAME);
120  public static final BuiltInClass RANDOM_STATE         = addClass(Symbol.RANDOM_STATE);
121  public static final BuiltInClass RATIO                = addClass(Symbol.RATIO);
122  public static final BuiltInClass RATIONAL             = addClass(Symbol.RATIONAL);
123  public static final BuiltInClass READTABLE            = addClass(Symbol.READTABLE);
124  public static final BuiltInClass REAL                 = addClass(Symbol.REAL);
125  public static final BuiltInClass RESTART              = addClass(Symbol.RESTART);
126  public static final BuiltInClass SEQUENCE             = addClass(Symbol.SEQUENCE); 
127  public static final BuiltInClass SIMPLE_ARRAY         = addClass(Symbol.SIMPLE_ARRAY);
128  public static final BuiltInClass SIMPLE_BASE_STRING   = addClass(Symbol.SIMPLE_BASE_STRING);
129  public static final BuiltInClass SIMPLE_BIT_VECTOR    = addClass(Symbol.SIMPLE_BIT_VECTOR);
130  public static final BuiltInClass SIMPLE_STRING        = addClass(Symbol.SIMPLE_STRING);
131  public static final BuiltInClass SIMPLE_VECTOR        = addClass(Symbol.SIMPLE_VECTOR);
132  public static final BuiltInClass SINGLE_FLOAT         = addClass(Symbol.SINGLE_FLOAT);
133  public static final BuiltInClass STRING               = addClass(Symbol.STRING);
134  public static final BuiltInClass SYMBOL               = addClass(Symbol.SYMBOL);
135  public static final BuiltInClass THREAD               = addClass(Symbol.THREAD);
136  public static final BuiltInClass VECTOR               = addClass(Symbol.VECTOR);
137  public static final BuiltInClass STACK_FRAME          = addClass(Symbol.STACK_FRAME);
138  public static final BuiltInClass LISP_STACK_FRAME     = addClass(Symbol.LISP_STACK_FRAME);
139  public static final BuiltInClass JAVA_STACK_FRAME     = addClass(Symbol.JAVA_STACK_FRAME);
140  public static final BuiltInClass WEAK_REFERENCE      = addClass(Symbol.WEAK_REFERENCE);
141
142
143  public static final StructureClass STRUCTURE_OBJECT =
144    (StructureClass)addClass(Symbol.STRUCTURE_OBJECT,
145             new StructureClass(Symbol.STRUCTURE_OBJECT, list(CLASS_T)));
146
147    /* All the stream classes below are being defined as structure classes
148       but won't be available as such until further action is taken:
149       the 'defstruct' internal administration is missing.
150
151       For STREAM and SYSTEM-STREAM, that bit is added in boot.lisp */
152
153  public static final LispClass STREAM =
154    addClass(Symbol.STREAM,
155             new StructureClass(Symbol.STREAM, list(STRUCTURE_OBJECT)));
156  public static final LispClass SYSTEM_STREAM =
157    addClass(Symbol.SYSTEM_STREAM,
158             new StructureClass(Symbol.SYSTEM_STREAM, list(STREAM)));
159  public static final LispClass TWO_WAY_STREAM =
160    addClass(Symbol.TWO_WAY_STREAM,
161             new StructureClass(Symbol.TWO_WAY_STREAM, list(SYSTEM_STREAM)));
162  public static final LispClass BROADCAST_STREAM =
163    addClass(Symbol.BROADCAST_STREAM,
164             new StructureClass(Symbol.BROADCAST_STREAM, list(SYSTEM_STREAM)));
165  public static final LispClass ECHO_STREAM =
166    addClass(Symbol.ECHO_STREAM,
167             new StructureClass(Symbol.ECHO_STREAM, list(SYSTEM_STREAM)));
168  public static final LispClass CASE_FROB_STREAM =
169    addClass(Symbol.CASE_FROB_STREAM,
170             new StructureClass(Symbol.CASE_FROB_STREAM, list(SYSTEM_STREAM)));
171  public static final LispClass STRING_STREAM =
172    addClass(Symbol.STRING_STREAM,
173             new StructureClass(Symbol.STRING_STREAM, list(SYSTEM_STREAM)));
174  public static final LispClass STRING_INPUT_STREAM =
175    addClass(Symbol.STRING_INPUT_STREAM,
176             new StructureClass(Symbol.STRING_INPUT_STREAM, list(STRING_STREAM)));
177  public static final LispClass STRING_OUTPUT_STREAM =
178    addClass(Symbol.STRING_OUTPUT_STREAM,
179             new StructureClass(Symbol.STRING_OUTPUT_STREAM, list(STRING_STREAM)));
180  public static final LispClass SYNONYM_STREAM =
181    addClass(Symbol.SYNONYM_STREAM,
182             new StructureClass(Symbol.SYNONYM_STREAM, list(SYSTEM_STREAM)));
183  public static final LispClass FILE_STREAM =
184    addClass(Symbol.FILE_STREAM,
185             new StructureClass(Symbol.FILE_STREAM, list(SYSTEM_STREAM)));
186  public static final LispClass JAR_STREAM =
187    addClass(Symbol.JAR_STREAM,
188             new StructureClass(Symbol.JAR_STREAM, list(SYSTEM_STREAM)));
189  public static final LispClass URL_STREAM =
190    addClass(Symbol.URL_STREAM,
191             new StructureClass(Symbol.URL_STREAM, list(SYSTEM_STREAM)));
192  public static final LispClass CONCATENATED_STREAM =
193    addClass(Symbol.CONCATENATED_STREAM,
194             new StructureClass(Symbol.CONCATENATED_STREAM, list(SYSTEM_STREAM)));
195
196
197
198    // Implementation defined streams
199  public static final LispClass SOCKET_STREAM =
200    addClass(Symbol.SOCKET_STREAM,
201             new StructureClass(Symbol.SOCKET_STREAM, list(TWO_WAY_STREAM)));
202  public static final LispClass SLIME_INPUT_STREAM =
203    addClass(Symbol.SLIME_INPUT_STREAM,
204             new StructureClass(Symbol.SLIME_INPUT_STREAM, list(STRING_STREAM)));
205  public static final LispClass SLIME_OUTPUT_STREAM =
206    addClass(Symbol.SLIME_OUTPUT_STREAM,
207             new StructureClass(Symbol.SLIME_OUTPUT_STREAM, list(STRING_STREAM)));
208
209
210
211  static
212  {
213    ARRAY.setDirectSuperclass(CLASS_T);
214    ARRAY.setCPL(ARRAY, CLASS_T);
215    BASE_STRING.setDirectSuperclass(STRING);
216    BASE_STRING.setCPL(BASE_STRING, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
217    BIGNUM.setDirectSuperclass(INTEGER);
218    BIGNUM.setCPL(BIGNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
219    BIT_VECTOR.setDirectSuperclass(VECTOR);
220    BIT_VECTOR.setCPL(BIT_VECTOR, VECTOR, ARRAY, SEQUENCE, CLASS_T);
221    BROADCAST_STREAM.setCPL(BROADCAST_STREAM, SYSTEM_STREAM, STREAM,
222                            STRUCTURE_OBJECT, CLASS_T);
223    CASE_FROB_STREAM.setCPL(CASE_FROB_STREAM, SYSTEM_STREAM, STREAM,
224                            STRUCTURE_OBJECT, CLASS_T);
225    CHARACTER.setDirectSuperclass(CLASS_T);
226    CHARACTER.setCPL(CHARACTER, CLASS_T);
227    CLASS_T.setCPL(CLASS_T);
228    COMPLEX.setDirectSuperclass(NUMBER);
229    COMPLEX.setCPL(COMPLEX, NUMBER, CLASS_T);
230    CONCATENATED_STREAM.setCPL(CONCATENATED_STREAM, SYSTEM_STREAM, STREAM,
231                               STRUCTURE_OBJECT, CLASS_T);
232    CONS.setDirectSuperclass(LIST);
233    CONS.setCPL(CONS, LIST, SEQUENCE, CLASS_T);
234    DOUBLE_FLOAT.setDirectSuperclass(FLOAT);
235    DOUBLE_FLOAT.setCPL(DOUBLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
236    ECHO_STREAM.setCPL(ECHO_STREAM, SYSTEM_STREAM, STREAM,
237                       STRUCTURE_OBJECT, CLASS_T);
238    ENVIRONMENT.setDirectSuperclass(CLASS_T);
239    ENVIRONMENT.setCPL(ENVIRONMENT, CLASS_T);
240    FIXNUM.setDirectSuperclass(INTEGER);
241    FIXNUM.setCPL(FIXNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
242    FILE_STREAM.setCPL(FILE_STREAM, SYSTEM_STREAM, STREAM,
243                       STRUCTURE_OBJECT, CLASS_T);
244    JAR_STREAM.setCPL(JAR_STREAM, SYSTEM_STREAM, STREAM,
245                      STRUCTURE_OBJECT, CLASS_T);
246    URL_STREAM.setCPL(URL_STREAM, SYSTEM_STREAM, STREAM,
247                      STRUCTURE_OBJECT, CLASS_T);
248    FLOAT.setDirectSuperclass(REAL);
249    FLOAT.setCPL(FLOAT, REAL, NUMBER, CLASS_T);
250    FUNCTION.setDirectSuperclass(CLASS_T);
251    FUNCTION.setCPL(FUNCTION, CLASS_T);
252    HASH_TABLE.setDirectSuperclass(CLASS_T);
253    HASH_TABLE.setCPL(HASH_TABLE, CLASS_T);
254    INTEGER.setDirectSuperclass(RATIONAL);
255    INTEGER.setCPL(INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
256    JAVA_OBJECT.setDirectSuperclass(CLASS_T);
257    JAVA_OBJECT.setCPL(JAVA_OBJECT, CLASS_T);
258    LIST.setDirectSuperclass(SEQUENCE);
259    LIST.setCPL(LIST, SEQUENCE, CLASS_T);
260    LOGICAL_PATHNAME.setDirectSuperclass(PATHNAME);
261    LOGICAL_PATHNAME.setCPL(LOGICAL_PATHNAME, PATHNAME, CLASS_T);
262    MAILBOX.setDirectSuperclass(CLASS_T);
263    MAILBOX.setCPL(MAILBOX, CLASS_T);
264    MUTEX.setDirectSuperclass(CLASS_T);
265    MUTEX.setCPL(MUTEX, CLASS_T);
266    NIL_VECTOR.setDirectSuperclass(STRING);
267    NIL_VECTOR.setCPL(NIL_VECTOR, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
268    NULL.setDirectSuperclass(LIST);
269    NULL.setCPL(NULL, SYMBOL, LIST, SEQUENCE, CLASS_T);
270    NUMBER.setDirectSuperclass(CLASS_T);
271    NUMBER.setCPL(NUMBER, CLASS_T);
272    PACKAGE.setDirectSuperclass(CLASS_T);
273    PACKAGE.setCPL(PACKAGE, CLASS_T);
274    PATHNAME.setDirectSuperclass(CLASS_T);
275    PATHNAME.setCPL(PATHNAME, CLASS_T);
276    JAR_PATHNAME.setDirectSuperclass(PATHNAME);
277    JAR_PATHNAME.setCPL(JAR_PATHNAME, PATHNAME, CLASS_T);
278    URL_PATHNAME.setDirectSuperclass(PATHNAME);
279    URL_PATHNAME.setCPL(URL_PATHNAME, PATHNAME, CLASS_T);
280    RANDOM_STATE.setDirectSuperclass(CLASS_T);
281    RANDOM_STATE.setCPL(RANDOM_STATE, CLASS_T);
282    RATIO.setDirectSuperclass(RATIONAL);
283    RATIO.setCPL(RATIO, RATIONAL, REAL, NUMBER, CLASS_T);
284    RATIONAL.setDirectSuperclass(REAL);
285    RATIONAL.setCPL(RATIONAL, REAL, NUMBER, CLASS_T);
286    READTABLE.setDirectSuperclass(CLASS_T);
287    READTABLE.setCPL(READTABLE, CLASS_T);
288    REAL.setDirectSuperclass(NUMBER);
289    REAL.setCPL(REAL, NUMBER, CLASS_T);
290    RESTART.setDirectSuperclass(CLASS_T);
291    RESTART.setCPL(RESTART, CLASS_T);
292    SEQUENCE.setDirectSuperclass(CLASS_T);
293    SEQUENCE.setCPL(SEQUENCE, CLASS_T);
294    SIMPLE_ARRAY.setDirectSuperclass(ARRAY);
295    SIMPLE_ARRAY.setCPL(SIMPLE_ARRAY, ARRAY, CLASS_T);
296    SIMPLE_BASE_STRING.setDirectSuperclasses(list(BASE_STRING, SIMPLE_STRING));
297    SIMPLE_BASE_STRING.setCPL(SIMPLE_BASE_STRING, BASE_STRING, SIMPLE_STRING,
298                              STRING, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
299                              CLASS_T);
300    SIMPLE_BIT_VECTOR.setDirectSuperclasses(list(BIT_VECTOR, SIMPLE_ARRAY));
301    SIMPLE_BIT_VECTOR.setCPL(SIMPLE_BIT_VECTOR, BIT_VECTOR, VECTOR,
302                             SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
303    SIMPLE_STRING.setDirectSuperclasses(list(BASE_STRING, STRING, SIMPLE_ARRAY));
304    SIMPLE_STRING.setCPL(SIMPLE_STRING, BASE_STRING, STRING, VECTOR,
305                         SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
306    SIMPLE_VECTOR.setDirectSuperclasses(list(VECTOR, SIMPLE_ARRAY));
307    SIMPLE_VECTOR.setCPL(SIMPLE_VECTOR, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
308                         CLASS_T);
309    SINGLE_FLOAT.setDirectSuperclass(FLOAT);
310    SINGLE_FLOAT.setCPL(SINGLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
311    SLIME_INPUT_STREAM.setCPL(SLIME_INPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
312                              STREAM, STRUCTURE_OBJECT, CLASS_T);
313    SLIME_OUTPUT_STREAM.setCPL(SLIME_OUTPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
314                               STREAM, STRUCTURE_OBJECT, CLASS_T);
315    SOCKET_STREAM.setCPL(SOCKET_STREAM, TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
316                         STRUCTURE_OBJECT, CLASS_T);
317    STREAM.setCPL(STREAM, STRUCTURE_OBJECT, CLASS_T);
318    STRING.setDirectSuperclass(VECTOR);
319    STRING.setCPL(STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
320    STRING_INPUT_STREAM.setCPL(STRING_INPUT_STREAM, STRING_STREAM,
321                               SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
322    STRING_OUTPUT_STREAM.setCPL(STRING_OUTPUT_STREAM, STRING_STREAM,
323                                SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
324    STRING_STREAM.setCPL(STRING_STREAM, SYSTEM_STREAM, STREAM,
325                         STRUCTURE_OBJECT, CLASS_T);
326    STRUCTURE_OBJECT.setCPL(STRUCTURE_OBJECT, CLASS_T);
327    SYMBOL.setDirectSuperclass(CLASS_T);
328    SYMBOL.setCPL(SYMBOL, CLASS_T);
329    SYNONYM_STREAM.setCPL(SYNONYM_STREAM, SYSTEM_STREAM,
330                          STREAM, STRUCTURE_OBJECT, CLASS_T);
331    SYSTEM_STREAM.setCPL(SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
332    THREAD.setDirectSuperclass(CLASS_T);
333    THREAD.setCPL(THREAD, CLASS_T);
334    TWO_WAY_STREAM.setCPL(TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
335                          STRUCTURE_OBJECT, CLASS_T);
336    VECTOR.setDirectSuperclasses(list(ARRAY, SEQUENCE));
337    VECTOR.setCPL(VECTOR, ARRAY, SEQUENCE, CLASS_T);
338    STACK_FRAME.setDirectSuperclasses(CLASS_T);
339    STACK_FRAME.setCPL(STACK_FRAME, CLASS_T);
340    LISP_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
341    LISP_STACK_FRAME.setCPL(LISP_STACK_FRAME, STACK_FRAME, CLASS_T);
342    JAVA_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
343    JAVA_STACK_FRAME.setCPL(JAVA_STACK_FRAME, STACK_FRAME, CLASS_T);
344  }
345
346  static
347  {
348    StandardClass.initializeStandardClasses();
349  }
350}
Note: See TracBrowser for help on using the repository browser.