|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpnuts.lang.Runtime
pnuts.lang.PnutsFunction
public class PnutsFunction
A PnutsFunction represents a group of Pnuts functions with a same name.
This class is serializable, whether the function is compiled or not. When an PnutsFunction object is serialized, the function definitions are written to the object stream, along with its attributes such as configuration, import environment, current package, and module list. Note that the current package is deeply copied, but the module list are written as an array of module names.
When the function is deserialized, the function definition is restored from the function definition read from the object stream. If the function had been compiled, the script is compiled. If modules referenced by the function are not used in the current context, the module is initialized for the function in such a way that it does not affect the current context.
On AST interpreter, nested functions with lexical scope can be serialized/deserialized. But with bytecode compiler, only top-level functions can be serialized/deserialized.
Serialized objects of this class will not be compatible with future releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class pnuts.lang.Runtime |
---|
Runtime.Accessor, Runtime.Break, Runtime.Continue, Runtime.FunctionSerializer, Runtime.TypeMap |
Field Summary | |
---|---|
static PnutsFunction |
AUTOLOAD
|
static PnutsFunction |
CATCH
|
static PnutsFunction |
CLASS
|
static PnutsFunction |
DEFINED
|
static PnutsFunction |
EVAL
|
static PnutsFunction |
GET_CONTEXT
|
static PnutsFunction |
IMPORT
|
static PnutsFunction |
LOAD
|
static PnutsFunction |
LOAD_FILE
|
protected java.lang.String |
name
the name |
static PnutsFunction |
PACKAGE
|
protected Package |
pkg
|
static PnutsFunction |
QUIT
|
static PnutsFunction |
REQUIRE
|
static PnutsFunction |
THROW
|
static PnutsFunction |
UNUSE
|
static PnutsFunction |
USE
|
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 |
PnutsFunction()
|
protected |
PnutsFunction(java.lang.String name)
Constructor |
protected |
PnutsFunction(java.lang.String name,
PnutsFunction parent)
Constructor |
Method Summary | |
---|---|
java.lang.Object |
accept(int narg,
Visitor visitor,
Context context)
|
protected void |
added(int narg)
This method is called when a Function object is registered to this object. |
java.lang.Object |
call(java.lang.Object[] args,
Context context)
Call a function in "context" with arguments "args". |
static java.lang.Object |
call(java.lang.String name,
java.lang.Object[] args,
Context context)
call a function "name" in "context" with arguments "args" |
java.lang.Object |
clone()
|
boolean |
defined(int narg)
Check if the function with narg parameter is defined |
protected java.util.Enumeration |
elements()
|
protected java.lang.Object |
exec(java.lang.Object[] args,
Context context)
Call a function in "context" with arguments "args". |
protected static java.lang.Object |
exec(PnutsFunction func,
java.lang.Object[] args,
Context context)
|
Function |
get(int narg)
|
java.lang.String[] |
getImportEnv(int narg)
|
java.lang.String |
getName()
|
Package |
getPackage()
Deprecated. |
boolean |
isBuiltin()
|
void |
setPackage(Package pkg)
|
java.lang.String |
toString()
|
protected void |
undefined(java.lang.Object[] args,
Context context)
|
java.lang.String |
unparse(int narg)
Retrieve the symbolic definition of the function. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
public static final PnutsFunction GET_CONTEXT
public static final PnutsFunction PACKAGE
public static final PnutsFunction IMPORT
public static final PnutsFunction CATCH
public static final PnutsFunction THROW
public static final PnutsFunction EVAL
public static final PnutsFunction LOAD_FILE
public static final PnutsFunction LOAD
public static final PnutsFunction AUTOLOAD
public static final PnutsFunction QUIT
public static final PnutsFunction DEFINED
public static final PnutsFunction USE
public static final PnutsFunction UNUSE
public static final PnutsFunction CLASS
public static final PnutsFunction REQUIRE
protected transient Package pkg
Constructor Detail |
---|
protected PnutsFunction()
protected PnutsFunction(java.lang.String name)
name
- the name of the functionprotected PnutsFunction(java.lang.String name, PnutsFunction parent)
name
- the name of the functionparent
- the parent functionMethod Detail |
---|
protected void added(int narg)
narg
- the number of parameterspublic final Function get(int narg)
public boolean defined(int narg)
narg
- the number of paramters.
public java.lang.String getName()
public final java.lang.Object call(java.lang.Object[] args, Context context)
call
in interface Callable
args
- the argumentscontext
- the context in which the object is called
protected java.lang.Object exec(java.lang.Object[] args, Context context)
protected void undefined(java.lang.Object[] args, Context context)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.Object call(java.lang.String name, java.lang.Object[] args, Context context)
protected static java.lang.Object exec(PnutsFunction func, java.lang.Object[] args, Context context)
public java.lang.String unparse(int narg)
narg
- the number of paramters. -1 means a arbitrary length
parameter.
public Package getPackage()
public void setPackage(Package pkg)
public java.lang.String[] getImportEnv(int narg)
narg
- the number of paramters. -1 means a arbitrary length
parameter.
public boolean isBuiltin()
public java.lang.Object accept(int narg, Visitor visitor, Context context)
narg
- the number of paramters. -1 means a arbitrary length
parameter.public java.lang.Object clone()
clone
in class java.lang.Object
protected java.util.Enumeration elements()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |