Class ConcreteValue
- java.lang.Object
-
- com.tonic.analysis.execution.state.ConcreteValue
-
public final class ConcreteValue extends Object
An immutable tagged JVM value, storing primitives as raw bits and references as a heap instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleasDouble()floatasFloat()intasInt()longasLong()ObjectInstanceasReference()intasReturnAddress()static ConcreteValuedoubleValue(double value)Creates a DOUBLE value, storing its raw bit pattern so NaN payloads survive.booleanequals(Object o)static ConcreteValuefloatValue(float value)Creates a FLOAT value, storing its raw bit pattern so NaN payloads survive.intgetCategory()ValueTaggetTag()inthashCode()static ConcreteValueintValue(int value)Creates an INT value, also used for the sub-int types.booleanisIntegral()booleanisNull()booleanisReference()booleanisWide()static ConcreteValuelongValue(long value)Creates a LONG value.static ConcreteValuenullRef()static ConcreteValuereference(ObjectInstance instance)Creates a REFERENCE value pointing at a heap instance.static ConcreteValuereturnAddress(int address)Creates the value pushed by jsr.StringtoString()
-
-
-
Method Detail
-
intValue
public static ConcreteValue intValue(int value)
Creates an INT value, also used for the sub-int types.- Parameters:
value- the integer- Returns:
- the tagged value
-
longValue
public static ConcreteValue longValue(long value)
Creates a LONG value.- Parameters:
value- the long- Returns:
- the tagged value
-
floatValue
public static ConcreteValue floatValue(float value)
Creates a FLOAT value, storing its raw bit pattern so NaN payloads survive.- Parameters:
value- the float- Returns:
- the tagged value
-
doubleValue
public static ConcreteValue doubleValue(double value)
Creates a DOUBLE value, storing its raw bit pattern so NaN payloads survive.- Parameters:
value- the double- Returns:
- the tagged value
-
reference
public static ConcreteValue reference(ObjectInstance instance)
Creates a REFERENCE value pointing at a heap instance.- Parameters:
instance- the target object, never null- Returns:
- the tagged value
- Throws:
IllegalArgumentException- if the instance is null
-
nullRef
public static ConcreteValue nullRef()
- Returns:
- a NULL-tagged reference value
-
returnAddress
public static ConcreteValue returnAddress(int address)
Creates the value pushed by jsr.- Parameters:
address- the bytecode offset to return to- Returns:
- the tagged value
-
getTag
public ValueTag getTag()
- Returns:
- the tag
-
isNull
public boolean isNull()
- Returns:
- true if this is the null reference
-
isWide
public boolean isWide()
- Returns:
- true if the value occupies two stack or local slots
-
isReference
public boolean isReference()
- Returns:
- true if the value is an object reference or null
-
isIntegral
public boolean isIntegral()
- Returns:
- true if the value is an int or a long
-
getCategory
public int getCategory()
- Returns:
- the JVM computational type category, 1 or 2
-
asInt
public int asInt()
- Returns:
- the int contents
- Throws:
IllegalStateException- if the value is not tagged INT
-
asLong
public long asLong()
- Returns:
- the long contents
- Throws:
IllegalStateException- if the value is not tagged LONG
-
asFloat
public float asFloat()
- Returns:
- the float decoded from the stored bits
- Throws:
IllegalStateException- if the value is not tagged FLOAT
-
asDouble
public double asDouble()
- Returns:
- the double decoded from the stored bits
- Throws:
IllegalStateException- if the value is not tagged DOUBLE
-
asReference
public ObjectInstance asReference()
- Returns:
- the referenced instance, or null when the value is the null reference
- Throws:
IllegalStateException- if the value is neither a reference nor null
-
asReturnAddress
public int asReturnAddress()
- Returns:
- the stored bytecode offset
- Throws:
IllegalStateException- if the value is not tagged RETURN_ADDRESS
-
-