jist.runtime
Class RewriterTraversalModifyEntityInvocation

java.lang.Object
  extended by jist.runtime.ClassTraversal.Empty
      extended by jist.runtime.RewriterTraversalModifyEntityInvocation
All Implemented Interfaces:
ClassTraversal.Visitor

 class RewriterTraversalModifyEntityInvocation
extends ClassTraversal.Empty

Traversal object that intercepts any method invocation instructions to entity objects. This conversion is a little bit tricky, because it involves a bit more bytecode generation. The basic idea has three parts. First, the appropriate method object is selected from the corresponding method stub field. Second, corresponding entity reference (or entity, in the case of a "this." call) is passed along. Lastly, all the invocation parameters on the stack are placed an object array of the appropriate size. Primitive types are first converted into their object equivalents.

Since:
JIST1.0
Author:
Rimon Barr <barr+jist@cs.cornell.edu>
See Also:
Controller.newEntityReference(jist.runtime.Entity), JistAPI.Entity, EntityRef

Field Summary
private  org.apache.bcel.generic.ConstantPoolGen cpg
          class constant pool.
private  org.apache.bcel.generic.InstructionFactory ifc
          class instruction factory.
private  Rewriter rewriter
          primary rewriter.
 
Constructor Summary
RewriterTraversalModifyEntityInvocation(Rewriter rewriter)
          Create rewriter object to modify entity invocation points.
 
Method Summary
 org.apache.bcel.generic.ClassGen doClass(org.apache.bcel.generic.ClassGen cg)
          Upcall to process class before field and method processing.
 void doInstruction(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionHandle ih, org.apache.bcel.generic.Instruction inst)
          Upcall to process instruction. Note that instructions can be inserted and deleted directly using the BCEL API, and therefore this method returns void.
private  void packParametersIntoArray(org.apache.bcel.generic.InstructionList il, org.apache.bcel.generic.Type[] args, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionHandle ih)
          Insert code to pack method parameters into object array.
 
Methods inherited from class jist.runtime.ClassTraversal.Empty
doClassPost, doField, doMethod, doMethodPost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ifc

private org.apache.bcel.generic.InstructionFactory ifc
class instruction factory.


cpg

private org.apache.bcel.generic.ConstantPoolGen cpg
class constant pool.


rewriter

private Rewriter rewriter
primary rewriter.

Constructor Detail

RewriterTraversalModifyEntityInvocation

public RewriterTraversalModifyEntityInvocation(Rewriter rewriter)
Create rewriter object to modify entity invocation points.

Parameters:
rewriter - reference to primary rewriter
Method Detail

doClass

public org.apache.bcel.generic.ClassGen doClass(org.apache.bcel.generic.ClassGen cg)
Upcall to process class before field and method processing.

Specified by:
doClass in interface ClassTraversal.Visitor
Overrides:
doClass in class ClassTraversal.Empty
Parameters:
cg - BCEL class generator object to process
Returns:
processed BCEL class generator object

packParametersIntoArray

private void packParametersIntoArray(org.apache.bcel.generic.InstructionList il,
                                     org.apache.bcel.generic.Type[] args,
                                     org.apache.bcel.generic.MethodGen mg,
                                     org.apache.bcel.generic.InstructionHandle ih)
                              throws java.lang.ClassNotFoundException
Insert code to pack method parameters into object array.

Parameters:
il - instruction list
args - method arguments
mg - method object
ih - instruction handle
Throws:
java.lang.ClassNotFoundException

doInstruction

public void doInstruction(org.apache.bcel.generic.ClassGen cg,
                          org.apache.bcel.generic.MethodGen mg,
                          org.apache.bcel.generic.InstructionHandle ih,
                          org.apache.bcel.generic.Instruction inst)
                   throws java.lang.ClassNotFoundException
Upcall to process instruction. Note that instructions can be inserted and deleted directly using the BCEL API, and therefore this method returns void.

Specified by:
doInstruction in interface ClassTraversal.Visitor
Overrides:
doInstruction in class ClassTraversal.Empty
Parameters:
cg - BCEL class generator object
mg - BCEL method generator object
ih - BCEL instruction handle object to process
inst - BCEL instruction object to process
Throws:
java.lang.ClassNotFoundException