net.sf.arise.piji
Class AbstractFunction

java.lang.Object
  |
  +--net.sf.arise.piji.AbstractFunction
All Implemented Interfaces:
Function
Direct Known Subclasses:
AbstractCompareFunction, AbstractLetFunction, AbstractLoopFunction, AccessFunction, AddFunction, AndFunction, ArrayGetFunction, ArrayLengthFunction, ArraySetFunction, BeginFunction, CastFunction, ClassFunction, DeclareFunction, DefineFunction, DivideFunction, DocumentationFunction, ForEachFunction, GlobStarFunction, ImplementFunction, IncfFunction, InFunction, InstanceofFunction, InvokeFunction, IsBoundFunction, IsNullFunction, Lambda, LambdaFunction, MultiplyFunction, NewArrayFunction, NewFunction, NewProxyFunction, NotFunction, OrFunction, PrintFunction, PrintlnFunction, SetFunction, SubtractFunction, SynchronizedFunction, ThreadFunction, ThrowFunction, TLambdaFunction, TryCatchFunction

public abstract class AbstractFunction
extends java.lang.Object
implements Function


Constructor Summary
protected AbstractFunction(java.lang.String docString, boolean vararg, int argCount, Context context)
           
protected AbstractFunction(java.lang.String docString, int argCount, Context context)
           
 
Method Summary
abstract  java.lang.Object apply(Context context, Expression[] nodes)
          Applies the function to a set of values in a given context and returns the result
protected  void checkArgumentCount(Expression[] args)
           
protected  LeafNode checkLeaf(Expression expr)
           
protected  LeafNode checkLeaf(Expression expr, java.lang.String msg)
           
protected  ListNode checkList(Expression expr)
           
protected  ListNode checkList(Expression expr, java.lang.String msg)
           
protected  java.lang.String checkString(Expression expr)
           
protected  java.lang.String checkString(Expression expr, java.lang.String msg)
           
protected  Symbol checkSymbol(Expression expr)
           
protected  Symbol checkSymbol(Expression expr, boolean fail)
           
protected  Symbol checkSymbol(Expression expr, java.lang.String msg)
           
protected  Symbol checkSymbol(Expression expr, java.lang.String msg, boolean fail)
           
protected  void fillContext(Context ctx, Context letCtx, ListNode list, boolean prog)
           
protected  void fillContext(Context ctx, ListNode list)
           
 int getArgumentCount()
          Gets the minimum number of required arguments
 Context getContext()
          Gets the definition context
 java.lang.String getDocumentationString()
          Returns a documentation string
protected static boolean isLeaf(Expression expr)
           
protected static boolean isList(Expression expr)
           
protected static boolean isString(Expression expr)
           
protected static boolean isSymbol(Expression expr)
           
 boolean isVararg()
          Returns true iff this function is vararg, ie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFunction

protected AbstractFunction(java.lang.String docString,
                           int argCount,
                           Context context)

AbstractFunction

protected AbstractFunction(java.lang.String docString,
                           boolean vararg,
                           int argCount,
                           Context context)
Method Detail

isVararg

public boolean isVararg()
Description copied from interface: Function
Returns true iff this function is vararg, ie. has alt upward bound on the number of arguments

Specified by:
isVararg in interface Function
Returns:
True iff this function is vararg

getDocumentationString

public java.lang.String getDocumentationString()
Description copied from interface: Function
Returns a documentation string

Specified by:
getDocumentationString in interface Function
Returns:
A documentation string

getArgumentCount

public int getArgumentCount()
Description copied from interface: Function
Gets the minimum number of required arguments

Specified by:
getArgumentCount in interface Function
Returns:
The number of required arguments

getContext

public Context getContext()
Description copied from interface: Function
Gets the definition context

Specified by:
getContext in interface Function
Returns:
The definition conetxt

checkArgumentCount

protected final void checkArgumentCount(Expression[] args)
                                 throws WrongArgumentCountException
WrongArgumentCountException

isList

protected static final boolean isList(Expression expr)

isLeaf

protected static final boolean isLeaf(Expression expr)

isSymbol

protected static final boolean isSymbol(Expression expr)

isString

protected static final boolean isString(Expression expr)

apply

public abstract java.lang.Object apply(Context context,
                                       Expression[] nodes)
                                throws java.lang.Throwable
Description copied from interface: Function
Applies the function to a set of values in a given context and returns the result

Specified by:
apply in interface Function
Parameters:
context - The context to apply this function in
Returns:
The result of the function applied to the arguments in the context
java.lang.Throwable

checkLeaf

protected final LeafNode checkLeaf(Expression expr)
                            throws BadArgumentException
BadArgumentException

checkLeaf

protected final LeafNode checkLeaf(Expression expr,
                                   java.lang.String msg)
                            throws BadArgumentException
BadArgumentException

checkString

protected final java.lang.String checkString(Expression expr)
                                      throws BadArgumentException
BadArgumentException

checkString

protected final java.lang.String checkString(Expression expr,
                                             java.lang.String msg)
                                      throws BadArgumentException
BadArgumentException

checkSymbol

protected final Symbol checkSymbol(Expression expr)
                            throws BadArgumentException
BadArgumentException

checkSymbol

protected final Symbol checkSymbol(Expression expr,
                                   boolean fail)
                            throws BadArgumentException
BadArgumentException

checkSymbol

protected final Symbol checkSymbol(Expression expr,
                                   java.lang.String msg)
                            throws BadArgumentException
BadArgumentException

checkSymbol

protected final Symbol checkSymbol(Expression expr,
                                   java.lang.String msg,
                                   boolean fail)
                            throws BadArgumentException
BadArgumentException

checkList

protected final ListNode checkList(Expression expr)
                            throws BadArgumentException
BadArgumentException

checkList

protected final ListNode checkList(Expression expr,
                                   java.lang.String msg)
                            throws BadArgumentException
BadArgumentException

fillContext

protected final void fillContext(Context ctx,
                                 ListNode list)
                          throws java.lang.Throwable
java.lang.Throwable

fillContext

protected final void fillContext(Context ctx,
                                 Context letCtx,
                                 ListNode list,
                                 boolean prog)
                          throws java.lang.Throwable
java.lang.Throwable


All code and documentation is

Copyright (c) : 2000-2003 Kjetil Valstadsve & Maja S. Bratseth