ptolemy.copernicus.c
Class CSwitch

java.lang.Object
  extended by ptolemy.copernicus.c.CSwitch
All Implemented Interfaces:
soot.jimple.ConstantSwitch, soot.jimple.ExprSwitch, soot.jimple.JimpleValueSwitch, soot.jimple.RefSwitch, soot.jimple.StmtSwitch, soot.util.Switch

public class CSwitch
extends java.lang.Object
implements soot.jimple.JimpleValueSwitch, soot.jimple.StmtSwitch

An implementation of the visitor design pattern that generates C code from Jimple statements. Code generated in this class is placed in an internal code stack (see _push(StringBuffer), and _pop()).

Since:
Ptolemy II 2.0
Version:
$Id: CSwitch.java,v 1.74 2007/12/06 21:56:50 cxh Exp $
Author:
Shuvra S. Bhattacharyya, Ankush Varma
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (ssb)

Field Summary
 boolean exceptionsExist
          Set to true if this statement is in the body of a method that requires exception-handling.
 byte indentLevel
          Current Indentation level: Used by other classes if they need to know or change the degree of indentation in the currently generated code.
 
Constructor Summary
CSwitch()
          Construct a new CSwitch with an empty context.
CSwitch(Context context)
          Construct a new CSwitch with a given context.
 
Method Summary
protected  java.lang.String _generateArguments(soot.jimple.InvokeExpr expression, int previousArguments)
          Generate code for a list of arguments from an invoke expression.
protected  java.lang.String _generateArrayAllocation(soot.Type elementType, int dimensionsToFill, java.lang.String sizeCode)
          Allocate memory for a given array.
protected  void _generateBinaryOperation(soot.jimple.BinopExpr expression, java.lang.String operator)
          Generate code for a binary operation expression.
protected  void _generateCompare(soot.jimple.BinopExpr v)
          Generate code for a compare expression.
protected  void _generateInstanceInvokeExpression(soot.jimple.InstanceInvokeExpr expression)
          Generate code for an instance invoke expression.
protected  java.lang.String _indent()
          Returns the appropriate indentation based on the value of the "indentLevel" variable.
protected  java.lang.StringBuffer _pop()
          Retrieve and remove the code at the top of the code stack.
protected  void _push(java.lang.String codeString)
          Push a string onto the code stack.
protected  void _push(java.lang.StringBuffer codeString)
          Push a string buffer onto the code stack.
