|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmars.assembler.MacroPool
public class MacroPool
Stores information of macros defined by now.
Will be used in first pass of assembling MIPS source code. When reached
.macro directive, parser calls
MacroPool#BeginMacro(String, int) and skips source code lines until
reaches .end_macro directive. then calls
MacroPool#CommitMacro(int) and the macro information stored in a
Macro instance will be added to macroList.
Each MIPSprogram will have one MacroPool
NOTE: Forward referencing macros (macro expansion before its definition in
source code) and Nested macro definition (defining a macro inside other macro
definition) are not supported.
| Constructor Summary | |
|---|---|
MacroPool(MIPSprogram mipsProgram)
Create an empty MacroPool for given program |
|
| Method Summary | |
|---|---|
void |
beginMacro(Token nameToken)
This method will be called by parser when reached .macro
directive.Instantiates a new Macro object and stores it in current
. |
void |
commitMacro(Token endToken)
This method will be called by parser when reached .end_macro
directive. |
ArrayList<Integer> |
getCallStack()
|
Macro |
getCurrent()
|
String |
getExpansionHistory()
|
Macro |
getMatchingMacro(TokenList tokens,
int callerLine)
Will be called by parser when reaches a macro expansion call |
int |
getNextCounter()
counter will be set to 0 on construction of this class and will
be incremented by each call. |
boolean |
matchesAnyMacroName(String value)
|
void |
popFromCallStack()
|
boolean |
pushOnCallStack(Token token)
|
void |
setCurrent(Macro current)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MacroPool(MIPSprogram mipsProgram)
mipsProgram - associated MIPS program| Method Detail |
|---|
public void beginMacro(Token nameToken)
.macro
directive.Macro object and stores it in current
. current will be added to macroList by
#CommitMacro(int)
nameToken - Token containing name of macro after .macro directivepublic void commitMacro(Token endToken)
.end_macro
directive. current macro into the macroList.
endToken - Token containing .end_macro directive in source code
public Macro getMatchingMacro(TokenList tokens,
int callerLine)
tokens - tokens passed to macro expansion call
Macro object matching the name and argument count of
tokens passedpublic boolean matchesAnyMacroName(String value)
value -
value
by now, not concerning arguments count.public Macro getCurrent()
public void setCurrent(Macro current)
public int getNextCounter()
counter will be set to 0 on construction of this class and will
be incremented by each call. parser calls this method once for every
expansions. it will be a unique id for each expansion of macro in a file
public ArrayList<Integer> getCallStack()
public boolean pushOnCallStack(Token token)
public void popFromCallStack()
public String getExpansionHistory()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||