|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--org.omegahat.Environment.Language.Method
Container for one or more functions with same name that are to be treated as a collection with calls being dispatched to the appropriate element whose signature "matches" the call. We use the Java method dispatching to implement this notion of matching and implement it by dynamically generating a class with a method for each of the functions in the table that simply identifies which function to invoke.
| Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
protected java.lang.Class |
dispatchClass
Reference to the class used to perform the identification and dispatching to the appropriate method within the table. |
protected java.util.Vector |
lazyArgs
Stores a list of which arguments we know to be lazy for each of the methods. |
protected DynamicClassLoader |
loader
Class loader that is capable of reading a class definition that is created on the fly via this byte compilation. |
protected java.lang.String |
name
The name by which all the methods in this table are known. |
protected int |
version
The version of the internal class which is incremented each time we re-define this class when methods are added or removed. |
| Constructor Summary | |
Method()
|
|
Method(Function f)
Initialize the collection with a single function. |
|
Method(Method m)
Copy the contents of the given collection into this one. |
|
Method(java.lang.String name,
Function f)
Initialize the collection with a single function and specify the name by which these functions can be called. |
|
| Method Summary | |
void |
addElement(java.lang.Object obj)
|
java.lang.Class |
compile()
Define/compile the internal class used for dispatching calls to the appropriate method in the table, providing the name as the single name used for grouping all the methods in the table and the current version number which is incremented each time we add or remove a method. |
java.lang.Class |
createDispatchClass(java.lang.String name)
|
protected int |
createJavaMethods(jas.ClassEnv env)
Iterates over all of the methods currently stored in the table and defines a Java method corresponding to each arranging to evaluate that function when it is called. |
java.lang.Class |
dispatchClass()
Retrieve the class used to perform the dispatching to the different methods, creating it if it has not been defines by this point. |
java.lang.Class |
dispatchClass(boolean force)
Retrieve the internal class used for identifying the appropriate method for a call, compiling it if has not yet been defined and force
is true. |
java.lang.Class |
dispatchClass(java.lang.Class c)
Store the specified class definition as the internal class used for disptaching calls to the appropriate method in this table, removing any previously defined class from the loader. |
java.lang.Object |
eval(Evaluator evaluator)
|
java.lang.Object |
eval(Function f,
List args,
java.lang.Object This,
Evaluator evaluator)
|
java.lang.Object |
eval(List args,
Evaluator evaluator)
|
java.lang.Object |
eval(java.lang.Object[] args,
Evaluator evaluator)
|
java.lang.Object |
eval(java.lang.String which,
List args,
java.lang.Object This,
Evaluator evaluator)
|
TypedDatabase |
frame(List args,
Evaluator evaluator,
java.lang.Class[] classes,
java.util.Vector ordered)
|
java.lang.String |
functionKey(Function f)
|
protected jas.CodeAttr |
jasBody(java.lang.String id,
int numArgs)
Construct the body of the internal class' method that returns the key into the function table which identifies which function to invoke for the given call. |
void |
jasDefaultConstructor(jas.ClassEnv env)
Create a public constructor that takes no arguments and just calls the corresponding default constructor for the class Object. |
protected jas.Method |
jasMethod(Function f,
java.lang.String key,
jas.ClassEnv env)
|
java.util.Vector |
jasSignature(Function f)
Construct the collection of signatures for the different functions stored in this method table. |
protected java.lang.Class |
load(java.lang.String name,
jas.ClassEnv env)
Load the class defined in the env
object by writing it to a buffer and loading
it via the
DynamicClassLoader
referring to it by the given name. |
DynamicClassLoader |
loader()
Retrieve the current value of the loader
field, instantiating an appropriate object if it is null. |
Function |
locateMethod(Database db,
java.lang.Class[] classes,
java.util.Vector orderedArgs,
Evaluator evaluator)
|
java.lang.Object |
lookupAndDispatch(List args,
Evaluator evaluator)
|
java.lang.String |
name()
Return the value of the name field. |
protected java.lang.String |
name(java.lang.String n)
Set and return the value of the { name field. |
void |
put(Function f)
|
void |
put(Method m)
Add all the functions from the other Method
object specified as the argument
into this table. |
| Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Vector lazyArgs
protected int version
protected java.lang.String name
protected java.lang.Class dispatchClass
protected transient DynamicClassLoader loader
| Constructor Detail |
public Method(Function f)
public Method(java.lang.String name,
Function f)
public Method()
public Method(Method m)
| Method Detail |
public java.lang.Object eval(Evaluator evaluator)
throws java.lang.Throwable
eval in interface Evaluable
public java.lang.Object eval(java.lang.Object[] args,
Evaluator evaluator)
throws java.lang.Throwable
eval in interface Evaluable
public java.lang.Object eval(List args,
Evaluator evaluator)
throws java.lang.Throwable
public java.lang.Object eval(java.lang.String which,
List args,
java.lang.Object This,
Evaluator evaluator)
throws java.lang.Throwable
public java.lang.Object eval(Function f,
List args,
java.lang.Object This,
Evaluator evaluator)
throws java.lang.Throwable
public void addElement(java.lang.Object obj)
public void put(Function f)
public void put(Method m)
Method
object specified as the argument
into this table.
public TypedDatabase frame(List args,
Evaluator evaluator,
java.lang.Class[] classes,
java.util.Vector ordered)
throws java.lang.Throwable
public java.lang.Object lookupAndDispatch(List args,
Evaluator evaluator)
throws java.lang.Throwable
public Function locateMethod(Database db,
java.lang.Class[] classes,
java.util.Vector orderedArgs,
Evaluator evaluator)
throws java.lang.Exception
public java.lang.String functionKey(Function f)
public java.lang.Class compile()
public java.lang.Class createDispatchClass(java.lang.String name)
throws jas.jasError
protected int createJavaMethods(jas.ClassEnv env)
throws jas.jasError
protected jas.Method jasMethod(Function f,
java.lang.String key,
jas.ClassEnv env)
throws jas.jasError
protected jas.CodeAttr jasBody(java.lang.String id,
int numArgs)
throws jas.jasError
public java.util.Vector jasSignature(Function f)
String
suitable for use in the Jas byte compiler
for defining a method.
public void jasDefaultConstructor(jas.ClassEnv env)
throws jas.jasError
Object.
protected java.lang.Class load(java.lang.String name,
jas.ClassEnv env)
env
object by writing it to a buffer and loading
it via the
DynamicClassLoader
referring to it by the given name.public java.lang.String name()
name field.protected java.lang.String name(java.lang.String n)
name field.public java.lang.Class dispatchClass()
public java.lang.Class dispatchClass(boolean force)
force
is true.public java.lang.Class dispatchClass(java.lang.Class c)
public DynamicClassLoader loader()
loader
field, instantiating an appropriate object if it is null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||