protected  void _unexpectedCase(java.lang.Object object, java.lang.String message)
          Report an error, with an associated object and a descriptive message, for an unexpected code generation situation.
 void addTarget(soot.Unit target)
          Register a unit as a target of a branch from some other statement.
 void caseAddExpr(soot.jimple.AddExpr v)
           
 void caseAndExpr(soot.jimple.AndExpr v)
           
 void caseArrayRef(soot.jimple.ArrayRef v)
          Generate code for an array reference.
 void caseAssignStmt(soot.jimple.AssignStmt stmt)
          Generate code for an assignment statement.
 void caseBreakpointStmt(soot.jimple.BreakpointStmt stmt)
           
 void caseCastExpr(soot.jimple.CastExpr v)
           
 void caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef v)
           
 void caseClassConstant(soot.jimple.ClassConstant v)
           
 void caseCmpExpr(soot.jimple.CmpExpr v)
          Generate code for a Compare expression.
 void caseCmpgExpr(soot.jimple.CmpgExpr v)
          Generate code for a Cmpg(compare greater than) expression.
 void caseCmplExpr(soot.jimple.CmplExpr v)
          Generate code for a Cmpl(compare less than) expression.
 void caseDivExpr(soot.jimple.DivExpr v)
           
 void caseDoubleConstant(soot.jimple.DoubleConstant v)
           
 void caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt stmt)
           
 void caseEqExpr(soot.jimple.EqExpr v)
           
 void caseExitMonitorStmt(soot.jimple.ExitMonitorStmt stmt)
           
 void caseFloatConstant(soot.jimple.FloatConstant v)
           
 void caseGeExpr(soot.jimple.GeExpr v)
           
 void caseGotoStmt(soot.jimple.GotoStmt stmt)
           
 void caseGtExpr(soot.jimple.GtExpr v)
           
 void caseIdentityStmt(soot.jimple.IdentityStmt stmt)
           
 void caseIfStmt(soot.jimple.IfStmt stmt)
          Generate code for an if statement.
 void caseInstanceFieldRef(soot.jimple.InstanceFieldRef v)
          Generate code for a reference to a non-static field of an object.
 void caseInstanceOfExpr(soot.jimple.InstanceOfExpr v)
          Generate code for an instanceof expression.
 void caseIntConstant(soot.jimple.IntConstant v)
          Push the value of an integer constant onto the code stack.
 void caseInterfaceInvokeExpr(soot.jimple.InterfaceInvokeExpr v)
          Generate code for calling a method that was declared in an interface.
 void caseInvokeStmt(soot.jimple.InvokeStmt stmt)
          Generate code for an invoke statement.
 void caseLeExpr(soot.jimple.LeExpr v)
          Generate code for a "less than or equal to" expression.
 void caseLengthExpr(soot.jimple.LengthExpr v)
          Generate code for an array length expression.
 void caseLocal(soot.Local l)
          Push the name of a local onto the code stack.
 void caseLongConstant(soot.jimple.LongConstant v)
          Generate the code for a long constant.
 void caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt stmt)
           
 void caseLtExpr(soot.jimple.LtExpr v)
          Generate the code for a "less than" expression.
 void caseMulExpr(soot.jimple.MulExpr v)
          Generate the code for a multiply expression.
 void caseNeExpr(soot.jimple.NeExpr v)
          Generate the code for an inequality expression.
 void caseNegExpr(soot.jimple.NegExpr v)
          Generate code for a "negative of" expression.
 void caseNewArrayExpr(soot.jimple.NewArrayExpr v)
           
 void caseNewExpr(soot.jimple.NewExpr v)
          Generate code for a "new object" expression.
 void caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr v)
          Generate code for defining a new multidimensional array.
 void caseNopStmt(soot.jimple.NopStmt stmt)
          Generate code for a Nop(No operation) statement.
 void caseNullConstant(soot.jimple.NullConstant v)
          Generate code for a null constant.
 void caseOrExpr(soot.jimple.OrExpr v)
          Generate code for an "bitwise or" expression.
 void caseParameterRef(soot.jimple.ParameterRef v)
          Generate code for a parameter reference.
 void caseRemExpr(soot.jimple.RemExpr v)
          Generate code for a remainder, or "mod", expression.
 void caseRetStmt(soot.jimple.RetStmt stmt)
          Generate code for a Ret statement.
 void caseReturnStmt(soot.jimple.ReturnStmt stmt)
          Generate code for a "return" statement.
 void caseReturnVoidStmt(soot.jimple.ReturnVoidStmt stmt)
          Generate code for a "return void" statement.
 void caseShlExpr(soot.jimple.ShlExpr v)
          Generate code for a shift-left expression.
 void caseShrExpr(soot.jimple.ShrExpr v)
          Generate code for a Shift Right expression.
 void caseSpecialInvokeExpr(soot.jimple.SpecialInvokeExpr v)
          Generate code for a special invoke expression.
 void caseStaticFieldRef(soot.jimple.StaticFieldRef v)
          Generate code for a reference to a static field.
 void caseStaticInvokeExpr(soot.jimple.StaticInvokeExpr v)
          Generate code for invoking a static method.
 void caseStringConstant(soot.jimple.StringConstant v)
          Generate code for a string constant.
 void caseSubExpr(soot.jimple.SubExpr v)
          Generate code for a subtract expression.
 void caseTableSwitchStmt(soot.jimple.TableSwitchStmt stmt)
          Generate code for a Table switch statement.
 void caseThisRef(soot.jimple.ThisRef v)
          Generate code for a "this" reference.
 void caseThrowStmt(soot.jimple.ThrowStmt stmt)
          Generate code for a throw statement.
 void caseUshrExpr(soot.jimple.UshrExpr v)
          Generate code for an "unsigned shift right" expression.
 void caseVirtualInvokeExpr(soot.jimple.VirtualInvokeExpr v)
          Generate code for a virtual invoke expression.
 void caseXorExpr(soot.jimple.XorExpr v)
          Generate code for an Xor expression.
 void clearTargets()
          Clear the set of branch targets encountered in the current method.
 void defaultCase(java.lang.Object obj)
          Generate code for unhandled expressions or statements.
 java.lang.StringBuffer getCode()
          Retrieve the code generated by the switch since the last time code was retrieved from it.
 java.lang.String getLabel(soot.Unit unit)
          Return the unique label associated with a unit that has been registered as the target of a branch from another statement.
 java.lang.String getThisLocalName()
          Return the name of the local in the current method that represents the current class.
 boolean isTarget(soot.Unit unit)
          Return true if the given unit has been registered as the target of a branch from another statement.
 void setReturnType(soot.Type type)
          Set the type to be cast for return statements.
 void setThisLocalName(java.lang.String name)
          Set the name of the local in the current method that represents the current class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indentLevel

