gnu.expr

Class ModuleMethod

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

NO_MATCH, NO_MATCH_AMBIGUOUS, NO_MATCH_BAD_TYPE, NO_MATCH_TOO_FEW_ARGS, NO_MATCH_TOO_MANY_ARGS, argTypes

Fields inherited from class gnu.mapping.ProcedureN

noArgs

Constructor Summary

ModuleMethod(ModuleBody module, int selector, Object name, int numArgs)
ModuleMethod(ModuleBody module, int selector, Object name, int numArgs, Object argTypes)

Method Summary

void
apply(CallContext ctx)
Object
apply0()
static Object
apply0Default(ModuleMethod method)
Object
apply1(Object arg1)
static Object
apply1Default(ModuleMethod method, Object arg1)
Object
apply2(Object arg1, Object arg2)
static Object
apply2Default(ModuleMethod method, Object arg1, Object arg2)
Object
apply3(Object arg1, Object arg2, Object arg3)
static Object
apply3Default(ModuleMethod method, Object arg1, Object arg2, Object arg3)
Object
apply4(Object arg1, Object arg2, Object arg3, Object arg4)
static Object
apply4Default(ModuleMethod method, Object arg1, Object arg2, Object arg3, Object arg4)
static void
applyError()
Helper methods for default ModuleBody actions.
Object
applyN(Object[] args)
static Object
applyNDefault(ModuleMethod method, Object[] args)
String
getName()
int
match0(CallContext ctx)
int
match1(Object arg1, CallContext ctx)
int
match2(Object arg1, Object arg2, CallContext ctx)
int
match3(Object arg1, Object arg2, Object arg3, CallContext ctx)
int
match4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)
int
matchN(Object[] args, CallContext ctx)
int
numArgs()
protected void
resolveParameterTypes()
Figure out parameter types.

Methods inherited from class gnu.mapping.MethodProc

applyN, getParameterType, isApplicable, matchFailAsException, mostSpecific, mostSpecific, numParameters, resolveParameterTypes

Methods inherited from class gnu.mapping.ProcedureN

apply0, apply1, apply2, apply3, apply4, applyN

Methods inherited from class gnu.mapping.Procedure

apply, apply, apply0, apply1, apply2, apply3, apply4, applyN, check0, check1, check2, check3, check4, checkArgCount, checkN, getName, getProperty, getSetter, getSymbol, match0, match1, match2, match3, match4, matchN, maxArgs, minArgs, name, numArgs, removeProperty, set0, set1, setN, setName, setProperty, setProperty, setSetter, setSymbol, toString

Field Details

module

public ModuleBody module

numArgs

protected int numArgs

selector

public final int selector

Constructor Details

ModuleMethod

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

ModuleMethod

public ModuleMethod(ModuleBody module,
                    int selector,
                    Object name,
                    int numArgs,
                    Object argTypes)

Method Details

apply

public void apply(CallContext ctx)
            throws Throwable
Overrides:
apply in interface Procedure

apply0

public Object apply0()
            throws Throwable
Overrides:
apply0 in interface ProcedureN

apply0Default

public static Object apply0Default(ModuleMethod method)
            throws Throwable

apply1

public Object apply1(Object arg1)
            throws Throwable
Overrides:
apply1 in interface ProcedureN

apply1Default

public static Object apply1Default(ModuleMethod method,
                                   Object arg1)
            throws Throwable

apply2

public Object apply2(Object arg1,
                     Object arg2)
            throws Throwable
Overrides:
apply2 in interface ProcedureN

apply2Default

public static Object apply2Default(ModuleMethod method,
                                   Object arg1,
                                   Object arg2)
            throws Throwable

apply3

public Object apply3(Object arg1,
                     Object arg2,
                     Object arg3)
            throws Throwable
Overrides:
apply3 in interface ProcedureN

apply3Default

public static Object apply3Default(ModuleMethod method,
                                   Object arg1,
                                   Object arg2,
                                   Object arg3)
            throws Throwable

apply4

public Object apply4(Object arg1,
                     Object arg2,
                     Object arg3,
                     Object arg4)
            throws Throwable
Overrides:
apply4 in interface ProcedureN

apply4Default

public static Object apply4Default(ModuleMethod method,
                                   Object arg1,
                                   Object arg2,
                                   Object arg3,
                                   Object arg4)
            throws Throwable

applyError

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

applyN

public Object applyN(Object[] args)
            throws Throwable
Overrides:
applyN in interface MethodProc

applyNDefault

public static Object applyNDefault(ModuleMethod method,
                                   Object[] args)
            throws Throwable

getName

public String getName()
Specified by:
getName in interface Named
Overrides:
getName in interface Procedure

match0

public int match0(CallContext ctx)
Overrides:
match0 in interface Procedure

match1

public int match1(Object arg1,
                  CallContext ctx)
Overrides:
match1 in interface Procedure

match2

public int match2(Object arg1,
                  Object arg2,
                  CallContext ctx)
Overrides:
match2 in interface Procedure

match3

public int match3(Object arg1,
                  Object arg2,
                  Object arg3,
                  CallContext ctx)
Overrides:
match3 in interface Procedure

match4

public int match4(Object arg1,
                  Object arg2,
                  Object arg3,
                  Object arg4,
                  CallContext ctx)
Overrides:
match4 in interface Procedure

matchN

public int matchN(Object[] args,
                  CallContext ctx)
Overrides:
matchN in interface Procedure

numArgs

public int numArgs()
Overrides:
numArgs in interface 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 interface MethodProc