jist.swans
Class Rewriter.ModifyTypeTraversal

java.lang.Object
  extended by jist.runtime.ClassTraversal.Empty
      extended by jist.swans.Rewriter.ModifyTypeTraversal
All Implemented Interfaces:
ClassTraversal.Visitor
Enclosing class:
Rewriter

public static class Rewriter.ModifyTypeTraversal
extends ClassTraversal.Empty

Class traversal that substitutes types in all the common places.

Since:
SWANS1.0
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
private  org.apache.bcel.generic.InstructionFactory ifc
          class instruction factory.
private  Rewriter.ModifyTypeInfo[] modifications
          type modification info.
 
Constructor Summary
Rewriter.ModifyTypeTraversal(Rewriter.ModifyTypeInfo[] modifications)
          Create a type-modifying traversal object.
 
Method Summary
 org.apache.bcel.generic.ClassGen doClass(org.apache.bcel.generic.ClassGen cg)
          Upcall to process class before field and method processing.
 org.apache.bcel.generic.FieldGen doField(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.FieldGen fg)
          Upcall to process field.
 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.
private  boolean isIgnored(java.lang.String classname)
           
private  boolean shouldAddJistPostInit(java.lang.String oldName)
           
private  boolean shouldTransformName(java.lang.String n)
           
private  boolean shouldTransformType(org.apache.bcel.generic.Type t)
           
private  boolean shouldTransformTypes(org.apache.bcel.generic.Type[] t)
           
private  java.lang.String transformName(java.lang.String n)
          Replace type by string.
private  org.apache.bcel.generic.Type transformType(org.apache.bcel.generic.Type t)
          Replace BCEL type.
private  org.apache.bcel.generic.Type[] transformTypes(org.apache.bcel.generic.Type[] t)
          Replace BCEL type array.
 
Methods inherited from class jist.runtime.ClassTraversal.Empty
doClassPost, 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.


modifications

private Rewriter.ModifyTypeInfo[] modifications
type modification info.

Constructor Detail

Rewriter.ModifyTypeTraversal

public Rewriter.ModifyTypeTraversal(Rewriter.ModifyTypeInfo[] modifications)
Create a type-modifying traversal object.

Parameters:
oldName - name of old type
newName - name of new type
addJistPostInit - whether to add a _jistPostInit call after an initializer call is modified.
Method Detail

transformType

private org.apache.bcel.generic.Type transformType(org.apache.bcel.generic.Type t)
Replace BCEL type.

Parameters:
t - type to replace
Returns:
replaced type

shouldTransformType

private boolean shouldTransformType(org.apache.bcel.generic.Type t)

transformTypes

private org.apache.bcel.generic.Type[] transformTypes(org.apache.bcel.generic.Type[] t)
Replace BCEL type array.

Parameters:
t - type array to substitute
Returns:
array with types replaced

shouldTransformTypes

private boolean shouldTransformTypes(org.apache.bcel.generic.Type[] t)

transformName

private java.lang.String transformName(java.lang.String n)
Replace type by string.

Parameters:
n - type string to substitute
Returns:
replaced type string

shouldTransformName

private boolean shouldTransformName(java.lang.String n)

isIgnored

private boolean isIgnored(java.lang.String classname)

shouldAddJistPostInit

private boolean shouldAddJistPostInit(java.lang.String oldName)

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

doField

public org.apache.bcel.generic.FieldGen doField(org.apache.bcel.generic.ClassGen cg,
                                                org.apache.bcel.generic.FieldGen fg)
Upcall to process field.

Specified by:
doField in interface ClassTraversal.Visitor
Overrides:
doField in class ClassTraversal.Empty
Parameters:
cg - BCEL class generator object
fg - BCEL field generator object to process
Returns:
processed BCEL field 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