public byte indentLevel
Current Indentation level: Used by other classes if they need to know or change the degree of indentation in the currently generated code.


exceptionsExist

public boolean exceptionsExist
Set to true if this statement is in the body of a method that requires exception-handling.

Constructor Detail

CSwitch

public CSwitch()
Construct a new CSwitch with an empty context.


CSwitch

public CSwitch(Context context)
Construct a new CSwitch with a given context.

Parameters:
context - The given context.
Method Detail

addTarget

public void addTarget(soot.Unit target)
Register a unit as a target of a branch from some other statement.

Parameters:
target - The unit.

caseAddExpr

public void caseAddExpr(soot.jimple.AddExpr v)
Specified by:
caseAddExpr in interface soot.jimple.ExprSwitch

caseAndExpr

public void caseAndExpr(soot.jimple.AndExpr v)
Specified by:
caseAndExpr in interface soot.jimple.ExprSwitch

caseArrayRef

public void caseArrayRef(soot.jimple.ArrayRef v)
Generate code for an array reference. This is done by generating a call to a macro from the run time library with the given base (array) and index expression.

Specified by:
caseArrayRef in interface soot.jimple.RefSwitch
Parameters:
v - The array reference whose code is to be generated.

caseAssignStmt

public void caseAssignStmt(soot.jimple.AssignStmt stmt)
Generate code for an assignment statement.

Specified by:
caseAssignStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The assignment statement.

caseBreakpointStmt

public void caseBreakpointStmt(soot.jimple.BreakpointStmt stmt)
Specified by:
caseBreakpointStmt in interface soot.jimple.StmtSwitch

caseCastExpr

public void caseCastExpr(soot.jimple.CastExpr v)
Specified by:
caseCastExpr in interface soot.jimple.ExprSwitch

caseCaughtExceptionRef

public void caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef v)
Specified by:
caseCaughtExceptionRef in interface soot.jimple.RefSwitch

caseClassConstant

public void caseClassConstant(soot.jimple.ClassConstant v)
Specified by:
caseClassConstant in interface soot.jimple.ConstantSwitch

caseCmpExpr

public void caseCmpExpr(soot.jimple.CmpExpr v)
Generate code for a Compare expression.

Specified by:
caseCmpExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseCmpgExpr

public void caseCmpgExpr(soot.jimple.CmpgExpr v)
Generate code for a Cmpg(compare greater than) expression. Presently this is equivalent to generating code for a Cmp expression since NaN is not supported at present.

Specified by:
caseCmpgExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseCmplExpr

public void caseCmplExpr(soot.jimple.CmplExpr v)
Generate code for a Cmpl(compare less than) expression. Presently this is equivalent to generating code for a Cmp expression since NaN is not supported at present.

Specified by:
caseCmplExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseDivExpr

public void caseDivExpr(soot.jimple.DivExpr v)
Specified by:
caseDivExpr in interface soot.jimple.ExprSwitch

caseDoubleConstant

public void caseDoubleConstant(soot.jimple.DoubleConstant v)
Specified by:
caseDoubleConstant in interface soot.jimple.ConstantSwitch

caseEnterMonitorStmt

public void caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt stmt)
Specified by:
caseEnterMonitorStmt in interface soot.jimple.StmtSwitch

caseEqExpr

public void caseEqExpr(soot.jimple.EqExpr v)
Specified by:
caseEqExpr in interface soot.jimple.ExprSwitch

caseExitMonitorStmt

public void caseExitMonitorStmt(soot.jimple.ExitMonitorStmt stmt)
Specified by:
caseExitMonitorStmt in interface soot.jimple.StmtSwitch

caseFloatConstant

