[armedbear-cvs] r13713 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Wed Jan 4 13:44:29 UTC 2012


Author: mevenson
Date: Wed Jan  4 05:44:27 2012
New Revision: 13713

Log:
[PATCH 1/2] add class METAOBJECT, splice it into mop class

>From 0d36155221ec6ac028cde6ba3741253e618773e9 Mon Sep 17 00:00:00 2001
 hierarchy.
... see AMOP table 5.1
---
 src/org/armedbear/lisp/GenericFunction.java |    2 +-
 src/org/armedbear/lisp/Metaobject.java      |   52 +++++++++++++++++++++++++++
 src/org/armedbear/lisp/StandardClass.java   |   40 ++++++++++++---------
 src/org/armedbear/lisp/Symbol.java          |    2 +
 4 files changed, 78 insertions(+), 18 deletions(-)
 create mode 100644 src/org/armedbear/lisp/Metaobject.java

Added:
   trunk/abcl/src/org/armedbear/lisp/Metaobject.java
Modified:
   trunk/abcl/src/org/armedbear/lisp/GenericFunction.java
   trunk/abcl/src/org/armedbear/lisp/StandardClass.java
   trunk/abcl/src/org/armedbear/lisp/Symbol.java

Modified: trunk/abcl/src/org/armedbear/lisp/GenericFunction.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/GenericFunction.java	Sun Jan  1 13:29:05 2012	(r13712)
+++ trunk/abcl/src/org/armedbear/lisp/GenericFunction.java	Wed Jan  4 05:44:27 2012	(r13713)
@@ -35,7 +35,7 @@
 
 import static org.armedbear.lisp.Lisp.*;
 
