dk.brics.string.java
Class CompositeMethodCallTranslator

java.lang.Object
  extended by dk.brics.string.java.CompositeMethodCallTranslator
All Implemented Interfaces:
MethodCallTranslator

public class CompositeMethodCallTranslator
extends Object
implements MethodCallTranslator

Groups multiple translators together. The underlying translators are called the children of the composite translator.

A method call is handled if any of the children can handle it. If more than one child can handle a method call, only the first of these children is assigned to handle it.


Constructor Summary
CompositeMethodCallTranslator()
          Creates a composite translator without any children.
CompositeMethodCallTranslator(MethodCallTranslator... translators)
          Creates a translator that groups multiple other translators together.
 
Method Summary
 List<MethodCallTranslator> getChildren()
          Gets a reference to the list of children.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeMethodCallTranslator

public CompositeMethodCallTranslator()
Creates a composite translator without any children.


CompositeMethodCallTranslator

public CompositeMethodCallTranslator(MethodCallTranslator... translators)
Creates a translator that groups multiple other translators together.

Parameters:
translators - translators to use, ordered by priority.
Method Detail

getChildren

public List<MethodCallTranslator> getChildren()
Gets a reference to the list of children.

Returns:
a mutable reference to the list of children.

translateAbstractMethodCall

public Variable translateAbstractMethodCall(InstanceInvokeExpr expr,
                                            SootMethod target,
                                            Variable callee,
                                            List<Variable> arguments,
                                            IntermediateFactory factory)
Description copied from interface: MethodCallTranslator
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 MethodCallTranslator.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 MethodCallTranslator.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.

Specified by:
translateAbstractMethodCall in interface MethodCallTranslator
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

public boolean translateConstructorCall(InstanceInvokeExpr expr,
                                        Variable callee,
                                        List<Variable> arguments,
                                        IntermediateFactory factory)
Description copied from interface: MethodCallTranslator
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.

Specified by:
translateConstructorCall in interface MethodCallTranslator
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

public Variable translateMethodCall(InstanceInvokeExpr expr,
                                    SootMethod target,
                                    Variable callee,
                                    List<Variable> arguments,
                                    IntermediateFactory factory)
Description copied from interface: MethodCallTranslator
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.

Specified by:
translateMethodCall in interface MethodCallTranslator
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

public Variable translateStaticMethodCall(InvokeExpr expr,
                                          List<Variable> arguments,
                                          IntermediateFactory factory)
Description copied from interface: MethodCallTranslator
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.

Specified by:
translateStaticMethodCall in interface MethodCallTranslator
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.