uk.ac.man.cs.rainbow.rapa.data
Class AbstractFunction
java.lang.Object
|
+--uk.ac.man.cs.rainbow.rapa.data.AbstractFunction
- Direct Known Subclasses:
- NAry, Unary
- public abstract class AbstractFunction
- extends Object
Abstract function evaluation map. When evaluating an expression
abstractly, a map
from function names to
instances of this class's subclasses must be supplied.
- See Also:
Application
Method Summary |
protected abstract Value[] |
eval(Value[] args)
Evaluate this function according to the free abstraction. |
Value[] |
evaluate(Value[] args)
|
int |
getNumArgs()
How many arguments are there to the function. |
protected abstract boolean |
supportsTop()
Whether the top of any type may be passed as an argument to the
type. |
String |
toString()
|
name
protected String name
numArgs
protected final int numArgs
AbstractFunction
public AbstractFunction(String name,
int numArgs)
eval
protected abstract Value[] eval(Value[] args)
- Evaluate this function according to the free abstraction.
- Parameters:
args
- Arguments to the function; may include the top of a type in
any position if supportsTop()
returns true.- Returns:
- Array of all possible function results.
supportsTop
protected abstract boolean supportsTop()
- Whether the top of any type may be passed as an argument to the
type. Currently it is not a good idea to fail to support
this unless you can be sure it will never be passed a top...
toString
public String toString()
- Overrides:
toString
in class Object
getNumArgs
public int getNumArgs()
- How many arguments are there to the function.
evaluate
public Value[] evaluate(Value[] args)