coins.ir.hir
Class SwitchStmtImpl

java.lang.Object
  extended bycoins.ir.hir.HIR_Impl
      extended bycoins.ir.hir.StmtImpl
          extended bycoins.ir.hir.SwitchStmtImpl
All Implemented Interfaces:
java.lang.Cloneable, HasStringObject, HIR, HIR0, IR, IR0, Stmt, SwitchStmt
Direct Known Subclasses:
SwitchModify

public class SwitchStmtImpl
extends StmtImpl
implements SwitchStmt

switch statement class. (by S. Fukuda)


Field Summary
 Label defaultLabel
           
 Label endLabel
           
 
Fields inherited from class coins.ir.hir.StmtImpl
fMultiBlock, fNextStmt, fPrevStmt
 
Fields inherited from class coins.ir.hir.HIR_Impl
fAdditionalChild, fChildCount, fChildNode1, fChildNode2, fDbgLevel, fHirAnnex, fOperator, fParentNode, fType, hirRoot, inversionTable, machineParam, sourceLanguage
 
Fields inherited from interface coins.ir.hir.HIR
OP_CODE_NAME, OP_CODE_NAME_DENSE
 
Fields inherited from interface coins.ir.IR
OP_INF, OP_LIST, OP_PROG, OP_SUBP_DEF
 
Fields inherited from interface coins.ir.hir.HIR0
FLAG_C_PTR, FLAG_CONST_EXP, FLAG_INIT_BLOCK, FLAG_LOOP_WITH_CONDITIONAL_INIT, FLAG_NOCHANGE, FLAG_NONTERMINAL, OP_ADD, OP_ADD_ASSIGN, OP_ADDR, OP_AND, OP_AND_ASSIGN, OP_ARROW, OP_ASM, OP_ASSIGN, OP_BLOCK, OP_CALL, OP_CMP_EQ, OP_CMP_GE, OP_CMP_GT, OP_CMP_LE, OP_CMP_LT, OP_CMP_NE, OP_COMMA, OP_CONST, OP_CONTENTS, OP_CONV, OP_DECAY, OP_DIV, OP_DIV_ASSIGN, OP_ELEM, OP_ENCLOSE, OP_EQ_ZERO, OP_EXP_STMT, OP_EXPLIST, OP_EXPREPEAT, OP_FOR, OP_IF, OP_INDEX, OP_INDEXED_LOOP, OP_JUMP, OP_LABEL, OP_LABEL_DEF, OP_LABELED_STMT, OP_LG_AND, OP_LG_OR, OP_MOD, OP_MOD_ASSIGN, OP_MULT, OP_MULT_ASSIGN, OP_NEG, OP_NOT, OP_NULL, OP_OFFSET, OP_OR, OP_OR_ASSIGN, OP_PARAM, OP_PHI, OP_POST_DECR, OP_POST_INCR, OP_PRE_DECR, OP_PRE_INCR, OP_QUAL, OP_REPEAT, OP_RETURN, OP_SELECT, OP_SEQ, OP_SETDATA, OP_SHIFT_L_ASSIGN, OP_SHIFT_LL, OP_SHIFT_R, OP_SHIFT_R_ASSIGN, OP_SHIFT_RL, OP_SIZEOF, OP_STMT, OP_STMT_UPPER, OP_SUB, OP_SUB_ASSIGN, OP_SUBP, OP_SUBS, OP_SWITCH, OP_SYM, OP_TYPE, OP_UNDECAY, OP_UNTIL, OP_VAR, OP_WHILE, OP_XOR, OP_XOR_ASSIGN
 
Constructor Summary
SwitchStmtImpl()
           
SwitchStmtImpl(HirRoot pHirRoot)
           
