pnuts.lang
Class PnutsImpl

java.lang.Object
  extended by pnuts.lang.Runtime
      extended by pnuts.lang.PnutsImpl
All Implemented Interfaces:
Executable, Implementation
Direct Known Subclasses:
CachedPnutsImpl, CompilerPnutsImpl, ImplementationAdapter, PnutsImplAdapter

public class PnutsImpl
extends Runtime
implements Implementation

This class defines an abstract interface of script interpreter's implementation, It also gives the default implementation, which is a pure interpreter.

See Also:
Context.setImplementation(Implementation), Context.getImplementation()

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  java.util.Properties properties
           
 
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
PnutsImpl()
           
 
Method Summary
 java.lang.Object accept(SimpleNode node, Context context)
          Interpret an AST
 java.lang.Object eval(java.lang.String expr, Context context)
          Evaluate an expreesion
static PnutsImpl getDefault()
          Returns the default PnutsImpl object
 java.lang.Object load(java.lang.String file, Context context)
          Load a script file using classloader
 java.lang.Object load(java.net.URL scriptURL, Context context)
          Load a script file from a URL
 java.lang.Object loadFile(java.lang.String filename, Context context)
          Load a script file from local file system
protected  void popFile(Context context)
          Tell the context that the current script file has been completed.
protected  void provide(java.lang.String file, Context context)
          Check if any exception handler for the specified exception is defined.
protected  void pushFile(java.lang.Object file, Context context)
          Tell the context that it's started processing the script file.
 java.lang.String queryProperty(java.lang.String key)
           
protected  void revoke(java.lang.String file, Context context)
           
 void setProperties(java.util.Properties properties)
           
 void setProperty(java.lang.String key, java.lang.String value)
           
 
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, toString, wait, wait, wait
 

Field Detail

properties

protected java.util.Properties properties
Constructor Detail

PnutsImpl

public PnutsImpl()
Method Detail

getDefault

public static PnutsImpl getDefault()
Returns the default PnutsImpl object

Returns:
the default PnutsImpl object

setProperties

public void setProperties(java.util.Properties properties)

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)

queryProperty

public java.lang.String queryProperty(java.lang.String key)

eval

public java.lang.Object eval(java.lang.String expr,
                             Context context)
Evaluate an expreesion

Specified by:
eval in interface Implementation
Parameters:
expr - the expression to be evaluated
context - the context in which the expression is evaluated
Returns:
the result of the evaluation

loadFile

public java.lang.Object loadFile(java.lang.String filename,
                                 Context context)
                          throws java.io.FileNotFoundException
Load a script file from local file system

Specified by:
loadFile in interface Implementation
Parameters:
filename - the file name of the script
context - the context in which the expression is evaluated
Returns:
the result of the evaluation
Throws:
java.io.FileNotFoundException

load

public java.lang.Object load(java.lang.String file,
                             Context context)
                      throws java.io.FileNotFoundException
Load a script file using classloader

Specified by:
load in interface Implementation
Parameters:
file - the name of the script
context - the context in which the script is executed
Returns:
the result of the evaluation
Throws:
java.io.FileNotFoundException

load

public java.lang.Object load(java.net.URL scriptURL,
                             Context context)
Load a script file from a URL

Specified by:
load in interface Implementation
Parameters:
scriptURL - the URL of the script
context - the context in which the script is executed
Returns:
the result of the evaluation

accept

public java.lang.Object accept(SimpleNode node,
                               Context context)
Description copied from interface: Implementation
Interpret an AST

Specified by:
accept in interface Implementation
Parameters:
node - the AST
context - the context in which the AST is interpreted

pushFile

protected void pushFile(java.lang.Object file,
                        Context context)
Tell the context that it's started processing the script file.


popFile

protected void popFile(Context context)
Tell the context that the current script file has been completed.


provide

protected void provide(java.lang.String file,
                       Context context)
Check if any exception handler for the specified exception is defined.


revoke

protected void revoke(java.lang.String file,
                      Context context)