Class SourceLine

java.lang.Object
mars.assembler.token.SourceLine

public class SourceLine extends Object
Handy class to represent, for a given line of source code, the code itself, the program containing it, and its line number within that program. This is used to separately keep track of the original file/position of a given line of code. When .include is used, it will migrate to a different line and possibly different program but the migration should not be visible to the user.
  • Constructor Details

    • SourceLine

      public SourceLine(SourceLocation location, String content, List<Token> tokens)
      Create a new SourceLine with the given information.
      Parameters:
      location - The location of the line in the source code.
      content - The raw source code of the line.
      tokens - The list of tokens that the line contains.
    • SourceLine

      public SourceLine(SourceLocation location, String content, List<Token> tokens, SourceLine originalLine)
      Create a new macro expansion SourceLine with the given information.
      Parameters:
      location - The location of the line in the source code.
      content - The raw source code of the line.
      tokens - The list of tokens that the line contains.
      originalLine - The line in the macro definition or included file that this line was created from.
  • Method Details

    • getLocation

      public SourceLocation getLocation()
      Get the location of this line in the source code.
      Returns:
      The line location.
    • setLocation

      public void setLocation(SourceLocation location)
    • getContent

      public String getContent()
      Get the raw source code of the line.
      Returns:
      The line content.
    • setContent

      public void setContent(String content)
    • getTokens

      public List<Token> getTokens()
      Get the list of tokens that the line contains.
      Returns:
      The token list.
    • getOriginalLine

      public SourceLine getOriginalLine()
      Get the line in the macro definition or included file that this line was created from, if applicable.
      Returns:
      The original line if this line is part of a macro expansion or included file, or null otherwise.
    • setOriginalLine

      public void setOriginalLine(SourceLine originalLine)