vasco.soot.examples
Class SignAnalysis

java.lang.Object
  extended by vasco.InterProceduralAnalysis<M,N,A>
      extended by vasco.ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
          extended by vasco.soot.examples.SignAnalysis

public class SignAnalysis
extends ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>

An inter-procedural simplified sign analysis.

This analysis maps numeric variables to a sign (negative, positive or zero), if it is statically determined to be singular, or else bottom (represented by null.

Flow functions are non-distributive for statements involving sums or products of two variables.

Author:
Rohan Padhye

Nested Class Summary
static class SignAnalysis.Sign
           
 
Field Summary
 
Fields inherited from class vasco.InterProceduralAnalysis
contexts, contextTransitions, freeResultsOnTheFly, reverse, verbose, worklist
 
Method Summary
 Map<Local,SignAnalysis.Sign> boundaryValue(SootMethod method)
          Returns the initial data flow value at the program entry points.
 Map<Local,SignAnalysis.Sign> callEntryFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context, SootMethod calledMethod, Unit unit, Map<Local,SignAnalysis.Sign> inValue)
          Processes the inter-procedural flow function for a method call at the start of the call, to handle parameters.
 Map<Local,SignAnalysis.Sign> callExitFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context, SootMethod calledMethod, Unit unit, Map<Local,SignAnalysis.Sign> exitValue)
          Processes the inter-procedural flow function for a method call at the end of the call, to handle return values.
 Map<Local,SignAnalysis.Sign> callLocalFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context, Unit unit, Map<Local,SignAnalysis.Sign> inValue)
          Processes the intra-procedural flow function for a method call at the call-site itself, to handle propagation of local values that are not involved in the call.
 Map<Local,SignAnalysis.Sign> copy(Map<Local,SignAnalysis.Sign> src)
          Returns a copy of the given data flow value.
 Map<Local,SignAnalysis.Sign> meet(Map<Local,SignAnalysis.Sign> op1, Map<Local,SignAnalysis.Sign> op2)
          Returns the meet of two data flow values.
 Map<Local,SignAnalysis.Sign> normalFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context, Unit unit, Map<Local,SignAnalysis.Sign> inValue)
          Processes the intra-procedural flow function of a statement that does not contain a method call.
 ProgramRepresentation<SootMethod,Unit> programRepresentation()
          Returns a default jimple representation.
 Map<Local,SignAnalysis.Sign> topValue()
          Returns an empty map.
 
Methods inherited from class vasco.ForwardInterProceduralAnalysis
doAnalysis, initContext
 
Methods inherited from class vasco.InterProceduralAnalysis
getCallers, getContext, getContexts, getContextTransitionTable, getMeetOverValidPathsSolution, getMethods, getTargets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

normalFlowFunction

public Map<Local,SignAnalysis.Sign> normalFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context,
                                                       Unit unit,
                                                       Map<Local,SignAnalysis.Sign> inValue)
Description copied from class: ForwardInterProceduralAnalysis
Processes the intra-procedural flow function of a statement that does not contain a method call.

Specified by:
normalFlowFunction in class ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
context - the value context at the call-site
unit - the statement whose flow function to process
inValue - the data flow value before the statement
Returns:
the data flow value after the statement

callEntryFlowFunction

public Map<Local,SignAnalysis.Sign> callEntryFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context,
                                                          SootMethod calledMethod,
                                                          Unit unit,
                                                          Map<Local,SignAnalysis.Sign> inValue)
Description copied from class: ForwardInterProceduralAnalysis
Processes the inter-procedural flow function for a method call at the start of the call, to handle parameters.

Specified by:
callEntryFlowFunction in class ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
context - the value context at the call-site
calledMethod - the target (or one of the targets) of this call site
unit - the statement containing the method call
inValue - the data flow value before the call
Returns:
the data flow value at the entry to the called procedure

callExitFlowFunction

public Map<Local,SignAnalysis.Sign> callExitFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context,
                                                         SootMethod calledMethod,
                                                         Unit unit,
                                                         Map<Local,SignAnalysis.Sign> exitValue)
Description copied from class: ForwardInterProceduralAnalysis
Processes the inter-procedural flow function for a method call at the end of the call, to handle return values.

Specified by:
callExitFlowFunction in class ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
context - the value context at the call-site
calledMethod - the target (or one of the targets) of this call site
unit - the statement containing the method call
exitValue - the data flow value at the exit of the called procedure
Returns:
the data flow value after the call (returned component)

callLocalFlowFunction

public Map<Local,SignAnalysis.Sign> callLocalFlowFunction(Context<SootMethod,Unit,Map<Local,SignAnalysis.Sign>> context,
                                                          Unit unit,
                                                          Map<Local,SignAnalysis.Sign> inValue)
Description copied from class: ForwardInterProceduralAnalysis
Processes the intra-procedural flow function for a method call at the call-site itself, to handle propagation of local values that are not involved in the call.

Specified by:
callLocalFlowFunction in class ForwardInterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
context - the value context at the call-site
unit - the statement containing the method call
inValue - the data flow value before the call
Returns:
the data flow value after the call (local component)

boundaryValue

public Map<Local,SignAnalysis.Sign> boundaryValue(SootMethod method)
Description copied from class: InterProceduralAnalysis
Returns the initial data flow value at the program entry points. For forward analyses this is the IN value at the ENTRY to each entry method, while for backward analyses this is the OUT value at the EXIT to each entry method.

Note that this method will be called exactly once per entry point specified by the program representation.

Specified by:
boundaryValue in class InterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
method - an entry point specified by the program representation
Returns:
the data flow value at the boundary
See Also:
ProgramRepresentation.getEntryPoints()

copy

public Map<Local,SignAnalysis.Sign> copy(Map<Local,SignAnalysis.Sign> src)
Description copied from class: InterProceduralAnalysis
Returns a copy of the given data flow value.

Specified by:
copy in class InterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
src - the data flow value to copy
Returns:
a new data flow value which is a copy of the argument

meet

public Map<Local,SignAnalysis.Sign> meet(Map<Local,SignAnalysis.Sign> op1,
                                         Map<Local,SignAnalysis.Sign> op2)
Description copied from class: InterProceduralAnalysis
Returns the meet of two data flow values.

Specified by:
meet in class InterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Parameters:
op1 - the first operand
op2 - the second operand
Returns:
a new data flow which is the result of the meet operation of the two operands

topValue

public Map<Local,SignAnalysis.Sign> topValue()
Returns an empty map.

Specified by:
topValue in class InterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Returns:
the default data flow value (lattice top)

programRepresentation

public ProgramRepresentation<SootMethod,Unit> programRepresentation()
Returns a default jimple representation.

Specified by:
programRepresentation in class InterProceduralAnalysis<SootMethod,Unit,Map<Local,SignAnalysis.Sign>>
Returns:
The program representation underlying this analysis
See Also:
DefaultJimpleRepresentation