envgen.codegen
Class EnvInterface

java.lang.Object
  |
  +--envgen.codegen.EnvInterface

public class EnvInterface
extends java.lang.Object

Discovers environment's interface that consists of environment classes, methods, and fields referenced in the unit.


Field Summary
(package private)  EnvCallGraph callGraph
           
(package private)  int debug
          Set to print debugging messages.
(package private) static java.util.List envMethods
          A list of concrete (analyzable) top-level environment methods
(package private)  java.util.HashMap envTable
          Keeps track of environment components, including only those that get called inside the unit.
(package private)  boolean unitAnalysis
           
(package private)  java.util.HashMap unitTable
          Keeps track of unit classes.
 
Constructor Summary
EnvInterface(java.util.HashMap unitTable, java.util.HashMap envTable, EnvCallGraph callGraph)
           
 
Method Summary
protected  void addAbstractMethods(soot.SootClass externalClass, soot.SootClass markedClass)
          If externalClass extends an abstract class, markedClass might need to have all of the methods that implement abstract methods of the parent.
protected  void addFinalFields(soot.SootClass externalClass, soot.SootClass markedClass)
          Gives markedClass all of the final fields of the externalClass to be able to resolve final field references that are present in the source code but might be absent in the class files.
 void addMethodToClass(soot.SootClass externalClass, soot.SootMethod externalMethod)
          Creates an image of externalMethod not including the body, and adds it to the externalClass.
 boolean envCheck(soot.SootClass sc)
          If sc is in the environment records it in the envTable if it's not there, and returns true.
protected  void envCheckExceptions(soot.SootMethod externalMethod)
          If any of the exceptions of the externalMethod are in the environment, records them in the envTable.
protected  void envCheckField(soot.SootField field)
          If field field is a part of the environment, records its type class in the envTable.
protected  void envCheckFieldRef(soot.SootField refField)
          If field reference fieldRef is a part of the environment, records it in the envTable.
protected  void envCheckFields(soot.SootClass internalClass)
           
protected  void envCheckInterfaces(soot.SootClass internalClass)
          If any of the interfaces of the unit class internalClass are external, records them in the envTable.
protected  void envCheckInvokeExpr(soot.jimple.Stmt site, soot.jimple.InvokeExpr expr, soot.SootMethod internalMethod)
          Resolves invoke expression expr and calls envCheckMethod for all possible methods at this site.
protected  void envCheckLocals(soot.Body jb)
          If any of the locals of the internalMethod are external, records them in the envTable.
protected  void envCheckMethod(soot.SootMethod internalMethod)
           
protected  void envCheckMethods(soot.SootClass internalClass)
           
protected  void envCheckMethodSignature(soot.SootMethod externalMethod)
          If any of the components of the externalMethod signature are in the environment, records them in the /envTable.
protected  void envCheckParams(soot.SootMethod externalMethod)
          If any of the parameter declared types of external method are in the environment, records them in the .
protected  void envCheckParent(soot.SootClass internalClass)
          If a parent of the unit class internalClass is external to the unit, records it in the envTable.
protected  void envCheckReturnType(soot.SootMethod externalMethod)
          If the return type of externalMethod is in the environment, records it in the envTable.
protected  void envCheckStmts(soot.SootMethod internalMethod, soot.Body jb)
          Records any of the external references found in the statement list of the internalMethod in the envTable.
 void envInsertClass(soot.SootClass sc)
           
protected  void envInsertMethod(soot.SootMethod externalMethod)
          If any of the components of the externalMethod signature are in the environment, records them in the /envTable.
protected  void envInsertMethods(soot.SootClass internalClass)
           
 void findMissingComponents()
          Processes unit classes and identifies all external references, recording them in the envTable.
 soot.SootClass getClass(soot.Type type)
          Given a type returns a soot class.
static java.util.List getEnvMethods()
           
 java.util.HashMap getEnvTable()
           
 java.util.HashSet getInterfaces(soot.SootClass sc)
          Gets interfaces of the class.
 soot.SootClass getParent(soot.SootClass sc)
          Gets a parent class from the system.
 java.util.ArrayList getSuperInterfaceClasses(soot.SootClass sc)
          This method gets interfaces that are directly implements by sc and the super interfaces of these interfaces.
 void setHierarchy()
          Sets the hierarchy among the environment classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unitTable

java.util.HashMap unitTable
Keeps track of unit classes.


envTable

java.util.HashMap envTable
Keeps track of environment components, including only those that get called inside the unit.


envMethods

static java.util.List envMethods
A list of concrete (analyzable) top-level environment methods


