|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--pnuts.lang.Runtime
This class provides runtime supports for Pnuts compiler/interpreter. Most of the methods are protected static, so that only subclasses can access them.
Constructor Summary | |
protected |
Runtime()
|
Method Summary | |
static java.lang.Class |
arrayType(java.lang.Class c,
int dim)
Creates an array type |
protected static java.lang.Object |
assignRange(java.lang.Object target,
java.lang.Number idx1,
java.lang.Number idx2,
java.lang.Object expr)
This method is called by the syntax "id[from..to] = sth" |
protected static java.lang.Object |
binary(java.lang.Object n1,
java.lang.Object n2,
int operator,
Context context)
Binary operation |
protected static java.lang.Object |
call(Context context,
java.lang.Object funcOrClass,
java.lang.Object[] args,
java.lang.Class[] casts)
This method is called by the syntax "funcOrClass(args...)" |
static java.lang.Object |
callConstructor(java.lang.Class c,
java.lang.Object[] args)
Call a constructor |
static java.lang.Object |
callConstructor(java.lang.Class c,
java.lang.Object[] args,
java.lang.Class[] types)
Call a constructor |
static java.lang.Object |
callConstructor(Context context,
java.lang.Class c,
java.lang.Object[] args,
java.lang.Class[] types)
Call a constructor |
protected static java.lang.Object |
callFunction(Context context,
PnutsFunction func,
java.lang.Object[] args)
Call a function |
static java.lang.Object |
callMethod(java.lang.Class c,
java.lang.String name,
java.lang.Object[] args,
java.lang.Class[] types,
java.lang.Object target)
Call a method |
static java.lang.Object |
callMethod(java.lang.Class c,
java.lang.String name,
java.lang.Object[] args,
java.lang.Object target)
Call a method |
static 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 |
static java.lang.Object |
cast(Context context,
java.lang.Class type,
java.lang.Object object,
boolean flag)
This method is called by the syntax "(Class)object" |
protected static void |
catchException(java.lang.Class type,
PnutsFunction func,
Context context)
This method is called when catch() function is called in a package(non-local) scope |
protected static void |
checkException(Context context,
java.lang.Throwable throwable)
|
protected static void |
checkException(Context context,
java.lang.Throwable throwable,
java.util.Hashtable tab)
Check if any exception handler is registered to the specified exception. |
protected static int |
compareTo(java.lang.Object n1,
java.lang.Object n2,
Context context)
Comparison operation |
protected static void |
escape(java.lang.Object v)
|
protected java.lang.Object |
exec(Context context)
This method is overrided by classes generated by the compiler. |
java.lang.Object |
execute(Context context)
Executes a compiled script. |
static java.net.URL |
fileToURL(java.io.File file)
|
static java.lang.String |
format(java.lang.Object object,
int maxArrayLength)
Get the String representation of the specified object. |
protected static int |
getBeginLine(Context context)
|
protected static java.lang.Class |
getBottomType(java.lang.Class clazz)
Get true component type from an array type. |
static Runtime |
getCompiledScript(java.lang.String name,
Context context)
This method is called by Pnuts.load() when the property "pnuts.compiled.script.prefix" is defined, to load pre-compiled scripts. |
protected static int |
getEndLine(Context context)
|
static java.lang.Object |
getField(Context context,
java.lang.Object target,
java.lang.String name)
Get the value of a instance field. |
protected static Function |
getFunction(Context context)
|
protected static Function |
getFunction(PnutsFunction pf,
int nargs)
|
protected static java.util.Enumeration |
getFunctions(PnutsFunction pf)
|
protected static java.lang.Object |
getIndex(java.lang.Object target,
int index,
Context context)
This method is called by the syntax "target[index]" |
protected static Runtime |
getRuntime(Context context)
|
protected static java.lang.Object |
getScriptSource(Context context)
|
static java.net.URL |
getScriptURL(java.lang.String name,
Context context)
|
static java.lang.Object |
getStaticField(Context context,
java.lang.Class clazz,
java.lang.String name)
Get the value of a static field. |
static boolean |
isArray(java.lang.Object obj)
Check if the parameter is an array |
protected static void |
jump(java.lang.Object v)
|
protected static int |
matchType(java.lang.Class type,
java.lang.Object obj)
|
protected static boolean |
namespaceRefreshed(Context context)
|
protected static java.lang.Object |
newInstance(Context context,
java.lang.Class clazz,
java.lang.Object[] args,
java.lang.Class[] casts)
This method is called by the syntax "clazz(args...)" |
static java.lang.Character |
parseChar(java.lang.String str)
Parse a character literal. |
static java.lang.Object[] |
parseFloat(java.lang.String str)
Parse a floating point number. |
static java.lang.Object[] |
parseInt(java.lang.String str)
Parse an integer. |
static java.lang.String |
parseString(java.lang.String str)
Parse a string literal. |
static java.lang.Object |
primitive(Context context,
java.lang.Class primitiveType,
java.lang.Object param,
boolean flag)
This method is called by the syntax "primitiveType(object)" and "(primitiveType)object" |
static void |
printError(java.lang.Throwable t,
Context context)
|
static void |
putField(Context context,
java.lang.Object target,
java.lang.String name,
java.lang.Object expr)
Assign an object to a instance field. |
static void |
putStaticField(Context context,
java.lang.Class clazz,
java.lang.String name,
java.lang.Object expr)
Assign an object to a static field. |
static java.lang.Object |
quantity(java.lang.Number number,
java.lang.String numberString,
java.lang.String unit,
Context context)
Creates an object from a number literal and a unit symbol |
protected static java.lang.Object |
range(java.lang.Object target,
java.lang.Number idx1,
java.lang.Number idx2,
Context context)
Range expression 'target[idx1..idx2]' |
static void |
readSymbolTable(pnuts.lang.SymbolTable table,
java.io.ObjectInputStream s)
Read a hashtable from objectInputStream. |
protected static void |
setLine(Context context,
int line)
|
protected static void |
setLine(Context context,
int beginLine,
int endLine)
Set line number information for error reporting |
protected static void |
setPackage(Package pkg,
Context context)
|
protected static java.lang.Object |
transform(java.lang.Class baseType,
java.lang.Object array)
Transform an array to a different array type. |
protected static java.lang.Object |
unary(java.lang.Object n,
int operator,
Context context)
Unary operation |
static int |
writeSymbolTable(pnuts.lang.SymbolTable tab,
pnuts.lang.SymbolTable notToSerialize,
java.io.ObjectOutputStream s)
Write a hashtable to the objectOutputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Runtime()
Method Detail |
public java.lang.Object execute(Context context)
context
- the context in which this object is executedprotected java.lang.Object exec(Context context)
context
- the context in which this object is executedpublic static 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)
context
- the context in which the method is calledc
- the class of methodname
- the method nameargs
- the paramterstypes
- the types of the paramterstarget
- the target objectpublic static java.lang.Object callMethod(java.lang.Class c, java.lang.String name, java.lang.Object[] args, java.lang.Object target) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
c
- the class of methodname
- the method nameargs
- the paramterstarget
- the target objectpublic static java.lang.Object callMethod(java.lang.Class c, java.lang.String name, java.lang.Object[] args, java.lang.Class[] types, java.lang.Object target) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
c
- the class of methodname
- the method nameargs
- the paramterstypes
- the types of the formal argumentstarget
- the target objectpublic static java.lang.Object callConstructor(Context context, java.lang.Class c, java.lang.Object[] args, java.lang.Class[] types)
context
- the context in which the constructor is calledc
- the class of methodargs
- the paramterstypes
- the types of the formal argumentspublic static java.lang.Object callConstructor(java.lang.Class c, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException
c
- the class of constructorargs
- the paramterspublic static java.lang.Object callConstructor(java.lang.Class c, java.lang.Object[] args, java.lang.Class[] types) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException
c
- the class of constructorargs
- the paramterstypes
- the types of the formal argumentspublic static void putStaticField(Context context, java.lang.Class clazz, java.lang.String name, java.lang.Object expr)
context
- the context in which the field is accessedclazz
- the class in which the static field is definedname
- the name of the static fieldexpr
- the value to be assignedpublic static java.lang.Object getStaticField(Context context, java.lang.Class clazz, java.lang.String name)
context
- the context in which the field is accessedclazz
- the class in which the static field is definedname
- the name of the static fieldpublic static void putField(Context context, java.lang.Object target, java.lang.String name, java.lang.Object expr)
context
- the context in which the field is accessedtarget
- the target object of the fieldname
- the name of the fieldexpr
- the value to be assignedpublic static java.lang.Object getField(Context context, java.lang.Object target, java.lang.String name)
context
- the context in which the field is accessedtarget
- the target object of the fieldname
- the name of the fieldprotected static java.lang.Class getBottomType(java.lang.Class clazz)
clazz
- An array type to be examinedpublic static java.lang.Class arrayType(java.lang.Class c, int dim)
c
- the component typedim
- the number of dimensionsprotected static java.lang.Object transform(java.lang.Class baseType, java.lang.Object array)
baseType
- The component type of which the array to createarray
- The source array of the transformationclazz
type that has same values as obj
public static int writeSymbolTable(pnuts.lang.SymbolTable tab, pnuts.lang.SymbolTable notToSerialize, java.io.ObjectOutputStream s) throws java.io.IOException
public static void readSymbolTable(pnuts.lang.SymbolTable table, java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
protected static int matchType(java.lang.Class type, java.lang.Object obj)
public static java.lang.Object[] parseInt(java.lang.String str)
public static java.lang.Object[] parseFloat(java.lang.String str)
public static java.lang.String parseString(java.lang.String str)
public static java.lang.Character parseChar(java.lang.String str)
public static java.lang.Object quantity(java.lang.Number number, java.lang.String numberString, java.lang.String unit, Context context)
number
- a number objectnumberString
- a symbol of the number literalunit
- a unit symbolcontext
- a context in which the quantity is createdpublic static java.lang.Object primitive(Context context, java.lang.Class primitiveType, java.lang.Object param, boolean flag)
context
- the contextprimitiveType
- a primitive typeparam
- the parameterflag
- string<->number conversionpublic static java.lang.Object cast(Context context, java.lang.Class type, java.lang.Object object, boolean flag)
context
- the contexttype
- the typeflag
- object_array<->primitive_array conversionpublic static final boolean isArray(java.lang.Object obj)
obj
- the object to be checkedprotected static java.lang.Object range(java.lang.Object target, java.lang.Number idx1, java.lang.Number idx2, Context context)
protected static java.lang.Object assignRange(java.lang.Object target, java.lang.Number idx1, java.lang.Number idx2, java.lang.Object expr)
protected static void checkException(Context context, java.lang.Throwable throwable)
protected static void checkException(Context context, java.lang.Throwable throwable, java.util.Hashtable tab)
context
- the Context in which the exception is checkedthrowable
- the exceptiontab
- the exception handler tableprotected static void catchException(java.lang.Class type, PnutsFunction func, Context context)
type
- the exception type of which an exception handler is registeredfunc
- the function to be registered as an exception handlercontext
- the context in which the exception handler is registeredprotected static java.lang.Object getIndex(java.lang.Object target, int index, Context context)
protected static java.lang.Object newInstance(Context context, java.lang.Class clazz, java.lang.Object[] args, java.lang.Class[] casts)
protected static final java.lang.Object callFunction(Context context, PnutsFunction func, java.lang.Object[] args)
context
- the context in which the function is calledfunc
- the function to be calledargs
- the argumentsprotected static final java.lang.Object call(Context context, java.lang.Object funcOrClass, java.lang.Object[] args, java.lang.Class[] casts)
protected static void jump(java.lang.Object v)
protected static void escape(java.lang.Object v)
protected static void setLine(Context context, int beginLine, int endLine)
protected static void setLine(Context context, int line)
protected static int getBeginLine(Context context)
protected static int getEndLine(Context context)
protected static Function getFunction(PnutsFunction pf, int nargs)
protected static java.util.Enumeration getFunctions(PnutsFunction pf)
protected static Runtime getRuntime(Context context)
protected static java.lang.Object getScriptSource(Context context)
protected static Function getFunction(Context context)
protected static boolean namespaceRefreshed(Context context)
protected static void setPackage(Package pkg, Context context)
public static java.lang.String format(java.lang.Object object, int maxArrayLength)
object
- the target object.maxArrayLength
- When the target object is an array and maxArrayLength is greater than zero, only the first maxArrayLength elements are printed and the rest of the elements are omitted as "...".protected static java.lang.Object binary(java.lang.Object n1, java.lang.Object n2, int operator, Context context)
n1
- the first argumentn2
- the second argumentoperator
- an integer which is corresponds to the operatorcontext
- the context in which the operation is taken placeprotected static int compareTo(java.lang.Object n1, java.lang.Object n2, Context context)
n1
- the first argumentn2
- the second argumentcontext
- the context in which the operation is taken placeprotected static java.lang.Object unary(java.lang.Object n, int operator, Context context)
n
- the argumentoperator
- an integer which corresponds to the operatorcontext
- the context in which the operation is taken placepublic static java.net.URL getScriptURL(java.lang.String name, Context context)
public static Runtime getCompiledScript(java.lang.String name, Context context)
name
- the script namecontext
- the context in which the class is loaded.public static java.net.URL fileToURL(java.io.File file) throws java.net.MalformedURLException
public static void printError(java.lang.Throwable t, Context context)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |