gnu.mapping

Class Procedure

Implemented Interfaces:
Named
Known Direct Subclasses:
AutoloadProcedure, Procedure0, Procedure0or1, Procedure1, Procedure1or2, Procedure2, Procedure3, Procedure4, ProcedureN

public abstract class Procedure
extends java.lang.Object
implements Named

The abstract parent for all Scheme functions.

Constructor Summary

Procedure()
Procedure(String n)

Method Summary

void
apply(CallContext ctx)
Call this Procedure using the explicit-CallContext-convention.
static void
apply(Procedure proc, CallContext ctx)
abstract Object
apply0()
abstract Object
apply1(Object arg1)
abstract Object
apply2(Object arg1, Object arg2)
abstract Object
apply3(Object arg1, Object arg2, Object arg3)
abstract Object
apply4(Object arg1, Object arg2, Object arg3, Object arg4)
abstract Object
applyN(Object[] args)
void
check0(CallContext ctx)
Does match0, plus throws exception on argument mismatch.
void
check1(Object arg1, CallContext ctx)
Does match1, plus throws exception on argument mismatch.
void
check2(Object arg1, Object arg2, CallContext ctx)
Does match, plus throws exception on argument mismatch.
void
check3(Object arg1, Object arg2, Object arg3, CallContext ctx)
Does match3, plus throws exception on argument mismatch.
void
check4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)
Does match4, plus throws exception on argument mismatch.
static void
checkArgCount(Procedure proc, int argCount)
Check that the number of arguments in a call is valid.
void
checkN(Object[] args, CallContext ctx)
Does matchN, plus throws exception on argument mismatch.
String
getName()
Object
getProperty(Object key, Object defaultValue)
Procedure
getSetter()
Object
getSymbol()
int
match0(CallContext ctx)
Pass zero arguments.
int
match1(Object arg1, CallContext ctx)
Pass one argument.
int
match2(Object arg1, Object arg2, CallContext ctx)
Pass two arguments.
int
match3(Object arg1, Object arg2, Object arg3, CallContext ctx)
Pass three arguments.
int
match4(Object arg1, Object arg2, Object arg3, Object arg4, CallContext ctx)
Pass four arguments.
int
matchN(Object[] args, CallContext ctx)
int
maxArgs()
Maximum number of arguments allowed, or -1 for unlimited.
int
minArgs()
Minimum number of arguments required.
String
name()
Deprecated.
int
numArgs()
Return minArgs()|(maxArgs<<12).
Object
removeProperty(Object key)
void
set0(Object result)
If HasSetter, the Procedure is called in the LHS of an assignment.
void
set1(Object arg1, Object value)
void
setN(Object[] args)
void
setName(String name)
void
setProperty(Object key, Object value)
static Object[]
setProperty(Object[] properties, Object key, Object value)
Given a property list, update it.
void
setSetter(Procedure setter)
void
setSymbol(Object name)
String
toString()

Constructor Details

Procedure

public Procedure()

Procedure

public Procedure(String n)

Method Details

apply

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

apply

public static void apply(Procedure proc,
                         CallContext ctx)
            throws Throwable

apply0

public abstract Object apply0()
            throws Throwable

apply1

public abstract Object apply1(Object arg1)
            throws Throwable

apply2

public abstract Object apply2(Object arg1,
                              Object arg2)
            throws Throwable

apply3

public abstract Object apply3(Object arg1,
                              Object arg2,
                              Object arg3)
            throws Throwable

apply4

public abstract Object apply4(Object arg1,
                              Object arg2,
                              Object arg3,
                              Object arg4)
            throws Throwable

applyN

public abstract Object applyN(Object[] args)
            throws Throwable

check0

public void check0(CallContext ctx)
Does match0, plus throws exception on argument mismatch.

check1

public void check1(Object arg1,
                   CallContext ctx)
Does match1, plus throws exception on argument mismatch.

check2

public void check2(Object arg1,
                   Object arg2,
                   CallContext ctx)
Does match, plus throws exception on argument mismatch.

check3

public void check3(Object arg1,
                   Object arg2,
                   Object arg3,
                   CallContext ctx)
Does match3, plus throws exception on argument mismatch.

check4

public void check4(Object arg1,
                   Object arg2,
                   Object arg3,
                   Object arg4,
                   CallContext ctx)
Does match4, plus throws exception on argument mismatch.

checkArgCount

public static void checkArgCount(Procedure proc,
                                 int argCount)
Check that the number of arguments in a call is valid.
Parameters:
proc - the Procedure being called
argCount - the number of arguments in the call

checkN

public void checkN(Object[] args,
                   CallContext ctx)
Does matchN, plus throws exception on argument mismatch.

getName

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

getProperty

public Object getProperty(Object key,
                          Object defaultValue)

getSetter

public Procedure getSetter()

getSymbol

public Object getSymbol()
Specified by:
getSymbol in interface Named

match0

public int match0(CallContext ctx)
Pass zero arguments.
Returns:
non-negative if the match succeeded, else negative.

match1

public int match1(Object arg1,
                  CallContext ctx)
Pass one argument.
Returns:
non-negative if the match succeeded, else negative.

match2

public int match2(Object arg1,
                  Object arg2,
                  CallContext ctx)
Pass two arguments.
Returns:
non-negative if the match succeeded, else negative.

match3

public int match3(Object arg1,
                  Object arg2,
                  Object arg3,
                  CallContext ctx)
Pass three arguments.
Returns:
non-negative if the match succeeded, else negative.

match4

public int match4(Object arg1,
                  Object arg2,
                  Object arg3,
                  Object arg4,
                  CallContext ctx)
Pass four arguments.
Returns:
non-negative if the match succeeded, else negative.

matchN

public int matchN(Object[] args,
                  CallContext ctx)

maxArgs

public final int maxArgs()
Maximum number of arguments allowed, or -1 for unlimited. (May also return -1 if there are keyword arguments, for implementation reasons.)

minArgs

public final int minArgs()
Minimum number of arguments required.

name

public final String name()

Deprecated.


numArgs

public int numArgs()
Return minArgs()|(maxArgs<<12).

removeProperty

public Object removeProperty(Object key)

set0

public void set0(Object result)
            throws Throwable
If HasSetter, the Procedure is called in the LHS of an assignment.

set1

public void set1(Object arg1,
                 Object value)
            throws Throwable

setN

public void setN(Object[] args)
            throws Throwable

setName

public final void setName(String name)
Specified by:
setName in interface Named

setProperty

public void setProperty(Object key,
                        Object value)

setProperty

public static Object[] setProperty(Object[] properties,
                                   Object key,
                                   Object value)
Given a property list, update it.
Parameters:
properties - the input property list
key -
value - associate this with key in result
Returns:
updated property list (maybe the same as the input)

setSetter

public void setSetter(Procedure setter)

setSymbol

public final void setSymbol(Object name)

toString

public String toString()