|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bc.jexp.impl.AbstractFunction
com.bc.jexp.impl.UserFunction
public final class UserFunction
A utility class which represents a user-defined function to be used within an expression.
User functions are created from a list parameters of type
and the function body, which is an arbitrary instance of Variable.
The function's return type is derived from the return type of the body.
Term
User function bodies can be recursive - they can contain a node of the type
, which calls the function itself.
An Term.Call is thrown if the maximum stack size is reached.
EvalException
getStackSizeMax(),
setStackSizeMax(int)| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.bc.jexp.impl.AbstractFunction |
|---|
AbstractFunction.B, AbstractFunction.D, AbstractFunction.I |
| Constructor Summary | |
|---|---|
UserFunction(String name,
Variable[] params,
Term body)
Construcs a new user function with the given name, parameter list and body. |
|
| 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. |
static int |
getStackSizeMax()
Gets the maximum stack size. |
static void |
setStackSizeMax(int stackSizeMax)
Sets the maximum stack size. |
| Methods inherited from class com.bc.jexp.impl.AbstractFunction |
|---|
getArgType, getName, getNumArgs, getRetType |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UserFunction(String name,
Variable[] params,
Term body)
name - the function's name, must not be nullparams - the parameter list, must not be nullbody - the function's body, must not be null| Method Detail |
|---|
public boolean evalB(EvalEnv env,
Term[] args)
throws EvalException
Functiondouble value.
env - the application dependant environment.args - the (un-evaluated) arguments passed to the function
double value
EvalException - if the evaluation fails
public int evalI(EvalEnv env,
Term[] args)
throws EvalException
Functionint value.
env - the application dependant environment.args - the (un-evaluated) arguments passed to the function
int value
EvalException - if the evaluation fails
public double evalD(EvalEnv env,
Term[] args)
Functiondouble value.
env - the application dependant environment.args - the (un-evaluated) arguments passed to the function
double valuepublic static int getStackSizeMax()
public static void setStackSizeMax(int stackSizeMax)
stackSizeMax - the maximum stack size in element units.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||