gnu.expr
Class ModuleMethod

java.lang.Object
  extended by gnu.mapping.Procedure
      extended by gnu.mapping.ProcedureN
          extended by gnu.mapping.MethodProc
              extended by gnu.expr.ModuleMethod
All Implemented Interfaces:
Named

public class ModuleMethod
extends MethodProc

Call a specified method in in a ModuleBody. We use an extra level of indirection, but we save by having to create fewer classes than in the one-class-per-procedure scheme, without having to use (slow) reflection.


Field Summary
 ModuleBody module
           
protected  int numArgs
           
 int selector
           
 
Fields inherited from class gnu.mapping.MethodProc
argTypes, NO_MATCH, NO_MATCH_AMBIGUOUS, NO_MATCH_BAD_TYPE, NO_MATCH_TOO_FEW_ARGS, NO_MATCH_TOO_MANY_ARGS
 
Fields inherited from class gnu.mapping.ProcedureN
noArgs
 
Constructor Summary
ModuleMethod(ModuleBody module, int selector, java.lang.Object name, int numArgs)
           
ModuleMethod(ModuleBody module, int selector, java.lang.Object name, int numArgs, java.lang.Object argTypes)
           
 
Method Summary
 void apply(CallContext ctx)
          Call this Procedure using the explicit-CallContext-convention.
 java.lang.Object apply0()
           
static java.lang.Object apply0Default(ModuleMethod method)
           
 java.lang.Object apply1(java.lang.Object arg1)
           
static java.lang.Object apply1Default(ModuleMethod method, java.lang.Object arg1)
           
 java.lang.Object apply2(java.lang.Object arg1, java.lang.Object arg2)
           
static java.lang.Object apply2Default(ModuleMethod method, java.lang.Object arg1, java.lang.Object arg2)
           
 java.lang.Object apply3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
           
static java.lang.Object apply3Default(ModuleMethod method, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
           
 java.lang.Object apply4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
           
static java.lang.Object apply4Default(ModuleMethod method, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
           
static void applyError()
          Helper methods for default ModuleBody actions.
 java.lang.Object applyN(java.lang.Object[] args)
           
static java.lang.Object applyNDefault(ModuleMethod method, java.lang.Object[] args)
           
 java.lang.String getName()
           
 int match0(CallContext ctx)
          Pass zero arguments.
 int match1(java.lang.Object arg1, CallContext ctx)
          Pass one argument.
 int match2(java.lang.Object arg1, java.lang.Object arg2, CallContext ctx)
          Pass two arguments.
 int match3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, CallContext ctx)
          Pass three arguments.
 int match4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, CallContext ctx)
          Pass four arguments.
 int matchN(java.lang.Object[] args, CallContext ctx)
           
 int numArgs()
          Return minArgs()|(maxArgs<<12).
protected  void resolveParameterTypes()
          Figure out parameter types.
 
Methods inherited from class gnu.mapping.MethodProc
getParameterType, isApplicable, matchFailAsException, mostSpecific, mostSpecific, numParameters
 
Methods inherited from class gnu.mapping.Procedure
apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getProperty, getSetter, getSymbol, maxArgs, minArgs, name, removeProperty, set0, set1, setN, setName, setProperty, setProperty, setSetter, setSymbol, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

module

public ModuleBody module

selector

public final int selector

numArgs

protected int numArgs
Constructor Detail

ModuleMethod

public ModuleMethod(ModuleBody module,
                    int selector,
                    java.lang.Object name,
                    int numArgs)

ModuleMethod

public ModuleMethod(ModuleBody module,
                    int selector,
                    java.lang.Object name,
                    int numArgs,
                    java.lang.Object argTypes)
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface Named
Overrides:
getName in class Procedure

resolveParameterTypes

protected void resolveParameterTypes()
Figure out parameter types. Uses reflection to get method parameter types. INCOMPLETE - does not handle procedures with optional or rest args.

Overrides:
resolveParameterTypes in class MethodProc

numArgs

public int numArgs()
Description copied from class: Procedure
Return minArgs()|(maxArgs<<12).

