coins.casttohir
クラス ToHirBase

java.lang.Object
  |
  +--coins.casttohir.ToHirVisit
        |
        +--coins.casttohir.ToHirBase

public class ToHirBase
extends ToHirVisit

Convert HIR-C to HIR-base.


フィールドの概要
 int fDbgLevel
           
protected  HIR hir
          HIR instance (used to create HIR objects).
protected  BlockStmt nowBlock
          Now processing block (used to create initializer).
protected  Sym sym
          Sym instance (used to create Sym objects).
protected  ToHir toHir
          Offers cooperation with the object of other packages.
 
コンストラクタの概要
ToHirBase(ToHir tohir)
          Constructor.
 
メソッドの概要
protected  Exp atAdd(Exp e)
          At add expression node.
protected  Exp atAddAssign(Exp e)
          At add-assign expression node.
protected  Exp atAddr(Exp e)
          At address expression node.
protected  Exp atAnd(Exp e)
          At and expression node.
protected  Exp atAndAssign(Exp e)
          At and-assign expression node.
protected  Exp atArrow(Exp e)
          At arrow expression node.
protected  Exp atARShift(Exp e)
          At arithmetic R-shift expression node.
protected  Exp atAssign(Exp e)
          At assign expression node.
protected  void atAssignStmt(AssignStmt s)
          At assign statement node.
protected  void atBlock(BlockStmt s)
          At block statement node.
protected  Exp atCall(FunctionExp e)
          At function call expression node.
protected  Exp atCmpEq(Exp e)
          At EQ expression node.
protected  Exp atCmpGe(Exp e)
          At GE expression node.
protected  Exp atCmpGt(Exp e)
          At GT expression node.
protected  Exp atCmpLe(Exp e)
          At LE expression node.
protected  Exp atCmpLt(Exp e)
          At LT expression node.
protected  Exp atCmpNe(Exp e)
          At NE expression node.
protected  Exp atComma(Exp e)
          At comma expression node.
protected  Exp atConst(ConstNode e)
          At constant node.
protected  Exp atContents(Exp e)
          At indirection expression node.
protected  Exp atConv(Exp e)
          At cast expression node.
protected  Exp atDecay(Exp e)
          At decay expression node.
protected  Exp atDiv(Exp e)
          At div expression node.
protected  Exp atDivAssign(Exp e)
          At div-assign expression node.
protected  Exp atElem(ElemNode e)
          At element node.
protected  Exp atEqZero(Exp e)
          At logical-not expression node.
protected  Exp atExpList(ExpListExp e)
          At expression list node.
protected  Exp atExpRepeat(Exp e)
          At expression repeatation node.
protected  void atExpStmt(ExpStmt s)
          At expression statement node.
protected  void atFor(LoopStmt s)
          At for statement node.
protected  void atIf(IfStmt s)
          At if statement node.
protected  Exp atIndex(Exp e)
          At index expression node.
protected  InfStmt atInfStmt(InfStmt pInf)
          atInfStmt parses the pragma body in the form of String and change its symbols to instances of Sym (Var, Subp, Label, Const) and items enclosed in parenthesis to IrList changing its elements to Sym, etc.
protected  void atJump(JumpStmt s)
          At goto statement node.
protected  void atLabeledStmt(LabeledStmt s)
          At labeled statement node.
protected  Exp atLgAnd(Exp e)
          At logical-and expression node.
protected  Exp atLgOr(Exp e)
          At logical-or expression node.
protected  Exp atLShift(Exp e)
          At L-shift expression node.
protected  Exp atLShiftAssign(Exp e)
          At L-shift-assign expression node.
protected  Exp atMod(Exp e)
          At mod expression node.
protected  Exp atModAssign(Exp e)
          At mod-assign expression node.
protected  Exp atMul(Exp e)
          At mul expression node.
protected  Exp atMulAssign(Exp e)
          At mul-assign expression node.
protected  Exp atNeg(Exp e)
          At negative expression node.
protected  Exp atNot(Exp e)
          At logical not expression node.
protected  Exp atOffset(Exp e)
          At offset(difference of address) expression node.
protected  Exp atOr(Exp e)
          At or expression node.
protected  Exp atOrAssign(Exp e)
          At or-assign expression node.
protected  Exp atPost(int op, Exp e)
          At post-operator expression node.
protected  Exp atPre(int op, Exp e)
          At pre-operator expression node.
protected  Exp atQual(Exp e)
          At member-access expression node.
protected  void atReturn(ReturnStmt s)
          At return statement node.
protected  Exp atRShift(Exp e)
          At logical R-shift expression node.
protected  Exp atRShiftAssign(Exp e)
          At R-shift-assign expression node.
protected  Exp atSelect(Exp e)
          At selection expression node.
protected  void atSetDataStmt(SetDataStmt s)
          At datacode statement node.
protected  Exp atSub(Exp e)
          At sub expression node.
protected  Exp atSubAssign(Exp e)
          At sub-assign expression node.
protected  Exp atSubp(SubpNode e)
          At function node.
protected  SubpDefinition atSubpDefinition(SubpDefinition s)
          At block statement node.
protected  Exp atSubs(Exp e)
          At subscript expression node.
protected  void atSwitch(SwitchStmt s)
          At switch statement node.
protected  Exp atUndecay(Exp e)
          At undecay expression node.
protected  void atUntil(LoopStmt s)
          At do-while statement node.
protected  Exp atVar(VarNode e)
          At variable node.
protected  void atWhile(LoopStmt s)
          At while statement node.
protected  Exp atXor(Exp e)
          At xor expression node.
protected  Exp atXorAssign(Exp e)
          At xor-assign expression node.
protected  boolean inInitBlock()
          Return true if now processing in the initialization block.
protected  void message(int level, java.lang.String mes)
          Output debug message.
(パッケージプライベート)  IrList processPragmaItem(ParseString pParseString, java.lang.String pNextItem, IrList pList)
           
(パッケージプライベート)  Exp visitExp(Exp e)
           
protected  void visitExpAsExpStmt(Exp e)
          Do the same as visitExpAsSequencePoint but this is for an expression whose value is not used (in such cases as procedure call (ExpStmt), non-last expression of comma expression (x of (x, y)), etc.).
protected  Exp visitExpAsSequencePoint(Exp e)
          Visit the expression e.
 void visitProgram()
          Visit HIR program tree.
(パッケージプライベート)  void visitProgram(Program program)
          Visit HIR program tree.
(パッケージプライベート)  void visitStmt(Stmt s)
          Call appropriate method by operator of statement node.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

toHir

protected final ToHir toHir
Offers cooperation with the object of other packages.


hir

protected final HIR hir
HIR instance (used to create HIR objects).


sym

protected final Sym sym
Sym instance (used to create Sym objects).


nowBlock

protected BlockStmt nowBlock
Now processing block (used to create initializer).


fDbgLevel

public final int fDbgLevel
コンストラクタの詳細

ToHirBase

public ToHirBase(ToHir tohir)
Constructor.

パラメータ:
tohir - Offers cooperation with the object of other packages.
メソッドの詳細

message

protected void message(int level,
                       java.lang.String mes)
Output debug message.

オーバーライド:
クラス ToHirVisit 内の message
パラメータ:
level - Debug level.
mes - Debug message.

atIf

protected void atIf(IfStmt s)
At if statement node.

オーバーライド:
クラス ToHirVisit 内の atIf
パラメータ:
s - IfStmt

atWhile

protected void atWhile(LoopStmt s)
At while statement node.

オーバーライド:
クラス ToHirVisit 内の atWhile
パラメータ:
s - LoopStmt

atFor

protected void atFor(LoopStmt s)
At for statement node. If conditional expression contains expantion, it is put in the loop of 'for'.

オーバーライド:
クラス ToHirVisit 内の atFor
パラメータ:
s - LoopStmt

atUntil

protected void atUntil(LoopStmt s)
At do-while statement node. If conditional expression contains expantion, it is put in the loop of 'do-while'.

オーバーライド:
クラス ToHirVisit 内の atUntil
パラメータ:
s - LoopStmt

atSwitch

protected void atSwitch(SwitchStmt s)
At switch statement node. If conditional expression contains backword expantion, it is put out in front of 'switch'.

オーバーライド:
クラス ToHirVisit 内の atSwitch
パラメータ:
s - SwitchStmt

atReturn

protected void atReturn(ReturnStmt s)
At return statement node.

オーバーライド:
クラス ToHirVisit 内の atReturn
パラメータ:
s - ReturnStmt

atExpStmt

protected void atExpStmt(ExpStmt s)
At expression statement node.

オーバーライド:
クラス ToHirVisit 内の atExpStmt
パラメータ:
s - ExpStmt

atSetDataStmt

protected void atSetDataStmt(SetDataStmt s)
At datacode statement node.

オーバーライド:
クラス ToHirVisit 内の atSetDataStmt
パラメータ:
s - SetDataStmt

visitExpAsSequencePoint

protected Exp visitExpAsSequencePoint(Exp e)
Visit the expression e. Treat the end of evaluation as the sequence point (side effect completion point) of this expression. The swept out statements (side effect statements generated during the evaluation of the expression e) are put in the buffer.prevList.

パラメータ:
e - Expression to be visited.
戻り値:
The expression already visited.

visitExpAsExpStmt

protected void visitExpAsExpStmt(Exp e)
Do the same as visitExpAsSequencePoint but this is for an expression whose value is not used (in such cases as procedure call (ExpStmt), non-last expression of comma expression (x of (x, y)), etc.).

パラメータ:
e - Expression to be visited.

atSubs

protected Exp atSubs(Exp e)
At subscript expression node.

オーバーライド:
クラス ToHirVisit 内の atSubs
パラメータ:
e - Exp
戻り値:
Exp

atCall

protected Exp atCall(FunctionExp e)
At function call expression node.

オーバーライド:
クラス ToHirVisit 内の atCall
パラメータ:
e - Exp
戻り値:
Exp

atAdd

protected Exp atAdd(Exp e)
At add expression node.

オーバーライド:
クラス ToHirVisit 内の atAdd
パラメータ:
e - Exp
戻り値:
Exp

atSub

protected Exp atSub(Exp e)
At sub expression node.

オーバーライド:
クラス ToHirVisit 内の atSub
パラメータ:
e - Exp
戻り値:
Exp

atMul

protected Exp atMul(Exp e)
At mul expression node.

オーバーライド:
クラス ToHirVisit 内の atMul
パラメータ:
e - Exp
戻り値:
Exp

atDiv

protected Exp atDiv(Exp e)
At div expression node.

オーバーライド:
クラス ToHirVisit 内の atDiv
パラメータ:
e - Exp
戻り値:
Exp

atMod

protected Exp atMod(Exp e)
At mod expression node.

オーバーライド:
クラス ToHirVisit 内の atMod
パラメータ:
e - Exp
戻り値:
Exp

atAnd

protected Exp atAnd(Exp e)
At and expression node.

オーバーライド:
クラス ToHirVisit 内の atAnd
パラメータ:
e - Exp
戻り値:
Exp

atOr

protected Exp atOr(Exp e)
At or expression node.

オーバーライド:
クラス ToHirVisit 内の atOr
パラメータ:
e - Exp
戻り値:
Exp

atXor

protected Exp atXor(Exp e)
At xor expression node.

オーバーライド:
クラス ToHirVisit 内の atXor
パラメータ:
e - Exp
戻り値:
Exp

atCmpEq

protected Exp atCmpEq(Exp e)
At EQ expression node.
 1)  a==b;      =>  a; b;
 2)  x = a==b;  =>  if(a==b) x=1; else x=0;
 3)  x + a==b;  =>  if(a==b) tmp=1; else tmp=0; x+tmp;
 

オーバーライド:
クラス ToHirVisit 内の atCmpEq
パラメータ:
e - Exp
戻り値:
Exp

atCmpNe

protected Exp atCmpNe(Exp e)
At NE expression node.

オーバーライド:
クラス ToHirVisit 内の atCmpNe
パラメータ:
e - Exp
戻り値:
Exp

atCmpGt

protected Exp atCmpGt(Exp e)
At GT expression node.

オーバーライド:
クラス ToHirVisit 内の atCmpGt
パラメータ:
e - Exp
戻り値:
Exp

atCmpGe

protected Exp atCmpGe(Exp e)
At GE expression node.

オーバーライド:
クラス ToHirVisit 内の atCmpGe
パラメータ:
e - Exp
戻り値:
Exp

atCmpLt

protected Exp atCmpLt(Exp e)
At LT expression node.

オーバーライド:
クラス ToHirVisit 内の atCmpLt
パラメータ:
e - Exp
戻り値:
Exp

atCmpLe

protected Exp atCmpLe(Exp e)
At LE expression node.

オーバーライド:
クラス ToHirVisit 内の atCmpLe
パラメータ:
e - Exp
戻り値:
Exp

atLShift

protected Exp atLShift(Exp e)
At L-shift expression node.

オーバーライド:
クラス ToHirVisit 内の atLShift
パラメータ:
e - Exp
戻り値:
Exp

atRShift

protected Exp atRShift(Exp e)
At logical R-shift expression node.

オーバーライド:
クラス ToHirVisit 内の atRShift
パラメータ:
e - Exp
戻り値:
Exp

atARShift

protected Exp atARShift(Exp e)
At arithmetic R-shift expression node.

オーバーライド:
クラス ToHirVisit 内の atARShift
パラメータ:
e - Exp
戻り値:
Exp

atNot

protected Exp atNot(Exp e)
At logical not expression node.

オーバーライド:
クラス ToHirVisit 内の atNot
パラメータ:
e - Exp
戻り値:
Exp

atNeg

protected Exp atNeg(Exp e)
At negative expression node.

オーバーライド:
クラス ToHirVisit 内の atNeg
パラメータ:
e - Exp
戻り値:
Exp

atAssign

protected Exp atAssign(Exp e)
At assign expression node.
 At first, visit the left operand and immediately store its result
 as left operand. (The left operand may be refered in the process
 of visiting the right operand.)
 Second, visit the right operand and then do following operations
 according to its returned expression:
 1) If same to the left operand, return the left operand;
 2) If null, return the left operand because an AssignStmt is already
    sweped out.
 3) If not null, sweep out AssignStmt during which do following operations
    according to parent type:
   a) If the parent is null, return null after sweeping out AssignStmt.
   b) If the parent is not null, return expression with less overhead
      by doing following transformation:
     i)   a = b[i]  -->  a = b[i];  (return the left side a)
     ii)  a[i] = 1  -->  a[i] = 1;  (return the right side 1)
     iii) a[i] = b[j] --> t=b[j]; a[i]=t; (return the temporal variable t)
 

オーバーライド:
クラス ToHirVisit 内の atAssign
パラメータ:
e - Exp to be visited.
戻り値:
Exp as above.

atOffset

protected Exp atOffset(Exp e)
At offset(difference of address) expression node.

オーバーライド:
クラス ToHirVisit 内の atOffset
パラメータ:
e - Exp
戻り値:
Exp

atLgAnd

protected Exp atLgAnd(Exp e)
At logical-and expression node.

オーバーライド:
クラス ToHirVisit 内の atLgAnd
パラメータ:
e - Exp
戻り値:
Exp

atLgOr

protected Exp atLgOr(Exp e)
At logical-or expression node.

オーバーライド:
クラス ToHirVisit 内の atLgOr
パラメータ:
e - Exp
戻り値:
Exp

atSelect

protected Exp atSelect(Exp e)
At selection expression node.

オーバーライド:
クラス ToHirVisit 内の atSelect
パラメータ:
e - Exp
戻り値:
Exp

atComma

protected Exp atComma(Exp e)
At comma expression node.

オーバーライド:
クラス ToHirVisit 内の atComma
パラメータ:
e - Exp
戻り値:
Exp

atPre

protected Exp atPre(int op,
                    Exp e)
At pre-operator expression node.
    1)  ++v       =>  ( v=v+1, v )
    2)  ++*p      =>  ( *p=*p+1, *p )
    3)  ++*(p+j)  =>  ( tmp=p+j, *tmp=*tmp+1, *tmp )
 else)  ++s.m     =>  ( tmp=&s.m, *tmp=*tmp+1, *tmp )
 

オーバーライド:
クラス ToHirVisit 内の atPre
パラメータ:
e - Exp
戻り値:
Exp

atPost

protected Exp atPost(int op,
                     Exp e)
At post-operator expression node.

オーバーライド:
クラス ToHirVisit 内の atPost
パラメータ:
e - Exp
戻り値:
Exp

atAddAssign

protected Exp atAddAssign(Exp e)
At add-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atAddAssign
パラメータ:
e - Exp
戻り値:
Exp

atSubAssign

protected Exp atSubAssign(Exp e)
At sub-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atSubAssign
パラメータ:
e - Exp
戻り値:
Exp

atMulAssign

protected Exp atMulAssign(Exp e)
At mul-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atMulAssign
パラメータ:
e - Exp
戻り値:
Exp

atDivAssign

protected Exp atDivAssign(Exp e)
At div-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atDivAssign
パラメータ:
e - Exp
戻り値:
Exp

atModAssign

protected Exp atModAssign(Exp e)
At mod-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atModAssign
パラメータ:
e - Exp
戻り値:
Exp

atLShiftAssign

protected Exp atLShiftAssign(Exp e)
At L-shift-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atLShiftAssign
パラメータ:
e - Exp
戻り値:
Exp

atRShiftAssign

protected Exp atRShiftAssign(Exp e)
At R-shift-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atRShiftAssign
パラメータ:
e - Exp
戻り値:
Exp

atAndAssign

protected Exp atAndAssign(Exp e)
At and-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atAndAssign
パラメータ:
e - Exp
戻り値:
Exp

atOrAssign

protected Exp atOrAssign(Exp e)
At or-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atOrAssign
パラメータ:
e - Exp
戻り値:
Exp

atXorAssign

protected Exp atXorAssign(Exp e)
At xor-assign expression node.

オーバーライド:
クラス ToHirVisit 内の atXorAssign
パラメータ:
e - Exp
戻り値:
Exp

inInitBlock

protected boolean inInitBlock()
Return true if now processing in the initialization block.

戻り値:
boolean

visitProgram

public final void visitProgram()
Visit HIR program tree.


visitProgram

final void visitProgram(Program program)
Visit HIR program tree.

パラメータ:
program - Program

visitStmt

final void visitStmt(Stmt s)
Call appropriate method by operator of statement node.

パラメータ:
s - Visited statement.

atBlock

protected void atBlock(BlockStmt s)
At block statement node.

パラメータ:
s - BlockStmt

atLabeledStmt

protected void atLabeledStmt(LabeledStmt s)
At labeled statement node.

パラメータ:
s - LabeledStmt

atAssignStmt

protected void atAssignStmt(AssignStmt s)
At assign statement node.

パラメータ:
s - AssignStmt

atJump

protected void atJump(JumpStmt s)
At goto statement node.

パラメータ:
s - JumpStmt

visitExp

final Exp visitExp(Exp e)

atConst

protected Exp atConst(ConstNode e)
At constant node.

パラメータ:
e - Exp
戻り値:
Exp

atVar

protected Exp atVar(VarNode e)
At variable node.

パラメータ:
e - Exp
戻り値:
Exp

atSubp

protected Exp atSubp(SubpNode e)
At function node.

パラメータ:
e - Exp
戻り値:
Exp

atElem

protected Exp atElem(ElemNode e)
At element node.

パラメータ:
e - Exp
戻り値:
Exp

atIndex

protected Exp atIndex(Exp e)
At index expression node.

パラメータ:
e - Exp
戻り値:
Exp

atQual

protected Exp atQual(Exp e)
At member-access expression node.

パラメータ:
e - Exp
戻り値:
Exp

atArrow

protected Exp atArrow(Exp e)
At arrow expression node.

パラメータ:
e - Exp
戻り値:
Exp

atAddr

protected Exp atAddr(Exp e)
At address expression node.

パラメータ:
e - Exp
戻り値:
Exp

atConv

protected Exp atConv(Exp e)
At cast expression node.

パラメータ:
e - Exp
戻り値:
Exp

atDecay

protected Exp atDecay(Exp e)
At decay expression node.

パラメータ:
e - Exp
戻り値:
Exp

atUndecay

protected Exp atUndecay(Exp e)
At undecay expression node.

パラメータ:
e - Exp
戻り値:
Exp

atContents

protected Exp atContents(Exp e)
At indirection expression node.

パラメータ:
e - Exp
戻り値:
Exp

atEqZero

protected Exp atEqZero(Exp e)
At logical-not expression node.

パラメータ:
e - Exp
戻り値:
Exp

atExpList

protected Exp atExpList(ExpListExp e)
At expression list node.

パラメータ:
e - Exp
戻り値:
Exp

atExpRepeat

protected Exp atExpRepeat(Exp e)
At expression repeatation node.

パラメータ:
e - Exp
戻り値:
Exp

atSubpDefinition

protected SubpDefinition atSubpDefinition(SubpDefinition s)
At block statement node.

パラメータ:
s - BlockStmt

atInfStmt

protected InfStmt atInfStmt(InfStmt pInf)
atInfStmt parses the pragma body in the form of String and change its symbols to instances of Sym (Var, Subp, Label, Const) and items enclosed in parenthesis to IrList changing its elements to Sym, etc. This may be called twice for the same pragma. In the second call, return pInf unchanged because it is already in the final form.

戻り値:
InfStmt having Sym elements and (nested) IrList.

processPragmaItem

IrList processPragmaItem(ParseString pParseString,
                         java.lang.String pNextItem,
                         IrList pList)