coins.ir.hir
インタフェース HIR0

すべてのスーパーインタフェース:
java.lang.Cloneable, IR0
既知のサブインタフェースの一覧:
AsmStmt, AssignStmt, BlockStmt, ConstNode, ElemNode, Exp, ExpListExp, ExpStmt, ForStmt, FunctionExp, HIR, HirList, HirSeq, IfStmt, IndexedLoopStmt, InfNode, InfStmt, JumpStmt, LabelDef, LabeledStmt, LabelNode, LoopStmt, NullNode, PhiExp, PointedExp, Program, QualifiedExp, RepeatStmt, ReturnStmt, SetDataStmt, Stmt, SubpDefinition, SubpNode, SubscriptedExp, SwitchStmt, SymNode, TypeNode, UntilStmt, VarNode, WhileStmt
既知の実装クラスの一覧:
AsmStmtImpl, AssignStmtImpl, BlockStmtImpl, ConstNodeImpl, ElemNodeImpl, ExpImpl, ExpListExpImpl, ExpStmtImpl, ForStmtImpl, FunctionExpImpl, HIR_Impl, HirListImpl, HirSeqImpl, IfStmtImpl, IndexedLoopStmtImpl, InfNodeImpl, InfStmtImpl, JumpStmtImpl, LabelDefImpl, LabeledStmtImpl, LabelNodeImpl, LoopStmtImpl, NullNodeImpl, PhiExpImpl, PointedExpImpl, ProgramImpl, QualifiedExpImpl, RepeatStmtImpl, ReturnStmtImpl, SetDataStmtImpl, StmtImpl, SubpDefinitionImpl, SubpNodeImpl, SubscriptedExpImpl, SwitchStmtImpl, SymNodeImpl, TypeNodeImpl, UntilStmtImpl, VarNodeImpl, WhileStmtImpl

public interface HIR0
extends IR0

