gnu.expr
Class MethodProc
java.lang.Object
|
+--gnu.mapping.Procedure
|
+--gnu.mapping.ProcedureN
|
+--gnu.expr.MethodProc
- Direct Known Subclasses:
- GenericProc, PrimProcedure
- public abstract class MethodProc
- extends ProcedureN
Similar to a CLOS method.
Can check if arguments "match" before committing to calling method.
|
Method Summary |
java.lang.Object |
applyN(java.lang.Object[] args)
|
abstract java.lang.Object |
applyV(java.lang.Object vars)
|
Type |
getParameterType(int index)
|
java.lang.Object |
getVarBuffer()
Return a buffer that can contain decoded (matched) arguments. |
int |
isApplicable(Type[] argTypes)
Test if method is applicable to an invocation with given arguments. |
java.lang.Object |
match(java.lang.Object[] args)
|
abstract java.lang.RuntimeException |
match(java.lang.Object vars,
java.lang.Object[] args)
Match the incoming arguments. |
static int |
mostSpecific(MethodProc[] procs,
int length)
Return the index of the most specific method. |
static MethodProc |
mostSpecific(MethodProc proc1,
MethodProc proc2)
Return the more specific of the arguments. |
int |
numParameters()
Return number of paramaters, including optional and rest arguments. |
| Methods inherited from class gnu.mapping.Procedure |
apply,
checkArgCount,
getName,
getSetter,
maxArgs,
minArgs,
name,
numArgs,
print,
set0,
set1,
setN,
setName |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MethodProc
public MethodProc()
getVarBuffer
public java.lang.Object getVarBuffer()
- Return a buffer that can contain decoded (matched) arguments.
isApplicable
public int isApplicable(Type[] argTypes)
- Test if method is applicable to an invocation with given arguments.
Returns -1 if no; 1 if yes; 0 if need to check at run-time.
numParameters
public int numParameters()
- Return number of paramaters, including optional and rest arguments.
getParameterType
public Type getParameterType(int index)
match
public abstract java.lang.RuntimeException match(java.lang.Object vars,
java.lang.Object[] args)
- Match the incoming arguments.
- Parameters:
args - the incoming argument listvars - where to save the matched result on success- Returns:
- null if the match succeeded, else an exception
match
public java.lang.Object match(java.lang.Object[] args)
applyV
public abstract java.lang.Object applyV(java.lang.Object vars)
applyN
public java.lang.Object applyN(java.lang.Object[] args)
- Overrides:
- applyN in class ProcedureN
mostSpecific
public static MethodProc mostSpecific(MethodProc proc1,
MethodProc proc2)
- Return the more specific of the arguments.
- Returns:
- null if neither is more specific.
mostSpecific
public static int mostSpecific(MethodProc[] procs,
int length)
- Return the index of the most specific method.