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

Inner Class Summary
static class AbstractFunction.UnsupportedTopException
           
static class AbstractFunction.WrongNumberOfArgumentsException
           
 
Field Summary
protected  String name
           
protected  int numArgs
           
 
Constructor Summary
AbstractFunction(String name, int numArgs)
           
 
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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

numArgs

protected final int numArgs
Constructor Detail

AbstractFunction

public AbstractFunction(String name,
                        int numArgs)
Method Detail

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)