类 Stack

  • 直接已知子类:
    TracedStack

    public class Stack
    extends java.lang.Object
    This class represents an operand stack that contains Value instances.
    • 构造器概要

      构造器 
      构造器 说明
      Stack​(int maxSize)
      Creates a new Stack with a given maximum size, accounting for the double space required by Category 2 values.
      Stack​(Stack stack)
      Creates a Stack that is a copy of the given Stack.
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      ReferenceValue apop()
      Pops the top ReferenceValue from the stack.
      void clear()
      Clears the stack.
      void copy​(Stack other)
      Copies the values of the given Stack into this Stack.
      DoubleValue dpop()
      Pops the top DoubleValue from the stack.
      void dup()
      Duplicates the top Category 1 value.
      void dup_x1()
      Duplicates the top Category 1 value, one Category 1 element down the stack.
      void dup_x2()
      Duplicates the top Category 1 value, two Category 1 elements (or one Category 2 element) down the stack.
      void dup2()
      Duplicates the top Category 2 value (or alternatively, the equivalent Category 1 stack elements).
      void dup2_x1()
      Duplicates the top Category 2 value, one Category 1 element down the stack (or alternatively, the equivalent Category 1 stack values).
      void dup2_x2()
      Duplicates the top Category 2 value, one Category 2 stack element down the stack (or alternatively, the equivalent Category 1 stack values).
      boolean equals​(java.lang.Object object)  
      FloatValue fpop()
      Pops the top FloatValue from the stack.
      boolean generalize​(Stack other)
      Generalizes the values of this Stack with the values of the given Stack.
      int getActualMaxSize()
      Returns the actual maximum stack size that was required for all stack operations, accounting for the double space required by Category 2 values.
      Value getBottom​(int index)
      Gets the specified Value from the stack, without disturbing it.
      Value getTop​(int index)
      Gets the specified Value from the stack, without disturbing it.
      int hashCode()  
      IntegerValue ipop()
      Pops the top IntegerValue from the stack.
      LongValue lpop()
      Pops the top LongValue from the stack.
      InstructionOffsetValue opop()
      Pops the top InstructionOffsetValue from the stack.
      Value pop()
      Pops the top Value from the stack.
      void pop1()
      Pops the top category 1 value from the stack.
      void pop2()
      Pops the top category 2 value from the stack (or alternatively, two Category 1 stack elements).
      void push​(Value value)
      Pushes the given Value onto the stack.
      void removeTop​(int index)
      Removes the specified Value from the stack.
      void replaceReferences​(Value toReplace, Value replacement)
      Replaces all the references to {@param toReplace} with references to {@param replacement}.
      void replaceReferencesIf​(java.util.function.Predicate<Value> predicate, java.util.function.UnaryOperator<Value> op)
      Apply {@param op} to all values that match {@param predicate}.
      void reset​(int maxSize)
      Resets this Stack, so that it can be reused.
      void setBottom​(int index, Value value)
      Sets the specified Value on the stack, without disturbing it.
      void setTop​(int index, Value value)
      Sets the specified Value on the stack, without disturbing it.
      int size()
      Returns the number of elements currently on the stack, accounting for the double space required by Category 2 values.
      void swap()
      Swaps the top two Category 1 values.
      java.lang.String toString()  
      • 从类继承的方法 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • values

        protected Value[] values
      • currentSize

        protected int currentSize
      • actualMaxSize

        protected int actualMaxSize
    • 构造器详细资料

      • Stack

        public Stack​(int maxSize)
        Creates a new Stack with a given maximum size, accounting for the double space required by Category 2 values.
      • Stack

        public Stack​(Stack stack)
        Creates a Stack that is a copy of the given Stack.
    • 方法详细资料

      • getActualMaxSize

        public int getActualMaxSize()
        Returns the actual maximum stack size that was required for all stack operations, accounting for the double space required by Category 2 values.
      • reset

        public void reset​(int maxSize)
        Resets this Stack, so that it can be reused.
      • copy

        public void copy​(Stack other)
        Copies the values of the given Stack into this Stack.
      • generalize

        public boolean generalize​(Stack other)
        Generalizes the values of this Stack with the values of the given Stack. The stacks must have the same current sizes.
        返回:
        whether the generalization has made any difference.
      • clear

        public void clear()
        Clears the stack.
      • size

        public int size()
        Returns the number of elements currently on the stack, accounting for the double space required by Category 2 values.
      • getBottom

        public Value getBottom​(int index)
        Gets the specified Value from the stack, without disturbing it.
        参数:
        index - the index of the stack element, counting from the bottom of the stack.
        返回:
        the value at the specified position.
      • setBottom

        public void setBottom​(int index,
                              Value value)
        Sets the specified Value on the stack, without disturbing it.
        参数:
        index - the index of the stack element, counting from the bottom of the stack.
        value - the value to set.
      • getTop

        public Value getTop​(int index)
        Gets the specified Value from the stack, without disturbing it.
        参数:
        index - the index of the stack element, counting from the top of the stack.
        返回:
        the value at the specified position.
      • setTop

        public void setTop​(int index,
                           Value value)
        Sets the specified Value on the stack, without disturbing it.
        参数:
        index - the index of the stack element, counting from the top of the stack.
        value - the value to set.
      • removeTop

        public void removeTop​(int index)
        Removes the specified Value from the stack.
        参数:
        index - the index of the stack element, counting from the top of the stack.
      • push

        public void push​(Value value)
        Pushes the given Value onto the stack.
      • pop

        public Value pop()
        Pops the top Value from the stack.
      • ipop

        public IntegerValue ipop()
        Pops the top IntegerValue from the stack.
      • lpop

        public LongValue lpop()
        Pops the top LongValue from the stack.
      • fpop

        public FloatValue fpop()
        Pops the top FloatValue from the stack.
      • dpop

        public DoubleValue dpop()
        Pops the top DoubleValue from the stack.
      • apop

        public ReferenceValue apop()
        Pops the top ReferenceValue from the stack.
      • pop1

        public void pop1()
        Pops the top category 1 value from the stack.
      • pop2

        public void pop2()
        Pops the top category 2 value from the stack (or alternatively, two Category 1 stack elements).
      • dup

        public void dup()
        Duplicates the top Category 1 value.
      • dup_x1

        public void dup_x1()
        Duplicates the top Category 1 value, one Category 1 element down the stack.
      • dup_x2

        public void dup_x2()
        Duplicates the top Category 1 value, two Category 1 elements (or one Category 2 element) down the stack.
      • dup2

        public void dup2()
        Duplicates the top Category 2 value (or alternatively, the equivalent Category 1 stack elements).
      • dup2_x1

        public void dup2_x1()
        Duplicates the top Category 2 value, one Category 1 element down the stack (or alternatively, the equivalent Category 1 stack values).
      • dup2_x2

        public void dup2_x2()
        Duplicates the top Category 2 value, one Category 2 stack element down the stack (or alternatively, the equivalent Category 1 stack values).
      • swap

        public void swap()
        Swaps the top two Category 1 values.
      • replaceReferences

        public void replaceReferences​(Value toReplace,
                                      Value replacement)
        Replaces all the references to {@param toReplace} with references to {@param replacement}.
      • replaceReferencesIf

        public void replaceReferencesIf​(java.util.function.Predicate<Value> predicate,
                                        java.util.function.UnaryOperator<Value> op)
        Apply {@param op} to all values that match {@param predicate}.
      • equals

        public boolean equals​(java.lang.Object object)
        覆盖:
        equals 在类中 java.lang.Object
      • hashCode

        public int hashCode()
        覆盖:
        hashCode 在类中 java.lang.Object
      • toString

        public java.lang.String toString()
        覆盖:
        toString 在类中 java.lang.Object