coins.ir
Class IrListImpl

java.lang.Object
  extended bycoins.ir.IrListImpl
All Implemented Interfaces:
java.lang.Cloneable, IR, IR0, IrList

public class IrListImpl
extends java.lang.Object
implements IrList

class IrListImpl List of expressions, symbols, and others. LinkedList in java.util is wrapped so that it can be treated as IR node and IR methods can be applied. This class may print messages to System.out instead of using put of Message because hirRoot/lirRoot might be null.


Field Summary
protected  HirAnnex fHirAnnex
           
protected  int fOperator
           
protected  IR fParent
           
 HirRoot hirRoot
           
 
Fields inherited from interface coins.ir.IR
OP_CODE_NAME, OP_INF, OP_LIST, OP_PROG, OP_SUBP_DEF
 
Constructor Summary
IrListImpl(HirRoot pHirRoot)
           
IrListImpl(HirRoot pHirRoot, java.util.LinkedList pList)
          IrList constructor foe HIR Wrap pList so that it can be treated as IR node.
 
Method Summary
 void add(int pInsertionPosition, java.lang.Object pObjectToBeInserted)
           
 void add(java.lang.Object pElement)
           
 void addInf(java.lang.String pInfKindInterned, java.lang.Object pInfObject)
          addInf Add (attach) information pInfObject to this IR node.
 IR buildNode(int pOperator)
           
 IR buildNode(int pOperator, IR pSource1)
           
 IR buildNode(int pOperator, IR pSource1, IR pSource2)
           
 IR buildSymNode(Sym pSym)
           
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object pObject)
           
 java.lang.Object get(int pIndex)
           
 IR getChild(int pNumber)
          getChild
 IR getChild1()
          getChild1 Get the first child of this node.
 IR getChild2()
          getChild2 Get the second child of this node.
 int getChildCount()
          getChildCount Get the number of children that may be attached to this node.
 IR getClone()
          getClone
 java.lang.Object getFirst()
           
 FlowAnalSym getFlowAnalSym()
           
 java.lang.String getIndentSpace(int pIndent)
           
 int getIndex()
          getIndex Get the index number assigned to "this" node.
 java.lang.Object getInf(java.lang.String pInfKindInterned)
          getInf Get the information of the kind pInfKindInterned.
 IrList getInfList()
          getInfList Get the information list attached to this node.
 java.lang.String getIrName()
           
 int getOperator()
          getOperator Get operation code of "this" node.
 IR getParent()
          getParent Get the parent of this node.
 Sym getResultOperand()
           
 IR getSourceNode(int pNumber)
           
 IR getSourceNode1()
           
 IR getSourceNode2()
           
 Sym getSym()
          getSym Get the symbol represented by "this" node if this is a node representing a symbol (simple variable, element/field name, subprogram, label, constant, etc.).
 java.lang.Object getWork()
           
 int indexOf(java.lang.Object pObject)
           
 boolean isEmpty()
           
 java.util.ListIterator iterator()
           
 void print(int pIndent)
          print Print this subtree in text format traversing all children of this node.
 void print(int pIndent, boolean pDetail)
          print Print this subtree in text format traversing all children of this node.
 java.lang.Object remove(int pRemovePosition)
           
 boolean remove(java.lang.Object pObject)
           
 void removeInf(java.lang.String pInfKindInterned)
          removeInf Remove the information of the kind pInfKindInterned.
 void replaceOperator(int pOperator)
           
 void replaceResultOperand(IR pOperand)
           
 void replaceSource(int pNumber, IR pOperand)
           
 void replaceSource1(IR pOperand)
           
 void replaceSource2(IR pOperand)
           
 void replaceThisNode(IR pNewNode)
           
 void set(int pIndex, java.lang.Object pElement)
           
 void setChild(int pNumber, IR pIr)
          setChild Set pHir as pNumber-th child of this node.
 void setChild1(IR p1)
           
 void setChild2(IR p2)
           
 void setIndex(int pIndex)
           
 void setParent(IR pParent)
           
 void setWork(java.lang.Object pWork)
           
 int size()
           
 java.lang.String toString()
           
 java.lang.String toStringShort()
          toStringShort
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hirRoot

public final HirRoot hirRoot

fOperator

protected int fOperator

fHirAnnex

protected HirAnnex fHirAnnex

fParent

protected IR fParent
Constructor Detail

IrListImpl

public IrListImpl(HirRoot pHirRoot,
                  java.util.LinkedList pList)
IrList constructor foe HIR Wrap pList so that it can be treated as IR node.

Parameters:
pList - LinkedList that may contain any objects. If pList is null, an empty LinkedList is created.

IrListImpl

public IrListImpl(HirRoot pHirRoot)
Method Detail

add

public void add(java.lang.Object pElement)
Specified by:
add in interface IrList

add

public void add(int pInsertionPosition,
                java.lang.Object pObjectToBeInserted)
Specified by:
add in interface IrList

getFirst

public java.lang.Object getFirst()
Specified by:
getFirst in interface IrList

get

public java.lang.Object get(int pIndex)
Specified by:
get in interface IrList

set

public void set(int pIndex,
                java.lang.Object pElement)
Specified by:
set in interface IrList

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface IrList

size

public int size()
Specified by:
size in interface IrList

contains

public boolean contains(java.lang.Object pObject)
Specified by:
contains in interface IrList

indexOf

public int indexOf(java.lang.Object pObject)
Specified by:
indexOf in interface IrList

remove

public java.lang.Object remove(int pRemovePosition)
Specified by:
remove in interface IrList

clear

public void clear()
Specified by:
clear in interface IrList

remove

public boolean remove(java.lang.Object pObject)
Specified by:
remove in interface IrList

iterator

public java.util.ListIterator iterator()
Specified by:
iterator in interface IrList

clone

public java.lang.Object clone()
                       throws java.lang.ClassCastException
Throws:
java.lang.ClassCastException

getClone

public IR getClone()
            throws java.lang.CloneNotSupportedException
Description copied from interface: IrList
getClone

Specified by:
getClone in interface IrList
Returns:
a clone of this list.
Throws:
java.lang.CloneNotSupportedException

getWork

public java.lang.Object getWork()

setWork

public void setWork(java.lang.Object pWork)

getIrName

public java.lang.String getIrName()

buildSymNode

public IR buildSymNode(Sym pSym)

buildNode

public IR buildNode(int pOperator)

buildNode

public IR buildNode(int pOperator,
                    IR pSource1)

buildNode

public IR buildNode(int pOperator,
                    IR pSource1,
                    IR pSource2)

getOperator

public int getOperator()
Description copied from interface: IR0
getOperator Get operation code of "this" node.

Specified by:
getOperator in interface IR0
Returns:
the operation code (value of operator field) of "this" node.

getParent

public IR getParent()
Description copied from interface: IR
getParent Get the parent of this node.

Specified by:
getParent in interface IR
Returns:
the parent of this node. If this has no parent, return null.

setParent

public void setParent(IR pParent)

getChildCount

public int getChildCount()
Description copied from interface: IR0
getChildCount Get the number of children that may be attached to this node. Abbreviated child (null child) is also counted.

Specified by:
getChildCount in interface IR0
Returns:
the number of children of this node.

getChild1

public IR getChild1()
Description copied from interface: IR
getChild1 Get the first child of this node. (This method does the same operation as getChild(1) but it may be more efficient.)

Specified by:
getChild1 in interface IR
Returns:
the child 1 of this node.

getChild2

public IR getChild2()
Description copied from interface: IR
getChild2 Get the second child of this node. (This method does the same operation as getChild(2) but it may be more efficient.)

Specified by:
getChild2 in interface IR
Returns:
the child 2 of this node.

getChild

public IR getChild(int pNumber)
Description copied from interface: IR0
getChild

Specified by:
getChild in interface IR0
Parameters:
pNumber - the child number of the child to be returned.
Returns:
the specified child of this node.

setChild1

public void setChild1(IR p1)

setChild2

public void setChild2(IR p2)

setChild

public void setChild(int pNumber,
                     IR pIr)
Description copied from interface: IR0
setChild Set pHir as pNumber-th child of this node.

Specified by:
setChild in interface IR0
Parameters:
pNumber - Child number

addInf

public void addInf(java.lang.String pInfKindInterned,
                   java.lang.Object pInfObject)
Description copied from interface: IR
addInf Add (attach) information pInfObject to this IR node. If information of the same kind is already exists in this node, then the old one is replaced with the new one (pInfObject).

Specified by:
addInf in interface IR
Parameters:
pInfObject - Object to be added as information. It may be String, Sym, IR, List, and so on, hence they may be non-IR elements.

getInf

public java.lang.Object getInf(java.lang.String pInfKindInterned)
Description copied from interface: IR
getInf Get the information of the kind pInfKindInterned. If there is no information of the specified kind, then null is returned. The kind names are listed in coins.Registry class. It should be interned (in such way as "coins_pragma".intern()). If there is no information of the kind pInfKindInterned, then return null. Note that the value returned by getInf is not restricted to IR objects but it may be Sym, Const, String.

Specified by:
getInf in interface IR
Returns:
the object of the specified kind attached to this node.

removeInf

public void removeInf(java.lang.String pInfKindInterned)
Description copied from interface: IR
removeInf Remove the information of the kind pInfKindInterned. If there is no information of the specified kind, then no effect remains.

Specified by:
removeInf in interface IR

getInfList

public IrList getInfList()
Description copied from interface: IR
getInfList Get the information list attached to this node. If no information is added, then null is returned. You can see if information is added or not by if (node.getInfList() == null) .... This method is prepared for persons who knows well the inside of the compiler. In ordinary usage, this method is unnecessary to be used. If you want to see the contents of the list, you should know the structure of the list defined in HirAnnex and LirAnnex.

Specified by:
getInfList in interface IR

getIndex

public int getIndex()
Description copied from interface: IR0
getIndex Get the index number assigned to "this" node. (The index number is used to refer the node in data flow analysis and debug-print.)

Specified by:
getIndex in interface IR0
Returns:
the index number assigned to "this" node. If the node has no index number, return 0.

setIndex

public void setIndex(int pIndex)

getSourceNode1

public IR getSourceNode1()

getSourceNode2

public IR getSourceNode2()

getSourceNode

public IR getSourceNode(int pNumber)

getSym

public Sym getSym()
Description copied from interface: IR
getSym Get the symbol represented by "this" node if this is a node representing a symbol (simple variable, element/field name, subprogram, label, constant, etc.).

Specified by:
getSym in interface IR
Returns:
the symbol represented by "this" node. In HIR, it is Var if VarNode Subp if SubpNode, Label if LabelNode or LabelDef Elem if ElemNode // Field if FieldNode Const if ConstNode. If "this" node does not represent any symbol, then return null. (If "this" is HIR leaf or nonleaf node, the symbol attached to the node is returned. If "this" has no symbol attached, then return null. If "this" is LIR node representing a symbol, the symbol is returned. If "this" is LIR computation node, null is returned.)

getFlowAnalSym

public FlowAnalSym getFlowAnalSym()

getResultOperand

public Sym getResultOperand()

replaceSource1

public void replaceSource1(IR pOperand)

replaceSource2

public void replaceSource2(IR pOperand)

replaceSource

public void replaceSource(int pNumber,
                          IR pOperand)

replaceResultOperand

public void replaceResultOperand(IR pOperand)

replaceThisNode

public void replaceThisNode(IR pNewNode)

replaceOperator

public void replaceOperator(int pOperator)

getIndentSpace

public java.lang.String getIndentSpace(int pIndent)

toString

public java.lang.String toString()

toStringShort

public java.lang.String toStringShort()
Description copied from interface: IrList
toStringShort

Specified by:
toStringShort in interface IrList
Returns:
the text representation of this list in short form.

print

public void print(int pIndent)
Description copied from interface: IR
print Print this subtree in text format traversing all children of this node. "this" may be any subtree (it may be a leaf node).

Specified by:
print in interface IR
Parameters:
pIndent - number of heading spaces for indentation.

print

public void print(int pIndent,
                  boolean pDetail)
Description copied from interface: IR
print Print this subtree in text format traversing all children of this node. "this" may be any subtree (it may be a leaf node).

Specified by:
print in interface IR
Parameters:
pIndent - number of heading spaces for indentation.
pDetail - true if detail print is requested, false otherwise.