|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectptolemy.copernicus.c.CSwitch
public class CSwitch
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()).
| Red (ssb) |
| 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 |
|---|
public byte indentLevel
public boolean exceptionsExist
| Constructor Detail |
|---|
public CSwitch()
public CSwitch(Context context)
context - The given context.| Method Detail |
|---|
public void addTarget(soot.Unit target)
target - The unit.public void caseAddExpr(soot.jimple.AddExpr v)
caseAddExpr in interface soot.jimple.ExprSwitchpublic void caseAndExpr(soot.jimple.AndExpr v)
caseAndExpr in interface soot.jimple.ExprSwitchpublic void caseArrayRef(soot.jimple.ArrayRef v)
caseArrayRef in interface soot.jimple.RefSwitchv - The array reference whose code is to be generated.public void caseAssignStmt(soot.jimple.AssignStmt stmt)
caseAssignStmt in interface soot.jimple.StmtSwitchstmt - The assignment statement.public void caseBreakpointStmt(soot.jimple.BreakpointStmt stmt)
caseBreakpointStmt in interface soot.jimple.StmtSwitchpublic void caseCastExpr(soot.jimple.CastExpr v)
caseCastExpr in interface soot.jimple.ExprSwitchpublic void caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef v)
caseCaughtExceptionRef in interface soot.jimple.RefSwitchpublic void caseClassConstant(soot.jimple.ClassConstant v)
caseClassConstant in interface soot.jimple.ConstantSwitchpublic void caseCmpExpr(soot.jimple.CmpExpr v)
caseCmpExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseCmpgExpr(soot.jimple.CmpgExpr v)
caseCmpgExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseCmplExpr(soot.jimple.CmplExpr v)
caseCmplExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseDivExpr(soot.jimple.DivExpr v)
caseDivExpr in interface soot.jimple.ExprSwitchpublic void caseDoubleConstant(soot.jimple.DoubleConstant v)
caseDoubleConstant in interface soot.jimple.ConstantSwitchpublic void caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt stmt)
caseEnterMonitorStmt in interface soot.jimple.StmtSwitchpublic void caseEqExpr(soot.jimple.EqExpr v)
caseEqExpr in interface soot.jimple.ExprSwitchpublic void caseExitMonitorStmt(soot.jimple.ExitMonitorStmt stmt)
caseExitMonitorStmt in interface soot.jimple.StmtSwitchpublic void caseFloatConstant(soot.jimple.FloatConstant v)
caseFloatConstant in interface soot.jimple.ConstantSwitchpublic void caseGeExpr(soot.jimple.GeExpr v)
caseGeExpr in interface soot.jimple.ExprSwitchpublic void caseGotoStmt(soot.jimple.GotoStmt stmt)
caseGotoStmt in interface soot.jimple.StmtSwitchpublic void caseGtExpr(soot.jimple.GtExpr v)
caseGtExpr in interface soot.jimple.ExprSwitchpublic void caseIdentityStmt(soot.jimple.IdentityStmt stmt)
caseIdentityStmt in interface soot.jimple.StmtSwitchpublic void caseIfStmt(soot.jimple.IfStmt stmt)
caseIfStmt in interface soot.jimple.StmtSwitchstmt - The if statement.public void caseInstanceFieldRef(soot.jimple.InstanceFieldRef v)
caseInstanceFieldRef in interface soot.jimple.RefSwitchv - The instance field reference.public void caseInstanceOfExpr(soot.jimple.InstanceOfExpr v)
caseInstanceOfExpr in interface soot.jimple.ExprSwitchv - The instanceof expression.public void caseIntConstant(soot.jimple.IntConstant v)
caseIntConstant in interface soot.jimple.ConstantSwitchv - The integer constant.public void caseInterfaceInvokeExpr(soot.jimple.InterfaceInvokeExpr v)
caseInterfaceInvokeExpr in interface soot.jimple.ExprSwitchv - The interface invoke expression.public void caseInvokeStmt(soot.jimple.InvokeStmt stmt)
caseInvokeStmt in interface soot.jimple.StmtSwitchstmt - The invoke statement.public void caseLeExpr(soot.jimple.LeExpr v)
caseLeExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseLengthExpr(soot.jimple.LengthExpr v)
caseLengthExpr in interface soot.jimple.ExprSwitchv - The length expression.public void caseLocal(soot.Local l)
caseLocal in interface soot.jimple.JimpleValueSwitchl - The local.public void caseLongConstant(soot.jimple.LongConstant v)
caseLongConstant in interface soot.jimple.ConstantSwitchv - The long constant.public void caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt stmt)
caseLookupSwitchStmt in interface soot.jimple.StmtSwitchpublic void caseLtExpr(soot.jimple.LtExpr v)
caseLtExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseMulExpr(soot.jimple.MulExpr v)
caseMulExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseNeExpr(soot.jimple.NeExpr v)
caseNeExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseNegExpr(soot.jimple.NegExpr v)
caseNegExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseNewArrayExpr(soot.jimple.NewArrayExpr v)
caseNewArrayExpr in interface soot.jimple.ExprSwitchpublic void caseNewExpr(soot.jimple.NewExpr v)
caseNewExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr v)
caseNewMultiArrayExpr in interface soot.jimple.ExprSwitchv - The "new multidimensional array" expression.public void caseNopStmt(soot.jimple.NopStmt stmt)
caseNopStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseNullConstant(soot.jimple.NullConstant v)
caseNullConstant in interface soot.jimple.ConstantSwitchv - The constant.public void caseOrExpr(soot.jimple.OrExpr v)
caseOrExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseParameterRef(soot.jimple.ParameterRef v)
caseParameterRef in interface soot.jimple.RefSwitchv - The parameter reference.public void caseRemExpr(soot.jimple.RemExpr v)
caseRemExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseRetStmt(soot.jimple.RetStmt stmt)
caseRetStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseReturnStmt(soot.jimple.ReturnStmt stmt)
caseReturnStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseReturnVoidStmt(soot.jimple.ReturnVoidStmt stmt)
caseReturnVoidStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseShlExpr(soot.jimple.ShlExpr v)
caseShlExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseShrExpr(soot.jimple.ShrExpr v)
caseShrExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseSpecialInvokeExpr(soot.jimple.SpecialInvokeExpr v)
caseSpecialInvokeExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseStaticFieldRef(soot.jimple.StaticFieldRef v)
caseStaticFieldRef in interface soot.jimple.RefSwitchv - The static field reference.public void caseStaticInvokeExpr(soot.jimple.StaticInvokeExpr v)
caseStaticInvokeExpr in interface soot.jimple.ExprSwitchv - The static invoke expression.public void caseStringConstant(soot.jimple.StringConstant v)
caseStringConstant in interface soot.jimple.ConstantSwitchv - The string constant.public void caseSubExpr(soot.jimple.SubExpr v)
caseSubExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseTableSwitchStmt(soot.jimple.TableSwitchStmt stmt)
caseTableSwitchStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseThisRef(soot.jimple.ThisRef v)
caseThisRef in interface soot.jimple.RefSwitchv - The reference.public void caseThrowStmt(soot.jimple.ThrowStmt stmt)
caseThrowStmt in interface soot.jimple.StmtSwitchstmt - The statement.public void caseUshrExpr(soot.jimple.UshrExpr v)
caseUshrExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseVirtualInvokeExpr(soot.jimple.VirtualInvokeExpr v)
caseVirtualInvokeExpr in interface soot.jimple.ExprSwitchv - The expression.public void caseXorExpr(soot.jimple.XorExpr v)
caseXorExpr in interface soot.jimple.ExprSwitchv - The expression.public void clearTargets()
public void defaultCase(java.lang.Object obj)
defaultCase in interface soot.jimple.ConstantSwitchdefaultCase in interface soot.jimple.ExprSwitchdefaultCase in interface soot.jimple.RefSwitchdefaultCase in interface soot.jimple.StmtSwitchobj - The object(expression or statement) to be handled.public java.lang.StringBuffer getCode()
public java.lang.String getLabel(soot.Unit unit)
unit - The unit.
java.lang.RuntimeException - If the unit has not yet been registered as
the target of a branch.public java.lang.String getThisLocalName()
setThisLocalName(String)public boolean isTarget(soot.Unit unit)
unit - The unit.
public void setReturnType(soot.Type type)
type - The type to be cast for a return statement.public void setThisLocalName(java.lang.String name)
name - The name.getThisLocalName()
protected java.lang.String _generateArguments(soot.jimple.InvokeExpr expression,
int previousArguments)
expression - The invoke expression.previousArguments - The number of arguments that have already
been generated for this invoke expression.
protected java.lang.String _generateArrayAllocation(soot.Type elementType,
int dimensionsToFill,
java.lang.String sizeCode)
elementType - The element type of array.dimensionsToFill - The number of dimensions to fill.sizeCode - The size code
protected void _generateBinaryOperation(soot.jimple.BinopExpr expression,
java.lang.String operator)
expression - The expression.operator - The string representation of the binary operator.protected void _generateCompare(soot.jimple.BinopExpr v)
v - The expression.protected void _generateInstanceInvokeExpression(soot.jimple.InstanceInvokeExpr expression)
expression - The instance invoke expression.protected java.lang.String _indent()
protected java.lang.StringBuffer _pop()
protected void _push(java.lang.StringBuffer codeString)
_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.
codeString - The string buffer.protected void _push(java.lang.String codeString)
_push(StringBuffer).
codeString - The string.
protected void _unexpectedCase(java.lang.Object object,
java.lang.String message)
object - The associated object.message - The descriptive message.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||