cfg
Class IfInst

java.lang.Object
  extended by cfg.TACInst
      extended by cfg.IfInst

public class IfInst
extends TACInst

A class representing a three-address code if instruction (IfInst). An if instruction consists of a condition type ('==', '!=', '<', '>', '>='), a left and right source operand to conditionally compare, a true target block, which is taken when the condition is true, and a false target block, which is taken when the condition is false. From TACInst it also inherits an opcode (INDIRCALL).

Author:
Marc Corliss and Lori Pietraszek

Field Summary
static int EQ
          Equals ('==') condition type ID
protected  BasicBlock falseTarg
          Target block when condition is false (fall through target)
static int GE
          Equals ('>=') condition type ID
static int GT
          Equals ('>') condition type ID
static int LE
          Equals ('<=') condition type ID
protected  java.lang.String leftSource
          Left source operand in condition
static int LT
          Equals ('<') condition type ID
static int NE
          Equals ('!=') condition type ID
protected  java.lang.String rightSource
          Right source operand in condition
protected  BasicBlock trueTarg
          Target block when condition is true (jump target)
protected  int type
          Type of condition (e.g., IfInst.EQ for '==', etc.)
 
Fields inherited from class cfg.TACInst
BINADD, BINAND, BINDIV, BINMOD, BINMUL, BINOR, BINSUB, comments, DIRCALL, ERRPARAM, IF, INDIRCALL, LDADDR, LDCONST, LDENTRY, LDVAR, NUM_INSN_TYPES, opcode, PHI, REFPARAM, RETN, STDPARAM, STENTRY, UNNEG, UNNOT
 
Constructor Summary
IfInst(int type, java.lang.String leftSource, java.lang.String rightSource, BasicBlock trueTarg, BasicBlock falseTarg)
          IfInst constructor
 
Method Summary
<ReturnType,ArgumentType>
ReturnType
accept(TACInstVisitor<ReturnType,ArgumentType> visitor, ArgumentType o)
          Abstract visitor method.
 boolean equals(java.lang.Object o)
          Compares this object with the parameter object
 BasicBlock getFalseTarg()
          Get the false target block
 java.lang.String getLeftSource()
          Get the left source operand
 java.lang.String getRightSource()
          Get the right source operand
 java.lang.String getString()
          Get string representation of instruction (without comments) (note: in general, you want to use toString() to get instruction string)
 BasicBlock getTrueTarg()
          Get the true target block
 int getType()
          Get the type of If condition
 void setFalseTarg(BasicBlock falseTarg)
          Get the false target block
 void setLeftSource(java.lang.String leftSource)
          Set the left soure operand
 void setRightSource(java.lang.String rightSource)
          Set the right soure operand
 void setTrueTarg(BasicBlock trueTarg)
          Set the true target block
 void setType(int type)
          Set the type of If condition
 
Methods inherited from class cfg.TACInst
addComment, checkBoolConst, checkConst, checkIntConst, checkLabel, checkStrConst, checkVar, getBinaryOpcode, getComments, getOp, getOpcode, getUnaryOpcode, isBinary, isCall, isIf, isLoad, isParam, isReturn, isStore, isUnary, isValidID, removeComments, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQ

public static final int EQ
Equals ('==') condition type ID

See Also:
Constant Field Values

NE

public static final int NE
Equals ('!=') condition type ID

See Also:
Constant Field Values

LT

public static final int LT
Equals ('<') condition type ID

See Also:
Constant Field Values

LE

public static final int LE
Equals ('<=') condition type ID

See Also:
Constant Field Values

GT

public static final int GT
Equals ('>') condition type ID

See Also:
Constant Field Values

GE

public static final int GE
Equals ('>=') condition type ID

See Also:
Constant Field Values

type

protected int type
Type of condition (e.g., IfInst.EQ for '==', etc.)


leftSource

protected java.lang.String leftSource
Left source operand in condition


rightSource

protected java.lang.String rightSource
Right source operand in condition


trueTarg

protected BasicBlock trueTarg
Target block when condition is true (jump target)


falseTarg

protected BasicBlock falseTarg
Target block when condition is false (fall through target)

Constructor Detail

IfInst

public IfInst(int type,
              java.lang.String leftSource,
              java.lang.String rightSource,
              BasicBlock trueTarg,
              BasicBlock falseTarg)
IfInst constructor

Parameters:
type - type of condition (e.g., IfInst.EQ for '==', etc.)
leftSource - left source operand in condition
rightSource - right source operand in condition
trueTarg - target block when condition is true (jump target)
falseTarg - target block when condition is false (fall through target)
Method Detail

getType

public int getType()
Get the type of If condition

Returns:
type of If

setType

public void setType(int type)
Set the type of If condition

Parameters:
type - the new type of If

getLeftSource

public java.lang.String getLeftSource()
Get the left source operand

Returns:
left source operand

setLeftSource

public void setLeftSource(java.lang.String leftSource)
Set the left soure operand

Parameters:
leftSource - new left source operand

getRightSource

public java.lang.String getRightSource()
Get the right source operand

Returns:
right source operand

setRightSource

public void setRightSource(java.lang.String rightSource)
Set the right soure operand

Parameters:
rightSource - new right source operand

getTrueTarg

public BasicBlock getTrueTarg()
Get the true target block

Returns:
true target block

setTrueTarg

public void setTrueTarg(BasicBlock trueTarg)
Set the true target block

Parameters:
trueTarg - new true target block

getFalseTarg

public BasicBlock getFalseTarg()
Get the false target block

Returns:
false target block

setFalseTarg

public void setFalseTarg(BasicBlock falseTarg)
Get the false target block

Parameters:
falseTarg - new false target block

equals

public boolean equals(java.lang.Object o)
Compares this object with the parameter object

Specified by:
equals in class TACInst
Parameters:
o - object to compare the reference object with
Returns:
boolean indicating whether the objects are equivalent

getString

public java.lang.String getString()
Get string representation of instruction (without comments) (note: in general, you want to use toString() to get instruction string)

Specified by:
getString in class TACInst
Returns:
string representation of three address code instruction (without comments)

accept

public <ReturnType,ArgumentType> ReturnType accept(TACInstVisitor<ReturnType,ArgumentType> visitor,
                                                   ArgumentType o)
Description copied from class: TACInst
Abstract visitor method.

Specified by:
accept in class TACInst
Parameters:
visitor - TACInstVisitor.
o - Data to pass down.
Returns:
return value of visitor.