coins
クラス SymRoot

java.lang.Object
  |
  +--coins.SymRoot

public class SymRoot
extends java.lang.Object

  SymRoot class is used to access Sym (symbol) information and
  information prepared by other classes such as IoRoot, HIR, etc.
  All Sym objects contain a reference to the SymRoot object
  from which symbol information and methods
  can be quickly accessed.
  The SymRoot object contains a reference to IoRoot.
  Thus, every Sym objects can access input/output methods, too.

 Symbol tables:

  public SymTable
    symTable        = null, // Instance to call SymTable methods.
    symTableRoot    = null, // Root of SymTable.
    symTableConst   = null, // Constant table.
    symTableUnique  = null, // SymTable that contains
                            // generated unique name.
    symTableCurrent = null, // Referes to the symbol table for
        // subprogram, etc. under construction or under processing.
        // At parsing phase, Sym methods pushSymTable and popSymTable
        // set symTableCurrent automatically. In parsing, at the point
        // of scope change, such as structure definition, symTableCurrent
        // should be properly set (by pushSymTable, popSymTable, or
        // by explicitly setting statements.)
        // In phases that modify HIR (optimization phase, etc.),
        // symTableCurrent should be set to the symbol table local
        // to the subprogram under processing.
    symTableCurrentSubp = null; // Symbol table of current subprogram.
                        // Some kind of symbols (type, etc.) are
                        // registered not in symTableCurrent
                        // but in symTableCurrentSubp.

 Type symbols representing basic types:
    They are recorded in SymTableRoot as symbols whose name
    is preceeded by " " so that they do not conflict with
    identifiers used in input program.
    The names are shown in the tail of following lines.
  public Type
    typeBool,       // bool  " bool"
    typeChar,       // character  " char"
    typeShort,      // short integer  " short"
    typeInt,        // integer  " int"
    typeLong,       // long integer  " long"
    typeLongLong,   // long long integer  " long_long"
    typeU_Char,     // unsigned character  " u_char"
    typeU_Short,    // unsigned short integer  " u_short"
    typeU_Int,      // unsigned integer  " u_int"
    typeU_Long,     // unsigned long integer  " u_long"
    typeU_LongLong, // unsigned long long integer  " u_long_long"
    typeFloat,      // float  " float"
    typeDouble,     // double float  " double"
    typeLongDouble, // long double  " long_double"
    typeVoid,       // void  " void"
    typeOffset,     // offset of address  " offset"
    typeAddress;    // address  " address"
  public Type
    typeStringAny;  // String type whose length is not fixed
                    // (VECT 0 typeU_Char).

 Other public symbols

  public Subp
     subpCurrent; // Current subprogram under processing.
                  // In flow analysis, alias analysis,
                  // optimization, parallelization, it is
                  // recommended to set this field to reflect
                  // the subprogram under processing.

  public BoolConst
    boolConstTrue,   // Bool constant representing true  " true"
    boolConstFalse;  // Bool constant representing false " false"

  public IntConst
    intConst0,             // constant 0
    intConst1,             // constant 1
    longConst0;            // long int const 0

  public FloatConst
    floatConst0,           // float  const 0.0
    doubleConst0;          // double const 0.0

 Coding rules in SymRoot

 Methods begin with lower case letter.
 Constants (final static int, etc.) are spelled in upper case letters.
 Indentation is 2 characters.
 Formal parameters begin with p.
 Local variables begin with l.
 Methods and variables are named so that meaning is easily guessed.
 Short names less than 3 characters are not used except for
 very local purpose.
 Protected or private fields starts with character f.
 Public fields of xxxRoot class might not start with character f.


フィールドの概要
 BoolConst boolConstFalse
           
 BoolConst boolConstTrue
           
 java.util.Set conflictingSpecialSyms
          conflictingSpecialSyms: Record symbols with '_' as heading character in order to avoid conflicts in generating symbols by generateLabel, generateVar, etc.
 FloatConst doubleConst0
           
protected  int fARegCount
           
protected  int fElemCount
           
protected  int fGenSymCount
           
protected  int fLabelCount
           
 FloatConst floatConst0
           
protected  int fMRegCount
           
protected  int fParamCount
           
protected  int fVarCount
           
 IntConst intConst0
           
 IntConst intConst1
           
 IoRoot ioRoot
          ioRoot records the reference to the IoRoot object passed as a parameter of SymRoot constructor.
 IntConst longConst0
           
 MachineParam machineParam
          Reference to MachineParam copied from ioRoot
 java.util.Set safeArray
          Set of arrays which are declared as safe, that is, their subscript values does not exceed their limit and accessed locations are always within the storage area allocated to the array variable.
 SourceLanguage sourceLanguage
          sourceLanguage is an instance of SourceLanguage class used to access source language dependent information and methods in such way as symRoot.sourceLanguage.makeCstringWithTrailing0(pureString).
 Subp subpCurrent
           
 Sym sym
          sym is an instance of Sym class used to access Sym methods such as creation of Sym instance, etc.
 SymRoot symRoot
          symRoot referes SymRoot object that is used to access SymRoot information.
 SymTable symTable
           
 SymTable symTableConst
           
 SymTable symTableCurrent
           
 SymTable symTableCurrentSubp
           
 SymTable symTableFlow
           
 SymTable symTableRoot
           
 SymTable symTableUnique
           
 Type typeAddress
          Type symbols representing basic types
 Type typeBool
          Type symbols representing basic types
 Type typeChar
          Type symbols representing basic types
 Type typeDouble
          Type symbols representing basic types
 Type typeFloat
          Type symbols representing basic types
 Type typeInt
          Type symbols representing basic types
 Type typeLong
          Type symbols representing basic types
 Type typeLongDouble
          Type symbols representing basic types
 Type typeLongLong
          Type symbols representing basic types
 Type typeOffset
          Type symbols representing basic types
 Type typeRegion
           
 Type typeShort
          Type symbols representing basic types
 Type typeStringAny
           
 Type typeU_Char
          Type symbols representing basic types
 Type typeU_Int
          Type symbols representing basic types
 Type typeU_Long
          Type symbols representing basic types
 Type typeU_LongLong
          Type symbols representing basic types
 Type typeU_Short
          Type symbols representing basic types
 Type typeVoid
          Type symbols representing basic types
 
コンストラクタの概要
SymRoot(IoRoot pIoRoot)
           
 
メソッドの概要
 void attachFlowRoot(FlowRoot pFlowRoot)
          attachFlowRoot: Attach FLowRoot information when it become available.
 void attachHirRoot(HirRoot pHirRoot)
          attachHirRoot: Attach HirRoot information when it become available after the creation of SymRoot object.
 int getARegCount()
          getARegCount: Get the generated abstract-register counter.
 Type getCharType()
          getCharType: //##27
 int getElemCount()
          getElemCount: Get the generated element counter.
 FlowRoot getFlowRoot()
          getFlowRoot: Get FlowRoot from symbol information.
 java.util.Set getFunctionsWithoutSideEffect()
          Get the set of functions without side effect.
 HirRoot getHirRoot()
          getHirRoot: Get the reference to the HirRoot object.
 Type getIntTypeOfAddress()
          getIntTypeOfAddress: //##10 Get integer type corresponding to the address type.
 Type getIntTypeOfChar()
          getIntTypeOfChar: //##10 Get integer type corresponding to the char type.
 int getLabelCount()
          getLabelCount: Get the generated label counter.
 int getMRegCount()
          getMRegCount: Get the generated machine-register counter.
 int getParamCount()
          getParamCount: Get the generated parameter counter.
 int getSymCount()
          getSymCount: Get the generated symbol counter.
 int getVarCount()
          getVarCount: Get the generated variable counter.
 int incrementARegCount()
          incrementARegCount: Increment the generated abstract register counter and return updated value.
 int incrementElemCount()
          incrementElemCount: Increment the generated element counter and return updated value.
 int incrementLabelCount()
          incrementLabelCount: Increment the generated label counter and return updated value.
 int incrementMRegCount()
          incrementMRegCount: Increment the generated machine register counter and return updated value.
 int incrementParamCount()
          incrementParamCount: Increment the generated parameter counter and return updated value.
 int incrementSymCount()
          incrementSymCount: Increment the generated symbol counter and return updated value.
 int incrementVarCount()
          incrementVarCount: Increment the generated variable counter and return updated value.
 void initiate()
          initiate() does the initiation procedure of SymRoot such as symbol table initiation, etc.
 IrList irList(java.util.LinkedList pList)
          irList creates an instance of IrList from LinkedList.
 void resetCounters()
          resetCounters: reset the counters for generated symbols.
 void useSymTableOfSubpDefinition(SubpDefinition pSubpDef)
          useSymTableOfSubpDefinition: //##16 Set the subpCurrent to the one corresponding to the subprogram definition pSubpDef, and set symTableCurrent, symTableCurrentSubp to the one corresponding to pSubpDef.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

ioRoot

public final IoRoot ioRoot
ioRoot records the reference to the IoRoot object passed as a parameter of SymRoot constructor. It is used in accessing IoRoot information and invoking IoRoot methods.


symRoot

public final SymRoot symRoot
symRoot referes SymRoot object that is used to access SymRoot information. All Sym objects contain a reference to the SymRoot object. As the SymRoot object contains a reference to the IoRoot object, all SymRoot information and IoRoot information can be accessed from Sym methods.


sym

public final Sym sym
sym is an instance of Sym class used to access Sym methods such as creation of Sym instance, etc. from othe classes in such way as symRoot.sym.defineVar("abc".intern(), symRoot.typeInt).


sourceLanguage

public final SourceLanguage sourceLanguage
sourceLanguage is an instance of SourceLanguage class used to access source language dependent information and methods in such way as symRoot.sourceLanguage.makeCstringWithTrailing0(pureString).


machineParam

public final MachineParam machineParam
Reference to MachineParam copied from ioRoot


symTable

public SymTable symTable

symTableRoot

public SymTable symTableRoot

symTableConst

public SymTable symTableConst

symTableUnique

public SymTable symTableUnique

symTableCurrent

public SymTable symTableCurrent

symTableCurrentSubp

public SymTable symTableCurrentSubp

symTableFlow

public SymTable symTableFlow

typeBool

public Type typeBool
Type symbols representing basic types


typeChar

public Type typeChar
Type symbols representing basic types


typeShort

public Type typeShort
Type symbols representing basic types


typeInt

public Type typeInt
Type symbols representing basic types


typeLong

public Type typeLong
Type symbols representing basic types


typeLongLong

public Type typeLongLong
Type symbols representing basic types


typeU_Char

public Type typeU_Char
Type symbols representing basic types


typeU_Short

public Type typeU_Short
Type symbols representing basic types


typeU_Int

public Type typeU_Int
Type symbols representing basic types


typeU_Long

public Type typeU_Long
Type symbols representing basic types


typeU_LongLong

public Type typeU_LongLong
Type symbols representing basic types


typeFloat

public Type typeFloat
Type symbols representing basic types


typeDouble

public Type typeDouble
Type symbols representing basic types


typeLongDouble

public Type typeLongDouble
Type symbols representing basic types


typeVoid

public Type typeVoid
Type symbols representing basic types


typeOffset

public Type typeOffset
Type symbols representing basic types


typeAddress

public Type typeAddress
Type symbols representing basic types


typeStringAny

public Type typeStringAny

typeRegion

public Type typeRegion

subpCurrent

public Subp subpCurrent

boolConstTrue

public BoolConst boolConstTrue

boolConstFalse

public BoolConst boolConstFalse

intConst0

public IntConst intConst0

intConst1

public IntConst intConst1

longConst0

public IntConst longConst0

floatConst0

public FloatConst floatConst0

doubleConst0

public FloatConst doubleConst0

conflictingSpecialSyms

public java.util.Set conflictingSpecialSyms
conflictingSpecialSyms: Record symbols with '_' as heading character in order to avoid conflicts in generating symbols by generateLabel, generateVar, etc. All symbols with heading '_' are recorded irrespective of source program symbol or generated symbols.


safeArray

public java.util.Set safeArray
Set of arrays which are declared as safe, that is, their subscript values does not exceed their limit and accessed locations are always within the storage area allocated to the array variable. The declaration may be given in such way as #pragma optControl safeArray var1 var2 ...


fVarCount

protected int fVarCount

fParamCount

protected int fParamCount

fElemCount

protected int fElemCount

fLabelCount

protected int fLabelCount

fGenSymCount

protected int fGenSymCount

fARegCount

protected int fARegCount

fMRegCount

protected int fMRegCount
コンストラクタの詳細

SymRoot