HIR0 interface

 Simplified High-level Intermediate Representation interface (HIR0).

 HIR0 is the simplified interface of HIR (High-level Intermediate Representation).
 Simple compiler can be built by using IR0, HIR0, and Sym0.
 Advanced methods to make complicated compilers will be find in
 the interface IR which extends IR0, HIR which extends HIR0, and
 Sym which extends Sym0.

 As for High Level Intermediate Representation (HIR) interface,
 all HIR classes implement all methods declared in HIR interface
 and IR interface which is inherited by the HIR interface.
 See IR, Stmt, Exp, Sym interfaces and HirRoot class.

 Preliminaries
   High level intermediate representation is composed of operation
   information in a tree form, symbol information, data flow
   information, and others.
   The operation information tree is composed of nodes and edges.
   A node with children is called as nonleaf node and a node without
   child is called a leaf node.
   The term "node" means either leaf node or nonleaf node,
   the term "subtree" means either pure subtree composed of
   several nonleafs and leafs, or one leaf.

 Class/interface hierarchy:
   (Root is a class, others are interfaces.
    An interface xxx is implemented by corresponding class
    named xxxImpl or xxx_Impl.)

 Root
 |
 |- Sym
 |   |- ...
 |
 |- Flow
 |   |- ...
 |
 |- IR
     |- IR_factory    // IR object creation factory.
     |- IrList        // List of indefinite number of objects.
     |   |- HirList   // IrList whose elements are HIR objects.
     |
     |- LIR           // Low level Intermediate Representation
     |   |- ...
     |
     |- HIR0 // Simple HIR interface.
        |
        HIR // High level Intermediate Representation.
         |  // Usual operations on HIR are done by using HIR methods.
         |
         |- Program         // Program definition node.
         |- SubpDefinition  // Subprogram definition node.
         |- HirSeq          // Sequence of definite number of
         |                  // HIR objects.
         |- HirList         // IrList whose elements are HIR objects.
         |                  // (Note that elements of IrList may be Sym
         |                  //  and String but elements of HirList should
         |                  //  be HIR objects.)
         |                  // (Multi-inheritance of interface)
         |- Stmt            // Statement
         |   |- LabeledStmt // Labeled statement.
         |   |- AssignStmt  // Assignment statement.
         |   |- IfStmt      // If-statement.
         |   |- JumpStmt    // Jump (goto) statement.
         |   |              //  (Jump unconditionally)
         |   |- LoopStmt    // Loop statement.
         |   |   |- ForLoop     // For-loop.
         |   |   |- WhileLoop   // While-loop.
         |   |   |- RepeatLoop  // Repeat-while-true loop.
         |   |   |- IndexedLoop // Loop with index range
         |   |                  // (such as Fortran DO loop).
         |   |- ReturnStmt   // Return statement.
         |   |- SwitchStmt   // Switch (case) statement.
         |   |- BlockStmt    // Block representing a sequence
         |   |               //   of statements.
         |   |- ExpStmt      // Expression treated as a statement.
         |   |               // Call statement is treated as an
         |   |               // expression statement of function call.
         |   |               // Loop start condition expression has
         |   |               // label and treated as ExpStmt.
         |   |- InfStmt      // An information node
         |                   // which can be treated as a statement.
         |                   //  (pragma, comment line, etc.)
         |- LabelDef         // Label definition node.
 //      |- InfNode          // IR information node.         DELETED
 //      |                   //  (pragma, comment line, etc.)
         |- Exp  // Expression
             |- ConstNode // Constant node
             |- SymNode   // Symbol node
             |   |- VarNode   // Variable name node.
 //          |   |   |- ParamNode // formal parameter name node
 //          |   |   |             DELETED
             |   |   |- ElemNode  // struct/union element name node
             |   |                 not DELETED
             |   |- SubpNode  // Subprogram name node.
             |   |- LabelNode // Label reference node.
             |   |- TypeNode  // Type name node.
             |
             |- SubscriptedExp // Subscripted variable.
             |- PointedExp     // Pointed object.
             |- QualifiedExp   // Qualified variable.
             |- FunctionExp    // Function call expression.
             |- PhiExp     // Phi function used in SSA
             |- ExpListExp // Expression representing a list of expressions
             |- NullNode   // Null (no-operation) node

  Deleted classes:
    ParamNode,
    StmtBody, AssignExp,
    Nonleaf, Leaf, HIRdetail, BBlock, PBlock, ExitStmt,
    ContinueStmt. (##10)

 Abstract syntax of HIR:

  Abstract syntax of HIR is shown as BNF syntax
  in the form ( operationCode attr child1 child2 ... ),
  where, child1 represents source operand 1, child2 represents
  source operand 2,  ... .  Instance of HIR may be regarded
  as a tree attached with operands as its subtree.
  The result operand is represented by the root node
  of the tree. The attr represents attributes
  such as type of the tree, etc.
  (Each node may be attached an expression identifier (expId)
  as an attribute. In such case, the expId attached to
  the root node of a subtree may be regarded as the identifier
  corresponding to the result value of the operation
  specified by the subtree.)
  Each child is also a subtree of the same form.
  Some child may be null.
  The operationCode and attr are not subtree but
  information attached to the root node of the subtree.
  (This notation is not explaining parse tree of HIR but
  explaining abstract syntax tree of HIR.)

  Notations in the following BNF descriptions..
    identifier starting with lower case letter except attr: terminal
    identifier starting with upper case letter:  nonterminal
      identifier ending with "_":
             nonterminal that is not an interface
      identifier that does not end with "_":
             nonterminal representing an interface
    xxxCode: operation code xxx
    xxxSym : symbol recorded in the symbol table
            progSym : program name symbol
            subpSym : subprogram name symbol
            varSym  : variable name symbol
                      (including array/struct/union name symbol)
            paramSym: formal parameter name symbol
            elemSym : struct/union element name symbol
            labelSym: label name symbol
            typeSym : type name symbol
    xxxConst: constant recorded in the symbol table
            intConst   : integer constant
                         (int/short/long/unsigned int/ ...)
            floatConst : floating constant (float/double/ ...)
            charConst  : character constant (signed/unsigned)
            stringConst: character string constant
            boolConst  : boolean constant
                      (true is 1, false is 0 if converted to  integer)
    intConstValue:    integer constant
                      (not a symbol table entry but value itself).
    stringConstValue: string  constant
                      (not a symbol table entry but value itself).
    null       : empty (nothing, epsilon)
    NullNode   : a leaf node with operation code null.
    List_of_xxx: java.util.List with elements xxxx. (##10)
    Parenthesis is not a syntactic component but a delimiter.
      One subtree begins with left parenthesis and end with
      right parenthesis.

  Note:
    Following items are not represented as a subtree
    dangling to a node but are represented as information
    attached to the node. They are not traversed when HIR tree
    is traversed but can be get by applying corresponding HIR
    methods to the node.
        Operation code     (xxxCode)
        Symbol table entry (xxxSym)
        Constant symbol    (xxxConst)
        Symbol table       (SymTable, GlobalSymTable_, LocalSymTable_)
        attr               (attribute such as node type which is
                            a symbol representing the type
                            of the result of HIR subtree.)
    Items represented as a subtree is indicated by @ to clarify.
    (@ is not a syntactic component but a postfix marker
     to avoid misunderstanding.)

  Program   ->             // Program represents a compile unit.
     ( progCode attr       //
       GlobalSymTable_     // Global symbols of the program
       ProgSym_ @          // Program name (may be null).
       InitiationPart_ @   // Initial value specification.
       SubpList_ @ )       // Subprogram definition list.
  ProgSym_  ->
     ( symCode attr progSym )   // Program name symbol.
   | null
  GlobalSymTable_  ->   // Global symbol table of the program.
     SymTable           // As for SymTable, see Sym and SymTable.
   | null
  InitiationPart_ ->    // Initial value specification (##14)
     InitiationBlock_
   | NullNode
  InitiationBlock_ ->   // Block containing initiation statements.
     ( blockCode attr
       InitiationStmtSeq_ @ )
  InitiationStmtSeq_ -> // Sequence of initiation statements
     InitiationStmt_ @ InitiationStmtSeq_ @
   | null
  InitiationStmt_ ->    // Initiation statement
     ( setDataCode attr         // with Exp_l_: l-value
        Exp_l_ @ ValueSpec_ @ ) // ValueSpec_: constant Exp.
   | InfStmt                    //##74
   | AssignStmt
  ValueSpec_ ->
      ConstExp_         // Constant expression
   | ( explistCode attr // ExpListExp of ValueSpec_
       List_of_ValueSpec_ @ )
   | ( exprepeatCode attr        // Expression to represent repeating
       ValueSpec_ @ intConst @ ) //   ValueSpec_ intConst-times.
  ConstExp_ ->          // BEGIN
     ConstNode          // Constant value
   | Exp                // Exp whose operands are all ConstNode
  SubpList_ ->
     ( listCode attr     // Subprogram definition list
       List_of_SubpDefinition @ )
  SubpDefinition ->      // Subprogram definition
     ( subpDefCode attr
       LocalSymTable_    // SymTable local in the subprogram.
       SubpNode @        // Subprogram name.
       InitiationPart_ @ // Subprogram initiation.
       SubpBody_ @ )     // HIR subprogram body
                         // (Control flow should be ended by return).
  //   LIR @ )      // LIR representation for the subprogram.  deleted
  SubpNode  ->      // Subprogram name node.
     ( symCode attr
       subpSym )
  LocalSymTable_ -> // Local symbol table (for subprogram, block, etc.)
     SymTable
   | null
  SubpBody_ ->      // HIR subprogram body is
     BlockStmt                 // block statement or
   | ( labeledStmtCode attr    // BlockStmt with Label.
        LabelDefinitionList_ @ // List of label definitions.
        BlockStmt @ )          // Statement body
    // BlockStmt of SubpBody should have LocalSymTable. //##70
  BlockStmt ->
     ( blockCode attr
       LocalSymTable_  // Define symbols local in the block.
       StmtSeq_ @ )    // Block makes a sequence of statements
                       // to be treated as one statement.
            // Statements in StmtSeq_ can be get
            // by getFirstStmt() and successive getNextStmt().
  StmtSeq_  ->
     Stmt @ StmtSeq_ @  // Statement sequence is a statement
   | Pragma @           // Pragma (direction to the compiler)
   | null               // followed by statements or empty.
  Stmt      ->          // Statement is
     LabeledStmt        // a statement with label definitions or
   | StmtBody_          // a statement without label definition.
  LabeledStmt ->        // Statement with label definition.
     ( labeledStmtCode attr
        LabelDefinitionList_ @ // List of label definitions.
        StmtBody_ @ )          // Statement body (statement that is
                               // peeled label off).
  LabelDefinitionList_ ->   // List of LabelDef nodes.
     ( listCode attr
       List_of_LabelDef @ )
  LabelDef   ->             // Label definition node.
     ( labelDefCode attr
       labelSym )
  StmtBody_  ->     // Statement body.
     AssignStmt     // Assignment statement.
   | IfStmt         // If statement.
   | JumpStmt       // Jump (goto) statement.
   | LoopStmt       // Loop statement.
   | CallStmt_      // Subprogram call statement.
   | ReturnStmt     // Return statement.
   | SwitchStmt     // Switch (case selection) statement.
   | BlockStmt      // Block statement.
   | ExpStmt        // Expression treated as a statement.
   | InfStmt        // Inf (information) statement        //##70
                    // #Pragma is represented as a kind of
                    // InfStmt.
   | AsmStmt        // Assembly language statement.
   | SetDataStmt    // Set initial data statement.

  AssignStmt ->     // Assign statement.
     ( assignCode attr
       Exp_l_ @     // l_value expression.
       Exp @ )      // Expression whose value is to be assigned.
                    // Exp_l_ and Exp should have the same type.
                    // Exp may be any scalar expression
                    // or struct/union expression.
                    // (Array expression will be permitted in future.)
   | ( CompoundAssignOperator_ attr  // HIR-C only
       Exp_l_ @
       Exp @ )
   | ( IncrDecrOperator_ attr        // HIR-C only
       Exp_l_ @ )
  Exp_l_  ->              // l-value expression is
     Exp                  // an expression representing an object
                          // (memory area to contain data).
  IfStmt    ->            // If statement
    ( ifCode attr
       ConditionalExp_ @  // Conditional expression.
       ThenPart_ @        // Then-part
       ElsePart_ @        // Else-part.
       LabeledStmt0_ @ )  // Statement with end-of-if label.
  ThenPart  ->
     LabeledStmt   // Executed if ConditionalExp is true.
   | null          //
  ElsePart  ->
     LabeledStmt   // Executed if ConditionalExp is false.
   | null          //
  LabeledStmt0_    ->         // LabeledStmt0_ is a labeled
     ( labeledStmtCode attr   // statement whose statement body
       LabelDefinitionList_ @ // may be null at first but it may become
       NullOrStmt_ @ )        // non-null by code optimization, etc.
                              // LabeledStmt0_ may be called labeled null.
  JumpStmt  ->
     ( jumpCode attr  // Jump to the statement with
       LabelNode @ )  // specified label.
  LoopStmt ->  // Loop statement is either for-loop, while-loop,
               // repeat-loop, indexed-loop, or other general loop.
               // All of them are implemented as a general loop
               // with some restriction depending on the loop type.
               // Compiler components (other than front part) should
               // treat general loop, that is, do not assume some child
               // is null without checking whether the child is null
               // or not. For example, a while-loop may be changed
               // to a loop with LoopInitPart_ and LoopStepPart_
               // by code optimizer. isSimpleForLoop(), isSimpleWhileLoop(),
               // isSimpleRepeatLoop() of LoopStmt interface check
               // whether the loop can be treated pure for-loop,
               // pure while-loop, etc.
               // There may be some cases where processing become
               // simple if the loop is either simple for-loop,
               // while-loop, repeat-loop, etc.
    ( LoopCode_ attr     // Loop kind code.
      LoopInitPart_ @    // Loop initiation part to be executed
                         // before repetition. It may be null.
                         // LoopInitPart_ should not contain
                         // control statements except for the one
                         // generated by addToConditionalInitPart
                         // of LoopStmt interface.
                         // As for expressions to be executed
                         // only once (loop invariant expressions, etc.),
                         // see addToConditionalInitPart of LoopStmt.
      StartConditionPart_ @  // Loop start conditional expression
                         // with loopBackLabel.
                         // If true, pass through to LoopBody_,
                         // otherwise transfer to LoopEndPart_
                         // to terminate the loop execution.
                         // If loop start condition part is null,
                         //  pass through to LoopBody_.
      LoopBody_ @        // Loop body repetitively executed.
                         // Pass through to EndCondition_.
                         // It is a block statement (BlockStmt)
                         // with loop start label and the blcok
                         // statement contains a labeled statement
                         // with loopStepLabel as its last statement.
                         // This should not be null but the block may
                         // have no executable statement and contains
                         // only a labeled statement with loopStepLabel.
                         // "continue" jumps to the loopStepLabel.
                         // The loopStepLabel may be omitted if
                         // there is no "jump loopStepLabel".
     EndCondition_ @     // Loop end condition expression.
                         // If false, transfer to LoopEndPart_
                         // to terminate the loop execution,
                         // otherwise pass through to
                         // LoopStepPart_.
     LoopStepPart_ @     // Loop step part that is to be executed
                         // before jumping to loopBackLabel.
                         // LoopStepPart_ should not contain
                         // control statements.
     LoopEndPart_ @ )    // Loop end part
                         // with loopEndLabel.
                         // "exit" (break in C) jumps to here.
     IndexedLoop_ attr   // Attributes for IndexedLoop.
                         // Not given for other loops.
  LoopCode_ attr ->
     whileCode attr      // while-loop
   | forCode attr        // for-loop
   | repeatCode attr     // repeat-while-true--loop
   | indexedLoopCode attr// indexed-loop
   | loopCode attr       // general loop other than above loops.
  LoopInitPart_   ->     // Loop initiation part.
     Stmt
   | null
  ConditionalInitPart_ ->  // This item is deleted. Give null for this item
     null                  // but use addToConditionalInitPart method
                           // of LoopStmt to move loop invariant expressions
                           // etc. from loop body so that they are executed
                           // only once.
  StartConditionPart_ ->      // Show start condition with
     ( labeledStmtCode attr   // loopBacklabel.
       LabelDefinitionList_ @
       BooleanExpStmtOrNull_ @ ) // loopStartConditionExpression.
  LoopBody_  ->               // Block statement with loopBodyLabel.
     ( labeledStmtCode attr   // The last statement of the block
       LabelDefinitionList_ @ // is a LabeledStmt0_ statement with
       BlockStmt_ @ )         // loopStepLabel.
  EndCondition_ ->            // ExpStmt showing loop end condition.
     BooleanExpStmtOrNull_
  LoopStepPart_  ->    // Statement to be executed before jumping
     Stmt              // to loopBackLabel.
   | null              // LoopStepPart_ should not contain
                       // statements that change control flow.
  LoopEndPart_  ->     // LabeledStmt0_ statement with loopEndLabel.
     LabeledStmt0_
  NullOrStmt_ ->       // Usually null but it may be
     null              // a statement (created during
   | Stmt              // HIR transformation).
  BooleanExpStmtOrNull_ ->    // Boolean expression statement or null.
     ExpStmt           // ExpStmt whose Exp part is a boolean expression.
   | null
  IndexedLoop_ attr  -> // Attributes for IndexedLoop.
     loopIndex attr     // Loop index (induction variable).
                        // See getLoopIndex().
     startValue attr    // Start value of the loop index.
                        // See getStartValue().
     endValue attr      // End value of the loop index.
                        // See getEndValue().
     stepValue attr     // Step value for the loop index.
                        // See getStepValue().

  // Note. LoopInf may contain goto-loop that is difficult or
  //   impossible to be represent by above LoopStmt.
  //   (goto-loop is not implemented by LoopStmt.)

  // LoopStmt is executed as follows:
  //   LoopInitPart_;
  //   if (loopStartConditionExpression == null) {
  //     Sequence of statements added by addToConditionalInitPart();
  //   }else {
  //     if (loopStartConditionExpression == false) {
  //       jump to loopEndLabel;
  //     }else { // ConditionalInitBlock
  //       Sequence of statements added by addToConditionalInitPart().
  //       jump to loopBodyLabel;
  //     }
  //   }
  //   loopBackLabel:
  //     if ((loopStartConditionExpression != null)&&
  //         (loopStartConditionExpression == false))
  //       jump to loopEndLabel;
  //   loopBodyLabel:
  //     Start of BlockStmt of LoopBody_
  //       Stastement sequence of the BlockStmt;
  //       (break statement jumps to loopEndLabel;)
  //       (continue statement jumps to loopStepLabel;)
  //       Rest of stastement sequence of the LoopBody_;
  //       loopStepLabel:;
  //     End of BlockStmt of LoopBody_
  //     if ((loopEndConditionExpression != null)&&
  //         (loopEndConditionExpression == false))
  //       jump to loopEndLabel;
  //     LoopStepPart;
  //     jump to loopBackLabel;
  //   loopEndLabel:
  //     Loop end part;

  // BEGIN #21
  // ForStmt is created as a general loop where contents of
  //   ConditionalInitPart_, EndCondition_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleForLoop().
  // WhileStmt is created as a general loop where contents of
  //   LoopInitPart_, ConditionalInitPart_, EndCondition_,
  //   LoopStepPart_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleWhileLoop().
  // RepeatStmt is created as a general loop where contents of
  //   LoopInitPart, ConditionalInitPart_, StartCondition_,
  //   LoopStepPart_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleUntilLoop().
  // IndexedLoopStmt is created as a general loop where contents of
  //   ConditionalInitPart_, EndCondition_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleIndexedLoop().
  // IndexedLoopStmt represents a Fortran type loop where
  //   value of loop index is incremented or decremented by loop
  //   step value starting from loop start value and stops
  //   to loop before crossing the barrier of loop end value.
  //   (See IndexedLoopStmt interface.)
  // Indexed loop attributes (IndexedLoopAttr_) are available
  // only for IndexedLoopStmt.
  // END #21

  CallStmt_   ->         // Subprogram call statement.
     ( expStmtCode attr  // Expression statement
       FunctionExp @ )   // with FunctionExp.
  FunctionExp ->         // Subprogram call expression.
     ( callCode attr
       Exp @             // Expression specifying subprogram
                         // to be called. It may be
                         // SubpNode or (addr SubpNode), etc.
       HirList @ )       // Actual parameter list.
  ReturnStmt ->          // Return statement.
     ( returnCode attr
       ReturnValue_ @ )  // Return value.
  ReturnValue_ ->
     Exp
   | null
  SwitchStmt ->          // Switch statement.
     ( switchCode attr
       Exp @             // Case selection expression.
       JumpTable_ @      // List of constants and statement labels.
       Stmt @            // Collection of statements to be selected.
       LabeledStmt0_ @ )  // Indicate end of case statement.
  JumpTable_ ->          // Jump table.
     ( seqCode attr
       JumpList_ @       // List of constant-label pairs.
       LabelNode @ )     // Default label.
  JumpList_ ->                 // Jump list.
     ( listCode attr           // Correlate Exp value
       List_of_SwitchCase @ )  // and list of SwitchCase_ pairs.
  SwitchCase_ ->       // List of SwitchCase_ pairs.
     ( seqCode attr
       ConstNode @     // Correlate Exp value and
       LabelNode @ )   // switch statement label.
  ExpStmt   ->         // Expression statement.
     ( expStmtCode attr
       Exp @ )         // Expression treated as a Stmt.
  NullNode  ->
     ( nullCode attr ) // NullNode is a terminal
                       // that is not null.
  InfStmt   ->
     ( infCode attr    // Information statement.
       InfKind_        // Information kind identifier.
       InfObject_  )   // Information.
                       // (InfKind_ and InfObject_ are not
                       // traversed by HIR traverse operations.)
  InfKind_  ->
     stringConst // String constant showing the kind of
                 // information such as pragma, comment, etc.
  InfObject_  -> // Information.
     Object      // Object such as Sym, Exp, etc. or
                 // a list of Objects. It may or may not be HIR.
  Pragma    ->   // Pragma is a direction to the compiler.
     ( infCode attr    // Pragma is represented as
                       // an information statement.
       InfKind_        // Pragma information kind identifier.
       InfObject_  )   // Pragma information.
  AsmStmt   ->
    ( asmCode attr  // Asm statement.
      StringConst @ // String constant representing
                    // parameter description pragma,
                    // clobber specification pragma, and
                    // assembly language instruction sequence
      HirList @ )   // List of l-value expressions (variable nodes,
                    // pointer expressions, etc.) and arithmetic
                    // expressions representing actual parameters.
     // As for detail, see AsmStmt interface.
  ConditionalExp_ ->     // boolean expression
     Exp
  Exp ->                 // Expression.
     Factor_
   | UnaryExp_
   | BinaryExp_
   | ExpListExp
   | TernaryExp_
   | NullNode
//   | InfNode
  Factor_  ->
     ConstNode
   | SymNode
   | CompoundVar_
   | FunctionExp
   | PhiExp
 //| AssignStmt          // HIR-C
   | ExpListExp
   | HirSeq              // Sequence of objects
  UnaryExp_ ->           // Unary expression.
     ( UnaryOperator_ attr
       Exp @ )
   | ( sizeofCode attr  // size of the type of Exp
        Exp @ )
   | ( sizeofCode attr  // size of the type
       TypeNode @ )     // represented by TypeNode.
  BinaryExp_ ->         // Binary expression.
     ( BinaryOperator_ attr
       Exp @
       Exp @ )
  TernaryExp_ ->        // Ternary expression.
       SelectExp          // HIR-C only
  CompoundVar_ ->    // Compound variable.
     SubscriptedExp  // Subscripted variable.
   | PointedExp      // Pointed variable.
   | QualifiedExp    // Qualified variable.
  SubscriptedExp ->  Subscripted variable.
     ( subsCode attr // Array with subscript expression.
       Exp @       // Expression indicating the array.
       Exp @ )     // Subscript expression.
//   | ( subsCode attr
//       Exp @       // Expression indicating an array.
//       ExpList @ ) // List of Subscripts.
//                   // (1st subscript, 2nd subscript,
//                   //  etc. for rectangular array.)
  ElemSize_    ->    // Element size.
     Exp
  QualifiedExp ->    // Qualified expression.
     ( qualCode attr // Qualified variable
       Exp @         // Should represent a structure or union.
       ElemNode @ )  // struct/union element.
  PointedExp ->       // Pointed expression.
     ( arrowCode attr // Pointed variable
       Exp @          // Expression representing a variable
       PointedElem_ @ ) // Pointed element.
  PointedElem_ ->
     ElemNode  // Pointed element (with displacement).
   | null      // Pointed location (0 displacement).
  ConstNode ->                      // Constant symbol.
     ( constCode attr intConst )    // integer   constant
   | ( constCode attr floatConst )  // float     constant
   | ( constCode attr charConst )   // character constant
   | ( constCode attr stringConst ) // string    constant
   | ( constCode attr boolConst )   // boolean   constant
  SymNode   ->        // Symbol node.
     (symCode Sym )   // Program name, etc.
   | VarNode
 //| ParamNode   DELETED
   | SubpNode
   | LabelNode
   | ElemNode   not DELETED
   | TypeNode
  VarNode   ->
     ( symCode attr varSym )   // Variable name node
  SubpNode  ->
     ( symCode attr subpSym )  // Subprogram name node
  LabelNode ->
     ( symCode attr labelSym ) // Label reference node
  ElemNode  ->
     ( symCode attr elemSym )  // structure/union element
                                    // name node.
  TypeNode  ->
     ( symCode attr typeSym )  // Type name node
  FunctionExp ->     // Function expression.
     ( callCode attr
       Exp @         // Expression specifying function
                     // to be called (SubpNode, (addr SubpNode), etc.).
       HirList @ )   // Actual parameter list.
                     // It is an HirList whose elements are Exp.
  IrList     ->
     ( listCode attr    // A List that can be treated as IR.
       List_of_Objects_ @ ) // Its elements may be Sym, String and IR object.
  HirList        ->
     ( listCode attr    // A List of HIR elements. It can be treated as HIR.
       List_of_HIR_Objects_ @ ) // Its elements should be HIR object.
  ExpListExp  ->        // Expression representing
     ( expListCode attr // a list of
       List_of_Exp @ )  // expressions in HIR form.
  HirSeq  ->
     ( seqCode attr HIR @ )  // Sequence of some definite
   | ( seqCode HIR @  HIR @ ) // number of HIR nodes.
   | ( seqCode HIR @  HIR @  HIR @ )
   | ( seqCode HIR @  HIR @  HIR @  HIR @ )
  PhiExp         ->
     (phiCode attr FlowVarList_ @ )  // phi function
  FlowVarList_   ->
     ( listCode attr
       List_of_VarLabelPair @ )
                               // List of (Var Label) pairs.
  VarLabelPair   ->
     ( listCode attr VarNode @  Label @)
  UnaryOperator_ ->
     notCode      // bitwise not (~) one's complement
                  // logical not (boolean not) (!)
   | negCode      // negate (unary minus)
   | addrCode     // get address (&)
   | contentsCode // get contents of pointed memory
   | convCode     // type conversion for basic type
   | decayCode    // convert array to pointer
   | sizeofCode   // sizeof operator
   | encloseCode  // honor parenthesis
   | IncrDecrOperator_  // Increment/decrement. HIR-C only.
  BinaryOperator_ ->
   | addCode      // add                 (+)
   | subCode      // subtract            (-)
   | offsetCode   // Offset between pointers (HIR-C only)
   | multCode     // multiply            (*)
   | divCode      // divide              (/)
   | modCode      // modulo              (%)
   | andCode      // bitwise and, logical and for bool (&)
   | orCode       // bitwise or,  logical or for bool  (|)
   | xorCode      // bitwise exclusive or, logical exclusive or (^)
   | shiftLLCode  // shift left  logical    (<<) //
   | shiftRCode   // shift right arithmetic (>>)
   | shiftRLCode  // shift right logical    (>>) //
   | undecayCode  // convert pointer to array
   | expRepeatCode   // Repeat constant values (operand 1)
                     //   count (operand 2) times.
   | CompareOperator_
   | CompareZeroOperator_            // HIR-C only
   | ShortCircuitOperator_           // HIR-C only
   | commaCode    // comma operator  // HIR-C only
  CompareOperator_ ->
     cmpEqCode    // equal
   | cmpNeCode    // not equal
   | cmpGtCode    // greater than
   | cmpGeCode    // greater or equal
   | cmpLtCode    // less than
   | cmpLeCode    // less or equal
  CompareZeroOperator_ ->                // HIR-C only
     eqZeroCode   // equal zero          // HIR-C only
  ShortCircuitOperator_ ->               // HIR-C only
     lgAndCode    // logical and (&&)    // HIR-C only
   | lgOrCode     // logical or  (||)    // HIR-C only
  IncrDeclOperator_ ->                             // HIR-C only
     preIncrCode  // pre-increment  (++) // HIR-C only
   | preDecrCode  // pre-decrement  (--) // HIR-C only
   | postIncrCode // post-increment (++) // HIR-C only
   | postDecrCode // post-decrement (--) // HIR-C only
  CompoundAssignmentOperator_ ->         // HIR-C only
     multAssignCode   // *=    // HIR-C only
   | divAssignCode    // /=    // HIR-C only
   | modAssignCode    // %=    // HIR-C only
   | addAssignCode    // +=    // HIR-C only
   | subAssignCode    // -=    // HIR-C only
   | shiftLAssignCode // <<=   // HIR-C only
   | shiftRAssignCode // >>=   // HIR-C only
   | andAssignCode    // &=    // HIR-C only
   | xorAssignCode    // ^=    // HIR-C only
   | orAssignCode     // |=    // HIR-C only
  SelectExp ->        //  (Exp ? Exp : Exp) // HIR-C only
     ( selectCode attr
       ConditionalExp @   Exp @  Exp @ )

  attr ->             // Attribute attached to the HIR node
     typeSym          // Shows the type of HIR subtree.
     OptionalAttrSeq_ // Sequence of optional attributes
                      // that are not inevitable at the first stage
                      // of HIR generation. The optional attributes
                      // may be attached to give information used
                      // in some specific compiler modules or
                      // to help compiling processes.
  OptionalAttrSeq_ ->
     OptionalAttr_ OptionalAttrSeq_
   | null
  OptionalAttr_ ->
     StmtAttr_      // Attributes for statements
   | IndexNumber_   // Index number to identify the HIR node.
   | Flag_          // true/false flag.
   | InfItem_       // Node-wise information.
   | ExpId          // Expression identifier used in flow analysis.
   | Work_          // Phase-wise information.
  StmtAttr_ ->      // Attributes attached to statement subtrees.
     FileName_      // Source program file containing the statement.
     LineNumber_    // Line number of the line in which the
                    // statement started.
  FileName_ ->
     stringConstValue
  LineNumber_
     intConstvalue
  IndexNumber_ ->
     intConstValue
  Flag_ ->
     FlagNumber_
     FlagValue_
  FlagNumber_ ->
     intConstValue   // Such as  FLAG_NOCHANGE, FLAG_C_PTR,
                     // FLAG_CONST_EXP
  FlagValue_ ->
     true
   | false
  InfItem_ ->
     InfKind_ InfObject_


  Deleted methods:
    buildXxx, getSym (use getSym in IR or getSymNodeSym in SymNode)
    insertBBlockCode, insertGBlockCode, insertPBlockCode.
  Deleted operators:
    addUCode, subUCode, multUCode, divUCode.
    (Decide by Type attached to each node.)
    addA, subA, multA, divA, modA, shiftL.   (##9)
    lgNot  (##10)

 Construction of HIR objects:
  Most HIR objects are constructed by object factory methods
  such as program(....), subpDefinition(....), assignStmt(....),
  ifStmt(....), exp(....), etc. specified in the HIR interface.
  Users are recommended to use the object factory methods so as
  to avoid forgetting to specify essential data and to make
  relation with other objects.  It is not recommended to use
  "new" directly to construct HIR objects.

 Transformation of HIR:
  HIR are transformed in various phases of the compiler
  for optimization, parallelization, etc.
  Such transformation can be executed by invoking transformation
  methods such as replaceThisNode, addNextStmt, etc.
  Transformed result should always be tree. Care should be taken
  not to share leafs and branches between subtrees.
  The simple way of keeping tree structure in transformation is
  to make a new subtree copying some part of original tree
  and replace some branch so that no node is linked from
  plural parent nodes.
  It is strongly recommended not to destroy the control structure
  of HIR. For exmple, jump into a loop from outside, jump out of
  loop from loop step part, jump into if statement from outside,
  etc. although such transformations are not automatically prohibited.

  HIR nodes should be numbered by applying setIndexNumberToAllNodes
  to Program tree or SubpDefinition subtree when HIR is created or
  modified. When HIR is created by a parser or entirely transformed
  by an optimizer, setIndexNumberToAllNodes(1) should be applied to
  hirRoot.programRoot. If subprogram-wise transformation is done
  (e.g., repeat to do subprogram-wise optimization and code generation),
  then apply setIndexNumberToAllNodes(subpDefinition.getNodeIndexMin())
  to SubpDefinition node "subpDefinition" of each subprogram.

 Operator number
public static final int
  OP_PROG          =  1,   // program( .... )
  OP_SUBP_DEF      =  2,   // subpDefinition( .... )
  OP_LABEL_DEF     =  3,   // labelDef( .... )
  OP_INF           =  4,   // infNode( .... )
  OP_CONST         =  5,   // constNode( .... )
  OP_SYM           =  6,   // symNode( .... )
  OP_VAR           =  7,   // varNode( .... )
  OP_PARAM         =  8,   //                UNNECESSARY ?
  OP_SUBP          =  9,   // subpNode( .... )
  OP_TYPE          = 10,   //                UNNECESSARY ?
  OP_LABEL         = 11,   // labelNode( .... )
  OP_ELEM          = 12,   // elemNode( .... )
  OP_LIST          = 14,   // irList( .... )  List of HIR/Sym objects
                           // such as HIR nodes and symbols
  OP_SEQ           = 15,   // hirSeq( .... )
  OP_ENCLOSE       = 16,   // exp( int, Exp ) Enclose subexpression

  OP_SUBS          = 17,   // subscriptedExp( .... )
  OP_QUAL          = 19,   // qualifiedExp( .... )
  OP_ARROW         = 20,   // pointedExp( .... )

  OP_STMT          = 21,   // Statement code lower. Stmt is
                           // an abstract class and there is
                           // no instance having OP_STMT.
  OP_LABELED_STMT  = 21,   // labeledStmt( .... )
                           // Use the same number as Stmt
                           // because Stmt is an abstract class.
  OP_ASSIGN        = 22,   // assignStmt( .... )
  OP_IF            = 23,   // ifStmt( .... )
  OP_WHILE         = 24,   // whileStmt( .... )
  OP_FOR           = 25,   // forStmt( .... )
  OP_REPEAT        = 26,   // repeatStmt( .... )
  OP_INDEXED_LOOP  = 27,   // indexedLoopStmt( .... )

  OP_JUMP          = 28,   // jumpStmt( .... )
  OP_SWITCH        = 32,   // switchStmt( .... )
  OP_CALL          = 33,   // callStmt( .... )
  OP_RETURN        = 34,   // returnStmt( .... )
  OP_BLOCK         = 35,   // blockStmt( .... )
  OP_EXP_STMT      = 36,   // expStmt( .... ) expression statement
  OP_ASM           = 37,   // asmStmt( .... )  //##70
  OP_STMT_UPPER    = 37,

// OP_ADD ... OP_XOR OP_CMP_EQ ... OP_CMP_LE OP_SHIFT_LL ... OP_SHIFT_LL
//         are binary operators used in exp(int, Exp, Exp).
  OP_ADD           = 38,
  OP_SUB           = 39,
  OP_MULT          = 41,
  OP_DIV           = 42,
  OP_MOD           = 43,

  OP_AND           = 46,
  OP_OR            = 47,
  OP_XOR           = 48,

  OP_CMP_EQ        = 51,
  OP_CMP_NE        = 52,
  OP_CMP_GT        = 53,
  OP_CMP_GE        = 54,
  OP_CMP_LT        = 55,
  OP_CMP_LE        = 56,

  OP_SHIFT_LL      = 58,
  OP_SHIFT_R       = 59,
  OP_SHIFT_RL      = 60,
//  OP_LG_NOT       = 61, // Use (OP_CMP_EQ e false) instead of (OP_LG_NOT e)
  OP_NOT           = 62,   // exp(OP_NOT, Exp)
  OP_NEG           = 63,   // exp(OP_NEG, Exp)
  OP_ADDR          = 64,   // exp(OP_ADDR, EXP )
  OP_CONV          = 65,   // convExp( .... )
  OP_DECAY         = 66,   // decayExp( .... )
  OP_UNDECAY       = 67,   // undecayExp( .... )
// OP_CONTENTS, OP_SSIZEOF are unary operator used in exp(int, Exp).
  OP_CONTENTS      = 68,   // contentsExp( .... )
  OP_SIZEOF        = 70,   // sizeofExp( .... )
//  OP_NOCHANGE_EXP = 71,   // See FLAG_NOCHANGE
  OP_SETDATA       = 71,
  OP_PHI           = 72,  // phiExp( .... )
  OP_NULL          = 73,  // nullNode();

// OP_OFFSET ... OP_LG_OR are binary operators used in exp(int, Exp, Exp).
  OP_OFFSET        = 76,  // exp( int, Exp, Exp ) // HIR-C only
  OP_LG_AND        = 77, // HIR-C only
  OP_LG_OR         = 78, // HIR-C only
  OP_SELECT        = 79, // HIR-C only
  OP_COMMA         = 80, // HIR-C only

  OP_EQ_ZERO       = 81, // ! // HIR-C only
  OP_PRE_INCR      = 82, // HIR-C only
  OP_PRE_DECR      = 83, // HIR-C only
  OP_POST_INCR     = 84, // HIR-C only
  OP_POST_DECR     = 85, // HIR-C only
  OP_ADD_ASSIGN    = 86, // HIR-C only
  OP_SUB_ASSIGN    = 87, // HIR-C only
  OP_MULT_ASSIGN   = 88, // HIR-C only
  OP_DIV_ASSIGN    = 89, // HIR-C only
  OP_MOD_ASSIGN    = 90, // HIR-C only

  OP_SHIFT_L_ASSIGN= 91, // HIR-C only
  OP_SHIFT_R_ASSIGN= 92, // HIR-C only
  OP_AND_ASSIGN    = 93, // HIR-C only
  OP_OR_ASSIGN     = 94, // HIR-C only
  OP_XOR_ASSIGN    = 95, // HIR-C only

  OP_EXPLIST       = 96, // Expression representing a list of expressions.
  OP_EXPREPEAT     = 97  // Repetition of the same values.
                         // OP_EXPLIST and OP_EXPREPEAT are used only in
                         // OP_SETDATA expression.
  ;

 Flag numbers applied to HIR nodes:
 static final int     // Flag numbers used in setFlag/getFlag.
                   // They should be a number between 1 to 31.
FLAG_NOCHANGE = 1, // This subtree should not be
                   // changed in optimization.
FLAG_C_PTR    = 2, // The operation (add, sub) is
                   // pointer operation peculiar to C.
FLAG_CONST_EXP= 3; // This subtree is a constant expression.
                   // (constant, address constant, null,
                   //  sizeof fixed-size-variable,
                   //  expression whose operands are all constant
                   //  expression)
  // Flag numbers 24-31 can be used in each phase for apbitrary purpose.
  // They may be destroyed by other phases.

 Coding rules applied to all classes in the sym, hir packeges:

 Methods begin with lower case letter.
 Constants (final static int, etc.) are spelled in upper case letters.
 Indentation is 2 characters. Tab is not used for indentation.
 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.


フィールドの概要
static int FLAG_C_PTR
          Flag numbers applied to HIR nodes
static int FLAG_CONST_EXP
          Flag numbers applied to HIR nodes
static int FLAG_INIT_BLOCK
          Flag numbers applied to HIR nodes
static int FLAG_LOOP_WITH_CONDITIONAL_INIT
          Flag numbers applied to HIR nodes
static int FLAG_NOCHANGE
          Flag numbers applied to HIR nodes
static int FLAG_NONTERMINAL
           
static int OP_ADD
          Operator number
static int OP_ADD_ASSIGN
          Operator number
static int OP_ADDR
          Operator number
static int OP_AND
          Operator number
static int OP_AND_ASSIGN
          Operator number
static int OP_ARROW
          Operator number
static int OP_ASM
          Operator number
static int OP_ASSIGN
          Operator number
static int OP_BLOCK
          Operator number
static int OP_CALL
          Operator number
static int OP_CMP_EQ
          Operator number
static int OP_CMP_GE
          Operator number
static int OP_CMP_GT
          Operator number
static int OP_CMP_LE
          Operator number
static int OP_CMP_LT
          Operator number
static int OP_CMP_NE
          Operator number
static int OP_COMMA
          Operator number
static int OP_CONST
          Operator number
static int OP_CONTENTS
          Operator number
static int OP_CONV
          Operator number
static int OP_DECAY
          Operator number
static int OP_DIV
          Operator number
static int OP_DIV_ASSIGN
          Operator number
static int OP_ELEM
          Operator number
static int OP_ENCLOSE
          Operator number
static int OP_EQ_ZERO
          Operator number
static int OP_EXP_STMT
          Operator number
static int OP_EXPLIST
          Operator number
static int OP_EXPREPEAT
          Operator number
static int OP_FOR
          Operator number
static int OP_IF
          Operator number
static int OP_INDEX
          Operator number
static int OP_INDEXED_LOOP
          Operator number
static int OP_JUMP
          Operator number
static int OP_LABEL
          Operator number
static int OP_LABEL_DEF
          Operator number
static int OP_LABELED_STMT
          Operator number
static int OP_LG_AND
          Operator number
static int OP_LG_OR
          Operator number
static int OP_MOD
          Operator number
static int OP_MOD_ASSIGN
          Operator number
static int OP_MULT
          Operator number
static int OP_MULT_ASSIGN
          Operator number
static int OP_NEG
          Operator number
static int OP_NOT
          Operator number
static int OP_NULL
          Operator number
static int OP_OFFSET
          Operator number
static int OP_OR
          Operator number
static int OP_OR_ASSIGN
          Operator number
static int OP_PARAM
          Operator number
static int OP_PHI
          Operator number
static int OP_POST_DECR
          Operator number
static int OP_POST_INCR
          Operator number
static int OP_PRE_DECR
          Operator number
static int OP_PRE_INCR
          Operator number
static int OP_QUAL
          Operator number
static int OP_REPEAT
          Operator number
static int OP_RETURN
          Operator number
static int OP_SELECT
          Operator number
static int OP_SEQ
          Operator number
static int OP_SETDATA
          Operator number
static int OP_SHIFT_L_ASSIGN
          Operator number
static int OP_SHIFT_LL
          Operator number
static int OP_SHIFT_R
          Operator number
static int OP_SHIFT_R_ASSIGN
          Operator number
static int OP_SHIFT_RL
          Operator number
static int OP_SIZEOF
          Operator number
static int OP_STMT
          Operator number
static int OP_STMT_UPPER
          Operator number
static int OP_SUB
          Operator number
static int OP_SUB_ASSIGN
          Operator number
static int OP_SUBP
          Operator number
static int OP_SUBS
          Operator number
static int OP_SWITCH
          Operator number
static int OP_SYM
          Operator number
static int OP_TYPE
          Operator number
static int OP_UNDECAY
          Operator number
static int OP_UNTIL
          Operator number
static int OP_VAR
          Operator number
static int OP_WHILE
          Operator number
static int OP_XOR
          Operator number
static int OP_XOR_ASSIGN
          Operator number
 
メソッドの概要
 void accept(HirVisitor pVisitor)
          accept Acceptor used in HIR visitor.
 AssignStmt assignStmt(Exp pLeft, Exp pRight)
          assignStmt Build an assignemnt statement.
 BlockStmt blockStmt(Stmt pStmtSequence)
          blockStmt Make an instance of block statement that may contain a sequence of statements.
 ExpStmt callStmt(Exp pSubpSpec, IrList pActualParamList)
          callStmt Build a subprogram call statement.
 ConstNode constNode(Const pConst)
          constNode Make a ConstNode instance having constant symbol pConst.
 Exp contentsExp(Exp pPointerExp)
          contentsExp Build an expression that gets the contents pointed by pPointerExp.
 Exp convExp(Type pType, Exp pExp)
          convExp Build an expression to convert the type of pExp to pType.
 HIR copyWithOperands()
          copyWithOperands Make a subtree that is the same to this subtree.
 HIR copyWithOperandsChangingLabels(IrList pLabelCorrespondence)
          copyWithOperandsChangingLabels Make a new subtree that is the same to this subtree.
 Exp decayExp(Exp pExp)
          decayExp Build an expression that decay a vector to a pointer to vector element, or decay a String into a pointer to Char element.
 ElemNode elemNode(Elem pElem)
          elemNode Make an ElemNode instance having Elem symbol pElem.
 Exp exp(int pOperator, Exp pExp1)
          exp Build unary expression according to the operator given: OP_NOT // bitwise not (~) one's complement // logical not for bool (!)
 Exp exp(int pOperator, Exp pExp1, Exp pExp2)
          exp Build binary expression.
 ExpStmt expStmt(Exp pExp)
          expStmt Create a statement treating pExp as a statement.
 ConstNode falseNode()
          falseNode Make a ConstNode instance having boolean false value.
 boolean finishHir()
           finishHir does closing operations for HIR.
 ForStmt forStmt(Stmt pInitStmt, Exp pCondition, Stmt pLoopBody, Stmt pStepPart)
           
 FunctionExp functionExp(Exp pFunctionSpec, IrList pActualParamList)
          functionExp Build a function expression node that computes function value.
 int getChildNumber()
          getChildNumber Get the child number of this node.
 boolean getFlag(int pFlagNumber)
          getFlag returns the value (true/false) of the flag indicated by pFlagNumber.
 FlagBox getFlagBox()
          getFlagBox Users are recommended to use getFlag( int pFlagNumber ) except when they understand the treatment of FlagBox in detail.
 Stmt getNextStmt()
          getNextStmt Get statement next to this statement.
 Stmt getStmtContainingThisNode()
          getStmtContainingThisNode Get the innermost statement or LabeledStmt containing this node by traversing ancestors of this node.
 Type getType()
          getType Get the type attached to this node.
 HIR hirClone()
          hirClone Make the clone of this node to get a clone in the situation where clone() can not be used directly.
 HirIterator hirIterator(IR pSubtree)
          hirIterator Get an iterator to traverse all nodes or statements under pSubtree.
 HirList hirList()
           
 HirSeq hirSeq(HIR pChild1, HIR pChild2)
          hirSeq Make an HirSeq node that have some definite number of children. //##59 (See HIR interface for HirSeq with more than 2 children.)
 IfStmt ifStmt(Exp pCondition, Stmt pThenPart, Stmt pElsePart)
          ifStmt Build an if-statement with then-part (pThenPart) and else-part (pElsePart).
 ConstNode intConstNode(long pIntValue)
          intConstNode Make a ConstNode instance having pIntValue as its value.
 IrList irList()
          irList Make an empty HirList node that make a LinkedList.
 boolean isSameAs(HIR pTree)
          isSameAs Compare this tree with pTree and if they have the same tree shape (same operator and same operands) then return true.
 JumpStmt jumpStmt(Label pLabelSym)
          jumpStmt Create a jump statement and increment reference count of pLabelSym.
 LabelDef labelDef(Label pLabel)
          labelDef Make a LabelDef instance that defines the label pLabel.
 LabeledStmt labeledStmt(Label pLabel, Stmt pStmt)
          labeledStmt Build labeled statement using pLabel as its label and pStmt as its statement body.
 LabelNode labelNode(Label pLabel)
          labelNode Make a LabelNode instance having Label symbol pLabel.
 PointedExp pointedExp(Exp pStructUnionExp, ElemNode pElemNode)
          pointedExp Build a pointed expression.
 void print(int pIndent, boolean pDetail)
          print Print this subtree in text format traversing all children of this node.
 Program program(Sym pProgName, SymTable pGlobalSymTable, IR pInitiationPart, IrList pSubpList)
          program Make a program node.
 QualifiedExp qualifiedExp(Exp pStructUnionExp, ElemNode pElemNode)
          qualifiedExp Build a qualified expression.
 RepeatStmt repeatStmt(Stmt pLoopBody, Exp pCondition)
           
 HIR replaceThisNode(HIR pNewNode)
          replaceThisNode Replace "this" node by pNewNode.
 ReturnStmt returnStmt(Exp pReturnValue)
          returnStmt Build return statement that terminates the execution of current subprogram under construction.
 void setFlag(int pFlagNumber, boolean pYesNo)
          setFlag sets the flag specified by pFlagNumber.
 int setIndexNumberToAllNodes(int pStartNumber)
          setIndexNumberToAllNodes Set sequencial index number to all nodes traversing the subtree rooted by this node in depth-first order.
 Exp sizeofExp(Exp pExp)
          sizeofExp Build the expression that get the size of pExp.
 Exp sizeofExp(Type pType)
          sizeofExp Build the expression that get the size of pType.
 SubpDefinition subpDefinition(Subp pSubpSym, SymTable pLocalSymTable)
          subpDefifnition Make a subprogram definition node and set symRoot.subpCurrent = pSubpSym, set symRoot.symTableCurrentSubp = pLocalSymTable.
 SubpNode subpNode(Subp pSubp)
          subpNode Make a SubpNode instance having Subp symbol pSubp.
 SubscriptedExp subscriptedExp(Exp pArrayExp, Exp pSubscript)
          subscriptedExp Build a subscripted expression.
 SwitchStmt switchStmt(Exp pSelectExp, IrList pJumpList, Label pDefaultLabel, Stmt pSwitchBody, Label pEndLabel)
          switchStmt Make a SwitchStmt instance.
 SymNode symNode(Sym pSym)
          symNode Make a SymNode instance having pSym as attached symbol.
 ConstNode trueNode()
          trueNode Make a ConstNode instance having boolean true value.
 Exp undecayExp(Exp pPointerExp, long pElemCount, long pLowerBound)
          undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.
 VarNode varNode(Var pVar)
          varNode Make a VarNode instance having Var symbol pVar.
 WhileStmt whileStmt(Exp pCondition, Stmt pLoopBody)
           
 
インタフェース coins.ir.IR0 から継承したメソッド
getChild, getChildCount, getIndex, getOperator, setChild
 

フィールドの詳細

OP_LABEL_DEF

public static final int OP_LABEL_DEF
Operator number

関連項目:
定数フィールド値

OP_CONST

public static final int OP_CONST
Operator number

関連項目:
定数フィールド値

OP_SYM

public static final int OP_SYM
Operator number

関連項目:
定数フィールド値

OP_VAR

public static final int OP_VAR
Operator number

関連項目:
定数フィールド値

OP_PARAM

public static final int OP_PARAM
Operator number

関連項目:
定数フィールド値

OP_SUBP

public static final int OP_SUBP
Operator number

関連項目:
定数フィールド値

OP_TYPE

public static final int OP_TYPE
Operator number

関連項目:
定数フィールド値

OP_LABEL

public static final int OP_LABEL
Operator number

関連項目:
定数フィールド値

OP_ELEM

public static final int OP_ELEM
Operator number

関連項目:
定数フィールド値

OP_SEQ

public static final int OP_SEQ
Operator number

関連項目:
定数フィールド値

OP_ENCLOSE

public static final int OP_ENCLOSE
Operator number

関連項目:
定数フィールド値

OP_SUBS

public static final int OP_SUBS
Operator number

関連項目:
定数フィールド値

OP_INDEX

public static final int OP_INDEX
Operator number

関連項目:
定数フィールド値

OP_QUAL

public static final int OP_QUAL
Operator number

関連項目:
定数フィールド値

OP_ARROW

public static final int OP_ARROW
Operator number

関連項目:
定数フィールド値

OP_STMT

public static final int OP_STMT
Operator number

関連項目:
定数フィールド値

OP_LABELED_STMT

public static final int OP_LABELED_STMT
Operator number

関連項目:
定数フィールド値

OP_ASSIGN

public static final int OP_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_IF

public static final int OP_IF
Operator number

関連項目:
定数フィールド値

OP_WHILE

public static final int OP_WHILE
Operator number

関連項目:
定数フィールド値

OP_FOR

public static final int OP_FOR
Operator number

関連項目:
定数フィールド値

OP_REPEAT

public static final int OP_REPEAT
Operator number

関連項目:
定数フィールド値

OP_UNTIL

public static final int OP_UNTIL
Operator number

関連項目:
定数フィールド値

OP_INDEXED_LOOP

public static final int OP_INDEXED_LOOP
Operator number

関連項目:
定数フィールド値

OP_JUMP

public static final int OP_JUMP
Operator number

関連項目:
定数フィールド値

OP_SWITCH

public static final int OP_SWITCH
Operator number

関連項目:
定数フィールド値

OP_CALL

public static final int OP_CALL
Operator number

関連項目:
定数フィールド値

OP_RETURN

public static final int OP_RETURN
Operator number

関連項目:
定数フィールド値

OP_BLOCK

public static final int OP_BLOCK
Operator number

関連項目:
定数フィールド値

OP_EXP_STMT

public static final int OP_EXP_STMT
Operator number

関連項目:
定数フィールド値

OP_ASM

public static final int OP_ASM
Operator number

関連項目:
定数フィールド値

OP_STMT_UPPER

public static final int OP_STMT_UPPER
Operator number

関連項目:
定数フィールド値

OP_ADD

public static final int OP_ADD
Operator number

関連項目:
定数フィールド値

OP_SUB

public static final int OP_SUB
Operator number

関連項目:
定数フィールド値

OP_MULT

public static final int OP_MULT
Operator number

関連項目:
定数フィールド値

OP_DIV

public static final int OP_DIV
Operator number

関連項目:
定数フィールド値

OP_MOD

public static final int OP_MOD
Operator number

関連項目:
定数フィールド値

OP_AND

public static final int OP_AND
Operator number

関連項目:
定数フィールド値

OP_OR

public static final int OP_OR
Operator number

関連項目:
定数フィールド値

OP_XOR

public static final int OP_XOR
Operator number

関連項目:
定数フィールド値

OP_CMP_EQ

public static final int OP_CMP_EQ
Operator number

関連項目:
定数フィールド値

OP_CMP_NE

public static final int OP_CMP_NE
Operator number

関連項目:
定数フィールド値

OP_CMP_GT

public static final int OP_CMP_GT
Operator number

関連項目:
定数フィールド値

OP_CMP_GE

public static final int OP_CMP_GE
Operator number

関連項目:
定数フィールド値

OP_CMP_LT

public static final int OP_CMP_LT
Operator number

関連項目:
定数フィールド値

OP_CMP_LE

public static final int OP_CMP_LE
Operator number

関連項目:
定数フィールド値

OP_SHIFT_LL

public static final int OP_SHIFT_LL
Operator number

関連項目:
定数フィールド値

OP_SHIFT_R

public static final int OP_SHIFT_R
Operator number

関連項目:
定数フィールド値

OP_SHIFT_RL

public static final int OP_SHIFT_RL
Operator number

関連項目:
定数フィールド値

OP_NOT

public static final int OP_NOT
Operator number

関連項目:
定数フィールド値

OP_NEG

public static final int OP_NEG
Operator number

関連項目:
定数フィールド値

OP_ADDR

public static final int OP_ADDR
Operator number

関連項目:
定数フィールド値

OP_CONV

public static final int OP_CONV
Operator number

関連項目:
定数フィールド値

OP_DECAY

public static final int OP_DECAY
Operator number

関連項目:
定数フィールド値

OP_UNDECAY

public static final int OP_UNDECAY
Operator number

関連項目:
定数フィールド値

OP_CONTENTS

public static final int OP_CONTENTS
Operator number

関連項目:
定数フィールド値

OP_SIZEOF

public static final int OP_SIZEOF
Operator number

関連項目:
定数フィールド値

OP_SETDATA

public static final int OP_SETDATA
Operator number

関連項目:
定数フィールド値

OP_PHI

public static final int OP_PHI
Operator number

関連項目:
定数フィールド値

OP_NULL

public static final int OP_NULL
Operator number

関連項目:
定数フィールド値

OP_OFFSET

public static final int OP_OFFSET
Operator number

関連項目:
定数フィールド値

OP_LG_AND

public static final int OP_LG_AND
Operator number

関連項目:
定数フィールド値

OP_LG_OR

public static final int OP_LG_OR
Operator number

関連項目:
定数フィールド値

OP_SELECT

public static final int OP_SELECT
Operator number

関連項目:
定数フィールド値

OP_COMMA

public static final int OP_COMMA
Operator number

関連項目:
定数フィールド値

OP_EQ_ZERO

public static final int OP_EQ_ZERO
Operator number

関連項目:
定数フィールド値

OP_PRE_INCR

public static final int OP_PRE_INCR
Operator number

関連項目:
定数フィールド値

OP_PRE_DECR

public static final int OP_PRE_DECR
Operator number

関連項目:
定数フィールド値

OP_POST_INCR

public static final int OP_POST_INCR
Operator number

関連項目:
定数フィールド値

OP_POST_DECR

public static final int OP_POST_DECR
Operator number

関連項目:
定数フィールド値

OP_ADD_ASSIGN

public static final int OP_ADD_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_SUB_ASSIGN

public static final int OP_SUB_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_MULT_ASSIGN

public static final int OP_MULT_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_DIV_ASSIGN

public static final int OP_DIV_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_MOD_ASSIGN

public static final int OP_MOD_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_SHIFT_L_ASSIGN

public static final int OP_SHIFT_L_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_SHIFT_R_ASSIGN

public static final int OP_SHIFT_R_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_AND_ASSIGN

public static final int OP_AND_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_OR_ASSIGN

public static final int OP_OR_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_XOR_ASSIGN

public static final int OP_XOR_ASSIGN
Operator number

関連項目:
定数フィールド値

OP_EXPLIST

public static final int OP_EXPLIST
Operator number

関連項目:
定数フィールド値

OP_EXPREPEAT

public static final int OP_EXPREPEAT
Operator number

関連項目:
定数フィールド値

FLAG_NOCHANGE

public static final int FLAG_NOCHANGE
Flag numbers applied to HIR nodes

関連項目:
定数フィールド値

FLAG_C_PTR

public static final int FLAG_C_PTR
Flag numbers applied to HIR nodes

関連項目:
定数フィールド値

FLAG_CONST_EXP

public static final int FLAG_CONST_EXP
Flag numbers applied to HIR nodes

関連項目:
定数フィールド値

FLAG_INIT_BLOCK

public static final int FLAG_INIT_BLOCK
Flag numbers applied to HIR nodes

関連項目:
定数フィールド値

FLAG_LOOP_WITH_CONDITIONAL_INIT

public static final int FLAG_LOOP_WITH_CONDITIONAL_INIT
Flag numbers applied to HIR nodes

関連項目:
定数フィールド値

FLAG_NONTERMINAL

public static final int FLAG_NONTERMINAL
関連項目:
定数フィールド値
メソッドの詳細

program

public Program program(Sym pProgName,
                       SymTable pGlobalSymTable,
                       IR pInitiationPart,
                       IrList pSubpList)
program Make a program node. See Program interface.

パラメータ:
pProgName - Program name (may be null).
pGlobalSymTable - Symbol table for global symbols.
pInitiationPart - Initiation statement (may be null).
pSubpList - List of subprograms; At first, it may be an empty list; (See addSubpDefinition of Program interface).

subpDefinition

public SubpDefinition subpDefinition(Subp pSubpSym,
                                     SymTable pLocalSymTable)
subpDefifnition Make a subprogram definition node and set symRoot.subpCurrent = pSubpSym, set symRoot.symTableCurrentSubp = pLocalSymTable. You may add initiation-part, HIR-body later by using addInitiationStmt, setHirBody of SubpDefinition interface. Start label and end label for the given subprogram are generated to make getStartLabel(), getEndLabel() of Subp interface effective.

パラメータ:
pSubpSym - Subprogram symbol. Should be given.
pLocalSymTable - Symbol table local in the subprogram; If subprogram uses a local symbol table, this parameter should be given (by using pushSymTable() of SymTable interface); If the source language permits no local symbol for subprogram, this parameter may be null.
戻り値:
the created SubpDefinition instance.

irList

public IrList irList()
irList Make an empty HirList node that make a LinkedList. Use methods of IrList to add elements to the list. The elements to be added are an HIR object or Sym object. The created list can be treated as an HIR node.

戻り値:
an empty IrList; Resultant list is also an instance of HIR.

hirList

public HirList hirList()

getType

public Type getType()
getType Get the type attached to this node. The type is usually attached when node is built by HIR factory methods such as exp.

戻り値:
the type attached to this node.

getNextStmt

public Stmt getNextStmt()
getNextStmt Get statement next to this statement.

戻り値:
the statement next to this statement if this is a statement; If this is not a statement, return null.

getFlag

public boolean getFlag(int pFlagNumber)
getFlag returns the value (true/false) of the flag indicated by pFlagNumber. See FLAG_NOCHANGE, FLAG_CONST_EXP, etc. of HIR interface.

パラメータ:
pFlagNumber - flag identification number.
戻り値:
the value of the flag.

setFlag

public void setFlag(int pFlagNumber,
                    boolean pYesNo)
setFlag sets the flag specified by pFlagNumber. See FLAG_NOCHANGE, FLAG_CONST_EXP, etc. of HIR interface. Some local flag numbers can be added in each phase.

パラメータ:
pFlagNumber - flag identification number.
pYesNo - true or false to be set to the flag.

getFlagBox

public FlagBox getFlagBox()
getFlagBox Users are recommended to use getFlag( int pFlagNumber ) except when they understand the treatment of FlagBox in detail.

戻り値:
the flag box attached to this node; null if flag box is not attached (no flag is set).

getChildNumber

public int getChildNumber()
getChildNumber Get the child number of this node. If not found, return -1. (Usually, it is unnecessary to use this because the child number is known by stack, etc.)


getStmtContainingThisNode

public Stmt getStmtContainingThisNode()
getStmtContainingThisNode Get the innermost statement or LabeledStmt containing this node by traversing ancestors of this node. If this is a statement, then this is the innermost statement. If the the parent of the innermost statement is a LabeledStmt, then the LabeledStmt is returned else the innermost statement is returned.

戻り値:
the innermost statement or LabeledStmt containing this node.

varNode

public VarNode varNode(Var pVar)
varNode Make a VarNode instance having Var symbol pVar.

パラメータ:
pVar - Variable symbol to be attached to the node.
戻り値:
the resultant VarNode.

elemNode

public ElemNode elemNode(Elem pElem)
elemNode Make an ElemNode instance having Elem symbol pElem.

パラメータ:
pElem - Struct/union element symbol to be attached to the node.
戻り値:
the resultant ElemNode.

subpNode

public SubpNode subpNode(Subp pSubp)
subpNode Make a SubpNode instance having Subp symbol pSubp.

パラメータ:
pSubp - Subprogram symbol to be attached to the node.
戻り値:
the resultant SubpNode.

labelNode

public LabelNode labelNode(Label pLabel)
labelNode Make a LabelNode instance having Label symbol pLabel. (See labelDef.)

パラメータ:
pLabel - Label symbol to be attached to the node.
戻り値:
the resultant LabelNode.

constNode

public ConstNode constNode(Const pConst)
constNode Make a ConstNode instance having constant symbol pConst.

パラメータ:
pConst - Constant symbol to be attached to the node.
戻り値:
the resultant ConstNode.

intConstNode

public ConstNode intConstNode(long pIntValue)
intConstNode Make a ConstNode instance having pIntValue as its value. The constant value is changed to Const symbol and attached to the constant node.

パラメータ:
pIntValue - Integer value to be attached to the node.
戻り値:
the resultant ConstNode.

trueNode

public ConstNode trueNode()
trueNode Make a ConstNode instance having boolean true value.

戻り値:
the true ConstNode.

falseNode

public ConstNode falseNode()
falseNode Make a ConstNode instance having boolean false value.

戻り値:
the false ConstNode.

symNode

public SymNode symNode(Sym pSym)
symNode Make a SymNode instance having pSym as attached symbol. This method is used for symbols other than Var, Elem, Subp, Label, and constant.

パラメータ:
pSym - Symbol to be attached to the node.
戻り値:
the resultant SymNode.

labelDef

public LabelDef labelDef(Label pLabel)
labelDef Make a LabelDef instance that defines the label pLabel. (See labelNode.)

パラメータ:
pLabel - Label symbol to be defined.
戻り値:
the resultant LabelDef.

exp

public Exp exp(int pOperator,
               Exp pExp1)
exp
  Build unary expression according to the
  operator given:
  OP_NOT      // bitwise not (~) one's complement
              // logical not for bool (!)
  OP_NEG      // negate (unary minus)
  OP_ADDR     // get address (&)
  OP_CONTENTS // get contents of pointed memory
  OP_CONV     // type conversion for basic type
  OP_DECAY    // convert array to pointer
  OP_SIZEOF   // sizeof operator
  OP_ENCLOSE  // honor parenthesis
  The type of resultant expression is set according to the rule
  described in the HIR specifications, however, it may be necessary
  to do language-wise treatment. In such case, front-end part of the
  language should set type after creating the instance of Exp.
  (In C, expressions related to pointer and vector are specially
   treated in C front end ToHirC.)

 

パラメータ:
pOperator - unary operator such as OP_NOT, OP_NEG, OP_ADDR, OP_CONTENTS, OP_CONV, OP_DECAY, OP_SIZEOF, OP_ENCLOSE defined in HIR interface.
pExp1 - operand expression.
戻り値:
the resultant unary expression subtree.

exp

public Exp exp(int pOperator,
               Exp pExp1,
               Exp pExp2)
exp Build binary expression. The type of resultant expression is set according to the rule described in the HIR specifications, however, it may be necessary to do language-wise treatment. In such case, front-end part of the language should set type after creating the instance of Exp. (In C, expressions related to pointer and vector are specially treated in C front end ToHirC.)

パラメータ:
pOperator - binary operator such as OP_ADD, OP_MULT, etc. defined in HIR interface.
pExp1 - operand 1 expression.
pExp2 - operand 2 expression.
戻り値:
the resultant binary expression subtree.

decayExp

public Exp decayExp(Exp pExp)
decayExp Build an expression that decay a vector to a pointer to vector element, or decay a String into a pointer to Char element.

パラメータ:
pExp - vector variable or string constant.
戻り値:
decay expression with pointer type.

undecayExp

public Exp undecayExp(Exp pPointerExp,
                      long pElemCount,
                      long pLowerBound)
undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.

パラメータ:
pPointerExp - pointer expression pointing to the first element of the resultant vector.
pElemCount - element count of the resultant vector.
pLowerBound - lower index bound of the resultant vector.
戻り値:
the vector expression.

subscriptedExp

public SubscriptedExp subscriptedExp(Exp pArrayExp,
                                     Exp pSubscript)
subscriptedExp Build a subscripted expression.

パラメータ:
pArrayExp - array expression to which subscript is to be attached; If multi-dimensional subscript is required, make pArrayExp as a subscripted variable and add more subscript by this method.
pSubscript - subscript expression.
戻り値:
subscripted expression node having operation code subsCode.

qualifiedExp

public QualifiedExp qualifiedExp(Exp pStructUnionExp,
                                 ElemNode pElemNode)
qualifiedExp Build a qualified expression.

パラメータ:
pStructUnionExp - expression specifying structure or union or region_variable to qualify.
pElemNode - An element of pStructUnionExp.
戻り値:
qualified expression node having operation code qualCode.

pointedExp

public PointedExp pointedExp(Exp pStructUnionExp,
                             ElemNode pElemNode)
pointedExp Build a pointed expression.

パラメータ:
pStructUnionExp - expression specifying structure or union whose element is to be pointed.
pElemNode - An element of pStructUnionExp.
戻り値:
pointed expression node having operation code arrowCode.

contentsExp

public Exp contentsExp(Exp pPointerExp)
contentsExp Build an expression that gets the contents pointed by pPointerExp.

パラメータ:
pPointerExp - Expression representing a pointer.
戻り値:
the expression that gets the pointed expression.

convExp

public Exp convExp(Type pType,
                   Exp pExp)
convExp Build an expression to convert the type of pExp to pType.

パラメータ:
pType - Type to which pExp is to be changed.
pExp - Expression to be converted.
戻り値:
the expression converted to pType.

sizeofExp

public Exp sizeofExp(Type pType)
sizeofExp Build the expression that get the size of pType.

パラメータ:
pType - Type of object.
戻り値:
the expression representing the size of pType.

sizeofExp

public Exp sizeofExp(Exp pExp)
sizeofExp Build the expression that get the size of pExp.

パラメータ:
pExp - Expression whose size is to be taken.
戻り値:
the expression representing the size of pExp.

functionExp

public FunctionExp functionExp(Exp pFunctionSpec,
                               IrList pActualParamList)
functionExp Build a function expression node that computes function value. The function may have no return value (void return value). If pFunctionSpec is (addr SubpNode) or SubpNode, then the subprogram represented by it is added to the call list of the current subprogram (symRoot.subpCurrent). The type of resultant expression is usually the type of return value, but type of pointed expression if pFunctionSpec is a pointer (to subprogram).

パラメータ:
pFunctionSpec - function specification part which may be either a function name (SubpNode), or an expression specifying a function name ((addr SubpNode), etc.).
pActualParamList - actual parameter list (made by hirList).
戻り値:
function expression node having operation code opCall.

callStmt

public ExpStmt callStmt(Exp pSubpSpec,
                        IrList pActualParamList)
callStmt Build a subprogram call statement. Parameters are the same as those of functionExp.

パラメータ:
pSubpSpec - subprogram specification part which may be either a subprogram name (SubpNode), or an expression specifying a subprogram name ((addr SubpNode), etc.).
pActualParamList - actual parameter list (made by hirList).
戻り値:
function expression node having operation code opCall.

assignStmt

public AssignStmt assignStmt(Exp pLeft,
                             Exp pRight)
assignStmt Build an assignemnt statement.

パラメータ:
pLeft - left hand side (l-value) expression to which the value of expression is to be assigned.
pRight - expression (subtree) that is to be assigned to pLeftSide.
戻り値:
the subtree of the built statement with statement body operator assignCode.

ifStmt

public IfStmt ifStmt(Exp pCondition,
                     Stmt pThenPart,
                     Stmt pElsePart)
ifStmt Build an if-statement with then-part (pThenPart) and else-part (pElsePart). Internal labels (then-label and else-label) are generated to be attached to the then-part and else-part. If pThenPart or pElsePart is null, a LabeledStmt with null statement body is generated as then-part or else-part.

パラメータ:
pCondition - conditional expression subtree.
pThenPart - then-part statement that is executed when pCondition is true.
pElsePart - else-part statement that is executed when pCondition is false.
戻り値:
the subtree of the built statement with statement body operator OP_IF; If else-part is not given, it is treated as null.

whileStmt

public WhileStmt whileStmt(Exp pCondition,
                           Stmt pLoopBody)

forStmt

public ForStmt forStmt(Stmt pInitStmt,
                       Exp pCondition,
                       Stmt pLoopBody,
                       Stmt pStepPart)

repeatStmt

public RepeatStmt repeatStmt(Stmt pLoopBody,
                             Exp pCondition)

labeledStmt

public LabeledStmt labeledStmt(Label pLabel,
                               Stmt pStmt)
labeledStmt Build labeled statement using pLabel as its label and pStmt as its statement body. It is recommended to use attachLabel of Stmt except in HIR access methods to make a labeled statement. If you want to use labeledStmt, give null as pStmt parameter. Relations between pStmt and others (such as previousStmt, nextStmt, parentNode) are not kept. If it is necessary to transfer such relations to this LabeledStmt, apply attachLabel method to pStmt instead of calling labeledStmt.


blockStmt

public BlockStmt blockStmt(Stmt pStmtSequence)
blockStmt Make an instance of block statement that may contain a sequence of statements. It is recommended to make an empty block statement by blockStmt(null) and then add statements by successively calling addLastStmt method of BlockStmt.

パラメータ:
pStmtSequence - statement to be included in BlockStmt (may be null).
戻り値:
the resultant BlockStmt.

returnStmt

public ReturnStmt returnStmt(Exp pReturnValue)
returnStmt Build return statement that terminates the execution of current subprogram under construction.

パラメータ:
pReturnValue - return value of function subprogram. If the subprogram has no return value, it is null.
戻り値:
the subtree of the built statement with statement body operator OP_RETURN.

jumpStmt

public JumpStmt jumpStmt(Label pLabelSym)
jumpStmt Create a jump statement and increment reference count of pLabelSym.

パラメータ:
pLabelSym - jump target label.
戻り値:
the created jump statement.

switchStmt

public SwitchStmt switchStmt(Exp pSelectExp,
                             IrList pJumpList,
                             Label pDefaultLabel,
                             Stmt pSwitchBody,
                             Label pEndLabel)
switchStmt Make a SwitchStmt instance. The jump list pJumpList is a list of pairs of case constant and case label. Following sequence may create a jump list: created an empty list by irList() of HIR; generate a case-label and attach it to the statement corresponding to the case-constant; add hir.hirSeq(case-constant node, case-label node) to the list; repeat the generation of case-label and addition to the jump list;

パラメータ:
pSelectExp - Expression to select case statement.
pJumpList - Jump list that correlate case constant and case label.
pDefaultLabel - label to be attached to default statement part.
pSwitchBody - Switch statement body that contains statements with case-label.
pEndLabel - Label as the target of jump corresponding to break.
戻り値:
the resultant SwitchStmt.

hirSeq

public HirSeq hirSeq(HIR pChild1,
                     HIR pChild2)
hirSeq Make an HirSeq node that have some definite number of children. //##59 (See HIR interface for HirSeq with more than 2 children.)

パラメータ:
pChild1 - Child 1 HIR node.
pChild2 - Child 2 HIR node.
戻り値:
HirSeq with 2 children.

expStmt

public ExpStmt expStmt(Exp pExp)
expStmt Create a statement treating pExp as a statement. ExpStmt appears as loop-condition, call statement, etc. The loop-condition is an expression but it has label, and so, it should be ExpStmt. The call statement is a function call expression treated as a stand alone statement, and so, it should be ExpStmt. It also certificates the value of getHirPosition() for labels. //##60

パラメータ:
pExp - expression to be treated as a statement.
戻り値:
the resultant ExpStmt.

setIndexNumberToAllNodes

public int setIndexNumberToAllNodes(int pStartNumber)
setIndexNumberToAllNodes Set sequencial index number to all nodes traversing the subtree rooted by this node in depth-first order. The index number of this node is set to pStartNumber. If this node is an instance of SubpDefinition, then the minimum and the maximum of the index numberes set to the nodes of this subtree are recorded in SubpDefinition instance so that they can be accessed by getNodeIndexMin() and getNodeIndexMax() of SubpDefinition.

パラメータ:
pStartNumber - starting value of the index (greater than 0).
戻り値:
(the last index number) + 1.

finishHir

public boolean finishHir()
 finishHir does closing operations for HIR.
 finishHir should be called for Program or SubpDefinition
 when HIR building or restructuring were completed in such
 timing as
   at the end of new HIR generation in front-end
    (call for hirRoot.programRoot),
   at the end of restructuring (optimization, parallelization, etc.)
    (call for corresponding SubpDefinition subtree).
 If finishHir is scheduled to be called for programRoot after successive
 generation or restructuring of SubpDefinitions before passing it to other
 phases, then it is unnecessary to call it for each SubpDefinition.
 finishHir set index number to all nodes of this subtree
 and verifies its tree structure.
 It also certificates the value of getHirPosition() for labels  //##60
 and buildLabelRefList is called for SubpDefinition
 (for Program, buildLabelRefList is called for every SubpDefinitions). //##62
 If finishHir is called then it is not necessary to call
 setIndexNumberToAllNnodes() nor isTree().
 If error is found, then finishHir() returns false after isuing
 error message. If no error is found then it returns true.
 In either case, processing will continue.

戻り値:
true if descrepancy is not found, false if descrepancy is found.

copyWithOperands

public HIR copyWithOperands()
copyWithOperands
  Make a subtree that is the same to this subtree.
  (Labels are not renamed.)
  In general, a subtree represents the computation of
  an operation and also the computation of its operands.
  Flow information is invalid as for copied subtree and
  should be computed again if required.
  If the subtree contains labels, it is recommended to use
  copyWithOperandsChangingLabels. Note that, IfStmt, LoopStmt
  (for, while, until, etc.), SwitchStmt
  contain internal labels and it is recommended to use
  copyWithOperandsChangingLabels to the subtree that may contain
  these statements.
  "this" should be the root node of a subtree contained
  in a subprogram body. Subprogram body itself should not be copied.

戻り値:
the subtree made by the copy operation.

copyWithOperandsChangingLabels

public HIR copyWithOperandsChangingLabels(IrList pLabelCorrespondence)
copyWithOperandsChangingLabels Make a new subtree that is the same to this subtree. If this subtree contains a label definition, then the label is renamed to avoid conflict. Flow information is invalid as for copied subtree and should be computed again if required. "this" should be the root node of a subtree contained in a subprogram body. Subprogram body should not be copied.

パラメータ:
pLabelCorrespondence - label correspondence list; It is usually null; If label correspondence is to be specified, it should be of the form (IrList (IrList of original labels) (IrList of new labels) ) "this" subtree should not contain labels listed in (IrList of new labels) so as escape from infinite replacement loop; This restriction is satisfied when pLabelCorrespondence is null; If this parameter is null, it is computed in this method and passed to HirModify subclass after calling copyWithOperands (without changing label).
戻り値:
the copied subtree with labels changed.

replaceThisNode

public HIR replaceThisNode(HIR pNewNode)
replaceThisNode Replace "this" node by pNewNode. If this has parent, then the link between this and the parent is changed to the link between pNewNode and the parent. "this" may be any node that makes sense by replacement.

パラメータ:
pNewNode - node that takes place of "this" node.

hirClone

public HIR hirClone()
hirClone Make the clone of this node to get a clone in the situation where clone() can not be used directly.

戻り値:
the clone of this node.

isSameAs

public boolean isSameAs(HIR pTree)
isSameAs Compare this tree with pTree and if they have the same tree shape (same operator and same operands) then return true. In the comparison, attributes are not compared. (This method is public but less efficient than the protected method isSameTree in flow.HirSubpFlowImpl.)

パラメータ:
pTree - HIR tree to be compared.
戻り値:
true if this tree has the same shape as pTree, false otherwise.

hirIterator

public HirIterator hirIterator(IR pSubtree)
hirIterator
  Get an iterator to traverse all nodes or statements under
  pSubtree. YOu can traverse the subtree by following methods
  of HirIterator
     next(): traverse all nodes.
     getNextStmt(): traverse all statements.
     getNextExecutableNode(): traverse executable nodes only.
  See HirIterator interface.
 

パラメータ:
pSubtree - root of the subtree to be traversed.
戻り値:
teh resultant HirIterator.

accept

public void accept(HirVisitor pVisitor)
accept Acceptor used in HIR visitor. See HirVisitor, HirVisitorModel1, HirVisitormodel2.

パラメータ:
pVisitor - HirVisitor

print

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

パラメータ:
pIndent - number of heading spaces for indentation.
pDetail - true if print all main attributes, false if some detail attributes are to be omitted.