Commit 210dff79 authored by rschlatte@1c010e3e-69d0-11dd-93a8-456734b0d56f's avatar rschlatte@1c010e3e-69d0-11dd-93a8-456734b0d56f
Browse files

Remove StandardGenericFunction class

parent 64e9d49b
......@@ -53,11 +53,11 @@ public final class EMFCache extends LispObject
return unreadableString("EMF-CACHE");
}
static final StandardGenericFunction checkStandardGenericFunction(LispObject obj)
static final FuncallableStandardObject checkStandardGenericFunction(LispObject obj)
{
if (obj instanceof StandardGenericFunction)
return (StandardGenericFunction) obj;
return (StandardGenericFunction) // Not reached.
if (obj instanceof FuncallableStandardObject)
return (FuncallableStandardObject) obj;
return (FuncallableStandardObject) // Not reached.
type_error(obj, Symbol.STANDARD_GENERIC_FUNCTION);
}
......@@ -135,7 +135,7 @@ public final class EMFCache extends LispObject
@Override
public LispObject execute(LispObject generic_function, LispObject eql_specializers)
{
final StandardGenericFunction gf = checkStandardGenericFunction(generic_function);
final FuncallableStandardObject gf = checkStandardGenericFunction(generic_function);
EMFCache cache = gf.cache;
cache.clearCache();
cache.eqlSpecializations = new EqlSpecialization[eql_specializers.length()];
......@@ -161,7 +161,7 @@ public final class EMFCache extends LispObject
public LispObject execute(LispObject first, LispObject second,
LispObject third)
{
final StandardGenericFunction gf = checkStandardGenericFunction(first);
final FuncallableStandardObject gf = checkStandardGenericFunction(first);
EMFCache cache = gf.cache;
LispObject args = second;
int numberOfRequiredArgs
......@@ -191,7 +191,7 @@ public final class EMFCache extends LispObject
@Override
public LispObject execute(LispObject first, LispObject second)
{
final StandardGenericFunction gf = checkStandardGenericFunction(first);
final FuncallableStandardObject gf = checkStandardGenericFunction(first);
EMFCache cache = gf.cache;
LispObject args = second;
int numberOfRequiredArgs
......
......@@ -42,6 +42,10 @@ public class FuncallableStandardObject extends StandardObject
{
LispObject function;
// KLUDGE: this is only needed for generic functions, but doesn't hurt
// to have it here.
EMFCache cache = new EMFCache();
protected FuncallableStandardObject()
{
super();
......@@ -189,11 +193,23 @@ public class FuncallableStandardObject extends StandardObject
return program_error("Invalid standard class layout for: "
+ arg.princToString() + ".");
}
FuncallableStandardObject o = new FuncallableStandardObject((Layout)l);
if (arg == StandardClass.STANDARD_GENERIC_FUNCTION || Symbol.SUBTYPEP.execute(arg, StandardClass.STANDARD_GENERIC_FUNCTION) != NIL) {
return new StandardGenericFunction((Layout)l);
} else {
return new FuncallableStandardObject((Layout)l);
// KLUDGE: this initialization should be moved Lisp-side
o.setInstanceSlotValue(Symbol.NAME, NIL);
o.setInstanceSlotValue(Symbol.LAMBDA_LIST, NIL);
o.setInstanceSlotValue(Symbol.REQUIRED_ARGS, NIL);
o.setInstanceSlotValue(Symbol.OPTIONAL_ARGS, NIL);
o.setInstanceSlotValue(Symbol.INITIAL_METHODS, NIL);
o.setInstanceSlotValue(Symbol.METHODS, NIL);
o.setInstanceSlotValue(Symbol.METHOD_CLASS, StandardClass.STANDARD_METHOD);
// method combination class set by clos.lisp:shared-initialize :after
o.setInstanceSlotValue(Symbol._METHOD_COMBINATION, list(Symbol.STANDARD));
o.setInstanceSlotValue(Symbol.ARGUMENT_PRECEDENCE_ORDER, NIL);
o.setInstanceSlotValue(Symbol.DECLARATIONS, NIL);
o.setInstanceSlotValue(Symbol._DOCUMENTATION, NIL);
}
return o;
}
return type_error(arg, Symbol.FUNCALLABLE_STANDARD_CLASS);
}
......
/*
* StandardGenericFunction.java
*
* Copyright (C) 2003-2006 Peter Graves
* $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 final class StandardGenericFunction extends FuncallableStandardObject
{
EMFCache cache = new EMFCache();
public StandardGenericFunction()
{
this(StandardClass.STANDARD_GENERIC_FUNCTION.getClassLayout());
}
public StandardGenericFunction(Layout layout)
{
super(layout);
setInstanceSlotValue(Symbol.NAME, NIL);
setInstanceSlotValue(Symbol.LAMBDA_LIST, NIL);
setInstanceSlotValue(Symbol.REQUIRED_ARGS, NIL);
setInstanceSlotValue(Symbol.OPTIONAL_ARGS, NIL);
setInstanceSlotValue(Symbol.INITIAL_METHODS, NIL);
setInstanceSlotValue(Symbol.METHODS, NIL);
setInstanceSlotValue(Symbol.METHOD_CLASS, StandardClass.STANDARD_METHOD);
// method combination class set by clos.lisp:shared-initialize :after
setInstanceSlotValue(Symbol._METHOD_COMBINATION, list(Symbol.STANDARD));
setInstanceSlotValue(Symbol.ARGUMENT_PRECEDENCE_ORDER, NIL);
setInstanceSlotValue(Symbol.DECLARATIONS, NIL);
setInstanceSlotValue(Symbol._DOCUMENTATION, NIL);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment