mars.assembler
Class Macro

java.lang.Object
  extended by mars.assembler.Macro

public class Macro
extends Object

Stores information of a macro definition.

Author:
M.H.Sekhavat

Constructor Summary
Macro()
           
 
Method Summary
 void addArg(String value)
           
 void addLabel(String value)
           
 boolean equals(Object obj)
           
 ArrayList<String> getArgs()
           
 int getFromLine()
           
 String getName()
           
 int getOriginalFromLine()
           
 int getOriginalToLine()
           
 MIPSprogram getProgram()
           
 String getSubstitutedLine(int line, TokenList args, long counter, ErrorList errors)
          Substitutes macro arguments in a line of source code inside macro definition to be parsed after macro expansion.
 int getToLine()
           
 void readyForCommit()
          Operations to be done on this macro before it is committed in macro pool.
 void setArgs(ArrayList<String> args)
           
 void setFromLine(int fromLine)
           
 void setName(String name)
           
 void setOriginalFromLine(int origFromLine)
           
 void setOriginalToLine(int origToLine)
           
 void setProgram(MIPSprogram program)
           
 void setToLine(int toLine)
           
static boolean tokenIsMacroParameter(String tokenValue, boolean acceptSpimStyleParameters)
          returns whether tokenValue is macro parameter or not
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Macro

public Macro()
Method Detail

getName

public String getName()

setName

public void setName(String name)

getProgram

public MIPSprogram getProgram()

setProgram

public void setProgram(MIPSprogram program)

getFromLine

public int getFromLine()

getOriginalFromLine

public int getOriginalFromLine()

setFromLine

public void setFromLine(int fromLine)

setOriginalFromLine

public void setOriginalFromLine(int origFromLine)

getToLine

public int getToLine()

getOriginalToLine

public int getOriginalToLine()

setToLine

public void setToLine(int toLine)

setOriginalToLine

public void setOriginalToLine(int origToLine)

getArgs

public ArrayList<String> getArgs()

setArgs

public void setArgs(ArrayList<String> args)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
Parameters:
obj - Macro object to check if their name and count of arguments are same

addArg

public void addArg(String value)

getSubstitutedLine

public String getSubstitutedLine(int line,
                                 TokenList args,
                                 long counter,
                                 ErrorList errors)
Substitutes macro arguments in a line of source code inside macro definition to be parsed after macro expansion.
Also appends "_M#" to all labels defined inside macro body where # is value of counter

Parameters:
line - source line number in macro definition to be substituted
args -
counter - unique macro expansion id
errors -
Returns:
line-th line of source code, with substituted arguments

tokenIsMacroParameter

public static boolean tokenIsMacroParameter(String tokenValue,
                                            boolean acceptSpimStyleParameters)
returns whether tokenValue is macro parameter or not

Parameters:
tokenValue -
acceptSpimStyleParameters - accepts SPIM-style parameters which begin with '$' if true
Returns:

addLabel

public void addLabel(String value)

readyForCommit

public void readyForCommit()
Operations to be done on this macro before it is committed in macro pool.