Class UndefinedSingleValue
- All Implemented Interfaces:
Cloneable
UndefinedSingleValue implements the Cloneable interface but returns the same instance when cloned, as all undefined values exhibit the same random behavior.
All arithmetic operations with undefined values result in undefined values, and comparison operations always return false to prevent undefined behavior from appearing as valid comparisons.
- Since:
- 1.0
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionPerforms addition with another value.clone()Returns the same UndefinedSingleValue instance.booleanequals(int n) Checks if this value equals the specified numeric value.intGets the value interpreted as a signed integer.intGets the value interpreted as an unsigned integer.booleanChecks if this value is in an undefined state.Performs multiplication with another value.set(int n) Sets this value to the specified numeric value.Performs subtraction with another value.toString()Returns a string representation of this value.
-
Method Details
-
getSigned
public int getSigned()Gets the value interpreted as a signed integer. The sign interpretation depends on the value type and configuration.For UndefinedSingleValue, returns a random value in the signed range by subtracting ValueMax from the random value to center it around zero.
-
getUnsigned
public int getUnsigned()Gets the value interpreted as an unsigned integer. All negative representations are treated as positive values.For UndefinedSingleValue, returns a random value in the unsigned range by taking the modulo with ValueMax.
- Specified by:
getUnsignedin classValue- Returns:
- the value as an unsigned integer
-
clone
Returns the same UndefinedSingleValue instance. Since all undefined values exhibit the same behavior, cloning returns the same instance for efficiency. -
set
Sets this value to the specified numeric value. The behavior depends on the concrete value type - some types may return a new instance while others modify the current instance.For UndefinedSingleValue, setting a concrete value creates a new SingleValue with that value, effectively "defining" the undefined value.
-
isUndefined
public boolean isUndefined()Checks if this value is in an undefined state. Undefined values represent uninitialized memory or registers.For UndefinedSingleValue, always returns true since the value is not defined.
- Overrides:
isUndefinedin classValue- Returns:
- true if this value is undefined, false for concrete values
-
add
Performs addition with another value. The operation is performed using the appropriate numeric representation and may handle sign extension or overflow based on the value types involved.For UndefinedSingleValue, any arithmetic operation results in an undefined value, so returns this instance.
-
sub
Performs subtraction with another value. The operation is performed using the appropriate numeric representation and may handle sign extension or underflow based on the value types involved.For UndefinedSingleValue, any arithmetic operation results in an undefined value, so returns this instance.
-
mul
Performs multiplication with another value. The operation is performed using the appropriate numeric representation and may handle overflow based on the value types involved.For UndefinedSingleValue, any arithmetic operation results in an undefined value, so returns this instance.
-
toString
Returns a string representation of this value. The representation uses the radix specified byConstants.getRadix()and may show special indicators for undefined values.For UndefinedSingleValue, returns "?" to visually indicate the undefined state.
-
equals
public boolean equals(int n) Checks if this value equals the specified numeric value. The comparison is performed against both signed and unsigned interpretations to handle cases where the same bit pattern can represent different values.For UndefinedSingleValue, always returns false since equality with an undefined value is undefined and should not be relied upon.
-