public final class StandardGenericFunction extends StandardObject
Modifier and Type | Class and Description |
---|---|
private static class |
StandardGenericFunction.CacheEntry |
private static class |
StandardGenericFunction.EqlSpecialization |
layout, slots
Constructor and Description |
---|
StandardGenericFunction() |
StandardGenericFunction(String name,
Package pkg,
boolean exported,
Function function,
LispObject lambdaList,
LispObject specializers) |
checkStandardObject, classOf, getInstanceSlotValue, getLispClass, getParts, setInstanceSlotValue, setSlotValue, SLOT_VALUE, typeOf, updateLayout
ABS, add, add, aref_long, aref, AREF, AREF, aset, aset, aset, ash, ash, atom, ATOM, caddr, cadr, car, cddr, cdr, CHAR, characterp, CHARACTERP, chars, COMPLEXP, constantp, CONSTANTP, copyToArray, decr, DENOMINATOR, dispatch, divideBy, doubleValue, elt, endp, ENDP, EQ, eql, eql, eql, EQL, equal, equal, EQUAL, equalp, equalp, evenp, EVENP, execute, floatp, FLOATP, floatValue, getBooleanValue, getDescription, getDocumentation, getFixnumSlotValue, getInstance, getPropertyList, getSlotValue_0, getSlotValue_1, getSlotValue_2, getSlotValue_3, getSlotValue, getSlotValueAsBoolean, getStringChars, getStringValue, getSymbolFunction, getSymbolFunctionOrDie, getSymbolSetfFunction, getSymbolSetfFunctionOrDie, getSymbolValue, incr, integerp, INTEGERP, intValue, IS_E, IS_GE, IS_GT, IS_LE, IS_LT, IS_NE, isEqualTo, isEqualTo, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNotEqualTo, isNotEqualTo, isSpecialOperator, isSpecialVariable, javaInstance, javaInstance, LDB, length, LENGTH, listp, LISTP, lockableInstance, LOGAND, LOGAND, LOGIOR, LOGIOR, LOGNOT, LOGXOR, LOGXOR, longValue, minusp, MINUSP, MOD, MOD, multiplyBy, multiplyBy, negate, noFillPointer, NOT, nreverse, NTH, NTH, nthcdr, numberp, NUMBERP, NUMERATOR, oddp, ODDP, plusp, PLUSP, psxhash, psxhash, push, rationalp, RATIONALP, realp, REALP, resolve, reverse, RPLACA, RPLACD, SCHAR, setCar, setCdr, setDocumentation, setPropertyList, setSlotValue_0, setSlotValue_1, setSlotValue_2, setSlotValue_3, setSlotValue, SIMPLE_STRING_P, STRING, stringp, STRINGP, subtract, subtract, SVREF, svset, sxhash, SYMBOLP, truncate, unreadableString, unreadableString, unreadableString, unreadableString, VECTOR_PUSH_EXTEND, VECTOR_PUSH_EXTEND, vectorp, VECTORP, vectorPushExtend, zerop, ZEROP
LispObject function
int numberOfRequiredArgs
ConcurrentHashMap<LispObject,LispObject> slotCache
private int callCount
private int hotCount
private static final Primitive _GENERIC_FUNCTION_NAME
private static final Primitive _SET_GENERIC_FUNCTION_NAME
private static final Primitive _GENERIC_FUNCTION_LAMBDA_LIST
private static final Primitive _SET_GENERIC_FUNCTION_LAMBDA_LIST
private static final Primitive FUNCALLABLE_INSTANCE_FUNCTION
private static final Primitive SET_FUNCALLABLE_INSTANCE_FUNCTION
private static final Primitive GF_REQUIRED_ARGS
private static final Primitive _SET_GF_REQUIRED_ARGS
private static final Primitive GENERIC_FUNCTION_INITIAL_METHODS
private static final Primitive SET_GENERIC_FUNCTION_INITIAL_METHODS
private static final Primitive GENERIC_FUNCTION_METHODS
private static final Primitive SET_GENERIC_FUNCTION_METHODS
private static final Primitive GENERIC_FUNCTION_METHOD_CLASS
private static final Primitive SET_GENERIC_FUNCTION_METHOD_CLASS
private static final Primitive GENERIC_FUNCTION_METHOD_COMBINATION
private static final Primitive SET_GENERIC_FUNCTION_METHOD_COMBINATION
private static final Primitive GENERIC_FUNCTION_ARGUMENT_PRECEDENCE_ORDER
private static final Primitive SET_GENERIC_FUNCTION_ARGUMENT_PRECEDENCE_ORDER
private static final Primitive GENERIC_FUNCTION_CLASSES_TO_EMF_TABLE
private static final Primitive SET_GENERIC_FUNCTION_CLASSES_TO_EMF_TABLE
private static final Primitive GENERIC_FUNCTION_DOCUMENTATION
private static final Primitive SET_GENERIC_FUNCTION_DOCUMENTATION
private static final Primitive _FINALIZE_GENERIC_FUNCTION
private static final Primitive CACHE_EMF
private static final Primitive GET_CACHED_EMF
private static final Primitive _GET_ARG_SPECIALIZATION
private static final Primitive CACHE_SLOT_LOCATION
private static final Primitive GET_CACHED_SLOT_LOCATION
private static final StandardGenericFunction GENERIC_FUNCTION_NAME
StandardGenericFunction.EqlSpecialization[] eqlSpecializations
private static final Primitive _INIT_EQL_SPECIALIZATIONS
public StandardGenericFunction()
public StandardGenericFunction(String name, Package pkg, boolean exported, Function function, LispObject lambdaList, LispObject specializers)
void finalizeInternal()
public LispObject typep(LispObject type)
typep
in class StandardObject
public LispObject getGenericFunctionName()
public void setGenericFunctionName(LispObject name)
public LispObject execute()
execute
in class LispObject
public LispObject execute(LispObject arg)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third, LispObject fourth)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third, LispObject fourth, LispObject fifth)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third, LispObject fourth, LispObject fifth, LispObject sixth)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third, LispObject fourth, LispObject fifth, LispObject sixth, LispObject seventh)
execute
in class LispObject
public LispObject execute(LispObject first, LispObject second, LispObject third, LispObject fourth, LispObject fifth, LispObject sixth, LispObject seventh, LispObject eighth)
execute
in class LispObject
public LispObject execute(LispObject[] args)
execute
in class LispObject
public String writeToString()
writeToString
in class StandardObject
public final int getCallCount()
getCallCount
in class LispObject
public void setCallCount(int n)
setCallCount
in class LispObject
public final void incrementCallCount()
incrementCallCount
in class LispObject
public final int getHotCount()
getHotCount
in class LispObject
public void setHotCount(int n)
setHotCount
in class LispObject
public final void incrementHotCount()
incrementHotCount
in class LispObject
LispObject getArgSpecialization(LispObject arg)
In the simplest case, when this generic function does not have EQL specialized methods, and therefore only argument types are relevant for choosing applicable methods, the value returned is the class of arg
If the function has EQL specialized methods: - if arg is EQL to some of the EQL-specializers, a special object representing equality to that specializer is returned. - otherwise class of the arg is returned.
Note that we do not consider argument position, when calculating arg specialization. In rare cases (when one argument is eql-specialized to a symbol specifying class of another argument) this may result in redundant cache entries caching the same method. But the method cached is anyway correct for the arguments (because in case of cache miss, correct method is calculated by other code, which does not rely on getArgSpecialization; and because EQL is true only for objects of the same type, which guaranties that if a type-specialized methods was chached by eql-specialization, all the cache hits into this records will be from args of the conforming type).
Consider:
(defgeneric f (a b)) (defmethod f (a (b (eql 'symbol))) "T (EQL 'SYMBOL)") (defmethod f ((a symbol) (b (eql 'symbol))) "SYMBOL (EQL 'SYMBOL)") (f 12 'symbol) => "T (EQL 'SYMBOL)" (f 'twelve 'symbol) => "SYMBOL (EQL 'SYMBOL)" (f 'symbol 'symbol) => "SYMBOL (EQL 'SYMBOL)"After the two above calls cache will contain three keys:
{ class FIXNUM, EqlSpecialization('SYMBOL) } { class SYMBOL, EqlSpecialization('SYMBOL) } { EqlSpecialization('SYMBOL), EqlSpecialization('SYMBOL) }.
public static final StandardGenericFunction checkStandardGenericFunction(LispObject obj)