public void caseFloatConstant(soot.jimple.FloatConstant v)
Specified by:
caseFloatConstant in interface soot.jimple.ConstantSwitch

caseGeExpr

public void caseGeExpr(soot.jimple.GeExpr v)
Specified by:
caseGeExpr in interface soot.jimple.ExprSwitch

caseGotoStmt

public void caseGotoStmt(soot.jimple.GotoStmt stmt)
Specified by:
caseGotoStmt in interface soot.jimple.StmtSwitch

caseGtExpr

public void caseGtExpr(soot.jimple.GtExpr v)
Specified by:
caseGtExpr in interface soot.jimple.ExprSwitch

caseIdentityStmt

public void caseIdentityStmt(soot.jimple.IdentityStmt stmt)
Specified by:
caseIdentityStmt in interface soot.jimple.StmtSwitch

caseIfStmt

public void caseIfStmt(soot.jimple.IfStmt stmt)
Generate code for an if statement.

Specified by:
caseIfStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The if statement.

caseInstanceFieldRef

public void caseInstanceFieldRef(soot.jimple.InstanceFieldRef v)
Generate code for a reference to a non-static field of an object. A non-static field belongs to an instance(object), not a class.

Specified by:
caseInstanceFieldRef in interface soot.jimple.RefSwitch
Parameters:
v - The instance field reference.

caseInstanceOfExpr

public void caseInstanceOfExpr(soot.jimple.InstanceOfExpr v)
Generate code for an instanceof expression.

Specified by:
caseInstanceOfExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The instanceof expression.

caseIntConstant

public void caseIntConstant(soot.jimple.IntConstant v)
Push the value of an integer constant onto the code stack.

Specified by:
caseIntConstant in interface soot.jimple.ConstantSwitch
Parameters:
v - The integer constant.

caseInterfaceInvokeExpr

public void caseInterfaceInvokeExpr(soot.jimple.InterfaceInvokeExpr v)
Generate code for calling a method that was declared in an interface.

Specified by:
caseInterfaceInvokeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The interface invoke expression.

caseInvokeStmt

public void caseInvokeStmt(soot.jimple.InvokeStmt stmt)
Generate code for an invoke statement.

Specified by:
caseInvokeStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The invoke statement.

caseLeExpr

public void caseLeExpr(soot.jimple.LeExpr v)
Generate code for a "less than or equal to" expression.

Specified by:
caseLeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseLengthExpr

public void caseLengthExpr(soot.jimple.LengthExpr v)
Generate code for an array length expression. This is performed by inserting a call to a length computation macro from the pccg run-time library.

Specified by:
caseLengthExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The length expression.

caseLocal

public void caseLocal(soot.Local l)
Push the name of a local onto the code stack.

Specified by:
caseLocal in interface soot.jimple.JimpleValueSwitch
Parameters:
l - The local.

caseLongConstant

public void caseLongConstant(soot.jimple.LongConstant v)
Generate the code for a long constant.

Specified by:
caseLongConstant in interface soot.jimple.ConstantSwitch
Parameters:
v - The long constant.

caseLookupSwitchStmt

public void caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt stmt)
Specified by:
caseLookupSwitchStmt in interface soot.jimple.StmtSwitch

caseLtExpr

public void caseLtExpr(soot.jimple.LtExpr v)
Generate the code for a "less than" expression.

Specified by:
caseLtExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseMulExpr

public void caseMulExpr(soot.jimple.MulExpr v)
Generate the code for a multiply expression.

Specified by:
caseMulExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseNeExpr

public void caseNeExpr(soot.jimple.NeExpr v)
Generate the code for an inequality expression.

Specified by:
caseNeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseNegExpr

public void caseNegExpr(soot.jimple.NegExpr v)
Generate code for a "negative of" expression.

Specified by:
caseNegExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseNewArrayExpr

public void caseNewArrayExpr(soot.jimple.NewArrayExpr v)
Specified by:
caseNewArrayExpr in interface soot.jimple.ExprSwitch

caseNewExpr

public void caseNewExpr(soot.jimple.NewExpr v)
Generate code for a "new object" expression.

Specified by:
caseNewExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseNewMultiArrayExpr

public void caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr v)
Generate code for defining a new multidimensional array.

Specified by:
caseNewMultiArrayExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The "new multidimensional array" expression.

caseNopStmt

