1 | /* |
---|
2 | * StandardClass.java |
---|
3 | * |
---|
4 | * Copyright (C) 2003-2005 Peter Graves |
---|
5 | * $Id: StandardClass.java 12749 2010-06-09 11:27:42Z 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., 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 | |
---|
34 | package org.armedbear.lisp; |
---|
35 | |
---|
36 | import static org.armedbear.lisp.Lisp.*; |
---|
37 | |
---|
38 | public class StandardClass extends SlotClass |
---|
39 | { |
---|
40 | |
---|
41 | public static Symbol symName = PACKAGE_MOP.intern("NAME"); |
---|
42 | public static Symbol symLayout = PACKAGE_MOP.intern("LAYOUT"); |
---|
43 | public static Symbol symDirectSuperclasses |
---|
44 | = PACKAGE_MOP.intern("DIRECT-SUPERCLASSES"); |
---|
45 | public static Symbol symDirectSubclasses |
---|
46 | = PACKAGE_MOP.intern("DIRECT-SUBCLASSES"); |
---|
47 | public static Symbol symPrecedenceList |
---|
48 | = PACKAGE_MOP.intern("PRECEDENCE-LIST"); |
---|
49 | public static Symbol symDirectMethods |
---|
50 | = PACKAGE_MOP.intern("DIRECT-METHODS"); |
---|
51 | public static Symbol symDocumentation |
---|
52 | = PACKAGE_MOP.intern("DOCUMENTATION"); |
---|
53 | public static Symbol symDirectSlots |
---|
54 | = PACKAGE_MOP.intern("DIRECT-SLOTS"); |
---|
55 | public static Symbol symSlots |
---|
56 | = PACKAGE_MOP.intern("SLOTS"); |
---|
57 | public static Symbol symDirectDefaultInitargs |
---|
58 | = PACKAGE_MOP.intern("DIRECT-DEFAULT-INITARGS"); |
---|
59 | public static Symbol symDefaultInitargs |
---|
60 | = PACKAGE_MOP.intern("DEFAULT-INITARGS"); |
---|
61 | public static Symbol symFinalizedP |
---|
62 | = PACKAGE_MOP.intern("FINALIZED-P"); |
---|
63 | |
---|
64 | static Layout layoutStandardClass = |
---|
65 | new Layout(null, |
---|
66 | list(symName, |
---|
67 | symLayout, |
---|
68 | symDirectSuperclasses, |
---|
69 | symDirectSubclasses, |
---|
70 | symPrecedenceList, |
---|
71 | symDirectMethods, |
---|
72 | symDirectSlots, |
---|
73 | symSlots, |
---|
74 | symDirectDefaultInitargs, |
---|
75 | symDefaultInitargs, |
---|
76 | symFinalizedP, |
---|
77 | symDocumentation), |
---|
78 | NIL) |
---|
79 | { |
---|
80 | @Override |
---|
81 | public LispClass getLispClass() |
---|
82 | { |
---|
83 | return STANDARD_CLASS; |
---|
84 | } |
---|
85 | }; |
---|
86 | |
---|
87 | public StandardClass() |
---|
88 | { |
---|
89 | super(layoutStandardClass); |
---|
90 | setDirectSuperclasses(NIL); |
---|
91 | setDirectSubclasses(NIL); |
---|
92 | setClassLayout(layoutStandardClass); |
---|
93 | setCPL(NIL); |
---|
94 | setDirectMethods(NIL); |
---|
95 | setDocumentation(NIL); |
---|
96 | setDirectSlotDefinitions(NIL); |
---|
97 | setSlotDefinitions(NIL); |
---|
98 | setDirectDefaultInitargs(NIL); |
---|
99 | setDefaultInitargs(NIL); |
---|
100 | setFinalized(false); |
---|
101 | } |
---|
102 | |
---|
103 | public StandardClass(Symbol symbol, LispObject directSuperclasses) |
---|
104 | { |
---|
105 | super(layoutStandardClass, |
---|
106 | symbol, directSuperclasses); |
---|
107 | setDirectSubclasses(NIL); |
---|
108 | setClassLayout(layoutStandardClass); |
---|
109 | setCPL(NIL); |
---|
110 | setDirectMethods(NIL); |
---|
111 | setDocumentation(NIL); |
---|
112 | setDirectSlotDefinitions(NIL); |
---|
113 | setSlotDefinitions(NIL); |
---|
114 | setDirectDefaultInitargs(NIL); |
---|
115 | setDefaultInitargs(NIL); |
---|
116 | setFinalized(false); |
---|
117 | } |
---|
118 | |
---|
119 | @Override |
---|
120 | public LispObject getName() |
---|
121 | { |
---|
122 | return getInstanceSlotValue(symName); |
---|
123 | } |
---|
124 | |
---|
125 | @Override |
---|
126 | public void setName(LispObject newName) |
---|
127 | { |
---|
128 | setInstanceSlotValue(symName, newName); |
---|
129 | } |
---|
130 | |
---|
131 | @Override |
---|
132 | public Layout getClassLayout() |
---|
133 | { |
---|
134 | LispObject layout = getInstanceSlotValue(symLayout); |
---|
135 | return (layout == UNBOUND_VALUE) ? null : (Layout)layout; |
---|
136 | } |
---|
137 | |
---|
138 | @Override |
---|
139 | public void setClassLayout(LispObject newLayout) |
---|
140 | { |
---|
141 | setInstanceSlotValue(symLayout, newLayout); |
---|
142 | } |
---|
143 | |
---|
144 | @Override |
---|
145 | public LispObject getDirectSuperclasses() |
---|
146 | { |
---|
147 | return getInstanceSlotValue(symDirectSuperclasses); |
---|
148 | } |
---|
149 | |
---|
150 | @Override |
---|
151 | public void setDirectSuperclasses(LispObject directSuperclasses) |
---|
152 | { |
---|
153 | setInstanceSlotValue(symDirectSuperclasses, directSuperclasses); |
---|
154 | } |
---|
155 | |
---|
156 | @Override |
---|
157 | public final boolean isFinalized() |
---|
158 | { |
---|
159 | return getInstanceSlotValue(symFinalizedP) != NIL; |
---|
160 | } |
---|
161 | |
---|
162 | @Override |
---|
163 | public final void setFinalized(boolean b) |
---|
164 | { |
---|
165 | setInstanceSlotValue(symFinalizedP, b ? T : NIL); |
---|
166 | } |
---|
167 | |
---|
168 | @Override |
---|
169 | public LispObject getDirectSubclasses() |
---|
170 | { |
---|
171 | return getInstanceSlotValue(symDirectSubclasses); |
---|
172 | } |
---|
173 | |
---|
174 | @Override |
---|
175 | public void setDirectSubclasses(LispObject directSubclasses) |
---|
176 | { |
---|
177 | setInstanceSlotValue(symDirectSubclasses, directSubclasses); |
---|
178 | } |
---|
179 | |
---|
180 | @Override |
---|
181 | public LispObject getCPL() |
---|
182 | { |
---|
183 | return getInstanceSlotValue(symPrecedenceList); |
---|
184 | } |
---|
185 | |
---|
186 | @Override |
---|
187 | public void setCPL(LispObject... cpl) |
---|
188 | { |
---|
189 | LispObject obj1 = cpl[0]; |
---|
190 | if (obj1.listp() && cpl.length == 1) |
---|
191 | setInstanceSlotValue(symPrecedenceList, obj1); |
---|
192 | else |
---|
193 | { |
---|
194 | Debug.assertTrue(obj1 == this); |
---|
195 | LispObject l = NIL; |
---|
196 | for (int i = cpl.length; i-- > 0;) |
---|
197 | l = new Cons(cpl[i], l); |
---|
198 | setInstanceSlotValue(symPrecedenceList, l); |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | @Override |
---|
203 | public LispObject getDirectMethods() |
---|
204 | { |
---|
205 | return getInstanceSlotValue(symDirectMethods); |
---|
206 | } |
---|
207 | |
---|
208 | @Override |
---|
209 | public void setDirectMethods(LispObject methods) |
---|
210 | { |
---|
211 | setInstanceSlotValue(symDirectMethods, methods); |
---|
212 | } |
---|
213 | |
---|
214 | @Override |
---|
215 | public LispObject getDocumentation() |
---|
216 | { |
---|
217 | return getInstanceSlotValue(symDocumentation); |
---|
218 | } |
---|
219 | |
---|
220 | @Override |
---|
221 | public void setDocumentation(LispObject doc) |
---|
222 | { |
---|
223 | setInstanceSlotValue(symDocumentation, doc); |
---|
224 | } |
---|
225 | |
---|
226 | @Override |
---|
227 | public LispObject getDirectSlotDefinitions() |
---|
228 | { |
---|
229 | return getInstanceSlotValue(symDirectSlots); |
---|
230 | } |
---|
231 | |
---|
232 | @Override |
---|
233 | public void setDirectSlotDefinitions(LispObject directSlotDefinitions) |
---|
234 | { |
---|
235 | setInstanceSlotValue(symDirectSlots, directSlotDefinitions); |
---|
236 | } |
---|
237 | |
---|
238 | @Override |
---|
239 | public LispObject getSlotDefinitions() |
---|
240 | { |
---|
241 | return getInstanceSlotValue(symSlots); |
---|
242 | } |
---|
243 | |
---|
244 | @Override |
---|
245 | public void setSlotDefinitions(LispObject slotDefinitions) |
---|
246 | { |
---|
247 | setInstanceSlotValue(symSlots, slotDefinitions); |
---|
248 | } |
---|
249 | |
---|
250 | @Override |
---|
251 | public LispObject getDirectDefaultInitargs() |
---|
252 | { |
---|
253 | return getInstanceSlotValue(symDirectDefaultInitargs); |
---|
254 | } |
---|
255 | |
---|
256 | @Override |
---|
257 | public void setDirectDefaultInitargs(LispObject directDefaultInitargs) |
---|
258 | { |
---|
259 | setInstanceSlotValue(symDirectDefaultInitargs, directDefaultInitargs); |
---|
260 | } |
---|
261 | |
---|
262 | @Override |
---|
263 | public LispObject getDefaultInitargs() |
---|
264 | { |
---|
265 | return getInstanceSlotValue(symDefaultInitargs); |
---|
266 | } |
---|
267 | |
---|
268 | @Override |
---|
269 | public void setDefaultInitargs(LispObject defaultInitargs) |
---|
270 | { |
---|
271 | setInstanceSlotValue(symDefaultInitargs, defaultInitargs); |
---|
272 | } |
---|
273 | |
---|
274 | @Override |
---|
275 | public LispObject typeOf() |
---|
276 | { |
---|
277 | return Symbol.STANDARD_CLASS; |
---|
278 | } |
---|
279 | |
---|
280 | @Override |
---|
281 | public LispObject classOf() |
---|
282 | { |
---|
283 | return STANDARD_CLASS; |
---|
284 | } |
---|
285 | |
---|
286 | @Override |
---|
287 | public LispObject typep(LispObject type) |
---|
288 | { |
---|
289 | if (type == Symbol.STANDARD_CLASS) |
---|
290 | return T; |
---|
291 | if (type == STANDARD_CLASS) |
---|
292 | return T; |
---|
293 | return super.typep(type); |
---|
294 | } |
---|
295 | |
---|
296 | public LispObject allocateInstance() |
---|
297 | { |
---|
298 | Layout layout = getClassLayout(); |
---|
299 | if (layout == null) |
---|
300 | { |
---|
301 | Symbol.ERROR.execute(Symbol.SIMPLE_ERROR, |
---|
302 | Keyword.FORMAT_CONTROL, |
---|
303 | new SimpleString("No layout for class ~S."), |
---|
304 | Keyword.FORMAT_ARGUMENTS, |
---|
305 | list(this)); |
---|
306 | } |
---|
307 | return new StandardObject(this, layout.getLength()); |
---|
308 | } |
---|
309 | |
---|
310 | @Override |
---|
311 | public String writeToString() |
---|
312 | { |
---|
313 | StringBuilder sb = |
---|
314 | new StringBuilder(Symbol.STANDARD_CLASS.writeToString()); |
---|
315 | if (getName() != null) |
---|
316 | { |
---|
317 | sb.append(' '); |
---|
318 | sb.append(getName().writeToString()); |
---|
319 | } |
---|
320 | return unreadableString(sb.toString()); |
---|
321 | } |
---|
322 | |
---|
323 | private static final LispObject standardClassSlotDefinitions() |
---|
324 | { |
---|
325 | // (CONSTANTLY NIL) |
---|
326 | Function initFunction = new Function() { |
---|
327 | @Override |
---|
328 | public LispObject execute() |
---|
329 | { |
---|
330 | return NIL; |
---|
331 | } |
---|
332 | }; |
---|
333 | |
---|
334 | return |
---|
335 | list(helperMakeSlotDefinition("NAME", initFunction), |
---|
336 | helperMakeSlotDefinition("LAYOUT", initFunction), |
---|
337 | helperMakeSlotDefinition("DIRECT-SUPERCLASSES", initFunction), |
---|
338 | helperMakeSlotDefinition("DIRECT-SUBCLASSES", initFunction), |
---|
339 | helperMakeSlotDefinition("PRECEDENCE-LIST", initFunction), |
---|
340 | helperMakeSlotDefinition("DIRECT-METHODS", initFunction), |
---|
341 | helperMakeSlotDefinition("DIRECT-SLOTS", initFunction), |
---|
342 | helperMakeSlotDefinition("SLOTS", initFunction), |
---|
343 | helperMakeSlotDefinition("DIRECT-DEFAULT-INITARGS", initFunction), |
---|
344 | helperMakeSlotDefinition("DEFAULT-INITARGS", initFunction), |
---|
345 | helperMakeSlotDefinition("FINALIZED-P", initFunction), |
---|
346 | helperMakeSlotDefinition("DOCUMENTATION", initFunction)); |
---|
347 | } |
---|
348 | |
---|
349 | |
---|
350 | |
---|
351 | private static final SlotDefinition helperMakeSlotDefinition(String name, |
---|
352 | Function init) |
---|
353 | { |
---|
354 | return |
---|
355 | new SlotDefinition(PACKAGE_MOP.intern(name), // name |
---|
356 | list(PACKAGE_MOP.intern("CLASS-" + name)), // readers |
---|
357 | init); |
---|
358 | } |
---|
359 | |
---|
360 | private static final StandardClass addStandardClass(Symbol name, |
---|
361 | LispObject directSuperclasses) |
---|
362 | { |
---|
363 | StandardClass c = new StandardClass(name, directSuperclasses); |
---|
364 | addClass(name, c); |
---|
365 | return c; |
---|
366 | } |
---|
367 | |
---|
368 | // At this point, BuiltInClass.java has not been completely loaded yet, and |
---|
369 | // BuiltInClass.CLASS_T is null. So we need to call setDirectSuperclass() |
---|
370 | // for STANDARD_CLASS and STANDARD_OBJECT in initializeStandardClasses() |
---|
371 | // below. |
---|
372 | public static final StandardClass STANDARD_CLASS = |
---|
373 | addStandardClass(Symbol.STANDARD_CLASS, list(BuiltInClass.CLASS_T)); |
---|
374 | public static final StandardClass STANDARD_OBJECT = |
---|
375 | addStandardClass(Symbol.STANDARD_OBJECT, list(BuiltInClass.CLASS_T)); |
---|
376 | |
---|
377 | public static final StandardClass SLOT_DEFINITION = |
---|
378 | new SlotDefinitionClass(); |
---|
379 | static |
---|
380 | { |
---|
381 | addClass(Symbol.SLOT_DEFINITION, SLOT_DEFINITION); |
---|
382 | |
---|
383 | STANDARD_CLASS.setClassLayout(layoutStandardClass); |
---|
384 | STANDARD_CLASS.setDirectSlotDefinitions(standardClassSlotDefinitions()); |
---|
385 | } |
---|
386 | |
---|
387 | public static final StandardClass DIRECT_SLOT_DEFINITION = |
---|
388 | addStandardClass(Symbol.DIRECT_SLOT_DEFINITION, list(SLOT_DEFINITION)); |
---|
389 | public static final StandardClass EFFECTIVE_SLOT_DEFINITION = |
---|
390 | addStandardClass(Symbol.EFFECTIVE_SLOT_DEFINITION, list(SLOT_DEFINITION)); |
---|
391 | |
---|
392 | // BuiltInClass.FUNCTION is also null here (see previous comment). |
---|
393 | public static final StandardClass GENERIC_FUNCTION = |
---|
394 | addStandardClass(Symbol.GENERIC_FUNCTION, list(BuiltInClass.FUNCTION, |
---|
395 | STANDARD_OBJECT)); |
---|
396 | |
---|
397 | public static final StandardClass CLASS = |
---|
398 | addStandardClass(Symbol.CLASS, list(STANDARD_OBJECT)); |
---|
399 | |
---|
400 | public static final StandardClass BUILT_IN_CLASS = |
---|
401 | addStandardClass(Symbol.BUILT_IN_CLASS, list(CLASS)); |
---|
402 | |
---|
403 | public static final StandardClass FORWARD_REFERENCED_CLASS = |
---|
404 | addStandardClass(Symbol.FORWARD_REFERENCED_CLASS, list(CLASS)); |
---|
405 | |
---|
406 | public static final StandardClass STRUCTURE_CLASS = |
---|
407 | addStandardClass(Symbol.STRUCTURE_CLASS, list(CLASS)); |
---|
408 | |
---|
409 | public static final StandardClass CONDITION = |
---|
410 | addStandardClass(Symbol.CONDITION, list(STANDARD_OBJECT)); |
---|
411 | |
---|
412 | public static final StandardClass SIMPLE_CONDITION = |
---|
413 | addStandardClass(Symbol.SIMPLE_CONDITION, list(CONDITION)); |
---|
414 | |
---|
415 | public static final StandardClass WARNING = |
---|
416 | addStandardClass(Symbol.WARNING, list(CONDITION)); |
---|
417 | |
---|
418 | public static final StandardClass SIMPLE_WARNING = |
---|
419 | addStandardClass(Symbol.SIMPLE_WARNING, list(SIMPLE_CONDITION, WARNING)); |
---|
420 | |
---|
421 | public static final StandardClass STYLE_WARNING = |
---|
422 | addStandardClass(Symbol.STYLE_WARNING, list(WARNING)); |
---|
423 | |
---|
424 | public static final StandardClass SERIOUS_CONDITION = |
---|
425 | addStandardClass(Symbol.SERIOUS_CONDITION, list(CONDITION)); |
---|
426 | |
---|
427 | public static final StandardClass STORAGE_CONDITION = |
---|
428 | addStandardClass(Symbol.STORAGE_CONDITION, list(SERIOUS_CONDITION)); |
---|
429 | |
---|
430 | public static final StandardClass ERROR = |
---|
431 | addStandardClass(Symbol.ERROR, list(SERIOUS_CONDITION)); |
---|
432 | |
---|
433 | public static final StandardClass ARITHMETIC_ERROR = |
---|
434 | addStandardClass(Symbol.ARITHMETIC_ERROR, list(ERROR)); |
---|
435 | |
---|
436 | public static final StandardClass CELL_ERROR = |
---|
437 | addStandardClass(Symbol.CELL_ERROR, list(ERROR)); |
---|
438 | |
---|
439 | public static final StandardClass CONTROL_ERROR = |
---|
440 | addStandardClass(Symbol.CONTROL_ERROR, list(ERROR)); |
---|
441 | |
---|
442 | public static final StandardClass FILE_ERROR = |
---|
443 | addStandardClass(Symbol.FILE_ERROR, list(ERROR)); |
---|
444 | |
---|
445 | public static final StandardClass DIVISION_BY_ZERO = |
---|
446 | addStandardClass(Symbol.DIVISION_BY_ZERO, list(ARITHMETIC_ERROR)); |
---|
447 | |
---|
448 | public static final StandardClass FLOATING_POINT_INEXACT = |
---|
449 | addStandardClass(Symbol.FLOATING_POINT_INEXACT, list(ARITHMETIC_ERROR)); |
---|
450 | |
---|
451 | public static final StandardClass FLOATING_POINT_INVALID_OPERATION = |
---|
452 | addStandardClass(Symbol.FLOATING_POINT_INVALID_OPERATION, list(ARITHMETIC_ERROR)); |
---|
453 | |
---|
454 | public static final StandardClass FLOATING_POINT_OVERFLOW = |
---|
455 | addStandardClass(Symbol.FLOATING_POINT_OVERFLOW, list(ARITHMETIC_ERROR)); |
---|
456 | |
---|
457 | public static final StandardClass FLOATING_POINT_UNDERFLOW = |
---|
458 | addStandardClass(Symbol.FLOATING_POINT_UNDERFLOW, list(ARITHMETIC_ERROR)); |
---|
459 | |
---|
460 | public static final StandardClass PROGRAM_ERROR = |
---|
461 | addStandardClass(Symbol.PROGRAM_ERROR, list(ERROR)); |
---|
462 | |
---|
463 | public static final StandardClass PACKAGE_ERROR = |
---|
464 | addStandardClass(Symbol.PACKAGE_ERROR, list(ERROR)); |
---|
465 | |
---|
466 | public static final StandardClass STREAM_ERROR = |
---|
467 | addStandardClass(Symbol.STREAM_ERROR, list(ERROR)); |
---|
468 | |
---|
469 | public static final StandardClass PARSE_ERROR = |
---|
470 | addStandardClass(Symbol.PARSE_ERROR, list(ERROR)); |
---|
471 | |
---|
472 | public static final StandardClass PRINT_NOT_READABLE = |
---|
473 | addStandardClass(Symbol.PRINT_NOT_READABLE, list(ERROR)); |
---|
474 | |
---|
475 | public static final StandardClass READER_ERROR = |
---|
476 | addStandardClass(Symbol.READER_ERROR, list(PARSE_ERROR, STREAM_ERROR)); |
---|
477 | |
---|
478 | public static final StandardClass END_OF_FILE = |
---|
479 | addStandardClass(Symbol.END_OF_FILE, list(STREAM_ERROR)); |
---|
480 | |
---|
481 | public static final StandardClass SIMPLE_ERROR = |
---|
482 | addStandardClass(Symbol.SIMPLE_ERROR, list(SIMPLE_CONDITION, ERROR)); |
---|
483 | |
---|
484 | public static final StandardClass TYPE_ERROR = |
---|
485 | addStandardClass(Symbol.TYPE_ERROR, list(ERROR)); |
---|
486 | |
---|
487 | public static final StandardClass SIMPLE_TYPE_ERROR = |
---|
488 | addStandardClass(Symbol.SIMPLE_TYPE_ERROR, list(SIMPLE_CONDITION, |
---|
489 | TYPE_ERROR)); |
---|
490 | |
---|
491 | public static final StandardClass UNBOUND_SLOT = |
---|
492 | addStandardClass(Symbol.UNBOUND_SLOT, list(CELL_ERROR)); |
---|
493 | |
---|
494 | public static final StandardClass UNBOUND_VARIABLE = |
---|
495 | addStandardClass(Symbol.UNBOUND_VARIABLE, list(CELL_ERROR)); |
---|
496 | |
---|
497 | public static final StandardClass UNDEFINED_FUNCTION = |
---|
498 | addStandardClass(Symbol.UNDEFINED_FUNCTION, list(CELL_ERROR)); |
---|
499 | |
---|
500 | public static final StandardClass COMPILER_ERROR = |
---|
501 | addStandardClass(Symbol.COMPILER_ERROR, list(CONDITION)); |
---|
502 | |
---|
503 | public static final StandardClass INTERNAL_COMPILER_ERROR = |
---|
504 | addStandardClass(Symbol.INTERNAL_COMPILER_ERROR, list(CONDITION)); |
---|
505 | |
---|
506 | public static final StandardClass COMPILER_UNSUPPORTED_FEATURE_ERROR = |
---|
507 | addStandardClass(Symbol.COMPILER_UNSUPPORTED_FEATURE_ERROR, |
---|
508 | list(CONDITION)); |
---|
509 | |
---|
510 | public static final StandardClass JAVA_EXCEPTION = |
---|
511 | addStandardClass(Symbol.JAVA_EXCEPTION, list(ERROR)); |
---|
512 | |
---|
513 | public static final StandardClass METHOD = |
---|
514 | addStandardClass(Symbol.METHOD, list(STANDARD_OBJECT)); |
---|
515 | |
---|
516 | public static final StandardClass STANDARD_METHOD = |
---|
517 | new StandardMethodClass(); |
---|
518 | static |
---|
519 | { |
---|
520 | addClass(Symbol.STANDARD_METHOD, STANDARD_METHOD); |
---|
521 | } |
---|
522 | |
---|
523 | public static final StandardClass STANDARD_READER_METHOD = |
---|
524 | new StandardReaderMethodClass(); |
---|
525 | static |
---|
526 | { |
---|
527 | addClass(Symbol.STANDARD_READER_METHOD, STANDARD_READER_METHOD); |
---|
528 | } |
---|
529 | |
---|
530 | public static final StandardClass STANDARD_GENERIC_FUNCTION = |
---|
531 | new StandardGenericFunctionClass(); |
---|
532 | static |
---|
533 | { |
---|
534 | addClass(Symbol.STANDARD_GENERIC_FUNCTION, STANDARD_GENERIC_FUNCTION); |
---|
535 | } |
---|
536 | |
---|
537 | public static void initializeStandardClasses() |
---|
538 | { |
---|
539 | // We need to call setDirectSuperclass() here for classes that have a |
---|
540 | // BuiltInClass as a superclass. See comment above (at first mention of |
---|
541 | // STANDARD_OBJECT). |
---|
542 | STANDARD_CLASS.setDirectSuperclass(CLASS); |
---|
543 | STANDARD_OBJECT.setDirectSuperclass(BuiltInClass.CLASS_T); |
---|
544 | GENERIC_FUNCTION.setDirectSuperclasses(list(BuiltInClass.FUNCTION, |
---|
545 | STANDARD_OBJECT)); |
---|
546 | |
---|
547 | ARITHMETIC_ERROR.setCPL(ARITHMETIC_ERROR, ERROR, SERIOUS_CONDITION, |
---|
548 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
549 | ARITHMETIC_ERROR.setDirectSlotDefinitions( |
---|
550 | list(new SlotDefinition(Symbol.OPERATION, |
---|
551 | list(PACKAGE_CL.intern("ARITHMETIC-ERROR-OPERATION"))), |
---|
552 | new SlotDefinition(Symbol.OPERANDS, |
---|
553 | list(PACKAGE_CL.intern("ARITHMETIC-ERROR-OPERANDS"))))); |
---|
554 | BUILT_IN_CLASS.setCPL(BUILT_IN_CLASS, CLASS, STANDARD_OBJECT, |
---|
555 | BuiltInClass.CLASS_T); |
---|
556 | CELL_ERROR.setCPL(CELL_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
557 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
558 | CELL_ERROR.setDirectSlotDefinitions( |
---|
559 | list(new SlotDefinition(Symbol.NAME, |
---|
560 | list(Symbol.CELL_ERROR_NAME)))); |
---|
561 | CLASS.setCPL(CLASS, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
562 | COMPILER_ERROR.setCPL(COMPILER_ERROR, CONDITION, STANDARD_OBJECT, |
---|
563 | BuiltInClass.CLASS_T); |
---|
564 | INTERNAL_COMPILER_ERROR.setCPL(INTERNAL_COMPILER_ERROR, CONDITION, STANDARD_OBJECT, |
---|
565 | BuiltInClass.CLASS_T); |
---|
566 | COMPILER_UNSUPPORTED_FEATURE_ERROR.setCPL(COMPILER_UNSUPPORTED_FEATURE_ERROR, |
---|
567 | CONDITION, STANDARD_OBJECT, |
---|
568 | BuiltInClass.CLASS_T); |
---|
569 | CONDITION.setCPL(CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
570 | CONDITION.setDirectSlotDefinitions( |
---|
571 | list(new SlotDefinition(Symbol.FORMAT_CONTROL, |
---|
572 | list(Symbol.SIMPLE_CONDITION_FORMAT_CONTROL)), |
---|
573 | new SlotDefinition(Symbol.FORMAT_ARGUMENTS, |
---|
574 | list(Symbol.SIMPLE_CONDITION_FORMAT_ARGUMENTS), |
---|
575 | NIL))); |
---|
576 | CONDITION.setDirectDefaultInitargs(list(Keyword.FORMAT_ARGUMENTS, |
---|
577 | // FIXME |
---|
578 | new Closure(list(Symbol.LAMBDA, NIL, NIL), |
---|
579 | new Environment()))); |
---|
580 | CONTROL_ERROR.setCPL(CONTROL_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
581 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
582 | DIVISION_BY_ZERO.setCPL(DIVISION_BY_ZERO, ARITHMETIC_ERROR, ERROR, |
---|
583 | SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
584 | BuiltInClass.CLASS_T); |
---|
585 | END_OF_FILE.setCPL(END_OF_FILE, STREAM_ERROR, ERROR, SERIOUS_CONDITION, |
---|
586 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
587 | ERROR.setCPL(ERROR, SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
588 | BuiltInClass.CLASS_T); |
---|
589 | FILE_ERROR.setCPL(FILE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
590 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
591 | FILE_ERROR.setDirectSlotDefinitions( |
---|
592 | list(new SlotDefinition(Symbol.PATHNAME, |
---|
593 | list(PACKAGE_CL.intern("FILE-ERROR-PATHNAME"))))); |
---|
594 | FLOATING_POINT_INEXACT.setCPL(FLOATING_POINT_INEXACT, ARITHMETIC_ERROR, |
---|
595 | ERROR, SERIOUS_CONDITION, CONDITION, |
---|
596 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
597 | FLOATING_POINT_INVALID_OPERATION.setCPL(FLOATING_POINT_INVALID_OPERATION, |
---|
598 | ARITHMETIC_ERROR, ERROR, |
---|
599 | SERIOUS_CONDITION, CONDITION, |
---|
600 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
601 | FLOATING_POINT_OVERFLOW.setCPL(FLOATING_POINT_OVERFLOW, ARITHMETIC_ERROR, |
---|
602 | ERROR, SERIOUS_CONDITION, CONDITION, |
---|
603 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
604 | FLOATING_POINT_UNDERFLOW.setCPL(FLOATING_POINT_UNDERFLOW, ARITHMETIC_ERROR, |
---|
605 | ERROR, SERIOUS_CONDITION, CONDITION, |
---|
606 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
607 | FORWARD_REFERENCED_CLASS.setCPL(FORWARD_REFERENCED_CLASS, CLASS, |
---|
608 | BuiltInClass.CLASS_T); |
---|
609 | GENERIC_FUNCTION.setCPL(GENERIC_FUNCTION, STANDARD_OBJECT, |
---|
610 | BuiltInClass.FUNCTION, |
---|
611 | BuiltInClass.CLASS_T); |
---|
612 | JAVA_EXCEPTION.setCPL(JAVA_EXCEPTION, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
613 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
614 | JAVA_EXCEPTION.setDirectSlotDefinitions( |
---|
615 | list(new SlotDefinition(Symbol.CAUSE, list(Symbol.JAVA_EXCEPTION_CAUSE)))); |
---|
616 | METHOD.setCPL(METHOD, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
617 | PACKAGE_ERROR.setCPL(PACKAGE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
618 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
619 | PACKAGE_ERROR.setDirectSlotDefinitions( |
---|
620 | list(new SlotDefinition(Symbol.PACKAGE, |
---|
621 | list(PACKAGE_CL.intern("PACKAGE-ERROR-PACKAGE"))))); |
---|
622 | PARSE_ERROR.setCPL(PARSE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
623 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
624 | PRINT_NOT_READABLE.setCPL(PRINT_NOT_READABLE, ERROR, SERIOUS_CONDITION, |
---|
625 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
626 | PRINT_NOT_READABLE.setDirectSlotDefinitions( |
---|
627 | list(new SlotDefinition(Symbol.OBJECT, |
---|
628 | list(PACKAGE_CL.intern("PRINT-NOT-READABLE-OBJECT"))))); |
---|
629 | PROGRAM_ERROR.setCPL(PROGRAM_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
630 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
631 | READER_ERROR.setCPL(READER_ERROR, PARSE_ERROR, STREAM_ERROR, ERROR, |
---|
632 | SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
633 | BuiltInClass.CLASS_T); |
---|
634 | SERIOUS_CONDITION.setCPL(SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
635 | BuiltInClass.CLASS_T); |
---|
636 | SIMPLE_CONDITION.setCPL(SIMPLE_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
637 | BuiltInClass.CLASS_T); |
---|
638 | SIMPLE_ERROR.setCPL(SIMPLE_ERROR, SIMPLE_CONDITION, ERROR, |
---|
639 | SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
640 | BuiltInClass.CLASS_T); |
---|
641 | SIMPLE_TYPE_ERROR.setDirectSuperclasses(list(SIMPLE_CONDITION, |
---|
642 | TYPE_ERROR)); |
---|
643 | SIMPLE_TYPE_ERROR.setCPL(SIMPLE_TYPE_ERROR, SIMPLE_CONDITION, |
---|
644 | TYPE_ERROR, ERROR, SERIOUS_CONDITION, |
---|
645 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
646 | SIMPLE_WARNING.setDirectSuperclasses(list(SIMPLE_CONDITION, WARNING)); |
---|
647 | SIMPLE_WARNING.setCPL(SIMPLE_WARNING, SIMPLE_CONDITION, WARNING, |
---|
648 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
649 | STANDARD_CLASS.setCPL(STANDARD_CLASS, CLASS, |
---|
650 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
651 | STANDARD_OBJECT.setCPL(STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
652 | STORAGE_CONDITION.setCPL(STORAGE_CONDITION, SERIOUS_CONDITION, CONDITION, |
---|
653 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
654 | STREAM_ERROR.setCPL(STREAM_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
655 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
656 | STREAM_ERROR.setDirectSlotDefinitions( |
---|
657 | list(new SlotDefinition(Symbol.STREAM, |
---|
658 | list(PACKAGE_CL.intern("STREAM-ERROR-STREAM"))))); |
---|
659 | STRUCTURE_CLASS.setCPL(STRUCTURE_CLASS, CLASS, STANDARD_OBJECT, |
---|
660 | BuiltInClass.CLASS_T); |
---|
661 | STYLE_WARNING.setCPL(STYLE_WARNING, WARNING, CONDITION, STANDARD_OBJECT, |
---|
662 | BuiltInClass.CLASS_T); |
---|
663 | TYPE_ERROR.setCPL(TYPE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION, |
---|
664 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
665 | TYPE_ERROR.setDirectSlotDefinitions( |
---|
666 | list(new SlotDefinition(Symbol.DATUM, |
---|
667 | list(PACKAGE_CL.intern("TYPE-ERROR-DATUM"))), |
---|
668 | new SlotDefinition(Symbol.EXPECTED_TYPE, |
---|
669 | list(PACKAGE_CL.intern("TYPE-ERROR-EXPECTED-TYPE"))))); |
---|
670 | UNBOUND_SLOT.setCPL(UNBOUND_SLOT, CELL_ERROR, ERROR, SERIOUS_CONDITION, |
---|
671 | CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
672 | UNBOUND_SLOT.setDirectSlotDefinitions( |
---|
673 | list(new SlotDefinition(Symbol.INSTANCE, |
---|
674 | list(PACKAGE_CL.intern("UNBOUND-SLOT-INSTANCE"))))); |
---|
675 | UNBOUND_VARIABLE.setCPL(UNBOUND_VARIABLE, CELL_ERROR, ERROR, |
---|
676 | SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
677 | BuiltInClass.CLASS_T); |
---|
678 | UNDEFINED_FUNCTION.setCPL(UNDEFINED_FUNCTION, CELL_ERROR, ERROR, |
---|
679 | SERIOUS_CONDITION, CONDITION, STANDARD_OBJECT, |
---|
680 | BuiltInClass.CLASS_T); |
---|
681 | WARNING.setCPL(WARNING, CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
682 | |
---|
683 | // Condition classes. |
---|
684 | STANDARD_CLASS.finalizeClass(); |
---|
685 | ARITHMETIC_ERROR.finalizeClass(); |
---|
686 | CELL_ERROR.finalizeClass(); |
---|
687 | COMPILER_ERROR.finalizeClass(); |
---|
688 | INTERNAL_COMPILER_ERROR.finalizeClass(); |
---|
689 | COMPILER_UNSUPPORTED_FEATURE_ERROR.finalizeClass(); |
---|
690 | CONDITION.finalizeClass(); |
---|
691 | CONTROL_ERROR.finalizeClass(); |
---|
692 | DIVISION_BY_ZERO.finalizeClass(); |
---|
693 | END_OF_FILE.finalizeClass(); |
---|
694 | ERROR.finalizeClass(); |
---|
695 | FILE_ERROR.finalizeClass(); |
---|
696 | FLOATING_POINT_INEXACT.finalizeClass(); |
---|
697 | FLOATING_POINT_INVALID_OPERATION.finalizeClass(); |
---|
698 | FLOATING_POINT_OVERFLOW.finalizeClass(); |
---|
699 | FLOATING_POINT_UNDERFLOW.finalizeClass(); |
---|
700 | JAVA_EXCEPTION.finalizeClass(); |
---|
701 | PACKAGE_ERROR.finalizeClass(); |
---|
702 | PARSE_ERROR.finalizeClass(); |
---|
703 | PRINT_NOT_READABLE.finalizeClass(); |
---|
704 | PROGRAM_ERROR.finalizeClass(); |
---|
705 | READER_ERROR.finalizeClass(); |
---|
706 | SERIOUS_CONDITION.finalizeClass(); |
---|
707 | SIMPLE_CONDITION.finalizeClass(); |
---|
708 | SIMPLE_ERROR.finalizeClass(); |
---|
709 | SIMPLE_TYPE_ERROR.finalizeClass(); |
---|
710 | SIMPLE_WARNING.finalizeClass(); |
---|
711 | STORAGE_CONDITION.finalizeClass(); |
---|
712 | STREAM_ERROR.finalizeClass(); |
---|
713 | STYLE_WARNING.finalizeClass(); |
---|
714 | TYPE_ERROR.finalizeClass(); |
---|
715 | UNBOUND_SLOT.finalizeClass(); |
---|
716 | UNBOUND_VARIABLE.finalizeClass(); |
---|
717 | UNDEFINED_FUNCTION.finalizeClass(); |
---|
718 | WARNING.finalizeClass(); |
---|
719 | |
---|
720 | // SYS:SLOT-DEFINITION is constructed and finalized in |
---|
721 | // SlotDefinitionClass.java, but we need to fill in a few things here. |
---|
722 | Debug.assertTrue(SLOT_DEFINITION.isFinalized()); |
---|
723 | SLOT_DEFINITION.setCPL(SLOT_DEFINITION, STANDARD_OBJECT, |
---|
724 | BuiltInClass.CLASS_T); |
---|
725 | SLOT_DEFINITION.setDirectSlotDefinitions(SLOT_DEFINITION.getClassLayout().generateSlotDefinitions()); |
---|
726 | // There are no inherited slots. |
---|
727 | SLOT_DEFINITION.setSlotDefinitions(SLOT_DEFINITION.getDirectSlotDefinitions()); |
---|
728 | |
---|
729 | DIRECT_SLOT_DEFINITION.setCPL(DIRECT_SLOT_DEFINITION, SLOT_DEFINITION, |
---|
730 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
731 | DIRECT_SLOT_DEFINITION.finalizeClass(); |
---|
732 | EFFECTIVE_SLOT_DEFINITION.setCPL(EFFECTIVE_SLOT_DEFINITION, SLOT_DEFINITION, |
---|
733 | STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
734 | EFFECTIVE_SLOT_DEFINITION.finalizeClass(); |
---|
735 | |
---|
736 | // STANDARD-METHOD |
---|
737 | Debug.assertTrue(STANDARD_METHOD.isFinalized()); |
---|
738 | STANDARD_METHOD.setCPL(STANDARD_METHOD, METHOD, STANDARD_OBJECT, |
---|
739 | BuiltInClass.CLASS_T); |
---|
740 | STANDARD_METHOD.setDirectSlotDefinitions(STANDARD_METHOD.getClassLayout().generateSlotDefinitions()); |
---|
741 | // There are no inherited slots. |
---|
742 | STANDARD_METHOD.setSlotDefinitions(STANDARD_METHOD.getDirectSlotDefinitions()); |
---|
743 | |
---|
744 | // STANDARD-READER-METHOD |
---|
745 | Debug.assertTrue(STANDARD_READER_METHOD.isFinalized()); |
---|
746 | STANDARD_READER_METHOD.setCPL(STANDARD_READER_METHOD, STANDARD_METHOD, |
---|
747 | METHOD, STANDARD_OBJECT, BuiltInClass.CLASS_T); |
---|
748 | STANDARD_READER_METHOD.setSlotDefinitions(STANDARD_READER_METHOD.getClassLayout().generateSlotDefinitions()); |
---|
749 | // All but the last slot are inherited. |
---|
750 | STANDARD_READER_METHOD.setDirectSlotDefinitions(list(STANDARD_READER_METHOD.getSlotDefinitions().reverse().car())); |
---|
751 | |
---|
752 | // STANDARD-GENERIC-FUNCTION |
---|
753 | Debug.assertTrue(STANDARD_GENERIC_FUNCTION.isFinalized()); |
---|
754 | STANDARD_GENERIC_FUNCTION.setCPL(STANDARD_GENERIC_FUNCTION, |
---|
755 | GENERIC_FUNCTION, STANDARD_OBJECT, |
---|
756 | BuiltInClass.FUNCTION, |
---|
757 | BuiltInClass.CLASS_T); |
---|
758 | STANDARD_GENERIC_FUNCTION.setDirectSlotDefinitions(STANDARD_GENERIC_FUNCTION.getClassLayout().generateSlotDefinitions()); |
---|
759 | // There are no inherited slots. |
---|
760 | STANDARD_GENERIC_FUNCTION.setSlotDefinitions(STANDARD_GENERIC_FUNCTION.getDirectSlotDefinitions()); |
---|
761 | } |
---|
762 | } |
---|