pnuts.compiler
Class DynamicRuntime

java.lang.Object
  extended by pnuts.lang.Runtime
      extended by pnuts.compiler.DynamicRuntime
All Implemented Interfaces:
Executable

public class DynamicRuntime
extends Runtime


Nested Class Summary
protected static class DynamicRuntime.DynamicAccessor
           
 
Nested classes/interfaces inherited from class pnuts.lang.Runtime
Runtime.Accessor, Runtime.Break, Runtime.Continue, Runtime.FunctionSerializer, Runtime.TypeMap
 
Field Summary
 
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
DynamicRuntime()
           
 
Method Summary
protected  java.lang.Object _callConstructor(Context context, java.lang.Class c, java.lang.Object[] args, java.lang.Class[] types)
          Call a constructor
protected  java.lang.Object _callConstructor(Context context, java.lang.Class c, java.lang.Object[] args, java.lang.Class[] types, pnuts.compiler.CodeLoader codeLoader)
           
protected  java.lang.Object _callMethod(Context context, java.lang.Class c, java.lang.String name, java.lang.Object[] args, java.lang.Class[] types, java.lang.Object target)
          call a method
 java.lang.Object getBeanProperty(java.lang.Object target, java.lang.String name)
          Gets a Bean property of the specified bean.
protected  java.lang.Object getBeanProperty(java.lang.Object target, java.lang.String name, java.lang.Class stopClass)
          Gets a Bean property of the specified bean.
 java.lang.Class getBeanPropertyType(java.lang.Class cls, java.lang.String name)
          Gets the type of a bean property
static PnutsFunction makeProxy(java.lang.reflect.Constructor cons)
          This method maps a proxy object of a Constructor to a PnutsFunction.
static PnutsFunction makeProxy(java.lang.reflect.Method method)
          This method maps a proxy object of a Method to a PnutsFunction.
 void setBeanProperty(java.lang.Object target, java.lang.String name, java.lang.Object value)
          Sets a Bean property of the specified bean.
protected  void setBeanProperty(java.lang.Object target, java.lang.String name, java.lang.Object value, java.lang.Class stopClass)
          Sets a Bean property of the specified bean.
 
Methods inherited from class pnuts.lang.Runtime
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, 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, 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
 

Constructor Detail

DynamicRuntime

public DynamicRuntime()
Method Detail

_callMethod

protected java.lang.Object _callMethod(Context context,
                                       java.lang.Class c,
                                       java.lang.String name,
                                       java.lang.Object[] args,
                                       java.lang.Class[] types,
                                       java.lang.Object target)
call a method

Overrides:
_callMethod in class Runtime
Parameters:
context - the context
c - the class of method
name - the method name
args - the paramters
types - the types of the formal arguments
target - the target object
Returns:
the return value

_callConstructor

protected java.lang.Object _callConstructor(Context context,
                                            java.lang.Class c,
                                            java.lang.Object[] args,
                                            java.lang.Class[] types)
Description copied from class: Runtime
Call a constructor

Overrides:
_callConstructor in class Runtime
Parameters:
context - the context in which the constructor is called
c - the class of method
args - the paramters
types - the types of the formal arguments
Returns:
the created instance

_callConstructor

protected java.lang.Object _callConstructor(Context context,
                                            java.lang.Class c,
                                            java.lang.Object[] args,
                                            java.lang.Class[] types,
                                            pnuts.compiler.CodeLoader codeLoader)
                                     throws java.lang.IllegalAccessException,
                                            java.lang.IllegalArgumentException,
                                            java.lang.reflect.InvocationTargetException,
                                            java.lang.InstantiationException
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException

makeProxy

public static PnutsFunction makeProxy(java.lang.reflect.Constructor cons)
This method maps a proxy object of a Constructor to a PnutsFunction. Call of the resulting function is faster than reflection API calls.

Parameters:
cons - a constructor
Returns:
an instance the constructor creates.

makeProxy

public static PnutsFunction makeProxy(java.lang.reflect.Method method)
This method maps a proxy object of a Method to a PnutsFunction. Call of the resulting function is expected to be faster than reflection API calls.

Parameters:
method - a method
Returns:
the result of the 'method' call.

getBeanProperty

public java.lang.Object getBeanProperty(java.lang.Object target,
                                        java.lang.String name)
                                 throws java.lang.IllegalAccessException
Gets a Bean property of the specified bean.

Overrides:
getBeanProperty in class Runtime
Parameters:
target - the target bean
name - the Bean property name
Throws:
java.lang.IllegalAccessException

getBeanProperty

protected java.lang.Object getBeanProperty(java.lang.Object target,
                                           java.lang.String name,
                                           java.lang.Class stopClass)
                                    throws java.lang.IllegalAccessException
Gets a Bean property of the specified bean.

Overrides:
getBeanProperty in class Runtime
Parameters:
target - the target bean
name - the Bean property name
stopClass - the Introspector's "stopClass"
Throws:
java.lang.IllegalAccessException

setBeanProperty

public void setBeanProperty(java.lang.Object target,
                            java.lang.String name,
                            java.lang.Object value)
                     throws java.lang.IllegalAccessException,
                            java.lang.reflect.InvocationTargetException
Sets a Bean property of the specified bean.

Overrides:
setBeanProperty in class Runtime
Parameters:
target - the target bean
name - the Bean property name
value - the new property value
Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

setBeanProperty

protected void setBeanProperty(java.lang.Object target,
                               java.lang.String name,
                               java.lang.Object value,
                               java.lang.Class stopClass)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException
Sets a Bean property of the specified bean.

Overrides:
setBeanProperty in class Runtime
Parameters:
target - the target bean
name - the Bean property name
value - the new property value
stopClass - the Introspector's "stopClass"
Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

getBeanPropertyType

public java.lang.Class getBeanPropertyType(java.lang.Class cls,
                                           java.lang.String name)
Gets the type of a bean property

Overrides:
getBeanPropertyType in class Runtime
Parameters:
cls - the class of the bean
name - the property name of the bean property
Returns:
the type of the property