source: branches/streams/abcl/src/org/armedbear/lisp/BuiltInClass.java

Last change on this file was 14796, checked in by ehuelsmann, 9 years ago

Streams no longer are structure objects.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.4 KB
Line 
1/*
2 * BuiltInClass.java
3 *
4 * Copyright (C) 2003-2007 Peter Graves
5 * $Id: BuiltInClass.java 14796 2015-09-07 12:24:42Z 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., 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 BuiltInClass STREAM = addClass(Symbol.STREAM);
154  public static final BuiltInClass SYSTEM_STREAM =
155    addClass(Symbol.SYSTEM_STREAM); 
156  public static final BuiltInClass TWO_WAY_STREAM =
157    addClass(Symbol.TWO_WAY_STREAM); 
158  public static final BuiltInClass BROADCAST_STREAM =
159    addClass(Symbol.BROADCAST_STREAM); 
160  public static final BuiltInClass ECHO_STREAM =
161    addClass(Symbol.ECHO_STREAM);
162  public static final BuiltInClass CASE_FROB_STREAM =
163    addClass(Symbol.CASE_FROB_STREAM); 
164  public static final BuiltInClass STRING_STREAM =
165    addClass(Symbol.STRING_STREAM); 
166  public static final BuiltInClass STRING_INPUT_STREAM =
167    addClass(Symbol.STRING_INPUT_STREAM); 
168  public static final BuiltInClass STRING_OUTPUT_STREAM =
169    addClass(Symbol.STRING_OUTPUT_STREAM); 
170  public static final BuiltInClass SYNONYM_STREAM =
171    addClass(Symbol.SYNONYM_STREAM); 
172  public static final BuiltInClass FILE_STREAM =
173    addClass(Symbol.FILE_STREAM); 
174  public static final BuiltInClass JAR_STREAM =
175    addClass(Symbol.JAR_STREAM); 
176  public static final BuiltInClass URL_STREAM =
177    addClass(Symbol.URL_STREAM); 
178  public static final BuiltInClass CONCATENATED_STREAM =
179    addClass(Symbol.CONCATENATED_STREAM); 
180
181
182
183    // Implementation defined streams
184  public static final LispClass SOCKET_STREAM =
185    addClass(Symbol.SOCKET_STREAM);
186  public static final LispClass SLIME_INPUT_STREAM =
187    addClass(Symbol.SLIME_INPUT_STREAM);
188  public static final LispClass SLIME_OUTPUT_STREAM =
189    addClass(Symbol.SLIME_OUTPUT_STREAM);
190
191
192  static
193  {
194    ARRAY.setDirectSuperclass(CLASS_T);
195    ARRAY.setCPL(ARRAY, CLASS_T);
196    BASE_STRING.setDirectSuperclass(STRING);
197    BASE_STRING.setCPL(BASE_STRING, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
198    BIGNUM.setDirectSuperclass(INTEGER);
199    BIGNUM.setCPL(BIGNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
200    BIT_VECTOR.setDirectSuperclass(VECTOR);
201    BIT_VECTOR.setCPL(BIT_VECTOR, VECTOR, ARRAY, SEQUENCE, CLASS_T);
202    BROADCAST_STREAM.setCPL(BROADCAST_STREAM, SYSTEM_STREAM, STREAM,
203                            STRUCTURE_OBJECT, CLASS_T);
204    CASE_FROB_STREAM.setCPL(CASE_FROB_STREAM, SYSTEM_STREAM, STREAM,
205                            STRUCTURE_OBJECT, CLASS_T);
206    CHARACTER.setDirectSuperclass(CLASS_T);
207    CHARACTER.setCPL(CHARACTER, CLASS_T);
208    CLASS_T.setCPL(CLASS_T);
209    COMPLEX.setDirectSuperclass(NUMBER);
210    COMPLEX.setCPL(COMPLEX, NUMBER, CLASS_T);
211    CONCATENATED_STREAM.setCPL(CONCATENATED_STREAM, SYSTEM_STREAM, STREAM,
212                               STRUCTURE_OBJECT, CLASS_T);
213    CONS.setDirectSuperclass(LIST);
214    CONS.setCPL(CONS, LIST, SEQUENCE, CLASS_T);
215    DOUBLE_FLOAT.setDirectSuperclass(FLOAT);
216    DOUBLE_FLOAT.setCPL(DOUBLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
217    ECHO_STREAM.setCPL(ECHO_STREAM, SYSTEM_STREAM, STREAM,
218                       STRUCTURE_OBJECT, CLASS_T);
219    ENVIRONMENT.setDirectSuperclass(CLASS_T);
220    ENVIRONMENT.setCPL(ENVIRONMENT, CLASS_T);
221    FIXNUM.setDirectSuperclass(INTEGER);
222    FIXNUM.setCPL(FIXNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
223    FILE_STREAM.setCPL(FILE_STREAM, SYSTEM_STREAM, STREAM,
224                       STRUCTURE_OBJECT, CLASS_T);
225    JAR_STREAM.setCPL(JAR_STREAM, SYSTEM_STREAM, STREAM,
226                      STRUCTURE_OBJECT, CLASS_T);
227    URL_STREAM.setCPL(URL_STREAM, SYSTEM_STREAM, STREAM,
228                      STRUCTURE_OBJECT, CLASS_T);
229    FLOAT.setDirectSuperclass(REAL);
230    FLOAT.setCPL(FLOAT, REAL, NUMBER, CLASS_T);
231    FUNCTION.setDirectSuperclass(CLASS_T);
232    FUNCTION.setCPL(FUNCTION, CLASS_T);
233    HASH_TABLE.setDirectSuperclass(CLASS_T);
234    HASH_TABLE.setCPL(HASH_TABLE, CLASS_T);
235    INTEGER.setDirectSuperclass(RATIONAL);
236    INTEGER.setCPL(INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
237    JAVA_OBJECT.setDirectSuperclass(CLASS_T);
238    JAVA_OBJECT.setCPL(JAVA_OBJECT, CLASS_T);
239    LIST.setDirectSuperclass(SEQUENCE);
240    LIST.setCPL(LIST, SEQUENCE, CLASS_T);
241    LOGICAL_PATHNAME.setDirectSuperclass(PATHNAME);
242    LOGICAL_PATHNAME.setCPL(LOGICAL_PATHNAME, PATHNAME, CLASS_T);
243    MAILBOX.setDirectSuperclass(CLASS_T);
244    MAILBOX.setCPL(MAILBOX, CLASS_T);
245    MUTEX.setDirectSuperclass(CLASS_T);
246    MUTEX.setCPL(MUTEX, CLASS_T);
247    NIL_VECTOR.setDirectSuperclass(STRING);
248    NIL_VECTOR.setCPL(NIL_VECTOR, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
249    NULL.setDirectSuperclass(LIST);
250    NULL.setCPL(NULL, SYMBOL, LIST, SEQUENCE, CLASS_T);
251    NUMBER.setDirectSuperclass(CLASS_T);
252    NUMBER.setCPL(NUMBER, CLASS_T);
253    PACKAGE.setDirectSuperclass(CLASS_T);
254    PACKAGE.setCPL(PACKAGE, CLASS_T);
255    PATHNAME.setDirectSuperclass(CLASS_T);
256    PATHNAME.setCPL(PATHNAME, CLASS_T);
257    JAR_PATHNAME.setDirectSuperclass(PATHNAME);
258    JAR_PATHNAME.setCPL(JAR_PATHNAME, PATHNAME, CLASS_T);
259    URL_PATHNAME.setDirectSuperclass(PATHNAME);
260    URL_PATHNAME.setCPL(URL_PATHNAME, PATHNAME, CLASS_T);
261    RANDOM_STATE.setDirectSuperclass(CLASS_T);
262    RANDOM_STATE.setCPL(RANDOM_STATE, CLASS_T);
263    RATIO.setDirectSuperclass(RATIONAL);
264    RATIO.setCPL(RATIO, RATIONAL, REAL, NUMBER, CLASS_T);
265    RATIONAL.setDirectSuperclass(REAL);
266    RATIONAL.setCPL(RATIONAL, REAL, NUMBER, CLASS_T);
267    READTABLE.setDirectSuperclass(CLASS_T);
268    READTABLE.setCPL(READTABLE, CLASS_T);
269    REAL.setDirectSuperclass(NUMBER);
270    REAL.setCPL(REAL, NUMBER, CLASS_T);
271    RESTART.setDirectSuperclass(CLASS_T);
272    RESTART.setCPL(RESTART, CLASS_T);
273    SEQUENCE.setDirectSuperclass(CLASS_T);
274    SEQUENCE.setCPL(SEQUENCE, CLASS_T);
275    SIMPLE_ARRAY.setDirectSuperclass(ARRAY);
276    SIMPLE_ARRAY.setCPL(SIMPLE_ARRAY, ARRAY, CLASS_T);
277    SIMPLE_BASE_STRING.setDirectSuperclasses(list(BASE_STRING, SIMPLE_STRING));
278    SIMPLE_BASE_STRING.setCPL(SIMPLE_BASE_STRING, BASE_STRING, SIMPLE_STRING,
279                              STRING, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
280                              CLASS_T);
281    SIMPLE_BIT_VECTOR.setDirectSuperclasses(list(BIT_VECTOR, SIMPLE_ARRAY));
282    SIMPLE_BIT_VECTOR.setCPL(SIMPLE_BIT_VECTOR, BIT_VECTOR, VECTOR,
283                             SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
284    SIMPLE_STRING.setDirectSuperclasses(list(BASE_STRING, STRING, SIMPLE_ARRAY));
285    SIMPLE_STRING.setCPL(SIMPLE_STRING, BASE_STRING, STRING, VECTOR,
286                         SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
287    SIMPLE_VECTOR.setDirectSuperclasses(list(VECTOR, SIMPLE_ARRAY));
288    SIMPLE_VECTOR.setCPL(SIMPLE_VECTOR, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
289                         CLASS_T);
290    SINGLE_FLOAT.setDirectSuperclass(FLOAT);
291    SINGLE_FLOAT.setCPL(SINGLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
292    SLIME_INPUT_STREAM.setCPL(SLIME_INPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
293                              STREAM, STRUCTURE_OBJECT, CLASS_T);
294    SLIME_OUTPUT_STREAM.setCPL(SLIME_OUTPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
295                               STREAM, STRUCTURE_OBJECT, CLASS_T);
296    SOCKET_STREAM.setCPL(SOCKET_STREAM, TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
297                         STRUCTURE_OBJECT, CLASS_T);
298    STREAM.setCPL(STREAM, CLASS_T);
299    STRING.setDirectSuperclass(VECTOR);
300    STRING.setCPL(STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
301    STRING_INPUT_STREAM.setCPL(STRING_INPUT_STREAM, STRING_STREAM,
302                               SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
303    STRING_OUTPUT_STREAM.setCPL(STRING_OUTPUT_STREAM, STRING_STREAM,
304                                SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
305    STRING_STREAM.setCPL(STRING_STREAM, SYSTEM_STREAM, STREAM,
306                         STRUCTURE_OBJECT, CLASS_T);
307    STRUCTURE_OBJECT.setCPL(STRUCTURE_OBJECT, CLASS_T);
308    SYMBOL.setDirectSuperclass(CLASS_T);
309    SYMBOL.setCPL(SYMBOL, CLASS_T);
310    SYNONYM_STREAM.setCPL(SYNONYM_STREAM, SYSTEM_STREAM,
311                          STREAM, STRUCTURE_OBJECT, CLASS_T);
312    SYSTEM_STREAM.setCPL(SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
313    THREAD.setDirectSuperclass(CLASS_T);
314    THREAD.setCPL(THREAD, CLASS_T);
315    TWO_WAY_STREAM.setCPL(TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
316                          STRUCTURE_OBJECT, CLASS_T);
317    VECTOR.setDirectSuperclasses(list(ARRAY, SEQUENCE));
318    VECTOR.setCPL(VECTOR, ARRAY, SEQUENCE, CLASS_T);
319    STACK_FRAME.setDirectSuperclasses(CLASS_T);
320    STACK_FRAME.setCPL(STACK_FRAME, CLASS_T);
321    LISP_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
322    LISP_STACK_FRAME.setCPL(LISP_STACK_FRAME, STACK_FRAME, CLASS_T);
323    JAVA_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
324    JAVA_STACK_FRAME.setCPL(JAVA_STACK_FRAME, STACK_FRAME, CLASS_T);
325  }
326
327  static
328  {
329    StandardClass.initializeStandardClasses();
330  }
331}
Note: See TracBrowser for help on using the repository browser.