|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--coins.opt.GlobalReform
入れ子クラスの概要 | |
protected class |
GlobalReform.MatchingData
The class MatchingData represents various matching insormation and provides methods to set/refer them. |
protected class |
GlobalReform.NontermPatInstance
This class holds information for the instance of a nonterminal or a pattern and provides methods for them. |
protected class |
GlobalReform.OptInf
OptInf is used to represent an object instanciated for each pattern and nonterminal. |
protected class |
GlobalReform.PatternCodeRange
PatternCodeRange represents pattern code range including upper value and lower value. |
フィールドの概要 | |
protected boolean |
fChanged
|
protected int[] |
fCodeIndexFrom
|
protected int[] |
fCodeIndexTo
|
protected CoinsOptions |
fCoinsOptions
|
protected java.util.Set |
fCompileTimeEval
|
protected Subp |
fCurrentPatternSym
|
protected Stmt |
fCurrentStmt
|
protected int |
fDbgLevel
|
(パッケージプライベート) static double |
fDontCareCode
|
protected java.util.Map |
fExpandedNonterm
|
protected java.util.Map |
fExpandedNontermInstance
|
protected java.util.Set |
fFittingSet
|
protected java.util.Set |
fFitToAnyCall
|
protected java.util.Set[] |
fFormalParams
|
protected java.util.Map |
fGlobalPatternParamMap
|
(パッケージプライベート) static double |
fHirCodeLim
|
(パッケージプライベート) static double |
fHirCodeLim2
|
(パッケージプライベート) static double |
fHirCodeLim3
|
(パッケージプライベート) static double |
fHirCodeLim4
|
(パッケージプライベート) static double |
fHirCodeLim5
|
(パッケージプライベート) static double |
fHirCodeLim6
|
protected java.util.Set |
fHirKeys
|
protected java.util.Map |
fInPatternMap
|
protected int[] |
fInstanceNumberForNonterminals
|
protected GlobalReform.MatchingData[] |
fLastMatchingDataForNonterm
|
protected java.util.Map |
fLocalVarListMap
|
protected java.util.Map |
fMatchingDataForNonterm
|
protected java.util.Map |
fMatchingDataForNontermInstance
|
protected int |
fMaxStmtsInPattern
|
protected Stmt |
fNextStmt
|
protected double |
fNextStmtCode
|
protected java.util.Set |
fNoFurtherChange
|
protected java.util.List |
fNonterminalList
|
protected java.util.Set |
fNonterminalParameters
|
protected java.util.Set |
fNonterminalSet
|
protected java.util.Map |
fNontermInstanceInPattern
|
protected Subp[] |
fNontermPat
|
protected int |
fNontermPatCount
|
protected GlobalReform.NontermPatInstance |
fNontermPatInstanceOfCurrentPattern
|
protected java.util.Map |
fOptionMap
|
protected java.util.Map |
fOriginalVarMap
|
protected java.util.Map |
fOutPatternMap
|
protected double[] |
fPatternCodeLower
|
protected double[] |
fPatternCodeUpper
|
protected int |
fPatternCount
|
protected java.util.List |
fPatternList
|
protected java.util.Set |
fPatternParameters
|
protected int |
fProductionCount
|
protected java.util.Map |
fProductionMap
|
protected int[] |
fProductionsInNonterminal
|
protected int[] |
fStmt1CodeIndexFrom
|
protected int[] |
fStmt1CodeIndexTo
|
protected int[] |
fStmt2CodeIndexFrom
|
protected int[] |
fStmt2CodeIndexTo
|
protected java.util.Set |
fStmtParamSet
|
protected int[] |
fStmtsInPattern
|
protected java.util.List |
fSubpToReform
|
protected int |
fSubrootCount
|
protected Stmt |
fTailStmtMatched
|
protected java.util.Map |
fTransparentMap
|
protected boolean[] |
fUsedAsPatternRoot
|
protected boolean[] |
fUsedAsSubRoot
|
protected HIR |
hir
|
protected HirRoot |
hirRoot
|
protected IoRoot |
ioRoot
|
protected SymRoot |
symRoot
|
コンストラクタの概要 | |
GlobalReform(HirRoot pHirRoot)
Constructor GlobalTransform. |
メソッドの概要 | |
protected java.util.Map |
adjustMatchingData(GlobalReform.MatchingData pData,
java.util.Map pParamCorresp)
Get the HIR corresponding to pattern parameters that are given as keys of pParamCorresp which maps pattern parameters to primary HIR that may contain parameters. |
protected HIR |
adjustNonterminal(GlobalReform.MatchingData pData,
GlobalReform.NontermPatInstance pNontermPatInstance,
HIR pCallNode,
java.util.Set pTraversedMatchingData,
int pNthInstance,
boolean pRevisedMatchingData)
Change a nonterminal call to a plain HIR subtree that has resolved parameters and nonterminal calls by executing following steps: (1) Get the instance of MatchingData lData1 corresponding to the nonterminal call pCallNode. |
protected HIR |
adjustOutPattern(GlobalReform.MatchingData pData,
HIR pOutHir,
java.util.Set pTraversedMatchingData,
int pNthInstance)
Adjust the out pattern pOutHir corresponding to the pattern/nonterminal represented by pData, that is, If pOutHir is a pattern/nonterminal param node, then replace it by the HIR corresponding to it; If pOutHir represents a nonterminal, then replace it by the expanded HIR corresponding to it invoking adjustNonterminal with a MachingData obtained by copying pData; If pOutHir represents _reform(n_th_instance, patternParam, replacementExp, nonterminalCallExp), then expand the nonterminal and then replace the pattern parameter (patternParam) contained in it with replacementExp and then replace the pattern parameters according to the correspondence given in pData. |
protected HIR |
adjustType(Exp pExp,
Type pType)
|
protected boolean |
checkConsistency(Subp pPattern,
java.util.List pLocalVarList,
HIR pInPattern,
HIR pOutPattern)
Check the consistency of parameters in in-pattern and out-pattern. |
protected void |
computePatternCodeRange()
computePatternCodeRange compute pattern code range (fPatternCodeUpper and fPatternCodeLower) of all patterns. |
protected GlobalReform.PatternCodeRange |
computePatternCodeRangeOf(HIR pHir)
computePatternCodeRangeOf(.....) computes pattern code range of pHir and set upper to pUpper[0], loper to pLower[0]. |
protected java.lang.String |
dbgMap(java.util.Map pMap)
make the text string showing the contents of the map pMap. |
protected void |
dbgOut(int pLevel,
java.lang.String pMessage)
|
protected void |
dbgOut(int pLevel,
java.lang.String pMessageClass,
java.lang.String pMessage)
|
protected java.lang.String |
dbgSet(java.util.Set pSet)
|
boolean |
doReform(java.util.List pReformPatternList)
doReform transforms subprograms listed up in #pragma globalReform target subp1 subp2 ... |
protected HIR |
evaluateReform(GlobalReform.MatchingData pData,
HIR pOutHir,
java.util.Set pTraversedMatchingData)
Evaluate the special function _reform by calling reformByChangingParam( ... ) after examining given arguments. |
protected HIR |
expandExp(GlobalReform.MatchingData pData,
HIR pExp,
GlobalReform.NontermPatInstance pParentNonterm)
Expand all nonterminal calls in pExp to the the expandedExp of the nonterminal instance corresponding to the nonterminal call. |
protected HIR |
expandNonterminal(GlobalReform.MatchingData pData,
GlobalReform.NontermPatInstance pNontermPatInstance,
HIR pCallExp,
java.util.Set pTraversedNonterminals)
expandNonterminal expands the right hand side of the selected productin of the nonterminal pNontermPatInstance and return it. |
protected HIR |
expandOutPattern(GlobalReform.MatchingData pData,
HIR pOutHir,
java.util.Set pTraversedNonterminals)
expandOutPattern expands pOutHir according to pData. |
protected HIR |
getExpandedHir(HIR pCallExp,
GlobalReform.NontermPatInstance pNontermInstance)
Get the expanded HIR corresponding to pCallExp calling pNonterminal. |
protected java.util.Map |
getFormalActualParamCorrespondence(GlobalReform.MatchingData pData,
GlobalReform.NontermPatInstance pNontermPat,
HIR pCallNode,
boolean pAdjustPhase)
Get formal-actual parameter correspondence for the nonterminal pNontermPat that is called by the node pCallNode and return the correspondence. |
(パッケージプライベート) int |
getIndex(Subp pSubp)
Get the index number of a pattern or a nonterminal. |
protected java.util.Set |
getLeafOperands(HIR pHir)
Get the set of leaf operands of pHir. |
protected GlobalReform.NontermPatInstance |
getNontermInstance(Subp pNonterm,
HIR pCallExp,
GlobalReform.NontermPatInstance pParentInstance)
Get the instance of the nonterminal pNonterm corresponding to the nonterminal call expression pCallExp seeing callToNontermInstanceMap of the parent nonterminal pParentInstance. |
protected Param |
getOriginalParam(Param pParam)
Get the original parameter from which pParam is instanciated. |
protected Var |
getOriginalVar(Var pVar)
Get the original variable from which pVar is instanciated. |
protected java.util.Map |
getParamCorrespForArgWithNonterm(GlobalReform.MatchingData pData,
HIR pArgExp,
Sym pCallerFormalParam,
GlobalReform.NontermPatInstance pParentNonterm,
boolean pAdjustPhase)
Get formal-actual parameter correspondence for the formal parameter pCallerFormalParam and actual parameter pArgExp that calls child nonterminal. |
protected Param |
getParamInstance(Param pParam,
GlobalReform.NontermPatInstance pNontermInstance)
Get the parameter instanciated from pParam for the instance of the nonterminal pNontermInstance. |
protected Var |
getVarInstance(Var pVar,
GlobalReform.NontermPatInstance pNontermInstance)
Get the variable instanciated from pVar for the instance of the nonterminal pNontermInstance. |
java.lang.String |
hirToString(HIR pHir)
|
protected Param |
instanciateParam(Subp pNonterm,
Param pParam,
int pInstanceNumber)
Get a new instance of the parameter pParam used in the nonterminal pnonterm. |
protected Var |
instanciateVar(Subp pNonterm,
Var pVar,
int pKind,
int pInstanceNumber)
Get the new instance of the variable pVar. |
protected boolean |
isFittingSym(Sym pSym)
If pSym is a fitting symbol or an instance of a fitting symbol, then return true, else return false. |
protected boolean |
isMatchedArray(GlobalReform.MatchingData pData,
HIR pSubPattern,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedArray discriminates whether HIR subtree pHir matches with the pattern pSubPattern (in-pattern or part of in-pattern) comparing pHir with pSubPattern where pHir or pSubPattern may be an expression representing an array (vector) or array element. |
protected boolean |
isMatchedAssignStmt(GlobalReform.MatchingData pData,
GlobalReform.NontermPatInstance pNontermInstance,
HIR pNontermCall,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
Examine whether the assign statement pHir matches with the pattern specified by _assignStmt. |
protected boolean |
isMatchedCondition(GlobalReform.MatchingData pData,
HIR pSubPattern,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedCondition: Check comparison expression having different operation code, where either pSubPattern or pHir have comparison operator. |
protected boolean |
isMatchedNonterminal(GlobalReform.MatchingData pData,
GlobalReform.NontermPatInstance pNontermInstance,
HIR pNontermCall,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedNonterminal discriminates whether the nonterminal (pMetaSym) refered by pNonterminalCall matches with the input HIR tree pHir. |
protected boolean |
isMatchedPattern(GlobalReform.MatchingData pData,
HIR pSubPattern,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedPattern discriminates whether HIR subtree pHir matches with the pattern pSubPattern (in-pattern or a part of in-pattern) comparing pHir with pSubPattern. |
protected boolean |
isMatchedStmtSeq(GlobalReform.MatchingData pData,
HIR pSubPattern,
Stmt pStmt,
int pPatternIndex,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedStmtSeq discriminates whether HIR subtree matches with the pattern pSubPattern (in-pattern or part of in-pattern) that is a sequence of statements comparing the statement sequence starting with pStmt. |
protected boolean |
isMatchedSubs(GlobalReform.MatchingData pData,
HIR pSubPattern,
HIR pHir,
GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
isMatchedSubs discriminates whether HIR subtree pHir matches with the pattern pSubPattern (in-pattern or part of in-pattern) comparing pHir with pSubPattern where pHir or pSubPattern may be an expression representing an array element. |
protected boolean |
isNontermParam(Sym pSym)
If pSym is a nonterminal parameter or an instance of a nonterminal parameter, then return true, else return false. |
protected boolean |
isPatternParam(Sym pSym)
If pSym is a pattern parameter or an instance of a pattern parameter, then return true, else return false. |
protected boolean |
isSameTree(HIR pTree1,
HIR pTree2)
isSameTree is a little different from that of coins.flow.HirSubpFlowImpl. |
protected boolean |
isTransparent(Var pDeclVar,
HIR pHir,
GlobalReform.MatchingData pData)
If pDeclVar is declared as transparent to some variables and if pHir contains any of such variables or pDeclVar is included in pHir then pHir is treated as not transparent to pDeclVar |
protected void |
listUpHeadingHir(Subp pNontermPatSym,
java.util.List pHeadingHirList,
HIR pHir)
List up top subtrees for pHir and add the subtrees to pHeadingHirList. |
protected HIR |
makeHirKey(HIR pExp)
Make an HIR that can be used as a key of maps so that there is only one instance for each group of HIR subtrees where member subtrees have the same shape when they are included in the same group (keeping one to one correspondence between key and group). |
protected void |
makeParamCorrespComplete(GlobalReform.MatchingData pData)
If a nonterminal param is mapped to a pattern param directly or indirectly (by tracing the sequence of nontermParam-to-nontermParam correspondence), then record the HIR corresponding to the nonterm parameter as the HIR corresponding to the pattern parameter. |
protected double |
patternCode(HIR pHir)
Compute the pattern code of pHir digging out up to 2 levels of children. |
(パッケージプライベート) boolean |
postProcess(boolean pMatched,
java.util.Map pGlobalPatternParamMap,
GlobalReform.MatchingData pData)
If matching failed, then restore fGlobalPatternParamMap by their previous value pGlobalPatternParamMap. |
protected void |
processTransparent(Subp pPattern,
java.lang.String pOptionName,
IrList pOptionList)
Process the pragma specifications such as #pragma globalReform transparentFitting pc (pzz2, pi2) and record the transparency relations to fTransparentMap. |
protected void |
putToMap(java.util.Map pMap,
Sym pSym,
HIR pHir)
Put the correspondence of pSym-pHir to pMap if it is not a circular reference that is, if pSym is not an operand of pHir. |
protected void |
recordExpandedHir(HIR pCallExp,
HIR pExpandedHir,
GlobalReform.NontermPatInstance pNontermPatInstance)
Record the copy of pExpandedHir to fExpandedNontermInstance using pNontermPatInstance as key and fExpandedNonterm using makeHirKey(pCallExp) as key. |
protected boolean |
recordParamCorresp(GlobalReform.MatchingData pData,
Sym pParam,
HIR pHir)
Record the correspondence between the parameter pParam and the (matched) input pHir. |
protected HIR |
reformByChangingParam(GlobalReform.MatchingData pData,
HIR pNontermCall,
HIR pParamNode,
HIR pRewriteExp,
java.util.Set pTraversedMatchingData,
int pNthInstance)
reformByChangingParam does the transformation specified by _reform(n_th_instance, patternParam, replacementExp, nonterminalCallExp) |
protected HIR |
replaceExpAdjustingType(Exp lOld,
Exp lNew)
Replace expression lOld by lNew adjusting type to that of lOld. |
protected HIR |
replaceHirTree(HIR pOld,
HIR pNew)
Replace pOld with pNew according to their kind. |
protected HIR |
replaceParameters(GlobalReform.MatchingData pData,
HIR pOutHir,
java.util.Set pTraversedMatchingData,
boolean pNontermParamOnly)
Replace nonterminal/pattern parameters and fitting symbols contained in pOutHi by the HIR correnponding to the parameters or fitting symbols where the correspondence is given by pData. |
protected HIR |
replaceStatementParameter(GlobalReform.MatchingData pData,
SymNode pSymNode,
java.util.Set pTraversedMatchingData,
boolean pNontermParamOnly)
Replace the node of statement parameter with the sequence of statements corresponding to it. |
protected void |
setNonterminalFlag(HIR pPattern)
Set FLAG_NONTERMINAL to all call nodes that call _bnfOr, _bnfSeq, or _assignStmt contained in pPattern. |
(パッケージプライベート) int |
setPatternCodeRange(int pStartIndex,
java.util.List pRangeList)
Set the pattern code ranges in pRangeList to fPatternCodeUpper/Lower starting from pStartIndex and return the updated next index value. |
protected HIR |
traceParamCorresp(GlobalReform.MatchingData pData,
Var pParamInstance,
HIR pMatchedHir,
boolean pAdjustPhase)
Trace the sequence of nonterminal parameter replacement and return the HIR that corresponds to the parameter pParamInstance directly or indirectly. |
protected HIR |
traceParamCorrespSimply(GlobalReform.MatchingData pData,
Var pParamInstance)
|
protected HIR |
traceReplacementSeq(GlobalReform.MatchingData pData,
Sym pParam,
java.util.Set pTracedParam,
java.util.Set pTraversedMatchingData,
boolean pNontermParamOnly)
traceReplacementSeq gets replica HIR that is used to replace pParam which may be either a nonterminal parameter or a pattern parameter. |
protected HIR |
transformByPatternSym(GlobalReform.MatchingData pData,
Subp pPatternSym,
HIR pInHir)
transformByPatternSym transforms pInHir according to the pair of in-pattern and out-pattern defined by pPatternSym. |
protected HIR |
transformStmtSeq(GlobalReform.MatchingData pData,
Subp pPatternSym,
Stmt pInStmt)
Transform the statement sequence beginning with pInStmt that matched with the statement pattern pPatternsym by applying adjustOutPattern to the corresponding out-pattern and then applying replaceParameters to the adjusted result. |
protected HIR |
tryToReform(GlobalReform.MatchingData pData,
HIR pHir)
Try to transform given HIR subtree pHir. |
クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
フィールドの詳細 |
protected HirRoot hirRoot
protected SymRoot symRoot
protected IoRoot ioRoot
protected java.util.Map fOptionMap
protected CoinsOptions fCoinsOptions
protected java.util.List fPatternList
protected java.util.Map fInPatternMap
protected java.util.Map fOutPatternMap
protected java.util.List fNonterminalList
protected java.util.Set fNonterminalSet
protected java.util.Map fProductionMap
protected java.util.Set fFittingSet
protected java.util.Map fTransparentMap
protected int fPatternCount
protected int fNontermPatCount
protected int fSubrootCount
protected int fProductionCount
protected Subp[] fNontermPat
protected java.util.Map fLocalVarListMap
protected java.util.List fSubpToReform
protected java.util.Set fStmtParamSet
protected java.util.Set fNoFurtherChange
protected java.util.Set fCompileTimeEval
protected java.util.Set fFitToAnyCall
protected Subp fCurrentPatternSym
protected boolean[] fUsedAsPatternRoot
protected boolean[] fUsedAsSubRoot
protected int[] fCodeIndexFrom
protected int[] fCodeIndexTo
protected int[] fStmt1CodeIndexFrom
protected int[] fStmt1CodeIndexTo
protected int[] fStmt2CodeIndexFrom
protected int[] fStmt2CodeIndexTo
protected double[] fPatternCodeUpper
protected double[] fPatternCodeLower
protected int[] fStmtsInPattern
protected java.util.Set fPatternParameters
protected java.util.Set fNonterminalParameters
protected int[] fProductionsInNonterminal
protected int fMaxStmtsInPattern
protected double fNextStmtCode
protected Stmt fCurrentStmt
protected Stmt fNextStmt
protected Stmt fTailStmtMatched
protected java.util.Map fMatchingDataForNontermInstance
protected java.util.Map fMatchingDataForNonterm
protected GlobalReform.MatchingData[] fLastMatchingDataForNonterm
protected java.util.Map fGlobalPatternParamMap
protected java.util.Map fExpandedNontermInstance
protected java.util.Map fExpandedNonterm
protected GlobalReform.NontermPatInstance fNontermPatInstanceOfCurrentPattern
protected java.util.Set fHirKeys
protected java.util.Set[] fFormalParams
protected int[] fInstanceNumberForNonterminals
protected java.util.Map fOriginalVarMap
protected java.util.Map fNontermInstanceInPattern
static double fHirCodeLim
static double fDontCareCode
static double fHirCodeLim2
static double fHirCodeLim3
static double fHirCodeLim4
static double fHirCodeLim5
static double fHirCodeLim6
protected boolean fChanged
protected int fDbgLevel
protected HIR hir
コンストラクタの詳細 |
public GlobalReform(HirRoot pHirRoot)
pHirRoot
- HirRoot conveyed.メソッドの詳細 |
public boolean doReform(java.util.List pReformPatternList)
pReformPatternList
- is empty at entry and contains
all patterns specified by #pragma globalReform at exit.
protected HIR tryToReform(GlobalReform.MatchingData pData, HIR pHir)
pHir
- HIR subtree to be transformed or statement
from which matching is to be started.
protected boolean isMatchedPattern(GlobalReform.MatchingData pData, HIR pSubPattern, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- matching data.pSubPattern
- in-pattern or part of in-pattern.pHir
- input expression/statement to be compared
with pSubPattern.pAncestorNontermPatInstance
- ancestor instance
of nonterminal or pattern.
boolean postProcess(boolean pMatched, java.util.Map pGlobalPatternParamMap, GlobalReform.MatchingData pData)
pMatched
- true if the matching succeeded, otherwise false.pGlobalPatternParamMap
- Previous pattern param mapping.
protected boolean isMatchedSubs(GlobalReform.MatchingData pData, HIR pSubPattern, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- matching data.pSubPattern
- in-pattern or its subexpression.pHir
- part of input program to be matched.pAncestorNontermPatInstance
- ancestor instance
of nonterminal or pattern.
protected boolean isMatchedArray(GlobalReform.MatchingData pData, HIR pSubPattern, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- matching data.pSubPattern
- in-pattern or its subexpression.pHir
- part of input program to be matched.pAncestorNontermPatInstance
- ancestor instance
of nonterminal or pattern.
protected boolean isMatchedStmtSeq(GlobalReform.MatchingData pData, HIR pSubPattern, Stmt pStmt, int pPatternIndex, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- Maching data.pSubPattern
- Pattern taking the form of a sequence
of statements.pStmt
- Statement from which comparison should
take place.pPatternIndex
- Index assigned to the pattern
(used to the number of statements in the pattern).pAncestorNontermPatInstance
- ancestor instance
of nonterminal or pattern.
protected boolean isMatchedCondition(GlobalReform.MatchingData pData, HIR pSubPattern, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- matching data.pSubPattern
- in-pattern or part of in-pattern.pHir
- input expression/statement to be compared
with pSubPattern.pAncestorNontermPatInstance
- ancestor instance
of nonterminal or pattern.
protected boolean isMatchedNonterminal(GlobalReform.MatchingData pData, GlobalReform.NontermPatInstance pNontermInstance, HIR pNontermCall, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- MatchingData to be refered and updated
in the matching.pNontermInstance
- Nonterminal instanciated for this
call (pNontermCall) which may be defined nonterminal
or meta symbol (_bnfOr, _bnfSeq, _reform).pNontermCall
- Expression calling pMetaSym.pHir
- Input HIR to be matched with the nonterminal.pAncestorNontermPatInstance
- Nonterminal instance
in which body the current nonterminal is instanciated
(by pNontermCall).
protected boolean isMatchedAssignStmt(GlobalReform.MatchingData pData, GlobalReform.NontermPatInstance pNontermInstance, HIR pNontermCall, HIR pHir, GlobalReform.NontermPatInstance pAncestorNontermPatInstance)
pData
- Matching data to be used.pNontermInstance
- Instance of the nonterminal
(_assignStmt) representing the pattern.pNontermCall
- HIR expression calling _assignStmt.pHir
- HIR to be matched with the pattern.pAncestorNontermPatInstance
- Ancestor pattern or
ancestor nonterminal.
protected HIR transformByPatternSym(GlobalReform.MatchingData pData, Subp pPatternSym, HIR pInHir)
pData
- matching data.pPatternSym
- pattern symbol showing in-pattern and
out-pattern to be used in transformation.pInHir
- a part of input program to be transformed.
protected HIR expandOutPattern(GlobalReform.MatchingData pData, HIR pOutHir, java.util.Set pTraversedNonterminals)
pData
- Matching data to be used.pOutHir
- HIR to be expanded.pTraversedNonterminals
- Set of traverced nonterminal
instances (used to avoid infinite loop).
protected HIR expandNonterminal(GlobalReform.MatchingData pData, GlobalReform.NontermPatInstance pNontermPatInstance, HIR pCallExp, java.util.Set pTraversedNonterminals)
pData
- MatchingData to be used.pNontermPatInstance
- Instance of a nonterminal.pCallExp
- Expression that calls the nonterminal.pTraversedNonterminals
- Set of traverced nonterminal
instances (used to avoid infinite loop).
protected HIR adjustOutPattern(GlobalReform.MatchingData pData, HIR pOutHir, java.util.Set pTraversedMatchingData, int pNthInstance)
pData
- Matching data to be used.pOutHir
- Out pattern corresponding to the pattern/nonterminal
represented by pData (it is already a copy and
unnecessary to be copied in this method).pTraversedMatchingData
- Set of traversed matching data
to be used to avoid the application of the same matching data.pNthInstance
- Sequence number (0, 1, 2, ...) assigned
to a nonterminal call to distinguish it from other nonterminal
calls having the same form in the definiton of a pattern.
protected HIR adjustNonterminal(GlobalReform.MatchingData pData, GlobalReform.NontermPatInstance pNontermPatInstance, HIR pCallNode, java.util.Set pTraversedMatchingData, int pNthInstance, boolean pRevisedMatchingData)
pData
- MatchingData instance to be used.pNontermPatInstance
- Nonterminal instance.pCallNode
- Nonterminal call node that instanciated
pNontermPatInstance.pTraversedMatchingData
- pNthInstance
- Sequence number (0, 1, 2, ...) assigned
to a nonterminal call to distinguish it from other nonterminal
calls having the same form in the definiton of a pattern.pRevisedMatchingData
- true if pData is a revised one and
unnecessary to use getMatchingData method.
protected HIR evaluateReform(GlobalReform.MatchingData pData, HIR pOutHir, java.util.Set pTraversedMatchingData)
pData
- Matching data to be used.pOutHir
- expanded HIR to be transformed.pTraversedMatchingData
- Set of traversed matching data.
protected java.util.Map adjustMatchingData(GlobalReform.MatchingData pData, java.util.Map pParamCorresp)
pData
- The instance of MatchingData to be used
in tracing the correspondence of parameters.pParamCorresp
- Input correspondence of pattern
parameters and replacement expressions.
protected HIR traceReplacementSeq(GlobalReform.MatchingData pData, Sym pParam, java.util.Set pTracedParam, java.util.Set pTraversedMatchingData, boolean pNontermParamOnly)
pData
- Matching data used in the replacement.pParam
- a pattern parameter or a nonterminal parameter.pTracedParam
- Set of traced parameters.pTraversedMatchingData
- Set of traversed matching data.pNontermParamOnly
- true if replacement is to be done for
nonterminal parameters and leave pattern parameters unchanged,
false if both of pattern parameters and nonterminal parameters
are to be replaced.
protected HIR traceParamCorresp(GlobalReform.MatchingData pData, Var pParamInstance, HIR pMatchedHir, boolean pAdjustPhase)
pData
- Matching data to be used in tracing the replacement
sequence.pParamInstance
- Instance of nonterminal parameter or pattern parameter.pMatchedHir
- Input HIR that matched to pParam.pAdjustPhase
- true if called in adjustOutPattern/adjustNonterminal,
false otherwize.
protected HIR traceParamCorrespSimply(GlobalReform.MatchingData pData, Var pParamInstance)
protected void makeParamCorrespComplete(GlobalReform.MatchingData pData)
pData
- Matching data in which nontermParam-to-nontermParam
correspondence is to be traced.protected HIR replaceParameters(GlobalReform.MatchingData pData, HIR pOutHir, java.util.Set pTraversedMatchingData, boolean pNontermParamOnly)
pData
- Matching data giving the correspondence of
parameters and HIR subtrees.pOutHir
- HIR subtree whose parameter nodes are
to be replaced (copy should be given if original HIR
subtree should not be changed).pTraversedMatchingData
- Set of matching data already
traversed (used to escape from infinite loop).pNontermParamOnly
- Set true if only nonterminal
parameter nodes are to be replaced and leave pattaern
parameter nodes are to be left unchanged, set false if
both of nonterminal/pattern parameter nodes are to be
replaced.
protected HIR replaceStatementParameter(GlobalReform.MatchingData pData, SymNode pSymNode, java.util.Set pTraversedMatchingData, boolean pNontermParamOnly)
pData
- MatchingData to be used.pSymNode
- Statement parameter node.pTraversedMatchingData
- Set of matching data already
traversed (used to escape from infinite loop).pNontermParamOnly
- Set true if only nonterminal
parameter nodes are to be replaced and leave pattaern
parameter nodes are to be left unchanged, set false if
both of nonterminal/pattern parameter nodes are to be
replaced.
protected HIR reformByChangingParam(GlobalReform.MatchingData pData, HIR pNontermCall, HIR pParamNode, HIR pRewriteExp, java.util.Set pTraversedMatchingData, int pNthInstance)
pData
- Matching data to be used.pNontermCall
- Nonterminal call expression specified
in _reform expression.pParamNode
- Parameter node to be rewritten as
as specified in _reform expression.pRewriteExp
- HIR to be used to replace pParamNode
as specified in _reform expression.pTraversedMatchingData
- Set of matching data already
traversed (used to convey information to adjustNonterminal).pNthInstance
- Sequence number of nonterminal instance
among the instances having the same form of call expression
in the in-pattern.
protected HIR transformStmtSeq(GlobalReform.MatchingData pData, Subp pPatternSym, Stmt pInStmt)
pData
- MatchingData instance to be used.pPatternSym
- Pattern symbol representing a statement pattern.pInStmt
- Heading statement of the matched statement sequence.
protected java.util.Map getFormalActualParamCorrespondence(GlobalReform.MatchingData pData, GlobalReform.NontermPatInstance pNontermPat, HIR pCallNode, boolean pAdjustPhase)
pData
- MatchingData inherited.pNontermPat
- nonterminal instance.pCallNode
- Node calling the nonterminal.pAdjustPhase
- True if called in adjust phase, false otherwise.
protected java.util.Map getParamCorrespForArgWithNonterm(GlobalReform.MatchingData pData, HIR pArgExp, Sym pCallerFormalParam, GlobalReform.NontermPatInstance pParentNonterm, boolean pAdjustPhase)
pData
- Inherited MatchingData.pArgExp
- Actual parameter that calls child nonterminal.pCallerFormalParam
- Formal parameter corresponding to pArgExp.pParentNonterm
- Nonterminal that calls the child nonterminal.
protected HIR expandExp(GlobalReform.MatchingData pData, HIR pExp, GlobalReform.NontermPatInstance pParentNonterm)
pData
- MatchingData to be used.pExp
- HIR to be expanded.pParentNonterm
- Nonterminal instance
protected boolean checkConsistency(Subp pPattern, java.util.List pLocalVarList, HIR pInPattern, HIR pOutPattern)
pPattern
- subprogram representing a pattern.pLocalVarList
- list of variables declared locally
in pOutPattern.pInPattern
- in-pattern.pOutPattern
- out-pattern.
protected double patternCode(HIR pHir)
pHir
- geven HIR subtree.
protected void computePatternCodeRange()
protected GlobalReform.PatternCodeRange computePatternCodeRangeOf(HIR pHir)
pHir
- HIR for which the pattern code range is to be computed.int setPatternCodeRange(int pStartIndex, java.util.List pRangeList)
pStartIndex
- start position to store the pattern codes.pRangeList
- list of pattern codes.
protected HIR replaceExpAdjustingType(Exp lOld, Exp lNew)
lOld
- old expression to be replaced.lNew
- new expression for replacement.
protected HIR adjustType(Exp pExp, Type pType)
protected HIR replaceHirTree(HIR pOld, HIR pNew)
pOld
- Old HIR to be replaced.pNew
- New HIR used to replace.
protected boolean isSameTree(HIR pTree1, HIR pTree2)
pTree1
- HIR tree to be compared.pTree2
- Another HIR tree to be compared.
protected void processTransparent(Subp pPattern, java.lang.String pOptionName, IrList pOptionList)
pPattern
- Pattern symbol.pOptionName
- Option name ("transparentFitting", etc.).pOptionList
- List of the transparency relation.protected void setNonterminalFlag(HIR pPattern)
pPattern
- HIR to which nodes nonterminal flag is
to be attached.int getIndex(Subp pSubp)
pSubp
- is a pattern or a nonterminal.
protected boolean isTransparent(Var pDeclVar, HIR pHir, GlobalReform.MatchingData pData)
pDeclVar
- variable that should be transparent.pHir
- HIR to be examined.
protected java.util.Set getLeafOperands(HIR pHir)
pHir
- HIR subtree.
protected void listUpHeadingHir(Subp pNontermPatSym, java.util.List pHeadingHirList, HIR pHir)
pNontermPatSym
- pattern symbol or nonterminal symbol.pHeadingHirList
- is a list to which top subtrees are
to be added.pHir
- is the right-hand side of the production
corresponding to the pattern or the nonterminal.protected boolean recordParamCorresp(GlobalReform.MatchingData pData, Sym pParam, HIR pHir)
pData
- matching data inherited.pParam
- symbol that may be (1) a pattern/nonterminal parameter instance
or (2) a pattern symbol itself representing recursive function
or (3) a fitting symbol instance.pHir
- input HIR that is treaded as matched with pParam.
protected void putToMap(java.util.Map pMap, Sym pSym, HIR pHir)
pMap
- map to record the correspondence.pSym
- variable (usually a parameter instance).pHir
- HIR subtree that corresponds to pSym.protected void dbgOut(int pLevel, java.lang.String pMessage)
protected void dbgOut(int pLevel, java.lang.String pMessageClass, java.lang.String pMessage)
protected java.lang.String dbgMap(java.util.Map pMap)
pMap
- Map to be displayed in the form of text string.
protected java.lang.String dbgSet(java.util.Set pSet)
public java.lang.String hirToString(HIR pHir)
protected void recordExpandedHir(HIR pCallExp, HIR pExpandedHir, GlobalReform.NontermPatInstance pNontermPatInstance)
pCallExp
- call expression for the nonterminal.pExpandedHir
- expanded HIR for the nonterminal.pNontermPatInstance
- nonterminal instance.protected HIR getExpandedHir(HIR pCallExp, GlobalReform.NontermPatInstance pNontermInstance)
pCallExp
- expression calling pNonterminal.
protected HIR makeHirKey(HIR pExp)
pExp
- HIR subtree to which key is to be searched.
protected GlobalReform.NontermPatInstance getNontermInstance(Subp pNonterm, HIR pCallExp, GlobalReform.NontermPatInstance pParentInstance)
pNonterm
- Nonterminal symbol.pCallExp
- Nonterminal call expression.pParentInstance
- Instance of parent nonterminal or pattern
whose definition body contains the nonterminal call pCallExp.
protected Param instanciateParam(Subp pNonterm, Param pParam, int pInstanceNumber)
pNonterm
- Nonterminal symbol.pParam
- Formal parameter of pNonterm.pInstanceNumber
- Instance number.
protected Var instanciateVar(Subp pNonterm, Var pVar, int pKind, int pInstanceNumber)
pNonterm
- Nonterminal containing the variable pVar.pVar
- Variable symbol.pKind
- Symbol kind of the variable.pInstanceNumber
- Instance number within the nonterminal
(this parameter is not yet used).
protected Param getParamInstance(Param pParam, GlobalReform.NontermPatInstance pNontermInstance)
pParam
- Formal parameter from which new parameter
is instanciated.pNontermInstance
- Instance of a nonterminal.
protected Var getVarInstance(Var pVar, GlobalReform.NontermPatInstance pNontermInstance)
pVar
- Variable from which new variable is instanciated.pNontermInstance
- Instance of a nonterminal.
protected Param getOriginalParam(Param pParam)
pParam
- Instance of a formal parameter.
protected Var getOriginalVar(Var pVar)
pVar
- Instance of a variable.
protected boolean isPatternParam(Sym pSym)
pSym
- Symbol to be examined.
protected boolean isNontermParam(Sym pSym)
pSym
- Symbol to be examined.
protected boolean isFittingSym(Sym pSym)
pSym
- Symbol to be examined.
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |