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.


Fields inherited from class gnu.mapping.Procedure
noArgs, sym_name
 
Constructor Summary
MethodProc()
           
 
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.ProcedureN
apply0, apply1, apply2, apply3, apply4
 
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
 

Constructor Detail

MethodProc

public MethodProc()
Method Detail

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 list
vars - 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.