dk.brics.string.java
Interface MethodCallTranslator

All Known Implementing Classes:
ApplicationMethodCallTranslator, BuiltinMethodCallTranslator, CompositeMethodCallTranslator, NaiveMethodCallTranslator, ResolverMethodCallTranslator

public interface MethodCallTranslator

Handles certain method calls specially by creating intermediate statements for them. These methods will typically be the string operations in String, StringBuffer, and StringBuilder. The goal of an implementation is to provide higher precision.

Even if the result of a method call is unknown or useless, it is still desirable to handle the call to indicate whether the callee and the arguments are modified.

This is an application of the Strategy pattern. Multiple method call translators can be grouped with CompositeMethodCallTranslator.


Method Summary
 Variable translateAbstractMethodCall(InstanceInvokeExpr expr, SootMethod target, Variable callee, List<Variable> arguments, IntermediateFactory factory)
          Translates a non-static method call made to the specified method, which might be directed to a different implementation than that method.
 boolean translateConstructorCall(InstanceInvokeExpr expr, Variable callee, List<Variable> arguments, IntermediateFactory factory)
          Translates a constructor invocation into a sequence of statements.
 Variable translateMethodCall(InstanceInvokeExpr expr, SootMethod target, Variable callee, List<Variable> arguments, IntermediateFactory factory)
          Translates a non-static method call into a sequence of statements.
 Variable translateStaticMethodCall(InvokeExpr expr, List<Variable> arguments, IntermediateFactory factory)
          Translates a static method call into a sequence of statements.
 

Method Detail

translateAbstractMethodCall

Variable translateAbstractMethodCall(InstanceInvokeExpr expr,
                                     SootMethod target,
                                     Variable callee,
                                     List<Variable> arguments,
                                     IntermediateFactory factory)
Translates a non-static method call made to the specified method, which might be directed to a different implementation than that method. As such, the specified method may be abstract and may be declared in an interface.

This is always called before the translateMethodCall(soot.jimple.InstanceInvokeExpr, soot.SootMethod, dk.brics.string.intermediate.Variable, java.util.List, dk.brics.string.java.IntermediateFactory) variant. If no translation can be found for an abstract invocation, each possible invocation target is inspected and translateMethodCall(soot.jimple.InstanceInvokeExpr, soot.SootMethod, dk.brics.string.intermediate.Variable, java.util.List, dk.brics.string.java.IntermediateFactory) will then be called for each target.

Parameters:
expr - the soot invocation expression. This provides access to the called method, parameter types, and declaring class.
target - the concrete implementation of the method being called. The expression might refer to a non-final method which is overridden or implemented by the target.
callee - variable holding the object being called on.
arguments - variables holding the (already evaluated) arguments.
factory - object used to create statements and variables.
Returns:
null if the method call could not be handled; a variable of type NONE if the method returned void; and otherwise a variable containing the method's return value.

translateConstructorCall

boolean translateConstructorCall(InstanceInvokeExpr expr,
                                 Variable callee,
                                 List<Variable> arguments,
                                 IntermediateFactory factory)
Translates a constructor invocation into a sequence of statements. The created statements should reflect the side-effects on the constructed object (callee) and the arguments.

Parameters:
expr - the soot invocation expression. This provides access to the called method, parameter types, and declaring class.
callee - variable holding the object being called on.
arguments - variables holding the (already evaluated) arguments.
factory - object used to create statements and variables.
Returns:
true if the constructor call could be handled, false otherwise.

translateMethodCall

Variable translateMethodCall(InstanceInvokeExpr expr,
                             SootMethod target,
                             Variable callee,
                             List<Variable> arguments,
                             IntermediateFactory factory)
Translates a non-static method call into a sequence of statements. The created statements should reflect the side-effects on the callee and the arguments, and the possible values of the return-value.

This method is called once for each possible target of the invocation, with target varying with each call.

Parameters:
expr - the soot invocation expression. This provides access to the called method, parameter types, and declaring class.
target - the concrete implementation of the method being called. The expression might refer to a non-final method which is overridden or implemented by the target.
callee - variable holding the object being called on.
arguments - variables holding the (already evaluated) arguments.
factory - object used to create statements and variables.
Returns:
null if the method call could not be handled; a variable of type NONE if the method returned void; and otherwise a variable containing the method's return value.

translateStaticMethodCall

Variable translateStaticMethodCall(InvokeExpr expr,
                                   List<Variable> arguments,
                                   IntermediateFactory factory)
Translates a static method call into a sequence of statements. The created statements should reflect the side-effects on the arguments, and the possible values of the return-value.

Parameters:
expr - the soot invocation expression. This provides access to the called method, parameter types, and declaring class.
arguments - variables holding the (already evaluated) arguments.
factory - object used to create statements and variables
Returns:
null if the method call could not be handled; a variable of type NONE if the method returned void; and otherwise a variable containing the method's return value.


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