public final class UserFunction extends AbstractFunction
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)
AbstractFunction.B, AbstractFunction.D, AbstractFunction.I
Constructor and Description |
---|
UserFunction(String name,
Variable[] params,
Term body)
Construcs a new user function with the given name, parameter list and body.
|
Modifier and Type | Method and Description |
---|---|
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.
|
getArgType, getName, getNumArgs, getRetType
public boolean evalB(EvalEnv env, Term[] args) throws EvalException
Function
double
value.env
- the application dependant environment.args
- the (un-evaluated) arguments passed to the functiondouble
valueEvalException
- if the evaluation failspublic int evalI(EvalEnv env, Term[] args) throws EvalException
Function
int
value.env
- the application dependant environment.args
- the (un-evaluated) arguments passed to the functionint
valueEvalException
- if the evaluation failspublic double evalD(EvalEnv env, Term[] args)
Function
double
value.env
- the application dependant environment.args
- the (un-evaluated) arguments passed to the functiondouble
valuepublic static int getStackSizeMax()
public static void setStackSizeMax(int stackSizeMax)
stackSizeMax
- the maximum stack size in element units.Copyright © 2002–2014 Brockmann Consult GmbH. All rights reserved.