edu.rice.cs.dynamicjava.interpreter
Class TreeCompiler.EvaluationAdapter

java.lang.Object
  extended by edu.rice.cs.dynamicjava.interpreter.TreeCompiler.EvaluationAdapter
Enclosing class:
TreeCompiler

public class TreeCompiler.EvaluationAdapter
extends java.lang.Object

Provides an interface through which compiled classes can invoke the interpreter. Each instance corresponds to a single compiled class; within the class, each relevant piece of syntax has a key (a string) generated at compile-time, which the adapter maps to the AST. Compiled classes must only provide that key and an environment in which to perform evaluation, and the adapter calls the appropriate interpreter methods.


Constructor Summary
TreeCompiler.EvaluationAdapter()
           
 
Method Summary
 void evaluateConstructorBody(java.lang.String key, RuntimeBindings bindings, java.lang.Object[] args)
          Evaluate a constructor body in the given environment, extended with the constructor parameters bound to the given arguments.
 java.lang.Object evaluateConstructorCallArg(java.lang.String key, int index, RuntimeBindings bindings, java.lang.Object[] args)
          Evaluate the argument to a this or super constructor call at the given index.
 java.lang.Object evaluateExpression(java.lang.String key, RuntimeBindings bindings)
          Evaluate an expression in the given environment.
 void evaluateInitializer(java.lang.String key, RuntimeBindings bindings)
          Evaluate an initializer in the given environment.
 java.lang.Object evaluateMethod(java.lang.String key, RuntimeBindings bindings, java.lang.Object[] args)
          Evaluate a method body in the given environment, extended with the method parameters bound to the given arguments.
 TreeCompiler.BindingsFactory makeBindingsFactory(RuntimeBindings bindings)
          Make a factory object for binding a value to this.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeCompiler.EvaluationAdapter

public TreeCompiler.EvaluationAdapter()
Method Detail

evaluateMethod

public java.lang.Object evaluateMethod(java.lang.String key,
                                       RuntimeBindings bindings,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
Evaluate a method body in the given environment, extended with the method parameters bound to the given arguments. If the method is non-static, this should be defined in bindings.

Returns:
The value returned by the method body (via a return statement); null if the return statement is void, or if no return statement is evaluated.
Throws:
java.lang.Throwable - Any exceptions (or errors) that occur during evaluation, without any wrapping.

evaluateExpression

public java.lang.Object evaluateExpression(java.lang.String key,
                                           RuntimeBindings bindings)
                                    throws java.lang.Throwable
Evaluate an expression in the given environment.

Returns:
The value of the interpreted expression.
Throws:
java.lang.Throwable - Any exceptions (or errors) that occur during evaluation, without any wrapping.

evaluateConstructorCallArg

public java.lang.Object evaluateConstructorCallArg(java.lang.String key,
                                                   int index,
                                                   RuntimeBindings bindings,
                                                   java.lang.Object[] args)
                                            throws java.lang.Throwable
Evaluate the argument to a this or super constructor call at the given index. The given environment is extended with the constructor parameters bound to the given arguments; this should be defined in bindings.

Parameters:
index - 0-based index into the call's arguments; -1 for the call's outer (prefix) expression
Throws:
java.lang.Throwable - Any exceptions (or errors) that occur during evaluation, without any wrapping.

evaluateConstructorBody

public void evaluateConstructorBody(java.lang.String key,
                                    RuntimeBindings bindings,
                                    java.lang.Object[] args)
                             throws java.lang.Throwable
Evaluate a constructor body in the given environment, extended with the constructor parameters bound to the given arguments. this should be defined in bindings.

Throws:
java.lang.Throwable - Any exceptions (or errors) that occur during evaluation, without any wrapping.

evaluateInitializer

public void evaluateInitializer(java.lang.String key,
                                RuntimeBindings bindings)
                         throws java.lang.Throwable
Evaluate an initializer in the given environment. If the initializer is non-static, this should be defined in bindings.

Throws:
java.lang.Throwable - Any exceptions (or errors) that occur during evaluation, without any wrapping.

makeBindingsFactory

public TreeCompiler.BindingsFactory makeBindingsFactory(RuntimeBindings bindings)
Make a factory object for binding a value to this. This level of indirection is necessary because constructors cannot pass "this" to a method until after the super constructor has run; in the mean time, other methods of this class or constructors of its inner classes may have been invoked, requiring some way to produce the complete bindings.

Parameters:
bindings - A set of bindings to extend.