com.bc.jexp
Interface Function

All Known Implementing Classes:
AbstractFunction, AbstractFunction.B, AbstractFunction.D, AbstractFunction.I, UserFunction

public interface Function

A representation of a function. A function has a name, a return type and can be evaluated by passing a number of arguments to it.

Within an expression, a reference to a function is created if the parser encounters a name followed by an argument list and the name can be resolved through the parser's current namespace. The resulting term in this case is an instance of Term.Call.

Version:
$Revision$ $Date$
Author:
Norman Fomferra (norman.fomferra@brockmann-consult.de)

Method Summary
 boolean evalB(EvalEnv env, Term[] args)
          Evaluates this function to a double value.
 double evalD(EvalEnv env, Term[] args)
          Evaluates this function to a double value.
 int evalI(EvalEnv env, Term[] args)
          Evaluates this function to an int value.
 int getArgType(int argIndex)
          Gets the type of a function's i-th argument.
 String getName()
          Gets the function's name.
 int getNumArgs()
          Gets the function's number of arguments.
 int getRetType()
          Gets the function's return type.
 

Method Detail

getName

String getName()
Gets the function's name.

Returns:
the name, should never be null.

getRetType

int getRetType()
Gets the function's return type.

Returns:
the type, should always be one of the TYPE_X constants defined in the Term class.

getNumArgs

int getNumArgs()
Gets the function's number of arguments.

Returns:
number of arguments.

getArgType

int getArgType(int argIndex)
Gets the type of a function's i-th argument.

Parameters:
argIndex - The argument index.
Returns:
an arry of types, each element should always be one of the TYPE_X constants defined in the Term class.

evalB

boolean evalB(EvalEnv env,
              Term[] args)
              throws EvalException
Evaluates this function to a double value.

Parameters:
env - the application dependant environment.
args - the (un-evaluated) arguments passed to the function
Returns:
a double value
Throws:
EvalException - if the evaluation fails

evalI

int evalI(EvalEnv env,
          Term[] args)
          throws EvalException
Evaluates this function to an int value.

Parameters:
env - the application dependant environment.
args - the (un-evaluated) arguments passed to the function
Returns:
an int value
Throws:
EvalException - if the evaluation fails

evalD

double evalD(EvalEnv env,
             Term[] args)
             throws EvalException
Evaluates this function to a double value.

Parameters:
env - the application dependant environment.
args - the (un-evaluated) arguments passed to the function
Returns:
a double value
Throws:
EvalException - if the evaluation fails


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.