gnu.mapping
Class Procedure

java.lang.Object
  extended by gnu.mapping.Procedure
All Implemented Interfaces:
Named
Direct Known 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(java.lang.String n)
           
 
Method Summary
 void apply(CallContext ctx)
          Call this Procedure using the explicit-CallContext-convention.
static void apply(Procedure proc, CallContext ctx)
           
abstract  java.lang.Object apply0()
           
abstract  java.lang.Object apply1(java.lang.Object arg1)
           
abstract  java.lang.Object apply2(java.lang.Object arg1, java.lang.Object arg2)
           
abstract  java.lang.Object apply3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
           
abstract  java.lang.Object apply4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
           
abstract  java.lang.Object applyN(java.lang.Object[] args)
           
 void check0(CallContext ctx)
          Does match0, plus throws exception on argument mismatch.
 void check1(java.lang.Object arg1, CallContext ctx)
          Does match1, plus throws exception on argument mismatch.
 void check2(java.lang.Object arg1, java.lang.Object arg2, CallContext ctx)
          Does match, plus throws exception on argument mismatch.
 void check3(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, CallContext ctx)
          Does match3, plus throws exception on argument mismatch.
 void check4(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.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(java.lang.Object[] args, CallContext ctx)
          Does matchN, plus throws exception on argument mismatch.
 java.lang.String getName()
           
 java.lang.Object getProperty(java.lang.Object key, java.lang.Object defaultValue)
           
 Procedure getSetter()
           
 java.lang.Object getSymbol()
           
 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 maxArgs()
          Maximum number of arguments allowed, or -1 for unlimited.
 int minArgs()
          Minimum number of arguments required.
 java.lang.String name()
          Deprecated.  
 int numArgs()
          Return minArgs()|(maxArgs<<12).
 java.lang.Object removeProperty(java.lang.Object key)
           
 void set0(java.lang.Object result)
          If HasSetter, the Procedure is called in the LHS of an assignment.
 void set1(java.lang.Object arg1, java.lang.Object value)
           
 void setN(java.lang.Object[] args)
           
 void setName(java.lang.String name)
           
static java.lang.Object[] setProperty(java.lang.Object[] properties, java.lang.Object key, java.lang.Object value)
          Given a property list, update it.
 void setProperty(java.lang.Object key, java.lang.Object value)
           
 void setSetter(Procedure setter)
           
 void setSymbol(java.lang.Object name)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Procedure

public Procedure()

Procedure

public Procedure(java.lang.String n)
Method Detail

getName

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

getSymbol

public java.lang.Object getSymbol()
Specified by:
getSymbol in interface Named

name

public final java.lang.String name()
Deprecated. 


setSymbol

public final void setSymbol(java.lang.Object name)

setName

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

applyN

public abstract java.lang.Object applyN(java.lang.Object[] args)
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

apply0

public abstract java.lang.Object apply0()
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

apply1

public abstract java.lang.Object apply1(java.lang.Object arg1)
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

apply2

public abstract java.lang.Object apply2(java.lang.Object arg1,
                                        java.lang.Object arg2)
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

apply3

public abstract java.lang.Object apply3(java.lang.Object arg1,
                                        java.lang.Object arg2,
                                        java.lang.Object arg3)
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

apply4

public abstract java.lang.Object apply4(java.lang.Object arg1,
                                        java.lang.Object arg2,
                                        java.lang.Object arg3,
                                        java.lang.Object arg4)
                                 throws java.lang.Throwable
Throws:
java.lang.Throwable

minArgs

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


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.)


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
Throws:
WrongArguments - there are too many or too few actual arguments

numArgs

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


apply

public void apply(CallContext ctx)
           throws java.lang.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.

Throws:
java.lang.Throwable

apply

public static void apply(Procedure proc,
                         CallContext ctx)
                  throws java.lang.Throwable
Throws:
java.lang.Throwable

match0

public int match0(CallContext ctx)
Pass zero arguments.

Returns:
non-negative if the match succeeded, else negative.

match1

public int match1(java.lang.Object arg1,
                  CallContext ctx)
Pass one argument.

Returns:
non-negative if the match succeeded, else negative.

match2

public int match2(java.lang.Object arg1,
                  java.lang.Object arg2,
                  CallContext ctx)
Pass two arguments.

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)
Pass three arguments.

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)
Pass four arguments.

Returns:
non-negative if the match succeeded, else negative.

matchN

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

check0

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


check1

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


check2

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


check3

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


check4

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


checkN

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


getSetter

public Procedure getSetter()

setSetter

public void setSetter(Procedure setter)

set0

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

Throws:
java.lang.Throwable

set1

public void set1(java.lang.Object arg1,
                 java.lang.Object value)
          throws java.lang.Throwable
Throws:
java.lang.Throwable

setN

public void setN(java.lang.Object[] args)
          throws java.lang.Throwable
Throws:
java.lang.Throwable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getProperty

public java.lang.Object getProperty(java.lang.Object key,
                                    java.lang.Object defaultValue)

setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object value)

setProperty

public static java.lang.Object[] setProperty(java.lang.Object[] properties,
                                             java.lang.Object key,
                                             java.lang.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)

removeProperty

public java.lang.Object removeProperty(java.lang.Object key)