Class Value

java.lang.Object
svm.value.Value
Direct Known Subclasses:
BooleanValue, GeneralAddress, IntegerValue, LongRealValue, ObjectAddress, ProgramAddress, RealValue, RecordValue, RepetitionValue, StringValue, TextValue

public class Value extends Object

Value.

value
	::= boolean_value | character_value
	::= integer_value | size_value
	::= real_value | longreal_value
	::= attribute_address | object_address
	::= general_address | program_address
	::= routine_address | record_value

Link to GitHub: Source File.

Author:
S-Port: Definition of S-code, Øystein Myhre Andersen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The type of the value
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Value other)
    Returns the result of: this value + other value
    and(Value other)
    Returns the result of: this value and other value
    boolean
    compare(int relation, Value other)
    Compare this Value with the given Value according to the given relation.
    Returns a copy of this Value object.
    div(Value other)
    Returns the result of: this value / other value
    void
    Add this value to the given DataSegment
    eqv(Value other)
    Returns the result of: this value eqv other value
    imp(Value other)
    Returns the result of: this value imp other value
    mult(Value other)
    Returns the result of: this value * other value
    neg()
    Returns the negative value of this Value object.
    or(Value other)
    Returns the result of: this value or other value
    void
    print(String indent)
    Utility print method.
    static Value
    read(int kind, AttributeInputStream inpt)
    Reads a Value of the given kind from the given input.
    static Value
    Reads a Value from the given input.
    rem(Value other)
    Returns the result of: this value rem other value
    shift(int shiftInstr, Value other)
    Returns the result of: this value shiftInstr other value S_LSHIFTA: Signed Left Shift << The left shift operator moves all bits by a given number of bits to the left. S_LSHIFTL: Unsigned Left Shift << The left shift operator moves all bits by a given number of bits to the left. S_RSHIFTA: Signed Right Shift >> The right shift operator moves all bits by a given number of bits to the right.
    sub(Value other)
    Returns the result of: this value - other value
    double
    Returns the double value of this Value object.
    float
    Returns the float value of this Value object.
    void
    Writes this Value to the given output.
    xor(Value other)
    Returns the result of: this value xor other value

    Methods inherited from class Object

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

    • type

      public Type type
      The type of the value
  • Constructor Details

    • Value

      public Value()
      Default Constructor
  • Method Details

    • print

      public void print(String indent)
      Utility print method.
      Parameters:
      indent - number of spaces leading the lines
    • emit

      public void emit(DataSegment dseg)
      Add this value to the given DataSegment
      Parameters:
      dseg - the DataSegment
    • toFloat

      public float toFloat()
      Returns the float value of this Value object.
      Returns:
      the float value of this Value object.
    • toDouble

      public double toDouble()
      Returns the double value of this Value object.
      Returns:
      the double value of this Value object.
    • copy

      public Value copy()
      Returns a copy of this Value object.
      Returns:
      a copy of this Value object.
    • neg

      public Value neg()
      Returns the negative value of this Value object.
      Returns:
      the negative value of this Value object.
    • add

      public Value add(Value other)
      Returns the result of: this value + other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value + other value
    • sub

      public Value sub(Value other)
      Returns the result of: this value - other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value - other value
    • mult

      public Value mult(Value other)
      Returns the result of: this value * other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value * other value
    • div

      public Value div(Value other)
      Returns the result of: this value / other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value / other value
    • rem

      public Value rem(Value other)
      Returns the result of: this value rem other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value rem other value
    • and

      public Value and(Value other)
      Returns the result of: this value and other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value and other value
    • or

      public Value or(Value other)
      Returns the result of: this value or other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value or other value
    • xor

      public Value xor(Value other)
      Returns the result of: this value xor other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value xor other value
    • imp

      public Value imp(Value other)
      Returns the result of: this value imp other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value imp other value
    • eqv

      public Value eqv(Value other)
      Returns the result of: this value eqv other value
      Parameters:
      other - the other value
      Returns:
      the result of: this value eqv other value
    • compare

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

      public Value shift(int shiftInstr, Value other)
      Returns the result of: this value shiftInstr other value S_LSHIFTA: Signed Left Shift << The left shift operator moves all bits by a given number of bits to the left. S_LSHIFTL: Unsigned Left Shift << The left shift operator moves all bits by a given number of bits to the left. S_RSHIFTA: Signed Right Shift >> The right shift operator moves all bits by a given number of bits to the right. S_RSHIFTL: Unsigned Right Shift >>> It is the same as the signed right shift, but the vacant leftmost position is filled with 0 instead of the sign bit.
      Parameters:
      shiftInstr - the actual shift instruction
      other - the other value
      Returns:
      the result of: this value shiftInstr other value
    • write

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

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

      public static Value read(int kind, AttributeInputStream inpt) throws IOException
      Reads a Value of the given kind from the given input.
      Parameters:
      kind - the value kind
      inpt - the input stream
      Returns:
      the Value read
      Throws:
      IOException - if IOException occur