Class Macro

java.lang.Object
mars.assembler.Macro

public class Macro extends Object
Stores information of a macro definition.
Author:
M.H.Sekhavat <sekhavat17@gmail.com>
  • Constructor Details

    • Macro

      public Macro()
  • Method Details

    • 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 a 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.