jist.runtime
Class RewriterTraversalAddSelfEntityRef

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

 class RewriterTraversalAddSelfEntityRef
extends ClassTraversal.Empty

Traversal object that adds the a self-reference EntityRef field, as well as the appropriate accessor methods (part of the Entity interface). This class also takes care of initializing the ref field. This is done by injecting code just after the invocation of the superclass constructor (the earliest possible time). In this manner, the ref value is initialized for use by any entity method invocations, including any that might be in the constructor body.

Since:
JIST1.0
Author:
Rimon Barr <barr+jist@cs.cornell.edu>
See Also:
Entity, EntityRef

Field Summary
private  boolean foundSuperInit
          whether a superclass initializer has been found.
private  org.apache.bcel.generic.InstructionFactory ifc
          class instruction factory.
private  boolean initializeRef
          whether to insert code to initialize entity reference.
 
Constructor Summary
RewriterTraversalAddSelfEntityRef(boolean initializeRef)
          Create rewriter object that will add an entity self-reference field.
 
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

foundSuperInit

private boolean foundSuperInit
whether a superclass initializer has been found.


ifc

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


initializeRef

private boolean initializeRef
whether to insert code to initialize entity reference.

Constructor Detail

RewriterTraversalAddSelfEntityRef

public RewriterTraversalAddSelfEntityRef(boolean initializeRef)
Create rewriter object that will add an entity self-reference field.

Parameters:
initializeRef - whether to insert code to initialize entity reference
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)
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