dk.brics.string.java
Class StatementTranslatorFacadeImpl

java.lang.Object
  extended by dk.brics.string.java.StatementTranslatorFacadeImpl
All Implemented Interfaces:
IntermediateFactory, StatementTranslatorFacade

public class StatementTranslatorFacadeImpl
extends Object
implements IntermediateFactory, StatementTranslatorFacade

Acts as the middle-man between MethodTranslator and StatementTranslatorImpl.

StatementTranslatorImpl requires a large facade implementation to use (IntermediateFactory), and the method translator wants a simple-to-use statement translator. This class satisfies both by acting as a facade pattern in both directions.


Constructor Summary
StatementTranslatorFacadeImpl(StatementTranslator translator)
           
 
Method Summary
 void addHotspot(Variable var, ValueBox box)
          Registers the specified value box as a hotspot.
 void addStatement(Statement s)
          Adds a statement to the intermediate program.
 boolean canBeNull(Local local)
          Returns whether the specified local might be null at the current program point.
 Variable createVariable(VariableType type)
          Creates a new variable with the specified type.
 void endBranch()
          Ends the current branch, by removing the position stored by the previous call to IntermediateFactory.startBranch(), and restores the position marked by the startBranch before that.
 VariableType fromSootType(Type type)
           
 Field getField(SootField field)
          Returns the intermediate field corresponding to the specified field;
 Automaton getFieldType(SootField field)
          Returns the static string type of the specified field, or null if the field has no static string type.
 Variable getLocal(Local local)
          Returns the intermediate variable corresponding to the specified local.
 Method getMethod(SootMethod method)
          Returns the intermediate method definition corresponding to the specified Soot method, or null if the method is external.
 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.
 Variable getNothing()
          Returns a variable representing everything we don't care about in the analysis.
 Variable getParameter(ParameterRef ref)
          Returns the variable corresponding to a soot parameter reference
 Automaton getParameterType(ParameterRef ref)
          Returns the static string type of the nth parameter to the specified method, or null if the parameter has no static string type.
 List<SootMethod> getTargetsOf(InstanceInvokeExpr expr)
          Gets a list of possible targets for the specified invocation.
 Method getToStringMethod(SootClass c)
          Returns the intermediate method representing the specified non-interface class's toString method.
 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(ValueBox value, Variable variable)
          Reports that the specified expression was evaluated and stored in the specified intermediate variable.
 void startBranch()
          Remembers the current position in the program, so successive calls to IntermediateFactory.useBranch() jumps back here.
 TranslatedStatement translateStatement(Stmt stmt, SootMethod sootMethod, NullnessAnalysis nullAnalysis, TranslationContext jt)
          Translates the specified Jimple-statement into intermediate code, and returns the entry- and exitpoint for the created graph.
 void useBranch()
          Jumps back to the statement added before the previous call to IntermediateFactory.startBranch(), so statements added with IntermediateFactory.addStatement(Statement) are added from there.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatementTranslatorFacadeImpl

public StatementTranslatorFacadeImpl(StatementTranslator translator)
Method Detail

addHotspot

public void addHotspot(Variable var,
                       ValueBox box)
Description copied from interface: IntermediateFactory
Registers the specified value box as a hotspot. Should only be called if IntermediateFactory.isHotspot(ValueBox) returned true for the specified value box.

Specified by:
addHotspot in interface IntermediateFactory
Parameters:
var - variable holding the result of the hotspto expression
box - value box containing the expression marked as a hotspot

addStatement

public void addStatement(Statement s)
Description copied from interface: IntermediateFactory
Adds a statement to the intermediate program. The same statement must not be added twice.

Specified by:
addStatement in interface IntermediateFactory
Parameters:
s - statement to add.

canBeNull

public boolean canBeNull(Local local)
Description copied from interface: IntermediateFactory
Returns whether the specified local might be null at the current program point.

Specified by:
canBeNull in interface IntermediateFactory
Parameters:
local - a soot local variable
Returns:
true if the specified local might be null.

createVariable

public Variable createVariable(VariableType type)
Description copied from interface: IntermediateFactory
Creates a new variable with the specified type.

Specified by:
createVariable in interface IntermediateFactory
Parameters:
type - type of the variable to create.
Returns:
a new variable.

endBranch

public void endBranch()
Description copied from interface: IntermediateFactory
Ends the current branch, by removing the position stored by the previous call to IntermediateFactory.startBranch(), and restores the position marked by the startBranch before that.

Specified by:
endBranch in interface IntermediateFactory

fromSootType

public VariableType fromSootType(Type type)
Specified by:
fromSootType in interface IntermediateFactory

getField

public Field getField(SootField field)
Description copied from interface: IntermediateFactory
Returns the intermediate field corresponding to the specified field;

Specified by:
getField in interface IntermediateFactory

getFieldType

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

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

getLocal

public Variable getLocal(Local local)
Description copied from interface: IntermediateFactory
Returns the intermediate variable corresponding to the specified local.

Specified by:
getLocal in interface IntermediateFactory

getMethod

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

Specified by:
getMethod in interface IntermediateFactory

getMethodReturnType

public Automaton getMethodReturnType(SootMethod method)
Description copied from interface: IntermediateFactory
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 IntermediateFactory
Parameters:
method - a soot method
Returns:
language of the static string type, or null if the return value has no static string type

getNothing

public Variable getNothing()
Description copied from interface: IntermediateFactory
Returns a variable representing everything we don't care about in the analysis. The variable has type NONE and must not be assigned to anything!

Specified by:
getNothing in interface IntermediateFactory
Returns:
a variable of type NONE.

getParameter

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

Specified by:
getParameter in interface IntermediateFactory

getParameterType

public Automaton getParameterType(ParameterRef ref)
Description copied from interface: IntermediateFactory
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 IntermediateFactory
Parameters:
ref - a parameter
Returns:
language of the static string type, or null if the parameter has no static string type

getTargetsOf

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

Specified by:
getTargetsOf in interface IntermediateFactory

getToStringMethod

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

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

isHotspot

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

Specified by:
isHotspot in interface IntermediateFactory

isSubtypeOf

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

Specified by:
isSubtypeOf in interface IntermediateFactory

setExpressionVariable

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

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

startBranch

public void startBranch()
Description copied from interface: IntermediateFactory
Remembers the current position in the program, so successive calls to IntermediateFactory.useBranch() jumps back here.

Specified by:
startBranch in interface IntermediateFactory

translateStatement

public TranslatedStatement translateStatement(Stmt stmt,
                                              SootMethod sootMethod,
                                              NullnessAnalysis nullAnalysis,
                                              TranslationContext jt)
Description copied from interface: StatementTranslatorFacade
Translates the specified Jimple-statement into intermediate code, and returns the entry- and exitpoint for the created graph.

Specified by:
translateStatement in interface StatementTranslatorFacade
Parameters:
stmt - the statement to translate.
sootMethod - the method whose body contains the statement.
Returns:
entry- and exitpoint for the in created graph.

useBranch

public void useBranch()
Description copied from interface: IntermediateFactory
Jumps back to the statement added before the previous call to IntermediateFactory.startBranch(), so statements added with IntermediateFactory.addStatement(Statement) are added from there.

Specified by:
useBranch in interface IntermediateFactory


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