From 3d54c11cd984ce6df5a563c57dce85765c1ab602 Mon Sep 17 00:00:00 2001
From: Rudi Schlatte <rudi@constantly.at>
Date: Mon, 2 Jan 2012 17:56:38 +0100
Subject: [PATCH 2/2] add class SPECIALIZER, splice it into mop class
 hierarchy.

---
 src/org/armedbear/lisp/Specializer.java   |   52 +++++++++++++++++++++++++++++
 src/org/armedbear/lisp/StandardClass.java |   18 ++++++----
 src/org/armedbear/lisp/Symbol.java        |    2 +
 3 files changed, 65 insertions(+), 7 deletions(-)
 create mode 100644 src/org/armedbear/lisp/Specializer.java

diff --git a/src/org/armedbear/lisp/Specializer.java b/src/org/armedbear/lisp/Specializer.java
new file mode 100644
index 0000000..5f33a20
--- /dev/null
+++ b/src/org/armedbear/lisp/Specializer.java
@@ -0,0 +1,52 @@
+/*
+ * Specializer.java
+ *
+ * Copyright (C) 2003-2005 Peter Graves, 2012 Rudolf Schlatte
+ * $Id$
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+package org.armedbear.lisp;
+
+import static org.armedbear.lisp.Lisp.*;
+
+public abstract class Specializer extends Metaobject
+{
+  protected Specializer(LispClass cls, int length)
+  {
+    super(cls, length);
+  }
+
+  @Override
+  public LispObject typep(LispObject type)
+  {
+    if (type == Symbol.SPECIALIZER)
+      return T;
+    return super.typep(type);
+  }
+}
diff --git a/src/org/armedbear/lisp/StandardClass.java b/src/org/armedbear/lisp/StandardClass.java
index 6698ce1..b808440 100644
--- a/src/org/armedbear/lisp/StandardClass.java
+++ b/src/org/armedbear/lisp/StandardClass.java
@@ -387,6 +387,8 @@ public class StandardClass extends SlotClass
     addStandardClass(Symbol.STANDARD_OBJECT, list(BuiltInClass.CLASS_T));
   public static final StandardClass METAOBJECT =
     addStandardClass(Symbol.METAOBJECT, list(STANDARD_OBJECT));
+  public static final StandardClass SPECIALIZER =
+    addStandardClass(Symbol.SPECIALIZER, list(METAOBJECT));
 
     public static final StandardClass SLOT_DEFINITION =
         addStandardClass(Symbol.SLOT_DEFINITION, list(METAOBJECT));
@@ -422,7 +424,7 @@ public class StandardClass extends SlotClass
                                                    BuiltInClass.FUNCTION));
 
   public static final StandardClass CLASS =
-    addStandardClass(Symbol.CLASS, list(STANDARD_OBJECT));
+    addStandardClass(Symbol.CLASS, list(SPECIALIZER));
 
   public static final StandardClass BUILT_IN_CLASS =
     addStandardClass(Symbol.BUILT_IN_CLASS, list(CLASS));
@@ -578,14 +580,14 @@ public class StandardClass extends SlotClass
                                list(PACKAGE_CL.intern("ARITHMETIC-ERROR-OPERATION"))),
             new SlotDefinition(Symbol.OPERANDS,
                                list(PACKAGE_CL.intern("ARITHMETIC-ERROR-OPERANDS")))));
-    BUILT_IN_CLASS.setCPL(BUILT_IN_CLASS, CLASS, STANDARD_OBJECT,
+    BUILT_IN_CLASS.setCPL(BUILT_IN_CLASS, CLASS, SPECIALIZER, METAOBJECT, STANDARD_OBJECT,
                           BuiltInClass.CLASS_T);
     CELL_ERROR.setCPL(CELL_ERROR, ERROR, SERIOUS_CONDITION, CONDITION,
                       STANDARD_OBJECT, BuiltInClass.CLASS_T);
     CELL_ERROR.setDirectSlotDefinitions(
       list(new SlotDefinition(Symbol.NAME,
                                list(Symbol.CELL_ERROR_NAME))));
-    CLASS.setCPL(CLASS, STANDARD_OBJECT, BuiltInClass.CLASS_T);
+    CLASS.setCPL(CLASS, SPECIALIZER, METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     COMPILER_ERROR.setCPL(COMPILER_ERROR, CONDITION, STANDARD_OBJECT,
                           BuiltInClass.CLASS_T);
     INTERNAL_COMPILER_ERROR.setCPL(INTERNAL_COMPILER_ERROR, CONDITION, STANDARD_OBJECT,
@@ -632,7 +634,7 @@ public class StandardClass extends SlotClass
                                     ERROR, SERIOUS_CONDITION, CONDITION,
                                     STANDARD_OBJECT, BuiltInClass.CLASS_T);
     FORWARD_REFERENCED_CLASS.setCPL(FORWARD_REFERENCED_CLASS, CLASS,
-                                    BuiltInClass.CLASS_T);
+                                    SPECIALIZER, METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     GENERIC_FUNCTION.setCPL(GENERIC_FUNCTION, METAOBJECT, STANDARD_OBJECT,
                             BuiltInClass.FUNCTION,
                             BuiltInClass.CLASS_T);
@@ -641,6 +643,7 @@ public class StandardClass extends SlotClass
     JAVA_EXCEPTION.setDirectSlotDefinitions(
       list(new SlotDefinition(Symbol.CAUSE, list(Symbol.JAVA_EXCEPTION_CAUSE))));
     METAOBJECT.setCPL(METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
+    SPECIALIZER.setCPL(SPECIALIZER, METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     METHOD.setCPL(METHOD, METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     PACKAGE_ERROR.setCPL(PACKAGE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION,
                          STANDARD_OBJECT, BuiltInClass.CLASS_T);
@@ -674,7 +677,7 @@ public class StandardClass extends SlotClass
     SIMPLE_WARNING.setDirectSuperclasses(list(SIMPLE_CONDITION, WARNING));
     SIMPLE_WARNING.setCPL(SIMPLE_WARNING, SIMPLE_CONDITION, WARNING,
                           CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T);
-    STANDARD_CLASS.setCPL(STANDARD_CLASS, CLASS,
+    STANDARD_CLASS.setCPL(STANDARD_CLASS, CLASS, SPECIALIZER, METAOBJECT,
                           STANDARD_OBJECT, BuiltInClass.CLASS_T);
     STANDARD_OBJECT.setCPL(STANDARD_OBJECT, BuiltInClass.CLASS_T);
     STORAGE_CONDITION.setCPL(STORAGE_CONDITION, SERIOUS_CONDITION, CONDITION,
@@ -684,8 +687,8 @@ public class StandardClass extends SlotClass
     STREAM_ERROR.setDirectSlotDefinitions(
       list(new SlotDefinition(Symbol.STREAM,
                                list(PACKAGE_CL.intern("STREAM-ERROR-STREAM")))));
-    STRUCTURE_CLASS.setCPL(STRUCTURE_CLASS, CLASS, STANDARD_OBJECT,
-                           BuiltInClass.CLASS_T);
+    STRUCTURE_CLASS.setCPL(STRUCTURE_CLASS, CLASS, SPECIALIZER, METAOBJECT,
+                           STANDARD_OBJECT, BuiltInClass.CLASS_T);
     STYLE_WARNING.setCPL(STYLE_WARNING, WARNING, CONDITION, STANDARD_OBJECT,
                          BuiltInClass.CLASS_T);
     TYPE_ERROR.setCPL(TYPE_ERROR, ERROR, SERIOUS_CONDITION, CONDITION,
@@ -729,6 +732,7 @@ public class StandardClass extends SlotClass
     FLOATING_POINT_UNDERFLOW.finalizeClass();
     JAVA_EXCEPTION.finalizeClass();
     METAOBJECT.finalizeClass();
+    SPECIALIZER.finalizeClass();
     PACKAGE_ERROR.finalizeClass();
     PARSE_ERROR.finalizeClass();
     PRINT_NOT_READABLE.finalizeClass();
diff --git a/src/org/armedbear/lisp/Symbol.java b/src/org/armedbear/lisp/Symbol.java
index 055407d..4c4a03b 100644
--- a/src/org/armedbear/lisp/Symbol.java
+++ b/src/org/armedbear/lisp/Symbol.java
@@ -2969,6 +2969,8 @@ public class Symbol extends LispObject implements java.io.Serializable
     PACKAGE_MOP.addInternalSymbol("CLASS-PRECEDENCE-LIST");
   public static final Symbol METAOBJECT =
     PACKAGE_MOP.addExternalSymbol("METAOBJECT");
+  public static final Symbol SPECIALIZER =
+    PACKAGE_MOP.addExternalSymbol("SPECIALIZER");
   public static final Symbol STANDARD_READER_METHOD =
     PACKAGE_MOP.addExternalSymbol("STANDARD-READER-METHOD");
   public static final Symbol DIRECT_SLOT_DEFINITION =
-- 
1.7.5.4

