Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.core
Class Function

java.lang.Object
  extended by imp.core.Function
Direct Known Subclasses:
Functions.Rule, Operator

public abstract class Function
extends Object

Defines and implements a function over value.


Constructor Summary
Function()
           
 
Method Summary
abstract  Value call(Expression value)
          Defines how this function evaluates the input value.
static Value eval(Value value)
          Returns the evaluation of the input value.
static void popContext(Value input)
          Pops an expression value from the present context.
static void pushContext(Value input, Value value)
          Pushes an expression value into the present context.
 Function setArity(int arity)
          Sets this function arity and return this.
 Function setFixedPoint(boolean fixed_point)
          Sets the fixed-point evaluation mechanism and return this.
 Function setName(String name)
          Sets this function name and returns this.
 Function setQuoted(boolean quoted)
          Sets if the function quotes or evaluate its arguments and return this.
 Function setRemember(boolean remember)
          Sets/Clears the evaluator map remember table of a function and return this.
static void setTrace(boolean trace)
          Sets if the eval function dumps a trace during evaluation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Function

public Function()
Method Detail

call

public abstract Value call(Expression value)
Defines how this function evaluates the input value.
Here, the function arity, remember mechanism, argument evaluation and input value element cloning as a Expression are transparent and managed in the eval method.

Parameters:
value - The value to be evaluated.
Returns:
The evaluation's result if evaluated, otherwise the input itself.

eval

public static Value eval(Value value)
Returns the evaluation of the input value.

Parameters:
value - The value to be evaluated.
Returns:
The evaluation's result if evaluated, otherwise the input itself.

popContext

public static void popContext(Value input)
Pops an expression value from the present context.

Parameters:
input - The expression to remove from the context.

pushContext

public static void pushContext(Value input,
                               Value value)
Pushes an expression value into the present context.
Each value must be pop/removed after being set.

Parameters:
input - The expression which has a specific value at the present state of the evaluation context.
value - The expression value in the present context.

setArity

public Function setArity(int arity)
Sets this function arity and return this.

Parameters:
arity - [optional, default is 0, no arity] The required number of arguments for this function or 0 if none.

setFixedPoint

public Function setFixedPoint(boolean fixed_point)
Sets the fixed-point evaluation mechanism and return this.

Parameters:
fixed_point - [optional, default is false] If true the function is evaluated as a fixed-point (i.e. evaluation is repeated until a stationary value is found). If fixed-point is set to true, the remember mechanism is activated.

setName

public Function setName(String name)
Sets this function name and returns this.

Parameters:
name - This function name.

setQuoted

public Function setQuoted(boolean quoted)
Sets if the function quotes or evaluate its arguments and return this.

Parameters:
quoted - [optional, default is false] If true the function arguments are not evaluated, else they are (default state).

setRemember

public Function setRemember(boolean remember)
Sets/Clears the evaluator map remember table of a function and return this.
Remembered values are defined by either a previous evaluation or value set/removed in the present context.

Parameters:
remember - [optional, default is false] If true the remember is cleared and used to save/returned already evaluated values, else no remember mechanism is used (default state).

setTrace

public static void setTrace(boolean trace)
Sets if the eval function dumps a trace during evaluation.