Overrides:
numArgs in class Procedure

match0

public int match0(CallContext ctx)
Description copied from class: Procedure
Pass zero arguments.

Overrides:
match0 in class Procedure
Returns:
non-negative if the match succeeded, else negative.

match1

public int match1(java.lang.Object arg1,
                  CallContext ctx)
Description copied from class: Procedure
Pass one argument.

Overrides:
match1 in class Procedure
Returns:
non-negative if the match succeeded, else negative.

match2

public int match2(java.lang.Object arg1,
                  java.lang.Object arg2,
                  CallContext ctx)
Description copied from class: Procedure
Pass two arguments.

Overrides:
match2 in class Procedure
Returns:
non-negative if the match succeeded, else negative.

match3

public int match3(java.lang.Object arg1,
                  java.lang.Object arg2,
                  java.lang.Object arg3,
                  CallContext ctx)
Description copied from class: Procedure
Pass three arguments.

Overrides:
match3 in class Procedure
Returns:
non-negative if the match succeeded, else negative.

match4

public int match4(java.lang.Object arg1,
                  java.lang.Object arg2,
                  java.lang.Object arg3,
                  java.lang.Object arg4,
                  CallContext ctx)
Description copied from class: Procedure
Pass four arguments.

Overrides:
match4 in class Procedure
Returns:
non-negative if the match succeeded, else negative.

matchN

public int matchN(java.lang.Object[] args,
                  CallContext ctx)
Overrides:
matchN in class Procedure

apply

public void apply(CallContext ctx)
           throws java.lang.Throwable
Description copied from class: Procedure
Call this Procedure using the explicit-CallContext-convention. The input arguments are (by default) in stack.args; the result is written to ctx.consumer.

Overrides:
apply in class Procedure
Throws:
java.lang.Throwable

apply0

public java.lang.Object apply0()
                        throws java.lang.Throwable
Overrides:
apply0 in class ProcedureN
Throws:
java.lang.Throwable

apply1

public java.lang.Object apply1(java.lang.Object arg1)
                        throws java.lang.Throwable
Overrides:
apply1 in class ProcedureN
Throws:
java.lang.Throwable

apply2

public java.lang.Object apply2(java.lang.Object arg1,
                               java.lang.Object arg2)
                        throws java.lang.Throwable
Overrides:
apply2 in class ProcedureN
Throws:
java.lang.Throwable

apply3

public java.lang.Object apply3(java.lang.Object arg1,
                               java.lang.Object arg2,
                               java.lang.Object arg3)
                        throws java.lang.Throwable
Overrides:
apply3 in class ProcedureN
Throws:
java.lang.Throwable

apply4

public java.lang.Object apply4(java.lang.Object arg1,
                               java.lang.Object arg2,
                               java.lang.Object arg3,
                               java.lang.Object arg4)
                        throws java.lang.Throwable
Overrides:
apply4 in class ProcedureN
Throws:
java.lang.Throwable

applyN

public java.lang.Object applyN(java.lang.Object[] args)
                        throws java.lang.Throwable
Overrides:
applyN in class MethodProc
Throws:
java.lang.Throwable

apply0Default

public static java.lang.Object apply0Default(ModuleMethod method)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

apply1Default

public static java.lang.Object apply1Default(ModuleMethod method,
                                             java.lang.Object arg1)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

apply2Default

public static java.lang.Object apply2Default(ModuleMethod method,
                                             java.lang.Object arg1,
                                             java.lang.Object arg2)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

apply3Default

public static java.lang.Object apply3Default(ModuleMethod method,
                                             java.lang.Object arg1,
                                             java.lang.Object arg2,
                                             java.lang.Object arg3)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

apply4Default

public static java.lang.Object apply4Default(ModuleMethod method,
                                             java.lang.Object arg1,
                                             java.lang.Object arg2,
                                             java.lang.Object arg3,
                                             java.lang.Object arg4)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

applyNDefault

public static java.lang.Object applyNDefault(ModuleMethod method,
                                             java.lang.Object[] args)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

applyError

public static void applyError()
Helper methods for default ModuleBody actions.