SwitchStmtImpl(HirRoot pHirRoot, Exp pSelectionExp, IrList pJumpList, Label pDefaultLabel, Stmt pBodyStmt, Label pEndLabel)
          SwitchStmtImpl SwitchStmt -> ( switchCode Exp @ // Case selection expression.
 
Method Summary
 void accept(HirVisitor pVisitor)
          accept Acceptor used in HIR visitor.
 java.lang.Object clone()
          clone Override Object.clone in HIR.
 void combineWithConditionalExp(Stmt pStmt, HIR pCond)
          Combine pStmt with conditional expression part pCond of control statement so that pStmt should be executed before pCond.
 Stmt getBodyStmt()
          Gget switch-body statement that contains case statements.
 Const getCaseConst(int index)
          Get the n-th (head is 0) case constant.
 int getCaseCount()
           
 Label getCaseLabel(int index)
          getCaseLabel Get n-th (head is 0) case label.
 LabelNode getCaseLabelNode(int index)
          getCaseLabelNode Get LabelNode of n-th (head is 0) case label.
 Label getDefaultLabel()
          Get default label
 LabelNode getDefaultLabelNode()
          Get default label node
 Label getEndLabel()
          Get break destination label (switch-end label) of this switch statement.
 Exp getSelectionExp()
          Get selection expression
 LabeledStmt getSwitchEndNode()
          Get the switch end node to where break statements jump.
 void setSelectionExp(Exp pSelectionExp)
          Set selection expression
 
Methods inherited from class coins.ir.hir.StmtImpl
addNextStmt, addNextStmt, adjustMultiBlockFlag, adjustMultiBlockFlag, ancestorControlStmtOfConditionalExp, attachLabel, attachLabelAsFirstOne, backTraceLabeledStmt, combineStmt, copyPosition, cutLabelLinkOfStmt, deleteNextStmt, deletePreviousStmt, deleteThisStmt, getBlockStmt, getFileName, getLabel, getLabelDefList, getLabeledStmt, getLineNumber, getNextStmt, getPreviousStmt, getStmtWithLabel, getUpperStmt, insertPreviousStmt, insertPreviousStmt, isBranchStmt, isLoopStmt, isMultiBlock, isolateThisStmt, printLinkage, replaceThisStmtWith, setFileName, setLineNumber, toStringDetail, traceFirstStmt, traceLastStmt
 
Methods inherited from class coins.ir.hir.HIR_Impl
addInf, addrExp, asmStmt, assignStmt, blockStmt, callStmt, checkLinkage, conditionalExp, conditionalExp1, constNode, contains, contentsExp, convExp, copyInfListFrom, copyWithOperands, copyWithOperandsChangingLabels, cutParentLink, cutParentLink, decayExp, elemNode, exp, exp, exp, expList, expRepeat, expStmt, falseNode, fatalError, finishHir, flagsAreAllFalse, forStmt, forStmt, functionExp, getChild, getChild1, getChild2, getChildCount, getChildNumber, getClone, getExpId, getFlag, getFlagBox, getFlowAnalSym, getIndentSpace, getIndex, getInf, getInfList, getInfString, getIrName, getNextNode, getNextNodeSeeingAncestor, getOperator, getParent, getResultOperand, getResultVar, getSourceNode, getSourceNode1, getSourceNode2, getStmtContainingThisNode, getSym, getSymOrExpId, getType, getWork, hirClone, hirIterator, hirList, hirNodeClone, hirSeq, hirSeq, hirSeq, ifStmt, indexedLoopStmt, indexedLoopStmt, infStmt, infStmt, intConstNode, intConstNode, irList, irList, isEmpty, isHIR, isLIR, isSameAs, isStmt, isSym, isTerminal, isTree, isTree, jumpStmt, labelDef, labeledStmt, labelNode, nullNode, nullStmt, offsetConstNode, phiExp, pointedExp, print, print, program, qualifiedExp, removeInf, repeatStmt, repeatStmt, replaceOperator, replaceResultOperand, replaceResultVar, replaceSource, replaceSource1, replaceSource2, replaceThisNode, returnStmt, returnStmt, setChild, setChild1, setChild2, setChildren, setChildren, setChildren, setChildren, setDataStmt, setFlag, setIndex, setIndexNumberToAllNodes, setIndexNumberToAllNodes, setIndexNumberToAllNodes2, setParameters, setParent, setType, setWork, severeError, sizeofExp, sizeofExp, slightError, subpDefinition, subpDefinition, subpDefinition, subpIterator, subpNode, subscriptedExp, subscriptedExp, switchStmt, symNode, toString, toStringShort, toStringWithChildren, trueNode, typeNode, undecayExp, undecayExp, undecayExp, undecayExp, varNode, warinig, whileStmt, whileStmt, withInf
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface coins.ir.hir.Stmt
addNextStmt, ancestorControlStmtOfConditionalExp, attachLabel, attachLabelAsFirstOne, combineStmt, copyPosition, cutLabelLinkOfStmt, deleteThisStmt, getBlockStmt, getFileName, getLabel, getLabelDefList, getLabeledStmt, getLineNumber, getPreviousStmt, getUpperStmt, insertPreviousStmt, insertPreviousStmt, isBranchStmt, isMultiBlock, isolateThisStmt, replaceThisStmtWith, setFileName, setLineNumber
 
Methods inherited from interface coins.ir.hir.HIR
addrExp, asmStmt, checkLinkage, conditionalExp, contains, copyInfListFrom, cutParentLink, exp, expList, expRepeat, forStmt, getExpId, getFlowAnalSym, getIndentSpace, getInfString, getIrName, getSourceNode, getSourceNode1, getSourceNode2, getSymOrExpId, getWork, hirNodeClone, hirSeq, hirSeq, indexedLoopStmt, indexedLoopStmt, infStmt, infStmt, intConstNode, irList, isEmpty, isStmt, isTree, nullNode, nullStmt, offsetConstNode, phiExp, repeatStmt, replaceSource, replaceSource1, replaceSource2, returnStmt, setChild1, setChild2, setChildren, setChildren, setDataStmt, setIndex, setIndexNumberToAllNodes, setParent, setType, setWork, subpDefinition, subpIterator, subscriptedExp, toString, toStringDetail, toStringShort, toStringWithChildren, undecayExp, undecayExp, undecayExp, whileStmt
 
Methods inherited from interface coins.ir.IR
addInf, getChild1, getChild2, getInf, getInfList, getParent, getSym, print, print, removeInf
 
Methods inherited from interface coins.ir.IR0
getChild, getChildCount, getIndex, getOperator, setChild
 
Methods inherited from interface coins.ir.hir.HIR0
assignStmt, blockStmt, callStmt, constNode, contentsExp, convExp, copyWithOperands, copyWithOperandsChangingLabels, decayExp, elemNode, exp, exp, expStmt, falseNode, finishHir, forStmt, functionExp, getChildNumber, getFlag, getFlagBox, getNextStmt, getStmtContainingThisNode, getType, hirClone, hirIterator, hirList, hirSeq, ifStmt, intConstNode, irList, isSameAs, jumpStmt, labelDef, labeledStmt, labelNode, pointedExp, print, program, qualifiedExp, repeatStmt, replaceThisNode, returnStmt, setFlag, setIndexNumberToAllNodes, sizeofExp, sizeofExp, subpDefinition, subpNode, subscriptedExp, switchStmt, symNode, trueNode, undecayExp, varNode, whileStmt
 

Field Detail

defaultLabel

public Label defaultLabel

endLabel

public Label endLabel
Constructor Detail

SwitchStmtImpl

public SwitchStmtImpl(HirRoot pHirRoot,
                      Exp pSelectionExp,
                      IrList pJumpList,
                      Label pDefaultLabel,
                      Stmt pBodyStmt,
                      Label pEndLabel)
SwitchStmtImpl SwitchStmt -> ( switchCode Exp @ // Case selection expression. JumpTable_ @ // List of constants and statement // labels. Stmt @ // Collection of statements to be // selected. LabelStmt_ @ ) // Indicates end of switch statement. JumpTable_ -> ( seqCode JumpList_ @ LabelNode @ ) // Default label. JumpList_ -> ( listCode List_of_SwitchCase @ ) // Corelate // Exp value and list of SwitchCase_ pairs. SwitchCase_ -> ( seqCode ConstNode @ // Corelate Exp value and LabelNode @ ) // switch statement label. child1: case selection expression child2: JumpTable of the form (seq jumpList LabelNode) where labelNode indicates default label, and jumpList is a list of const-label pairs (hirList (hirSeq constNode labelNode) ... ) child3: statement containing statements to be selected. child4: LabeledStmt indicating end of switch statement. If default statement does not appear (defaultLabel.getHIRposition() is null), then the defaultLabel is attached to the switch end statement (statement with endlabel).


SwitchStmtImpl

public SwitchStmtImpl()

SwitchStmtImpl

public SwitchStmtImpl(HirRoot pHirRoot)
Method Detail

getSelectionExp

public Exp getSelectionExp()
Description copied from interface: SwitchStmt
Get selection expression

Specified by:
getSelectionExp in interface SwitchStmt
Returns:
the selection expression.

setSelectionExp

public void setSelectionExp(Exp pSelectionExp)
Description copied from interface: SwitchStmt
Set selection expression

Specified by:
setSelectionExp in interface SwitchStmt
Parameters:
pSelectionExp - Selection expression of this switch statement.

getCaseCount

public int getCaseCount()
Specified by:
getCaseCount in interface SwitchStmt
Returns:
the number of case branches of this switch.

getCaseConst

public Const getCaseConst(int index)
Description copied from interface: SwitchStmt
Get the n-th (head is 0) case constant. If out of range , return null

Specified by:
getCaseConst in interface SwitchStmt
Returns:
the n-th case constant.

getCaseLabel

public Label getCaseLabel(int index)
Description copied from interface: SwitchStmt
getCaseLabel Get n-th (head is 0) case label. If out of range , return null.

Specified by:
getCaseLabel in interface SwitchStmt
Returns:
the n-th case label.

getCaseLabelNode

public LabelNode getCaseLabelNode(int index)
Description copied from interface: SwitchStmt
getCaseLabelNode Get LabelNode of n-th (head is 0) case label. If out of range , return null.

Specified by:
getCaseLabelNode in interface SwitchStmt
Returns:
the n-th case label node.

getDefaultLabel

public Label getDefaultLabel()
Description copied from interface: SwitchStmt
Get default label

Specified by:
getDefaultLabel in interface SwitchStmt
Returns:
the default label

getDefaultLabelNode

public LabelNode getDefaultLabelNode()
Description copied from interface: SwitchStmt
Get default label node

Specified by:
getDefaultLabelNode in interface SwitchStmt
Returns:
the default label node

getEndLabel

public Label getEndLabel()
Description copied from interface: SwitchStmt
Get break destination label (switch-end label) of this switch statement.

Specified by:
getEndLabel in interface SwitchStmt
Returns:
the break destination label.

getBodyStmt

public Stmt getBodyStmt()
Description copied from interface: SwitchStmt
Gget switch-body statement that contains case statements. (Usually, it is BlockStmt.)

Specified by:
getBodyStmt in interface SwitchStmt
Returns:
the body statement of this switch statement.

getSwitchEndNode

public LabeledStmt getSwitchEndNode()
Description copied from interface: SwitchStmt
Get the switch end node to where break statements jump.

Specified by:
getSwitchEndNode in interface SwitchStmt
Returns:
the switch end node with switch-end label.

combineWithConditionalExp

public void combineWithConditionalExp(Stmt pStmt,
                                      HIR pCond)
Combine pStmt with conditional expression part pCond of control statement so that pStmt should be executed before pCond.

Specified by:
combineWithConditionalExp in interface Stmt
Overrides:
combineWithConditionalExp in class StmtImpl
Parameters:
pStmt - statement to be executed before pCond.
pCond - conditional expression to be combined with pStmt.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from class: HIR_Impl
clone Override Object.clone in HIR.

Overrides:
clone in class StmtImpl
Throws:
java.lang.CloneNotSupportedException

accept

public void accept(HirVisitor pVisitor)
Description copied from interface: HIR0
accept Acceptor used in HIR visitor. See HirVisitor, HirVisitorModel1, HirVisitormodel2.

Specified by:
accept in interface HIR0
Overrides:
accept in class HIR_Impl