pnuts.lang
Class Function

java.lang.Object
  extended by pnuts.lang.Runtime
      extended by pnuts.lang.Function
All Implemented Interfaces:
java.io.Serializable, Executable

public class Function
extends Runtime
implements java.io.Serializable

This class represents a function with a certain number of parameters. In Pnuts, functions should be accessed through PnutsFunction. This class is used mainly by compiler implementors. Note that there is no way to create a Function object through public API.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class pnuts.lang.Runtime
Runtime.Accessor, Runtime.Break, Runtime.Continue, Runtime.FunctionSerializer, Runtime.TypeMap
 
Field Summary
protected  Configuration config
           
protected  java.lang.Object file
          file name in which this function is defined
protected  java.lang.String funcName
          name of the function including the scope information
protected  PnutsFunction function
          reference to PnutsFunction
protected  pnuts.lang.ImportEnv importEnv
          "import" environment
protected  java.lang.String[] locals
          local parameters
protected  pnuts.lang.ModuleList moduleList
          Used modules
protected  java.lang.String name
          name of the function without the scope information
protected  int nargs
          the number of arguments
protected  SimpleNode node
          reference to the definition
protected  Function outer
          reference to the outer function
protected  Package pkg
           
protected  java.lang.String pkgName
          the package name in which this function is defined
protected  boolean varargs
          variable length arugments
 
Fields inherited from class pnuts.lang.Runtime
BOOLEAN_SYMBOL, BYTE_SYMBOL, CHAR_SYMBOL, CLONE, DOUBLE_SYMBOL, EXCEPTOIN_FIELD_SYMBOL, FLOAT_SYMBOL, INT_SYMBOL, LONG_SYMBOL, SHORT_SYMBOL, VOID_SYMBOL
 
Constructor Summary
protected Function()
           
protected Function(java.lang.String func, java.lang.String[] locals, int nargs, boolean varargs, SimpleNode node, Package pkg, Context context)
           
protected Function(java.lang.String func, java.lang.String[] locals, int nargs, SimpleNode node, Package pkg, Context context)
           
 
Method Summary
protected  java.lang.Object accept(Visitor visitor, Context context)
           
protected  java.lang.Object exec(java.lang.Object[] args, Context context)
           
 java.lang.String[] getImportEnv()
           
 java.lang.String getName()
          Returns the name of the function
protected  SimpleNode getNode()
           
 int getNumberOfParameter()
          Returns the number of parameters
 Package getPackage()
           
 java.lang.Object getScriptSource()
           
protected  PnutsFunction register(PnutsFunction pf)
           
protected  PnutsFunction register(PnutsFunction pf, boolean isChild)
           
 void setPackage(Package pkg)
           
 java.lang.String toString()
           
protected  java.lang.String unparse(Context context)
           
 
Methods inherited from class pnuts.lang.Runtime
_callConstructor, _callMethod, add, add, add1, add1, addImport, addStaticMembers, and, and, applyGenerator, arraydim, arrayType, call, call, callConstructor, callFunction, callMethod, cast, catchException, checkException, checkException, compareObjects, compareTo, compareTo, createList, createMap, defineTopLevelFunction, defineUnboundFunction, divide, divide, eq, eq, escape, exec, execute, fileToURL, findCallableMethod, format, format, ge, ge, getArrayLength, getBeanProperty, getBeanProperty, getBeanProperty, getBeanPropertyType, getBeginColumn, getBeginLine, getBottomType, getCompiledScript, getConstructors, getElement, getElementAt, getEndLine, getField, getField, getFunction, getFunction, getFunctions, getMessage, getMethods, getProperty, getRange, getRuntime, getScriptReader, getScriptSource, getScriptURL, getStaticField, getThreadContext, gt, gt, isArray, isGenerator, jump, le, le, loadNode, lt, lt, makeArray, matchType, mod, mod, multiply, multiply, ne, ne, negate, negate, newInstance, not, not, or, or, parseChar, parseFloat, parseInt, parseString, primitive, printError, putField, putStaticField, quantity, replaceChar, run, saveNode, setBeanProperty, setBeanProperty, setBeanProperty, setElement, setExitHook, setLine, setLine, setPackage, setRange, setThreadContext, shiftArithmetic, shiftArithmetic, shiftLeft, shiftLeft, shiftRight, shiftRight, subtract, subtract, subtract1, subtract1, throwException, toBoolean, toEnumeration, transform, transform, unparse, xor, xor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

funcName

protected java.lang.String funcName
name of the function including the scope information


name

protected java.lang.String name
name of the function without the scope information


nargs

protected int nargs
the number of arguments


varargs

protected boolean varargs
variable length arugments


locals

protected java.lang.String[] locals
local parameters


file

protected transient java.lang.Object file
file name in which this function is defined


node

protected SimpleNode node
reference to the definition


importEnv

protected pnuts.lang.ImportEnv importEnv
"import" environment


moduleList

protected pnuts.lang.ModuleList moduleList
Used modules


outer

protected Function outer
reference to the outer function


pkgName

protected java.lang.String pkgName
the package name in which this function is defined


function

protected PnutsFunction function
reference to PnutsFunction


pkg

protected transient Package pkg

config

protected Configuration config
Constructor Detail

Function

protected Function()

Function

protected Function(java.lang.String func,
                   java.lang.String[] locals,
                   int nargs,
                   SimpleNode node,
                   Package pkg,
                   Context context)

Function

protected Function(java.lang.String func,
                   java.lang.String[] locals,
                   int nargs,
                   boolean varargs,
                   SimpleNode node,
                   Package pkg,
                   Context context)
Method Detail

getName

public java.lang.String getName()
Returns the name of the function


getNumberOfParameter

public int getNumberOfParameter()
Returns the number of parameters


getScriptSource

public java.lang.Object getScriptSource()

exec

protected java.lang.Object exec(java.lang.Object[] args,
                                Context context)

getPackage

public Package getPackage()

setPackage

public void setPackage(Package pkg)

getImportEnv

public java.lang.String[] getImportEnv()

register

protected PnutsFunction register(PnutsFunction pf)

register

protected PnutsFunction register(PnutsFunction pf,
                                 boolean isChild)

getNode

protected SimpleNode getNode()

accept

protected java.lang.Object accept(Visitor visitor,
                                  Context context)

unparse

protected java.lang.String unparse(Context context)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object