public SymRoot(IoRoot pIoRoot)
メソッドの詳細

irList

public IrList irList(java.util.LinkedList pList)
irList creates an instance of IrList from LinkedList. It makes a list that can be treated as an instance of IR from linked list of objects.

戻り値:
an instance of IrList containing objects given in pList.

initiate

public void initiate()
initiate() does the initiation procedure of SymRoot such as symbol table initiation, etc.


getHirRoot

public HirRoot getHirRoot()
getHirRoot: Get the reference to the HirRoot object. The reference to the HirRoot object will be set by attachHirRoot when HirRoot information become available. This method is used to access HIR information from Sym methods.


getFlowRoot

public FlowRoot getFlowRoot()
getFlowRoot: Get FlowRoot from symbol information. It will be set by attachFlowRoot when FlowRoot information become available.


attachHirRoot

public void attachHirRoot(HirRoot pHirRoot)
attachHirRoot: Attach HirRoot information when it become available after the creation of SymRoot object.


attachFlowRoot

public void attachFlowRoot(FlowRoot pFlowRoot)
attachFlowRoot: Attach FLowRoot information when it become available.


useSymTableOfSubpDefinition

public void useSymTableOfSubpDefinition(SubpDefinition pSubpDef)
useSymTableOfSubpDefinition: //##16 Set the subpCurrent to the one corresponding to the subprogram definition pSubpDef, and set symTableCurrent, symTableCurrentSubp to the one corresponding to pSubpDef. This should be called before processing a subprogram where new symbol may be created (for optimizing/parallelizing transformation, etc.) in the process.


getIntTypeOfAddress

public Type getIntTypeOfAddress()
getIntTypeOfAddress: //##10 Get integer type corresponding to the address type.

戻り値:
one of typeInt, typeU_Int, typeLong, typeU_Long, type_U_LongLong.

getIntTypeOfChar

public Type getIntTypeOfChar()
getIntTypeOfChar: //##10 Get integer type corresponding to the char type.

戻り値:
one of typeInt, typeU_Int.

getCharType

public Type getCharType()
getCharType: //##27

戻り値:
typeChar if INT_TYPE_OF_CHAR is INT_TYPE_OF_CHAR_IS_INT else return typeU_Char.

getFunctionsWithoutSideEffect

public java.util.Set getFunctionsWithoutSideEffect()
Get the set of functions without side effect. If HIR is not yet built or program initiation part is not given then retuen sourcelanguage.fFunctionsWithoutSideEffect; else { if the set is not yet recorded, copy sourcelanguage.fFunctionsWithoutSideEffect and adjust the copied set by #pragma optControl functionsWithoutSideEffect f1 f2 ... #pragma optControl functionsWithSideEffect g1 g2 ... and return the result after recording the set. else return the recorded set. }

戻り値:
the set of functions without side effect.

getVarCount

public int getVarCount()
getVarCount: Get the generated variable counter.


incrementVarCount

public int incrementVarCount()
incrementVarCount: Increment the generated variable counter and return updated value.


getParamCount

public int getParamCount()
getParamCount: Get the generated parameter counter.


incrementParamCount

public int incrementParamCount()
incrementParamCount: Increment the generated parameter counter and return updated value.


getElemCount

public int getElemCount()
getElemCount: Get the generated element counter.


incrementElemCount

public int incrementElemCount()
incrementElemCount: Increment the generated element counter and return updated value.


getLabelCount

public int getLabelCount()
getLabelCount: Get the generated label counter.


incrementLabelCount

public int incrementLabelCount()
incrementLabelCount: Increment the generated label counter and return updated value.


getSymCount

public int getSymCount()
getSymCount: Get the generated symbol counter.


incrementSymCount

public int incrementSymCount()
incrementSymCount: Increment the generated symbol counter and return updated value.


getARegCount

public int getARegCount()
getARegCount: Get the generated abstract-register counter.


incrementARegCount

public int incrementARegCount()
incrementARegCount: Increment the generated abstract register counter and return updated value.


getMRegCount

public int getMRegCount()
getMRegCount: Get the generated machine-register counter.


incrementMRegCount

public int incrementMRegCount()
incrementMRegCount: Increment the generated machine register counter and return updated value.


resetCounters

public void resetCounters()
resetCounters: reset the counters for generated symbols.