dk.brics.string.java
Interface IntermediateFactory

All Known Implementing Classes:
StatementTranslatorFacadeImpl

public interface IntermediateFactory

This is a Facade pattern, used by StatementTranslatorImpl and MethodCallTranslator. It is designed to minimize the amount of code required in these classes.

The main objective of the interface is to abstract away all contextual information for the translator. For example, addStatement(dk.brics.string.intermediate.Statement) itself determines where to place a statement, and canBeNull(soot.Local) itself knows which statement is currently being translated.

It is likely that more methods will be added during development.


Method Summary
 void addHotspot(Variable var, ValueBox box)
          Registers the specified value box as a hotspot.
 void addStatement(Statement stm)
          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 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 invocation)
          Gets a list of possible targets for the specified invocation.
 Method getToStringMethod(SootClass clazz)
          Returns the intermediate method representing the specified non-interface class's toString method.
 boolean isHotspot(ValueBox box)
          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 useBranch() jumps back here.
 void useBranch()
          Jumps back to the statement added before the previous call to startBranch(), so statements added with addStatement(Statement) are added from there.
 

Method Detail

addHotspot

void addHotspot(Variable var,
                ValueBox box)
Registers the specified value box as a hotspot. Should only be called if isHotspot(ValueBox) returned true for the specified value box.

Parameters:
var - variable holding the result of the hotspto expression
box - value box containing the expression marked as a hotspot

addStatement

void addStatement(Statement stm)
Adds a statement to the intermediate program. The same statement must not be added twice.

Parameters:
stm - statement to add.

canBeNull

boolean canBeNull(Local local)
Returns whether the specified local might be null at the current program point.

Parameters:
local - a soot local variable
Returns:
true if the specified local might be null.

createVariable

Variable createVariable(VariableType type)
Creates a new variable with the specified type.

Parameters:
type - type of the variable to create.
Returns:
a new variable.

endBranch

void endBranch()
Ends the current branch, by removing the position stored by the previous call to startBranch(), and restores the position marked by the startBranch before that.


fromSootType

VariableType fromSootType(Type type)

getField

Field getField(SootField field)
Returns the intermediate field corresponding to the specified field;


getFieldType

Automaton getFieldType(SootField field)
Returns the static string type of the specified field, or null if the field has no static string type.

Parameters:
field - a field
Returns:
language of the static string type, or null if the field has no static string type

getLocal

Variable getLocal(Local local)
Returns the intermediate variable corresponding to the specified local.


getMethod

Method getMethod(SootMethod method)
Returns the intermediate method definition corresponding to the specified Soot method, or null if the method is external.


getMethodReturnType

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.

Parameters:
method - a soot method
Returns:
language of the static string type, or null if the return value has no static string type

getNothing

Variable getNothing()
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!

Returns:
a variable of type NONE.

getParameter

Variable getParameter(ParameterRef ref)
Returns the variable corresponding to a soot parameter reference


getParameterType

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.

Parameters:
ref - a parameter
Returns:
language of the static string type, or null if the parameter has no static string type

getTargetsOf

List<SootMethod> getTargetsOf(InstanceInvokeExpr invocation)
Gets a list of possible targets for the specified invocation.


getToStringMethod

Method getToStringMethod(SootClass clazz)
Returns the intermediate method representing the specified non-interface class's toString method.

Parameters:
clazz - an application class that is not an interface.
Returns:
an intermediate method.

isHotspot

boolean isHotspot(ValueBox box)
Returns true if the specified value is marked as a hotspot.


isSubtypeOf

boolean isSubtypeOf(SootClass a,
                    SootClass b)
Returns true if the first argument is a type that extends, implements, or equals the second argument.


setExpressionVariable

void setExpressionVariable(ValueBox value,
                           Variable variable)
Reports that the specified expression was evaluated and stored in the specified intermediate variable.

Parameters:
value - a jimple expression
variable - an intermediate variable

startBranch

void startBranch()
Remembers the current position in the program, so successive calls to useBranch() jumps back here.


useBranch

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



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