Class ConcreteLocals
- java.lang.Object
-
- com.tonic.analysis.execution.state.ConcreteLocals
-
public final class ConcreteLocals extends Object
Fixed-size local variable table of concrete values, with wide values occupying two slots.
-
-
Constructor Summary
Constructors Constructor Description ConcreteLocals(int maxLocals)Creates an empty table.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConcreteLocalsforMethod(MethodEntry method, ConcreteValue[] args)Creates a table sized for a method with its arguments preloaded by slot category.ConcreteValueget(int slot)Reads a slot.doublegetDouble(int slot)Reads a slot as a double.floatgetFloat(int slot)Reads a slot as a float.intgetInt(int slot)Reads a slot as an int.longgetLong(int slot)Reads a slot as a long.ObjectInstancegetReference(int slot)Reads a slot as a reference.booleanisDefined(int slot)Tests whether a slot holds a value.voidset(int slot, ConcreteValue value)Stores a value, clearing the following slot for wide values.voidsetDouble(int slot, double value)Stores a double.voidsetFloat(int slot, float value)Stores a float.voidsetInt(int slot, int value)Stores an int.voidsetLong(int slot, long value)Stores a long.voidsetNull(int slot)Stores a null reference.voidsetReference(int slot, ObjectInstance instance)Stores a reference.intsize()Map<Integer,ConcreteValue>snapshot()Captures the defined slots as an unmodifiable map.StringtoString()
-
-
-
Method Detail
-
set
public void set(int slot, ConcreteValue value)Stores a value, clearing the following slot for wide values.- Parameters:
slot- target slotvalue- value to store- Throws:
IndexOutOfBoundsException- if the slot is out of rangeIllegalArgumentException- if a wide value would overflow the table
-
setInt
public void setInt(int slot, int value)Stores an int.- Parameters:
slot- target slotvalue- value to store
-
setLong
public void setLong(int slot, long value)Stores a long.- Parameters:
slot- target slotvalue- value to store
-
setFloat
public void setFloat(int slot, float value)Stores a float.- Parameters:
slot- target slotvalue- value to store
-
setDouble
public void setDouble(int slot, double value)Stores a double.- Parameters:
slot- target slotvalue- value to store
-
setReference
public void setReference(int slot, ObjectInstance instance)Stores a reference.- Parameters:
slot- target slotinstance- instance to store
-
setNull
public void setNull(int slot)
Stores a null reference.- Parameters:
slot- target slot
-
get
public ConcreteValue get(int slot)
Reads a slot.- Parameters:
slot- slot to read- Returns:
- the stored value
- Throws:
IndexOutOfBoundsException- if the slot is out of rangeIllegalStateException- if the slot is undefined
-
getInt
public int getInt(int slot)
Reads a slot as an int.- Parameters:
slot- slot to read- Returns:
- the int value
-
getLong
public long getLong(int slot)
Reads a slot as a long.- Parameters:
slot- slot to read- Returns:
- the long value
-
getFloat
public float getFloat(int slot)
Reads a slot as a float.- Parameters:
slot- slot to read- Returns:
- the float value
-
getDouble
public double getDouble(int slot)
Reads a slot as a double.- Parameters:
slot- slot to read- Returns:
- the double value
-
getReference
public ObjectInstance getReference(int slot)
Reads a slot as a reference.- Parameters:
slot- slot to read- Returns:
- the instance, or null for a null reference
-
size
public int size()
- Returns:
- the number of slots
-
isDefined
public boolean isDefined(int slot)
Tests whether a slot holds a value.- Parameters:
slot- slot to test- Returns:
- true if the slot is in range and defined
-
snapshot
public Map<Integer,ConcreteValue> snapshot()
Captures the defined slots as an unmodifiable map.- Returns:
- slot-to-value map of defined slots
-
forMethod
public static ConcreteLocals forMethod(MethodEntry method, ConcreteValue[] args)
Creates a table sized for a method with its arguments preloaded by slot category.- Parameters:
method- the method to size forargs- argument values in order, or null for none- Returns:
- the initialized locals
- Throws:
IllegalArgumentException- if the method is null or the arguments overflow the table
-
-