org.fun4j.compiler
Class BaseFunction

java.lang.Object
  extended by org.fun4j.compiler.BaseFunction
All Implemented Interfaces:
Function, NamedObject
Direct Known Subclasses:
Add, Catch, Div, Hash, Map, Mul, Sub

public abstract class BaseFunction
extends java.lang.Object
implements Function, NamedObject

abstract baseclass implementing the Function interface. This class is used by the compiler to produce new function instances by implementing the abstract method applyInternal(Object...). This class can also be used by user code to implement Functions.

Author:
Thomas Mahler

Field Summary
static int indent
           
 
Constructor Summary
BaseFunction()
           
 
Method Summary
 java.lang.Object apply(java.lang.Object... args)
          apply is used as a template method here, defining the handling of tracing and partial application.
 int arity()
           
 java.lang.String getDocumentation()
          returns the documention of the object.
 java.lang.String getName()
          returns the name of the object.
 boolean isLazy()
           
 boolean isMacro()
           
 void setArity(int i)
           
 void setLazy(boolean lazy)
           
 void setMacro(boolean macro)
           
static java.lang.Boolean setTracing(java.lang.Boolean onOff)
           
 java.lang.String toString()
          The compiler writes a human readable String representation of the precompiled AST into the field pcode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

indent

public static int indent
Constructor Detail

BaseFunction

public BaseFunction()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: NamedObject
returns the name of the object.

Specified by:
getName in interface NamedObject

getDocumentation

public java.lang.String getDocumentation()
Description copied from interface: NamedObject
returns the documention of the object.

Specified by:
getDocumentation in interface NamedObject

setTracing

public static java.lang.Boolean setTracing(java.lang.Boolean onOff)

toString

public java.lang.String toString()
The compiler writes a human readable String representation of the precompiled AST into the field pcode.

Overrides:
toString in class java.lang.Object

apply

public java.lang.Object apply(java.lang.Object... args)
apply is used as a template method here, defining the handling of tracing and partial application. The actual user code is executed by calling applyInternal(Object...).

Specified by:
apply in interface Function
Parameters:
args - the arguments passed to the function call
Returns:
the result of applying the function to its arguments

arity

public int arity()

setArity

public void setArity(int i)

setMacro

public void setMacro(boolean macro)

isMacro

public boolean isMacro()

setLazy

public void setLazy(boolean lazy)

isLazy

public boolean isLazy()