Class StateSnapshot


  • public final class StateSnapshot
    extends Object
    An immutable snapshot of simulation state at one instruction.
    • Method Detail

      • getBlock

        public IRBlock getBlock()
        Returns:
        the block the snapshot was taken in
      • getInstructionIndex

        public int getInstructionIndex()
        Returns:
        the instruction index within the block
      • getStackDepth

        public int getStackDepth()
        Returns:
        the stack depth
      • getMaxStackDepth

        public int getMaxStackDepth()
        Returns:
        the high-water stack depth reached before the snapshot
      • getStackValues

        public List<SimValue> getStackValues()
        Returns:
        the captured stack values, bottom to top
      • getLocalValues

        public Map<Integer,​SimValue> getLocalValues()
        Returns:
        the captured locals, keyed by slot
      • getCallDepth

        public int getCallDepth()
        Returns:
        the call depth
      • getTimestamp

        public long getTimestamp()
        Returns:
        the logical timestamp, unique per snapshot
      • getTopOfStack

        public SimValue getTopOfStack()
        Returns:
        the topmost captured stack value, or null if the stack was empty
      • getStackValue

        public SimValue getStackValue​(int depth)
        Looks up a captured stack value counting down from the top.
        Parameters:
        depth - the distance below the top, where 0 is the top
        Returns:
        the value at that depth, or null if it is out of range
      • getLocalValue

        public SimValue getLocalValue​(int index)
        Looks up a captured local variable.
        Parameters:
        index - the local slot
        Returns:
        the value in that slot, or null if the slot was unoccupied
      • toState

        public SimulationState toState()
        Rebuilds a simulation state from the captured stack, locals and position.
        Returns:
        the reconstructed state
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object