callGraph

EnvCallGraph callGraph

unitAnalysis

boolean unitAnalysis

debug

int debug
Set to print debugging messages.

Constructor Detail

EnvInterface

public EnvInterface(java.util.HashMap unitTable,
                    java.util.HashMap envTable,
                    EnvCallGraph callGraph)
Method Detail

findMissingComponents

public void findMissingComponents()
Processes unit classes and identifies all external references, recording them in the envTable.


envCheckParent

protected void envCheckParent(soot.SootClass internalClass)
If a parent of the unit class internalClass is external to the unit, records it in the envTable.


envCheckInterfaces

protected void envCheckInterfaces(soot.SootClass internalClass)
If any of the interfaces of the unit class internalClass are external, records them in the envTable.


envCheckFields

protected void envCheckFields(soot.SootClass internalClass)

envCheckMethods

protected void envCheckMethods(soot.SootClass internalClass)

envCheckMethod

protected void envCheckMethod(soot.SootMethod internalMethod)

envCheckLocals

protected void envCheckLocals(soot.Body jb)
If any of the locals of the internalMethod are external, records them in the envTable.


envCheckStmts

protected void envCheckStmts(soot.SootMethod internalMethod,
                             soot.Body jb)
Records any of the external references found in the statement list of the internalMethod in the envTable.


envCheckInvokeExpr

protected void envCheckInvokeExpr(soot.jimple.Stmt site,
                                  soot.jimple.InvokeExpr expr,
                                  soot.SootMethod internalMethod)
Resolves invoke expression expr and calls envCheckMethod for all possible methods at this site.


envCheckMethodSignature

protected void envCheckMethodSignature(soot.SootMethod externalMethod)
If any of the components of the externalMethod signature are in the environment, records them in the /envTable.


envCheckReturnType

protected void envCheckReturnType(soot.SootMethod externalMethod)
If the return type of externalMethod is in the environment, records it in the envTable.


envCheckParams

protected void envCheckParams(soot.SootMethod externalMethod)
If any of the parameter declared types of external method are in the environment, records them in the .


envCheckExceptions

protected void envCheckExceptions(soot.SootMethod externalMethod)
If any of the exceptions of the externalMethod are in the environment, records them in the envTable.


envCheckFieldRef

protected void envCheckFieldRef(soot.SootField refField)
If field reference fieldRef is a part of the environment, records it in the envTable.


envCheckField

protected void envCheckField(soot.SootField field)
If field field is a part of the environment, records its type class in the envTable.


envCheck

public boolean envCheck(soot.SootClass sc)
If sc is in the environment records it in the envTable if it's not there, and returns true.


envInsertClass

public void envInsertClass(soot.SootClass sc)

envInsertMethods

protected void envInsertMethods(soot.SootClass internalClass)

envInsertMethod

protected void envInsertMethod(soot.SootMethod externalMethod)
If any of the components of the externalMethod signature are in the environment, records them in the /envTable.


getClass

public soot.SootClass getClass(soot.Type type)
Given a type returns a soot class.


setHierarchy

public void setHierarchy()
Sets the hierarchy among the environment classes. This allows to leave out some classes from the environment.


getParent

public soot.SootClass getParent(soot.SootClass sc)
Gets a parent class from the system.


getInterfaces

public java.util.HashSet getInterfaces(soot.SootClass sc)
Gets interfaces of the class.


getSuperInterfaceClasses

public java.util.ArrayList getSuperInterfaceClasses(soot.SootClass sc)
This method gets interfaces that are directly implements by sc and the super interfaces of these interfaces.

Parameters:
sc - The soot class of which its direct implemented interfaces and the super interfaces of thes interfaces need to be found.
Returns:
A list of the interfaces that are directly implements by sc and the super interfaces of these interfaces.

addFinalFields

protected void addFinalFields(soot.SootClass externalClass,
                              soot.SootClass markedClass)
Gives markedClass all of the final fields of the externalClass to be able to resolve final field references that are present in the source code but might be absent in the class files.


addAbstractMethods

protected void addAbstractMethods(soot.SootClass externalClass,
                                  soot.SootClass markedClass)
If externalClass extends an abstract class, markedClass might need to have all of the methods that implement abstract methods of the parent. This method should be used after the hierarchy has been established among the environment classes.


addMethodToClass

public void addMethodToClass(soot.SootClass externalClass,
                             soot.SootMethod externalMethod)
Creates an image of externalMethod not including the body, and adds it to the externalClass.


getEnvTable

public java.util.HashMap getEnvTable()

getEnvMethods

public static java.util.List getEnvMethods()