public void caseNopStmt(soot.jimple.NopStmt stmt)
Generate code for a Nop(No operation) statement.

Specified by:
caseNopStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseNullConstant

public void caseNullConstant(soot.jimple.NullConstant v)
Generate code for a null constant.

Specified by:
caseNullConstant in interface soot.jimple.ConstantSwitch
Parameters:
v - The constant.

caseOrExpr

public void caseOrExpr(soot.jimple.OrExpr v)
Generate code for an "bitwise or" expression.

Specified by:
caseOrExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseParameterRef

public void caseParameterRef(soot.jimple.ParameterRef v)
Generate code for a parameter reference. Not currently implemented.

Specified by:
caseParameterRef in interface soot.jimple.RefSwitch
Parameters:
v - The parameter reference.

caseRemExpr

public void caseRemExpr(soot.jimple.RemExpr v)
Generate code for a remainder, or "mod", expression.

Specified by:
caseRemExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseRetStmt

public void caseRetStmt(soot.jimple.RetStmt stmt)
Generate code for a Ret statement. This is currently not supported.

Specified by:
caseRetStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseReturnStmt

public void caseReturnStmt(soot.jimple.ReturnStmt stmt)
Generate code for a "return" statement.

Specified by:
caseReturnStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseReturnVoidStmt

public void caseReturnVoidStmt(soot.jimple.ReturnVoidStmt stmt)
Generate code for a "return void" statement.

Specified by:
caseReturnVoidStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseShlExpr

public void caseShlExpr(soot.jimple.ShlExpr v)
Generate code for a shift-left expression.

Specified by:
caseShlExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseShrExpr

public void caseShrExpr(soot.jimple.ShrExpr v)
Generate code for a Shift Right expression. The upper bits should be filled with the sign.

Specified by:
caseShrExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseSpecialInvokeExpr

public void caseSpecialInvokeExpr(soot.jimple.SpecialInvokeExpr v)
Generate code for a special invoke expression.

Specified by:
caseSpecialInvokeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseStaticFieldRef

public void caseStaticFieldRef(soot.jimple.StaticFieldRef v)
Generate code for a reference to a static field.

Specified by:
caseStaticFieldRef in interface soot.jimple.RefSwitch
Parameters:
v - The static field reference.

caseStaticInvokeExpr

public void caseStaticInvokeExpr(soot.jimple.StaticInvokeExpr v)
Generate code for invoking a static method.

Specified by:
caseStaticInvokeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The static invoke expression.

caseStringConstant

public void caseStringConstant(soot.jimple.StringConstant v)
Generate code for a string constant.

Specified by:
caseStringConstant in interface soot.jimple.ConstantSwitch
Parameters:
v - The string constant.

caseSubExpr

public void caseSubExpr(soot.jimple.SubExpr v)
Generate code for a subtract expression.

Specified by:
caseSubExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseTableSwitchStmt

public void caseTableSwitchStmt(soot.jimple.TableSwitchStmt stmt)
Generate code for a Table switch statement. There is also a related statement called a lookup switch statement.

Specified by:
caseTableSwitchStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseThisRef

public void caseThisRef(soot.jimple.ThisRef v)
Generate code for a "this" reference. Currently not supported.

Specified by:
caseThisRef in interface soot.jimple.RefSwitch
Parameters:
v - The reference.

caseThrowStmt

public void caseThrowStmt(soot.jimple.ThrowStmt stmt)
Generate code for a throw statement.

Specified by:
caseThrowStmt in interface soot.jimple.StmtSwitch
Parameters:
stmt - The statement.

caseUshrExpr

public void caseUshrExpr(soot.jimple.UshrExpr v)
Generate code for an "unsigned shift right" expression. This causes the empty upper bits to be filled with zeros.

Specified by:
caseUshrExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseVirtualInvokeExpr

public void caseVirtualInvokeExpr(soot.jimple.VirtualInvokeExpr v)
Generate code for a virtual invoke expression.

Specified by:
caseVirtualInvokeExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

caseXorExpr

public void caseXorExpr(soot.jimple.XorExpr v)
Generate code for an Xor expression.

Specified by:
caseXorExpr in interface soot.jimple.ExprSwitch
Parameters:
v - The expression.

clearTargets

public void clearTargets()
Clear the set of branch targets encountered in the current method.


