Class DataSegment

java.lang.Object
svm.segment.Segment
svm.segment.DataSegment

public final class DataSegment extends Segment

Data Segment.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • values

      Vector<Value> values
      The set of values in this DataSegment.
  • Constructor Details

    • DataSegment

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

    • ofOffset

      public ObjectAddress ofOffset(int ofst)
      Returns the ObjectAddress with the given offset
      Parameters:
      ofst - the offset
      Returns:
      the ObjectAddress with the given offset
    • nextAddress

      public ObjectAddress nextAddress()
      Returns the next ObjectAddress
      Returns:
      the next ObjectAddress
    • size

      public int size()
      Returns the size of this DataSegment
      Returns:
      the size of this DataSegment
    • store

      public void store(int index, Value value)
      Store a value into this DataSegment at the given index
      Parameters:
      index - the index
      value - the value
    • load

      public Value load(int index)
      Load a value from this DataSegment at the given index
      Parameters:
      index - the index
      Returns:
      the value at the given index
    • emit

      public ObjectAddress emit(Value value)
      Emit a value by adding it to this DataSegment.
      Parameters:
      value - value to be added
      Returns:
      the address of the value emitted
    • listData

      private void listData(String indent, int idx)
      Listing utility: List a DataSegment entry
      Parameters:
      indent - indentation String
      idx - index to the value
    • emitDefaultValue

      public void emitDefaultValue(int size, int repCount)
      Emit default value by emiting the necessary number of null values.
      Parameters:
      size - the value size
      repCount - the repetition count
    • emitChars

      public ObjectAddress emitChars(String chars)
      Emit the characters in the given String
      Parameters:
      chars - the String
      Returns:
      the address of the first character emitted
    • dump

      public void dump(String title)
      Description copied from class: Segment
      Utility: Segment dump
      Specified by:
      dump in class Segment
      Parameters:
      title - the printout title
    • dump

      public void dump(String title, int from, int to)
      Description copied from class: Segment
      Utility: Segment dump
      Specified by:
      dump in class Segment
      Parameters:
      title - the printout title
      from - Segment index
      to - Segment index
    • toString

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

      public void write(AttributeOutputStream oupt) throws IOException
      Description copied from class: Segment
      Writes a Segment to the given output.
      Overrides:
      write in class Segment
      Parameters:
      oupt - the output stream
      Throws:
      IOException - if IOException occur
    • readObject

      public static DataSegment readObject(AttributeInputStream inpt, int segmentKind) throws IOException
      Returns a DataSegment read from the given AttributeInputStream
      Parameters:
      inpt - the AttributeInputStream
      segmentKind - the Segment kind code
      Returns:
      a DataSegment read from the given AttributeInputStream
      Throws:
      IOException - if IOException occur