jist.runtime
Class RewriterTraversalModifyEntityCreation

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

 class RewriterTraversalModifyEntityCreation
extends ClassTraversal.Empty

Traversal object that ensures all entity creation operations are modified to result in an EntityRef on the stack, instead of the original Entity. The way this is done is by searching for constructor (<init>) method calls on entity objects. At the end of this method call there is an instance of the object on the stack. We use this instance to call Controller.newRef(Entity), which creates and returns a new entityRef that refers to the current entity. Additionally, this traversal object modifies entity array creation.

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

Field Summary
private  org.apache.bcel.generic.ConstantPoolGen cpg
          class constant pool.
private  org.apache.bcel.generic.InstructionFactory ifc
          class instruction factory.
private  int NEWs
          number of (nested) new instructions.
private  Rewriter rewriter
          primary rewriter.
 
Constructor Summary
RewriterTraversalModifyEntityCreation(Rewriter rewriter)
          Create rewriter object to modify entity creation 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.
 org.apache.bcel.generic.MethodGen doMethod(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg)
          Upcall to process method before instruction processing.
 
Methods inherited from class jist.runtime.ClassTraversal.Empty
doClassPost, doField, doMethodPost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rewriter

private Rewriter rewriter
primary rewriter.


ifc

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


cpg

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


NEWs

private int NEWs
number of (nested) new instructions.

Constructor Detail

RewriterTraversalModifyEntityCreation

public RewriterTraversalModifyEntityCreation(Rewriter rewriter)
Create rewriter object to modify entity creation 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

doMethod

public org.apache.bcel.generic.MethodGen doMethod(org.apache.bcel.generic.ClassGen cg,
                                                  org.apache.bcel.generic.MethodGen mg)
Upcall to process method before instruction processing.

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

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