defaultCase

public void defaultCase(java.lang.Object obj)
Generate code for unhandled expressions or statements.

Specified by:
defaultCase in interface soot.jimple.ConstantSwitch
Specified by:
defaultCase in interface soot.jimple.ExprSwitch
Specified by:
defaultCase in interface soot.jimple.RefSwitch
Specified by:
defaultCase in interface soot.jimple.StmtSwitch
Parameters:
obj - The object(expression or statement) to be handled.

getCode

public java.lang.StringBuffer getCode()
Retrieve the code generated by the switch since the last time code was retrieved from it.

Returns:
The code generated by the switch.

getLabel

public java.lang.String getLabel(soot.Unit unit)
Return the unique label associated with a unit that has been registered as the target of a branch from another statement. Uniqueness is with respect to the current method.

Parameters:
unit - The unit.
Returns:
The label.
Throws:
java.lang.RuntimeException - If the unit has not yet been registered as the target of a branch.

getThisLocalName

public java.lang.String getThisLocalName()
Return the name of the local in the current method that represents the current class.

Returns:
The name.
See Also:
setThisLocalName(String)

isTarget

public boolean isTarget(soot.Unit unit)
Return true if the given unit has been registered as the target of a branch from another statement.

Parameters:
unit - The unit.
Returns:
True if the given unit is the target branch of another statement.

setReturnType

public void setReturnType(soot.Type type)
Set the type to be cast for return statements.

Parameters:
type - The type to be cast for a return statement.

setThisLocalName

public void setThisLocalName(java.lang.String name)
Set the name of the local in the current method that represents the current class.

Parameters:
name - The name.
See Also:
getThisLocalName()

_generateArguments

protected java.lang.String _generateArguments(soot.jimple.InvokeExpr expression,
                                              int previousArguments)
Generate code for a list of arguments from an invoke expression.

Parameters:
expression - The invoke expression.
previousArguments - The number of arguments that have already been generated for this invoke expression.
Returns:
The code.

_generateArrayAllocation

protected java.lang.String _generateArrayAllocation(soot.Type elementType,
                                                    int dimensionsToFill,
                                                    java.lang.String sizeCode)
Allocate memory for a given array.

Parameters:
elementType - The element type of array.
dimensionsToFill - The number of dimensions to fill.
sizeCode - The size code
Returns:
a String that will allocate the array.

_generateBinaryOperation

protected void _generateBinaryOperation(soot.jimple.BinopExpr expression,
                                        java.lang.String operator)
Generate code for a binary operation expression.

Parameters:
expression - The expression.
operator - The string representation of the binary operator.

_generateCompare

protected void _generateCompare(soot.jimple.BinopExpr v)
Generate code for a compare expression. The following semantics of a compare expression is assumed:
(op1 > op2) ==> return 1
(op1 < op2) ==> return -1
(op1 == op2) ==> return 0

Parameters:
v - The expression.

_generateInstanceInvokeExpression

protected void _generateInstanceInvokeExpression(soot.jimple.InstanceInvokeExpr expression)
Generate code for an instance invoke expression.

Parameters:
expression - The instance invoke expression.

_indent

protected java.lang.String _indent()
Returns the appropriate indentation based on the value of the "indentLevel" variable.

Returns:
A String containing 4 spaces for every level of indentation.

_pop

protected java.lang.StringBuffer _pop()
Retrieve and remove the code at the top of the code stack. Code that exists on entry to a visitation method should not be removed (popped) by the method.

Returns:
The code at the top of the code stack.

_push

protected void _push(java.lang.StringBuffer codeString)
Push a string buffer onto the code stack. On exit from a visitation method, any code that results from the method should be placed (pushed) on the stack in a single string buffer (or through a single call to _push(String)). Any other code (intermediate strings that do not represent code generated by the method) should be removed from the stack before exiting the visitation method.

Parameters:
codeString - The string buffer.

_push

protected void _push(java.lang.String codeString)
Push a string onto the code stack. See _push(StringBuffer).

Parameters:
codeString - The string.

_unexpectedCase

protected void _unexpectedCase(java.lang.Object object,
                               java.lang.String message)
Report an error, with an associated object and a descriptive message, for an unexpected code generation situation. The resulting message is pushed onto the top of the code stack.

Parameters:
object - The associated object.
message - The descriptive message.