Package gnu.mapping
Class MethodProc
java.lang.Object
gnu.mapping.PropertySet
gnu.mapping.Procedure
gnu.mapping.ProcedureN
gnu.mapping.MethodProc
- All Implemented Interfaces:
Named
- Direct Known Subclasses:
AppendValues,Attributes,CallCC,Children,CommentConstructor,CompiledProc,Continuation,GenericProc,IteratorItems,LambdaExp.Closure,ListItems,MakeCDATA,MakeResponseHeader,NodeConstructor,OrderedMap,PrimProcedure,RelativeStep,TreeScanner,TypeSwitch,ValuesFilter,ValuesMap
Similar to a CLOS method.
Can check if arguments "match" before committing to calling method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MethodHandleprotected ObjectThe parameter types.static final intReturn code from match: Unspecified failure.static final intReturn code from match: Ambigious which method to select.static final intReturn code from match: Invalid argument type.static final intstatic final intReturn code from match: Too few actual arguments.static final intReturn code from match: Too many actual arguments.static final intReturn code from match: Unused keyword argument.static final intFields inherited from class gnu.mapping.ProcedureN
applyToObject, noArgsFields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKeyFields inherited from class gnu.mapping.PropertySet
nameKey -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectapplyToConsumerDefaultMP(Procedure proc, CallContext ctx) getParameterType(int index) intisApplicable(Type[] argTypes, Type restType) Test if method is applicable to an invocation with given arguments.static RuntimeExceptionmatchFailAsException(int code, Procedure proc, ArgList args) Helper method to throw an exception if amatchXmethod fails.static MethodProcmostSpecific(MethodProc proc1, MethodProc proc2) Return the more specific of the arguments.intReturn number of parameters, including optional and rest arguments.static booleanoverrideEquivalent(MethodProc proc1, MethodProc proc2) An approximation of "override-equivalent" as defined in the JLS.protected voidFigure out or decode the parameter types, setting argTypes.Methods inherited from class gnu.mapping.ProcedureN
applyToObjectMethods inherited from class gnu.mapping.Procedure
apply0, apply1, apply2, apply3, apply4, applyL, applyN, applyToConsumerDefault, applyToObjectDefault, checkArgCount, checkBadCode, getApplyMethod, getApplyToConsumerMethod, getApplyToObjectMethod, getReturnType, getSetter, getSourceLocation, isSideEffectFree, lookupApplyHandle, maxArgs, maxArgs, minArgs, minArgs, numArgs, set0, set1, setN, setSetter, setSourceLocation, toStringMethods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
Field Details
-
argTypes
The parameter types. Usually either an Type[] or a String encoding. -
THROW_ON_EXCEPTION
public static final int THROW_ON_EXCEPTION- See Also:
-
NO_MATCH
public static final int NO_MATCHReturn code from match: Unspecified failure.- See Also:
-
NO_MATCH_TOO_FEW_ARGS
public static final int NO_MATCH_TOO_FEW_ARGSReturn code from match: Too few actual arguments. The lower half is the minimum number of arguments (if not 0xffff).- See Also:
-
NO_MATCH_TOO_MANY_ARGS
public static final int NO_MATCH_TOO_MANY_ARGSReturn code from match: Too many actual arguments. The lower half is the maximum number of arguments (if not 0xffff).- See Also:
-
NO_MATCH_AMBIGUOUS
public static final int NO_MATCH_AMBIGUOUSReturn code from match: Ambigious which method to select.- See Also:
-
NO_MATCH_BAD_TYPE
public static final int NO_MATCH_BAD_TYPEReturn code from match: Invalid argument type. In that case the lower half is the 1-origin index of the first argument that does not match.- See Also:
-
NO_MATCH_UNUSED_KEYWORD
public static final int NO_MATCH_UNUSED_KEYWORDReturn code from match: Unused keyword argument. I.e. a keyword in the call doesn't match a keyword parameter. In that case the lower half is the 1-origin index of the first keyword argument that does not match.- See Also:
-
NO_MATCH_GUARD_FALSE
public static final int NO_MATCH_GUARD_FALSE- See Also:
-
applyToConsumerDefaultMP
-
-
Constructor Details
-
MethodProc
public MethodProc() -
MethodProc
-
-
Method Details
-
isApplicable
Test if method is applicable to an invocation with given arguments.- Parameters:
argTypes- array of known "single" arguments.restType- If null, the arguments are fully specified by argTypes. If non-null, there may be an unknown number of extra arguments of the given restType. This is used for splices, where we usually don't know at compile-time how many argument values we have.- Returns:
- -1 if no; 1 if yes; 0 if need to check at run-time.
-
numParameters
public int numParameters()Return number of parameters, including optional and rest arguments. -
resolveParameterTypes
protected void resolveParameterTypes()Figure out or decode the parameter types, setting argTypes. -
getParameterType
-
matchFailAsException
Helper method to throw an exception if amatchXmethod fails. -
mostSpecific
Return the more specific of the arguments.- Returns:
- null if neither is more specific.
-
overrideEquivalent
An approximation of "override-equivalent" as defined in the JLS. -
applyToConsumerDefaultMP
- Throws:
Throwable
-