Class ObjectAddress

java.lang.Object
svm.value.Value
svm.value.ObjectAddress

public class ObjectAddress extends Value

ObjectAddress.

object_address ::= c-oaddr global_or_const:tag

Link to GitHub: Source File.

Author:
S-Port: Definition of S-code, /** Address kind */ ystein Myhre Andersen
  • Field Details

    • kind

      public int kind
      Address kind
    • segID

      public String segID
      Segment ident when kind SEGMNT_ADDR
    • ofst

      public int ofst
      Address offset
    • indexed

      public boolean indexed
      Signals 'indexed' address. In that case an index offset is pushed to the runtime stack.
    • SEGMNT_ADDR

      public static final int SEGMNT_ADDR
      Address kind
      See Also:
    • REMOTE_ADDR

      public static final int REMOTE_ADDR
      Address kind
      See Also:
    • REFER_ADDR

      public static final int REFER_ADDR
      Address kind
      See Also:
    • REL_ADDR

      public static final int REL_ADDR
      Address kind
      See Also:
    • STACK_ADDR

      public static final int STACK_ADDR
      Address kind
      See Also:
  • Constructor Details

    • ObjectAddress

      public ObjectAddress()
      Default Constructor
    • ObjectAddress

      protected ObjectAddress(int kind, String segID, int ofst, boolean indexed)
      Construct a new ObjectAddress with the given parameters
      Parameters:
      kind - the address kind
      segID - the Segment ident when kind SEGMNT_ADDR
      ofst - The offset
      indexed - Signals 'indexed' address. In that case an index offset is pushed to the runtime stack.
  • Method Details

    • ofScode

      public static ObjectAddress ofScode()
      Scans the remaining S-Code (if any) belonging to this ObjectAddress Value. Then construct a new ObjectAddress instance.
      Returns:
      that ObjectAddress instance.
    • ofSegAddr

      public static ObjectAddress ofSegAddr(String segID, int ofst)
      Create a new Segment address with the given parameters
      Parameters:
      segID - the Segment ident
      ofst - The offset
      Returns:
      an ObjectAddress
    • ofSegAddr

      public static ObjectAddress ofSegAddr(DataSegment seg, int ofst)
      Create a new Segment address with the given parameters
      Parameters:
      seg - the Segment
      ofst - The offset
      Returns:
      an ObjectAddress
    • ofRemoteAddr

      public static ObjectAddress ofRemoteAddr()
      Create a new Remote address.
      Returns:
      an ObjectAddress
    • ofReferAddr

      public static ObjectAddress ofReferAddr()
      Create a new Refer address.
      Returns:
      an ObjectAddress
    • ofRelFrameAddr

      public static ObjectAddress ofRelFrameAddr(int ofst)
      Create a new Relative address with the given offset
      Parameters:
      ofst - The offset
      Returns:
      an ObjectAddress
    • ofFixup

      public static ObjectAddress ofFixup()
      Create a new Fixup address.
      Returns:
      an ObjectAddress
    • segment

      public DataSegment segment()
      Returns the DataSegment part of a Segment Address
      Returns:
      the DataSegment part of a Segment Address
    • copy

      public Value copy()
      Returns a copy of this ObjectAddress
      Overrides:
      copy in class Value
      Returns:
      a copy of this ObjectAddress
    • addOffset

      public ObjectAddress addOffset(int ofst)
      Increment the offset part by the given ofst
      Parameters:
      ofst - the ofst to be added
      Returns:
      the resulting ObjectAddress
    • fixupAddress

      public void fixupAddress(ObjectAddress oaddr)
      Fixup this ObjectAddress by the given address
      Parameters:
      oaddr - an Object address
    • toStackAddress

      public ObjectAddress toStackAddress()
      If this ObjectAddress is a Relative Address it is converted to a absolute Stack Address.
      Returns:
      an ObjectAddress possibly converted
    • toRTMemAddr

      public ObjectAddress toRTMemAddr()

      Force 'objadr' unstacked. Ie. pop off any stacked part and form the resulting address 'resadr'.

      The unstacking of the 'objadr' depend on its address kind:

      • REMOTE_ADDR: object address 'oaddr' is popped of the Runtime stack. resadr := oaddr + objadr.offset
      • REFER_ADDR: 'offset' and object address 'oaddr' is popped of the Runtime stack. resadr := oaddr + objadr.offset + offset
      • Otherwise: resadr := objadr
      Returns:
      resadr as calculated
    • emit

      public void emit(DataSegment dseg)
      Description copied from class: Value
      Add this value to the given DataSegment
      Overrides:
      emit in class Value
      Parameters:
      dseg - the DataSegment
    • store

      public void store(int idx, Value value)
      Store the given value into memory address: this ObectAddress + idx
      Parameters:
      idx - the index to use
      value - the value to be stored
    • load

      public Value load(int idx)
      Load a value from memory address: this ObectAddress + idx
      Parameters:
      idx - the index to use
      Returns:
      value the value loaded
    • add

      public Value add(Value other)
      Description copied from class: Value
      Returns the result of: this value + other value
      Overrides:
      add in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value + other value
    • sub

      public Value sub(Value other)
      Description copied from class: Value
      Returns the result of: this value - other value
      Overrides:
      sub in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value - other value
    • compare

      public boolean compare(int relation, Value other)
      Description copied from class: Value
      Compare this Value with the given Value according to the given relation.
      Overrides:
      compare in class Value
      Parameters:
      relation - one of: LT, LE, EQ, GE, GT, NE
      other - the other Value
      Returns:
      true: if the relation holds
    • dumpArea

      public void dumpArea(String title, int lng)
      Debug utility: dumpArea
      Parameters:
      title - the title of the dump printout
      lng - the length of the dump
    • toString

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

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

      public void writeBody(AttributeOutputStream oupt) throws IOException
      Writes the body of this ObjectAddress to the given output.
      Parameters:
      oupt - the output stream
      Throws:
      IOException - if IOException occur
    • read

      public static ObjectAddress read(AttributeInputStream inpt) throws IOException
      Reads a ObjectAddress from the given input.
      Parameters:
      inpt - the AttributeInputStream
      Returns:
      the ObjectAddress read
      Throws:
      IOException - if IOException occur