Class SourceFileIndexer

java.lang.Object
ghidra.sleigh.grammar.SourceFileIndexer

public class SourceFileIndexer extends Object
This class is used to index source files in a SLEIGH language module. The SLEIGH compiler records the index of the source file for a constructor rather than the file name. This is an optimization to avoid repeating the file name in the .sla files.
  • Constructor Details

    • SourceFileIndexer

      public SourceFileIndexer()
      Creates a {code SourceFileIndexer} object with an empty index.
  • Method Details

    • index

      public Integer index(Location loc)
      Adds the filename of a location to the index if it is not already present.
      Parameters:
      loc - location containing filename to add
      Returns:
      index associated with filename, or null if a null Location or a Location with a null filename was provided as input.
    • getIndex

      public Integer getIndex(String filename)
      Returns the index for a filename
      Parameters:
      filename - file
      Returns:
      index or null if filename is not in the index.
    • getFileName

      public String getFileName(Integer index)
      Returns the file name at a given index
      Parameters:
      index - index
      Returns:
      file name or null if there is no file with that index
    • encode

      public void encode(Encoder encoder) throws IOException
      Encode the index to a stream
      Parameters:
      encoder - stream to write to
      Throws:
      IOException - for errors writing to the stream
    • decode

      public void decode(Decoder decoder) throws DecoderException
      Decode an index from a stream
      Parameters:
      decoder - is the stream
      Throws:
      DecoderException - for errors in the encoding