dk.brics.string.java
Class Jimple2Intermediate

java.lang.Object
  extended by dk.brics.string.java.Jimple2Intermediate
All Implemented Interfaces:
StaticStringTypes, TranslationContext

public class Jimple2Intermediate
extends Object
implements TranslationContext

Converter from Jimple code to intermediate representation.

Basic rundown of the translation process:

  1. Create intermediate Method objects with empty bodies for each method in the application.
  2. Create the wrapper method, which is a special method that calls all externally visible methods with corrupt/unknown arguments.
  3. Create methods modelling the toString-method for each application class.
  4. Translate the method bodies from jimple into intermediate code.
The first three steps are handled by this class, while the fourth and most complicated step is delegated to several other classes. See MethodTranslator for an overview how how step four is executed.

See Also:
StringAnalysis, MethodTranslator

Constructor Summary
Jimple2Intermediate(ExternalVisibility ext)
          Deprecated. 
Jimple2Intermediate(ExternalVisibility ext, Collection<? extends Resolver> resolvers)
          Deprecated. 
Jimple2Intermediate(Jimple2IntermediateFactory af)
           
Jimple2Intermediate(TaintAnalysisStrategy taintAnalysisStrategy, Collection<? extends Resolver> resolvers, ExternalVisibility ext)
          Deprecated. 
 
Method Summary
 VariableType fromSootType(Type type)
          Given the static type of a variable, returns the most specific variable type we can assign to it.
 Application getApplication()
           
 Map<ValueBox,String> getClassNameMap()
          Returns class name for each expression.
 Variable getExpressionVariable(Value value)
          Returns the variable holding the result of the specified expression.
 Automaton getFieldType(SootField field)
          Returns the static string type of the specified field, or null if the field has no static string type.
 Map<ValueBox,Integer> getLineNumberMap()
          Returns line number for each expression.
 Method getMethod(SootMethod method)
          Returns the intermediate method definition corresponding to the specified Soot method, or null if the method is external.
 Method getMethod(String signature)
          Returns the method object for the given signature.
 Map<ValueBox,String> getMethodNameMap()
          Returns method name for each expression.
 Automaton getMethodReturnType(SootMethod method)
          Returns the static string type of the specified method's return value, or null if the return value has no static string type.
 int getNumberOfExpsSkipped()
          Returns the number of string constants that have been skipped because they are non-hotspot arguments to non-application class methods.
 Variable getParameter(SootMethod sm, int index)
          Returns the parameter variable for the given relevant-arg number in the current method.
 Variable getParameter(SootMethod sm, ParameterRef ref)
          Returns the variable corresponding to a soot parameter reference
 Automaton getParameterType(SootMethod method, int paramIndex)
          Returns the static string type of the nth parameter to the specified method, or null if the parameter has no static string type.
 int[] getRelevantArgNumbers(String signature)
          Returns the relevant-arg numbers for the given method.
 Map<ValueBox,String> getSourceFileMap()
          Returns source file name for each expression.
 TaintAnalysisStrategy getTaintAnalysisStrategy()
           
 List<SootMethod> getTargetsOf(InstanceInvokeExpr expr)
          Gets a list of possible targets for the specified invocation.
 Map<SootClass,StringStatement> getToStringHotspotMap()
          Returns hotspots for toString methods.
 Method getToStringMethod(SootClass c)
          Returns the intermediate method representing the specified non-interface class's toString method.
 Map<ValueBox,Statement> getTranslationMap()
          Returns the translation map.
 Automaton getTypeAutomaton(Type t)
           
 VariableManager getVariableManager()
           
 boolean isApplicationClass(SootClass c)
          Checks whether the given class is an application class.
 boolean isHotspot(ValueBox expr)
          Returns true if the specified value is marked as a hotspot.
 boolean isSubtypeOf(SootClass a, SootClass b)
          Returns true if the first argument is a type that extends, implements, or equals the second argument.
 void setExpressionVariable(Value value, Variable variable)
          Reports that the specified expression was evaluated and stored in the specified intermediate variable.
 Application translateApplicationClasses()
          Translates the application classes considering all expressions as hotspots.
 Application translateApplicationClasses(Collection<ValueBox> hotspots)
          Translates the application classes considering the given expressions as hotspots.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jimple2Intermediate

@Deprecated
public Jimple2Intermediate(ExternalVisibility ext)
Deprecated. 

Constructs a new converter using no resolvers.


Jimple2Intermediate

@Deprecated
public Jimple2Intermediate(ExternalVisibility ext,
                                      Collection<? extends Resolver> resolvers)
Deprecated. 

Constructs a new converter using the given resolvers.


Jimple2Intermediate

public Jimple2Intermediate(Jimple2IntermediateFactory af)

Jimple2Intermediate

@Deprecated
public Jimple2Intermediate(TaintAnalysisStrategy taintAnalysisStrategy,
                                      Collection<? extends Resolver> resolvers,
                                      ExternalVisibility ext)
Deprecated. 

Method Detail

fromSootType

public VariableType fromSootType(Type type)
Given the static type of a variable, returns the most specific variable type we can assign to it.

For example, a variable of type Cloneable might be an array, so this returns ARRAY if the argument equals java.lang.Cloneable. On the other hand, if the argument is java.io.Serializable, it returns OBJECT because all the interesting types implement Serializable.

Specified by:
fromSootType in interface TranslationContext
Parameters:
type - a soot type
Returns:
a variable type. null and VariableType.NULL are never returned.

getApplication

public Application getApplication()
Specified by:
getApplication in interface TranslationContext

getClassNameMap

public Map<ValueBox,String> getClassNameMap()
Returns class name for each expression.


getExpressionVariable

public Variable getExpressionVariable(Value value)
Description copied from interface: TranslationContext
Returns the variable holding the result of the specified expression.

Specified by:
getExpressionVariable in interface TranslationContext
Parameters:
value - a jimple expression
Returns:
an intermediate variable, or null if the expression has not been translated

getFieldType

public Automaton getFieldType(SootField field)
Description copied from interface: StaticStringTypes
Returns the static string type of the specified field, or null if the field has no static string type.

Specified by:
getFieldType in interface StaticStringTypes
Parameters:
field - a field
Returns:
language of the static string type, or null if the field has no static string type

getLineNumberMap

public Map<ValueBox,Integer> getLineNumberMap()
Returns line number for each expression.


getMethod

public Method getMethod(SootMethod method)
Description copied from interface: TranslationContext
Returns the intermediate method definition corresponding to the specified Soot method, or null if the method is external.

Specified by:
getMethod in interface TranslationContext

getMethod

public Method getMethod(String signature)
Returns the method object for the given signature.


getMethodNameMap

public Map<ValueBox,String> getMethodNameMap()
Returns method name for each expression.


getMethodReturnType

public Automaton getMethodReturnType(SootMethod method)
Description copied from interface: StaticStringTypes
Returns the static string type of the specified method's return value, or null if the return value has no static string type.

Specified by:
getMethodReturnType in interface StaticStringTypes
Parameters:
method - a soot method
Returns:
language of the static string type, or null if the return value has no static string type

getNumberOfExpsSkipped

public int getNumberOfExpsSkipped()
Returns the number of string constants that have been skipped because they are non-hotspot arguments to non-application class methods.


getParameter

public Variable getParameter(SootMethod sm,
                             int index)
Returns the parameter variable for the given relevant-arg number in the current method.


getParameter

public Variable getParameter(SootMethod sm,
                             ParameterRef ref)
Description copied from interface: TranslationContext
Returns the variable corresponding to a soot parameter reference

Specified by:
getParameter in interface TranslationContext

getParameterType

public Automaton getParameterType(SootMethod method,
                                  int paramIndex)
Description copied from interface: StaticStringTypes
Returns the static string type of the nth parameter to the specified method, or null if the parameter has no static string type.

Specified by:
getParameterType in interface StaticStringTypes
Parameters:
method - a soot method
paramIndex - index of the parameter
Returns:
language of the static string type, or null if the parameter has no static string type

getRelevantArgNumbers

public int[] getRelevantArgNumbers(String signature)
Returns the relevant-arg numbers for the given method.


getSourceFileMap

public Map<ValueBox,String> getSourceFileMap()
Returns source file name for each expression.


getTaintAnalysisStrategy

public TaintAnalysisStrategy getTaintAnalysisStrategy()

getTargetsOf

public List<SootMethod> getTargetsOf(InstanceInvokeExpr expr)
Description copied from interface: TranslationContext
Gets a list of possible targets for the specified invocation.

Specified by:
getTargetsOf in interface TranslationContext

getToStringHotspotMap

public Map<SootClass,StringStatement> getToStringHotspotMap()
Returns hotspots for toString methods.


getToStringMethod

public Method getToStringMethod(SootClass c)
Description copied from interface: TranslationContext
Returns the intermediate method representing the specified non-interface class's toString method.

Specified by:
getToStringMethod in interface TranslationContext
Parameters:
c - an application class that is not an interface.
Returns:
an intermediate method.

getTranslationMap

public Map<ValueBox,Statement> getTranslationMap()
Returns the translation map. translateApplicationClasses must be called first.

Returns:
map from Jimple expression to intermediate representation statement

getTypeAutomaton

public Automaton getTypeAutomaton(Type t)

getVariableManager

public VariableManager getVariableManager()
Specified by:
getVariableManager in interface TranslationContext

isApplicationClass

public boolean isApplicationClass(SootClass c)
Checks whether the given class is an application class.


isHotspot

public boolean isHotspot(ValueBox expr)
Description copied from interface: TranslationContext
Returns true if the specified value is marked as a hotspot.

Specified by:
isHotspot in interface TranslationContext

isSubtypeOf

public boolean isSubtypeOf(SootClass a,
                           SootClass b)
Description copied from interface: TranslationContext
Returns true if the first argument is a type that extends, implements, or equals the second argument.

Specified by:
isSubtypeOf in interface TranslationContext

setExpressionVariable

public void setExpressionVariable(Value value,
                                  Variable variable)
Description copied from interface: TranslationContext
Reports that the specified expression was evaluated and stored in the specified intermediate variable.

Specified by:
setExpressionVariable in interface TranslationContext
Parameters:
value - a jimple expression
variable - an intermediate variable

translateApplicationClasses

public Application translateApplicationClasses()
Translates the application classes considering all expressions as hotspots.


translateApplicationClasses

public Application translateApplicationClasses(Collection<ValueBox> hotspots)
Translates the application classes considering the given expressions as hotspots.



Copyright © 2003-2009 Anders Møller, Aske Simon Christensen, Asger Feldthaus.