-public abstract class GenericFunction extends StandardObject
+public abstract class GenericFunction extends Metaobject
 {
     protected GenericFunction(LispClass cls, int length)
     {

Added: trunk/abcl/src/org/armedbear/lisp/Metaobject.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/abcl/src/org/armedbear/lisp/Metaobject.java	Wed Jan  4 05:44:27 2012	(r13713)
@@ -0,0 +1,52 @@
+/*
+ * Metaobject.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 Metaobject extends StandardObject
+{
+  protected Metaobject(LispClass cls, int length)
+  {
+    super(cls, length);
+  }
+
+  @Override
+  public LispObject typep(LispObject type)
+  {
+    if (type == Symbol.METAOBJECT)
+      return T;
+    return super.typep(type);
+  }
+}

Modified: trunk/abcl/src/org/armedbear/lisp/StandardClass.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/StandardClass.java	Sun Jan  1 13:29:05 2012	(r13712)
+++ trunk/abcl/src/org/armedbear/lisp/StandardClass.java	Wed Jan  4 05:44:27 2012	(r13713)
@@ -385,9 +385,11 @@
     addStandardClass(Symbol.STANDARD_CLASS, list(BuiltInClass.CLASS_T));
   public static final StandardClass STANDARD_OBJECT =
     addStandardClass(Symbol.STANDARD_OBJECT, list(BuiltInClass.CLASS_T));
+  public static final StandardClass METAOBJECT =
+    addStandardClass(Symbol.METAOBJECT, list(STANDARD_OBJECT));
 
     public static final StandardClass SLOT_DEFINITION =
-        addStandardClass(Symbol.SLOT_DEFINITION, list(STANDARD_OBJECT));
+        addStandardClass(Symbol.SLOT_DEFINITION, list(METAOBJECT));
     public static final StandardClass STANDARD_SLOT_DEFINITION =
         addClass(Symbol.STANDARD_SLOT_DEFINITION, new SlotDefinitionClass(Symbol.STANDARD_SLOT_DEFINITION, list(SLOT_DEFINITION)));
 
@@ -416,8 +418,8 @@
 
   // BuiltInClass.FUNCTION is also null here (see previous comment).
   public static final StandardClass GENERIC_FUNCTION =
-    addStandardClass(Symbol.GENERIC_FUNCTION, list(BuiltInClass.FUNCTION,
-                                                    STANDARD_OBJECT));
+    addStandardClass(Symbol.GENERIC_FUNCTION, list(METAOBJECT,
+                                                   BuiltInClass.FUNCTION));
 
   public static final StandardClass CLASS =
     addStandardClass(Symbol.CLASS, list(STANDARD_OBJECT));
@@ -536,7 +538,7 @@
     addStandardClass(Symbol.JAVA_EXCEPTION, list(ERROR));
 
   public static final StandardClass METHOD =
-    addStandardClass(Symbol.METHOD, list(STANDARD_OBJECT));
+    addStandardClass(Symbol.METHOD, list(METAOBJECT));
 
   public static final StandardClass STANDARD_METHOD =
     new StandardMethodClass();
@@ -566,8 +568,8 @@
     // STANDARD_OBJECT).
     STANDARD_CLASS.setDirectSuperclass(CLASS);
     STANDARD_OBJECT.setDirectSuperclass(BuiltInClass.CLASS_T);
-    GENERIC_FUNCTION.setDirectSuperclasses(list(BuiltInClass.FUNCTION,
-                                                 STANDARD_OBJECT));
+    GENERIC_FUNCTION.setDirectSuperclasses(list(METAOBJECT,
+                                                BuiltInClass.FUNCTION));
 
     ARITHMETIC_ERROR.setCPL(ARITHMETIC_ERROR, ERROR, SERIOUS_CONDITION,
                             CONDITION, STANDARD_OBJECT, BuiltInClass.CLASS_T);
@@ -631,14 +633,15 @@
                                     STANDARD_OBJECT, BuiltInClass.CLASS_T);
     FORWARD_REFERENCED_CLASS.setCPL(FORWARD_REFERENCED_CLASS, CLASS,
                                     BuiltInClass.CLASS_T);
-    GENERIC_FUNCTION.setCPL(GENERIC_FUNCTION, STANDARD_OBJECT,
+    GENERIC_FUNCTION.setCPL(GENERIC_FUNCTION, METAOBJECT, STANDARD_OBJECT,
                             BuiltInClass.FUNCTION,
                             BuiltInClass.CLASS_T);
     JAVA_EXCEPTION.setCPL(JAVA_EXCEPTION, ERROR, SERIOUS_CONDITION, CONDITION,
                           STANDARD_OBJECT, BuiltInClass.CLASS_T);
     JAVA_EXCEPTION.setDirectSlotDefinitions(
       list(new SlotDefinition(Symbol.CAUSE, list(Symbol.JAVA_EXCEPTION_CAUSE))));
-    METHOD.setCPL(METHOD, STANDARD_OBJECT, BuiltInClass.CLASS_T);
+    METAOBJECT.setCPL(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);
     PACKAGE_ERROR.setDirectSlotDefinitions(
@@ -725,6 +728,7 @@
     FLOATING_POINT_OVERFLOW.finalizeClass();
     FLOATING_POINT_UNDERFLOW.finalizeClass();
     JAVA_EXCEPTION.finalizeClass();
+    METAOBJECT.finalizeClass();
     PACKAGE_ERROR.finalizeClass();
     PARSE_ERROR.finalizeClass();
     PRINT_NOT_READABLE.finalizeClass();
@@ -747,33 +751,33 @@
     // SYS:SLOT-DEFINITION is constructed and finalized in
     // SlotDefinitionClass.java, but we need to fill in a few things here.
     Debug.assertTrue(SLOT_DEFINITION.isFinalized());
-    SLOT_DEFINITION.setCPL(SLOT_DEFINITION, STANDARD_OBJECT,
+    SLOT_DEFINITION.setCPL(SLOT_DEFINITION, METAOBJECT, STANDARD_OBJECT,
                            BuiltInClass.CLASS_T);
     SLOT_DEFINITION.setDirectSlotDefinitions(SLOT_DEFINITION.getClassLayout().generateSlotDefinitions());
     // There are no inherited slots.
     SLOT_DEFINITION.setSlotDefinitions(SLOT_DEFINITION.getDirectSlotDefinitions());
 
     DIRECT_SLOT_DEFINITION.setCPL(DIRECT_SLOT_DEFINITION, SLOT_DEFINITION,
-                                  STANDARD_OBJECT, BuiltInClass.CLASS_T);
+                                  METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     DIRECT_SLOT_DEFINITION.finalizeClass();
     EFFECTIVE_SLOT_DEFINITION.setCPL(EFFECTIVE_SLOT_DEFINITION, SLOT_DEFINITION,
-                                     STANDARD_OBJECT, BuiltInClass.CLASS_T);
+                                     METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     EFFECTIVE_SLOT_DEFINITION.finalizeClass();
     STANDARD_SLOT_DEFINITION.setCPL(STANDARD_SLOT_DEFINITION, SLOT_DEFINITION,
-                                    STANDARD_OBJECT, BuiltInClass.CLASS_T);
+                                    METAOBJECT, STANDARD_OBJECT, BuiltInClass.CLASS_T);
     STANDARD_SLOT_DEFINITION.finalizeClass();
     STANDARD_DIRECT_SLOT_DEFINITION.setCPL(STANDARD_DIRECT_SLOT_DEFINITION, STANDARD_SLOT_DEFINITION,
-                                           DIRECT_SLOT_DEFINITION, SLOT_DEFINITION, STANDARD_OBJECT,
+                                           DIRECT_SLOT_DEFINITION, SLOT_DEFINITION, METAOBJECT, STANDARD_OBJECT,
                                            BuiltInClass.CLASS_T);
     STANDARD_DIRECT_SLOT_DEFINITION.finalizeClass();
     STANDARD_EFFECTIVE_SLOT_DEFINITION.setCPL(STANDARD_EFFECTIVE_SLOT_DEFINITION, STANDARD_SLOT_DEFINITION,
-                                              EFFECTIVE_SLOT_DEFINITION, SLOT_DEFINITION, STANDARD_OBJECT,
+                                              EFFECTIVE_SLOT_DEFINITION, SLOT_DEFINITION, METAOBJECT, STANDARD_OBJECT,
                                               BuiltInClass.CLASS_T);
     STANDARD_EFFECTIVE_SLOT_DEFINITION.finalizeClass();
 
     // STANDARD-METHOD
     Debug.assertTrue(STANDARD_METHOD.isFinalized());
-    STANDARD_METHOD.setCPL(STANDARD_METHOD, METHOD, STANDARD_OBJECT,
+    STANDARD_METHOD.setCPL(STANDARD_METHOD, METHOD, METAOBJECT, STANDARD_OBJECT,
                            BuiltInClass.CLASS_T);
     STANDARD_METHOD.setDirectSlotDefinitions(STANDARD_METHOD.getClassLayout().generateSlotDefinitions());
     // There are no inherited slots.
@@ -782,7 +786,8 @@
     // STANDARD-READER-METHOD
     Debug.assertTrue(STANDARD_READER_METHOD.isFinalized());
     STANDARD_READER_METHOD.setCPL(STANDARD_READER_METHOD, STANDARD_METHOD,
-                                  METHOD, STANDARD_OBJECT, BuiltInClass.CLASS_T);
+                                  METHOD, METAOBJECT, STANDARD_OBJECT,
+                                  BuiltInClass.CLASS_T);
     STANDARD_READER_METHOD.setSlotDefinitions(STANDARD_READER_METHOD.getClassLayout().generateSlotDefinitions());
     // All but the last slot are inherited.
     STANDARD_READER_METHOD.setDirectSlotDefinitions(list(STANDARD_READER_METHOD.getSlotDefinitions().reverse().car()));
@@ -790,7 +795,8 @@
     // STANDARD-GENERIC-FUNCTION
     Debug.assertTrue(STANDARD_GENERIC_FUNCTION.isFinalized());
     STANDARD_GENERIC_FUNCTION.setCPL(STANDARD_GENERIC_FUNCTION,
-                                     GENERIC_FUNCTION, STANDARD_OBJECT,
+                                     GENERIC_FUNCTION, METAOBJECT,
+                                     STANDARD_OBJECT,
                                      BuiltInClass.FUNCTION,
                                      BuiltInClass.CLASS_T);
     STANDARD_GENERIC_FUNCTION.setDirectSlotDefinitions(STANDARD_GENERIC_FUNCTION.getClassLayout().generateSlotDefinitions());

Modified: trunk/abcl/src/org/armedbear/lisp/Symbol.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Symbol.java	Sun Jan  1 13:29:05 2012	(r13712)
+++ trunk/abcl/src/org/armedbear/lisp/Symbol.java	Wed Jan  4 05:44:27 2012	(r13713)
@@ -2967,6 +2967,8 @@
     PACKAGE_MOP.addInternalSymbol("CLASS-LAYOUT");
   public static final Symbol CLASS_PRECEDENCE_LIST =
     PACKAGE_MOP.addInternalSymbol("CLASS-PRECEDENCE-LIST");
+  public static final Symbol METAOBJECT =
+    PACKAGE_MOP.addExternalSymbol("METAOBJECT");
   public static final Symbol STANDARD_READER_METHOD =
     PACKAGE_MOP.addExternalSymbol("STANDARD-READER-METHOD");
   public static final Symbol DIRECT_SLOT_DEFINITION =




More information about the armedbear-cvs mailing list