|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
Subp interface
Subp (subprogram) class interface. Subprogram means such program construct as procedure, function, method, constructor, destructor, statement function, library function, etc. Each subprogram has its local symbol table which is maintained by pushSymbolTable, popSymbolTable, reopenSymbolTable in Sym interface. To define a subprogram, write such statement sequence as follows (see guidance.txt): Subp lMain = sym.defineSubp("main".intern(), symRoot.typeInt); //-- int printf(char* pFormat, ...); Subp lPrintf = sym.defineSubp("printf".intern(), symRoot.typeInt); Type lCharPtr = sym.pointerType(symRoot.typeChar); SymTable lLocalSymTable1 = symRoot.symTableRoot.pushSymTable(lPrintf); Param lParam1 = sym.defineParam("pFormat".intern(),symRoot.typeStringAny); lPrintf.addParam(lParam1); lPrintf.setOptionalParam(); lPrintf.setVisibility(Sym.SYM_EXTERN); lPrintf.closeSubpHeader(); lLocalSymTable1.popSymTable(); lLocalSymTable2 = symRoot.symTableRoot.pushSymTable(lMain); lMain.closeSubpHeader(); .... Enhancement is required to implement object oriented languages. (method overloading, etc.) Related methods: To traverse local symbols declared in this subprogram, use getSymNestIterator() of SymTable get by getSymTable(). To traverse local variables declared in this subprogram, use getVarIterator() of SymTable get by getSymTable(). To traverse formal parameters of this subprogram, use iterator() of IrList get by getParamList(). See methods of SubpDefinition interface such as getLirBody, initiationProcedure, addInitiationStmt, etc. See methods of SubpFlow interface such as getEntryBBlock, etc. See methods of DataFlow interface such as getBBlockList, etc.
フィールドの概要 |
インタフェース coins.sym.Sym から継承したフィールド |
KIND_NAME, VISIBILITY |
メソッドの概要 | |
void |
addParam(Param pParam)
addParam Add parameter to the parameter list of this subprogram. |
void |
addParamType(Type pParamType)
addParamType Add parameter type to a temporal parameter type list. |
void |
addToCallList(Subp pCallee)
addToCallList Add pCallee as a subprogram to the call list of this subprogram. |
void |
addToErrorCount(int pCount)
addToErrorCount Add pCount to the number of syntax/semantic error counter of this subprogram. |
void |
buildLabelRefList()
Build the list of labels defined in the subprogram so as getLabelDefList() returns proper list, and build the list of LabelNode for every labels to show the label node refering them. |
void |
closeSubpHeader()
closeSubpHeader Finalize the header part of subprogram. |
void |
closeSubpPrototype()
closeSubpPrototype Finalize a prototype declaration of subprogram. |
IrList |
getCallList()
getCallList Get the list of subprograms called in this subprogram. |
Label |
getEndLabel()
getEndLabel setEndLabel Get/set a label attached to the exit point of this subprogram. |
int |
getErrorCount()
getErrorCount Get the number of syntax/semantic errors of this subprogram. |
java.lang.Object |
getFlowInf()
Get/set information locally used for flow analysis, optimization, parallelyzation, etc. of this subprogram. (##5) The information will not conflict with others and will not be destroyed by aliasing. |
Stmt |
getHirBody()
getHirBody Get the procedural body in HIR of this subprogram. |
Subp |
getNextSubp()
getNextSubp Get the subprogram next to this one having the same scope as this. |
java.lang.Object |
getOptInf()
|
java.lang.Object |
getParallelInf()
|
IrList |
getParamList()
getParamList Get the parameter list of this subprogram. |
IrList |
getParamTypeList()
getParamTypeList Get the parameter type list of this subprogram. |
Type |
getReturnValueType()
getReturnValueType Get the return value type of this subprogram. |
Label |
getStartLabel()
getStartLabel setStartLabel Get/set a label attached to the entry point of this subprogram. |
Stmt |
getStmtWithLabel(Label pLabel)
getStmtWithLabel Get the HIR Stmt attached with pLabel. |
SubpDefinition |
getSubpDefinition()
getSubpDefinition Get the SubpDefinition node defining the IR body of this subprogram. |
int |
getSubpKind()
getSubpKind Get subprogram kind: (subpOrdinary/subpMember/subpConstructor/subpDestructor). |
SymTable |
getSymTable()
getSymTable Get the symbol table local to this subprogram. |
int |
getVisibility()
getVisibility Get the visibility attribute of the subprogram. |
boolean |
hasNoParamSpec()
|
boolean |
hasOptionalParam()
hasOptionalParam |
boolean |
isSafeArrayAll()
|
void |
printLabelRefList()
Print the label reference list built by buildLabelRefList(). |
void |
resetLabelLink()
resetLabelLink Reset label reference list of labels in this subprogram. |
void |
setEndLabel(Label pLabel)
|
void |
setFlowInf(java.lang.Object pInf)
|
void |
setHirBody(Stmt pHirBody,
Label pStartLabel,
Label pEndLabel)
setHirBody Set the procedural body of this subprogram represented in high level intermediate representation (HIR). |
void |
setNextSubp(Subp pNext)
setNextSubp Set pNext as the subprogram next to this one and make the original next subprogram as the next one of pNext. |
void |
setNoParamSpec()
Permit any number of parameters of any type for this subprogram. |
void |
setOptInf(java.lang.Object pInf)
|
void |
setParallelInf(java.lang.Object pInf)
|
void |
setReturnValueType(Type pType)
setReturnValueType Set the return value type of this subprogram. |
void |
setStartLabel(Label pLabel)
|
void |
setSubpDefinition(SubpDefinition pSubpDefinition)
setSubpDefinition Set the SubpDefinition node defining the IR body of this subprogram. |
void |
setSubpKind(int pSubpKind)
setSubpKind Set subprogram kind (subpOrdinary/subpMember/subpConstructor/subpDestructor). |
void |
setSymTable(SymTable pSymTalbe)
setSymTable Set the symbol table local to this subprogram. |
void |
setVisibility(int pVisibility)
SetVisibility Sset the visibility attribute of the subprogram. |
インタフェース coins.sym.Sym0 から継承したメソッド |
charConst, definedType, defineElem, defineLabel, defineParam, defineSubp, defineVar, enumType, floatConst, getDefinedFile, getDefinedIn, getFlag, getName, getNextSym, getRecordedIn, getSymKind, getSymType, getUniqueName, intConst, isGlobal, namedConst, pointerType, setFlag, stringConst, structType, subpType, unionType, vectorType, vectorTypeUnfixed |
メソッドの詳細 |
public Subp getNextSubp()
public void setNextSubp(Subp pNext)
pNext
- subprogram defined in the same scope as this
subprogram.public int getSubpKind()
public void setSubpKind(int pSubpKind)
pSubpKind
- subprogram kind to be set to this subprogram.public int getVisibility()
Get the visibility attribute of the subprogram. (SYM_EXTERN, SYM_PUBLIC, SYM_PROTECTED, SYM_PRIVATE, SYM_COMPILE_UNIT)
public void setVisibility(int pVisibility)
pVisibility
- visibility attribute to be set by setVisibility.
(SYM_EXTERN, SYM_PUBLIC, SYM_PROTECTED, SYM_PRIVATE,
SYM_COMPILE_UNIT)public SymTable getSymTable()
public void setSymTable(SymTable pSymTalbe)
public Type getReturnValueType()
public void setReturnValueType(Type pType)
pType
- the return value type.public IrList getParamList()
public IrList getParamTypeList()
public void addParam(Param pParam)
Add parameter to the parameter list of this subprogram. If closeSubpPrototype has been called by processing prototype declaration, getParamTypeList will return the list of parameter types. It is recommended to check the consistency between prototype declaration and subprogram definition before calling addParam for each parameter. If null is returned by getParamTypeList, then prototype declaration is not yet given (closeSubpPrototype is not yet called.) See closeSubpHeader.
public void addParamType(Type pParamType)
public void closeSubpHeader()
Finalize the header part of subprogram. This method will set subprogram type for this subprogram and set other inevitable information for this subprogram. Before calling this method, addParam, setOptionalParam, setVisibility should be called if required and return value type should be given if required as it is written in defineSubp of Sym interface. It is the responsibility of language dependent front end to check the consistency between prototype declaration and subprogram definition. If closeSubpPrototype has been called by processing prototype declaration, getParamTypeList will return the list of parameter types. It is recommended to check the consistency between prototype declaration and subprogram definition before calling addParam for each parameter. The closeSubpHeader will adjust the parameter type list according to the list get by getParamList and so the consistency check will not be effective after the call.
public void closeSubpPrototype()
Finalize a prototype declaration of subprogram. This method will set subprogram type for this subprogram. Before calling this method, addParamType, setOptionalParam, setVisibility should be called if required and return value type should also be given if required. It is the responsibility of language dependent front end to check the consistency between prototype declaration and subprogram definition. Typical sequence of processing prototype declaration is: Subp lSubp = symRoot.sym.defineSubp("name".intern(), returnType); lSubp.resetParamTypeList(); // If multiple declaration is allowed. lSubp.addParamType(paramType1); lSubp.addParamType(paramType2); .... lSubp.setOptionalparam(); // only when optional parameter is given. lSubp.setVisibility(Sym.SYM_PUBLIC); // only if public. lSubp.closeSubpPrototype();
public boolean hasOptionalParam()
public boolean hasNoParamSpec()
public void setNoParamSpec()
public SubpDefinition getSubpDefinition()
public void setSubpDefinition(SubpDefinition pSubpDefinition)
pSubpDefinition
- the SubpDefinition node of this subprogram.public Stmt getStmtWithLabel(Label pLabel)
pLabel
- Label with which Stmt is to be searched.
public Stmt getHirBody()
Get the procedural body in HIR of this subprogram. See SubpDefinition interface and getLirBody of SubpDefinition. Return the procedural body of this subprogram represented in HIR. If no procedural body is given in this compile unit (i.e. external subprogram) then return null.
public void setHirBody(Stmt pHirBody, Label pStartLabel, Label pEndLabel)
Set the procedural body of this subprogram represented in high level intermediate representation (HIR). Usually this is invoked when SubpDefinition is created. pStartLabel, pEndLabel will be generated in SubpDefinition (See subpDefinition of HIR interface).
pHirBody
- procedural body represented in HIR specifying
operations to be performed when this subprogram is called.pStartLabel
- Label to be attached at entry point.pEndLabel
- Label to be attached at exit point.public void buildLabelRefList()
public void printLabelRefList()
public void resetLabelLink()
public Label getStartLabel()
public void setStartLabel(Label pLabel)
public Label getEndLabel()
public void setEndLabel(Label pLabel)
public IrList getCallList()
public void addToCallList(Subp pCallee)
pCallee
- a subprogram called in this subprogram.public boolean isSafeArrayAll()
public java.lang.Object getFlowInf()
public void setFlowInf(java.lang.Object pInf)
public java.lang.Object getOptInf()
public void setOptInf(java.lang.Object pInf)
public java.lang.Object getParallelInf()
public void setParallelInf(java.lang.Object pInf)
public void addToErrorCount(int pCount)
public int getErrorCount()
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |