Class Segment

java.lang.Object
svm.segment.Segment
Direct Known Subclasses:
DataSegment, ProgramSegment

public abstract class Segment extends Object

Segment.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Segment ident
    protected int
    K_SEG_DATA, K_SEG_CONST, K_SEG_CODE
    private int
    Segment Sequence number
    private static int
    Used to generate Segment Sequence numbers
  • Constructor Summary

    Constructors
    Constructor
    Description
    Segment(String ident, int segmentKind)
    Segment constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    compare(String LHSegID, int lhSegOfst, int relation, String RHSegID, int rhSegOfst)
    Compare two Segment addresses according to the given relation.
    abstract void
    dump(String title)
    Utility: Segment dump
    abstract void
    dump(String title, int from, int to)
    Utility: Segment dump
    private static boolean
    equals(String s1, String s2)
    Returns true if the two specified Strings are equal to one another.
    static Segment
    lookup(String ident)
    Lookup Segment by its ident
     
    void
    Writes a Segment to the given output.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ident

      public String ident
      Segment ident
    • segmentKind

      protected int segmentKind
      K_SEG_DATA, K_SEG_CONST, K_SEG_CODE
    • sequ

      private int sequ
      Segment Sequence number
    • SEQU

      private static int SEQU
      Used to generate Segment Sequence numbers
  • Constructor Details

    • Segment

      public Segment(String ident, int segmentKind)
      Segment constructor.
      Parameters:
      ident - the Segment ident
      segmentKind - K_SEG_DATA, K_SEG_CONST, K_SEG_CODE
  • Method Details

    • lookup

      public static Segment lookup(String ident)
      Lookup Segment by its ident
      Parameters:
      ident - the Segment ident
      Returns:
      the Segment found
    • compare

      public static boolean compare(String LHSegID, int lhSegOfst, int relation, String RHSegID, int rhSegOfst)
      Compare two Segment addresses according to the given relation.
      Parameters:
      LHSegID - the left hand Segment ident
      lhSegOfst - the left hand Segment address offset
      relation - one of: LT, LE, EQ, GE, GT, NE
      RHSegID - the right hand Segment ident
      rhSegOfst - the right hand Segment address offset
      Returns:
      true if the relation holds
    • equals

      private static boolean equals(String s1, String s2)
      Returns true if the two specified Strings are equal to one another.
      Parameters:
      s1 - one String to be tested for equality
      s2 - the other String to be tested for equality
      Returns:
      true if the two Strings are equal
    • dump

      public abstract void dump(String title)
      Utility: Segment dump
      Parameters:
      title - the printout title
    • dump

      public abstract void dump(String title, int from, int to)
      Utility: Segment dump
      Parameters:
      title - the printout title
      from - Segment index
      to - Segment index
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • write

      public void write(AttributeOutputStream oupt) throws IOException
      Writes a Segment to the given output.
      Parameters:
      oupt - the output stream
      Throws:
      IOException - if IOException occur