Class ConcreteStack


  • public final class ConcreteStack
    extends Object
    Fixed-capacity operand stack of concrete values with the JVM dup and swap shuffle operations.
    • Constructor Detail

      • ConcreteStack

        public ConcreteStack​(int maxStack)
        Creates an empty stack.
        Parameters:
        maxStack - capacity in slots
    • Method Detail

      • pushInt

        public void pushInt​(int value)
        Pushes an int.
        Parameters:
        value - value to push
      • pushLong

        public void pushLong​(long value)
        Pushes a long.
        Parameters:
        value - value to push
      • pushFloat

        public void pushFloat​(float value)
        Pushes a float.
        Parameters:
        value - value to push
      • pushDouble

        public void pushDouble​(double value)
        Pushes a double.
        Parameters:
        value - value to push
      • pushReference

        public void pushReference​(ObjectInstance instance)
        Pushes a reference, mapping null to the null value.
        Parameters:
        instance - instance to push, may be null
      • pushNull

        public void pushNull()
        Pushes a null reference.
      • popInt

        public int popInt()
        Pops the top value as an int.
        Returns:
        the int value
      • popLong

        public long popLong()
        Pops the top value as a long.
        Returns:
        the long value
      • popFloat

        public float popFloat()
        Pops the top value as a float.
        Returns:
        the float value
      • popDouble

        public double popDouble()
        Pops the top value as a double.
        Returns:
        the double value
      • popReference

        public ObjectInstance popReference()
        Pops the top value as a reference.
        Returns:
        the instance, or null for a null reference
      • pop

        public void pop​(int count)
        Discards values from the top.
        Parameters:
        count - number of values to discard
        Throws:
        IllegalArgumentException - if the count is negative
        IllegalStateException - if the count exceeds the current depth
      • peek

        public ConcreteValue peek​(int depth)
        Reads a value below the top without popping.
        Parameters:
        depth - distance from the top, zero for the top
        Returns:
        the value at that depth
        Throws:
        IllegalStateException - if the depth is out of range
      • get

        public ConcreteValue get​(int index)
        Reads a value by absolute index from the bottom.
        Parameters:
        index - absolute index
        Returns:
        the value at that index
        Throws:
        IndexOutOfBoundsException - if the index is out of range
      • dup

        public void dup()
        Duplicates the top value.
      • dupX1

        public void dupX1()
        Duplicates the top value beneath the second value.
      • dupX2

        public void dupX2()
        Duplicates the top value beneath the third value.
      • dup2

        public void dup2()
        Duplicates the top two slots: one wide value or two narrow values.
      • dup2X1

        public void dup2X1()
        Duplicates the top two values beneath the third value.
      • dup2X2

        public void dup2X2()
        Duplicates the top two values beneath the fourth value.
      • swap

        public void swap()
        Swaps the top two values.
      • depth

        public int depth()
        Returns:
        the current number of values
      • maxDepth

        public int maxDepth()
        Returns:
        the capacity
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if no values are on the stack
      • clear

        public void clear()
        Removes all values.
      • snapshot

        public List<ConcreteValue> snapshot()
        Captures the stack bottom-to-top as an unmodifiable list.
        Returns:
        the current values