Package org.codehaus.groovy.classgen.asm

# Class OperandStack

java.lang.Object
org.codehaus.groovy.classgen.asm.OperandStack

public class OperandStack extends Object

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OperandStack(WriterController controller)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassNode`
  `box()`
  `void`
  `castToBool(int mark, boolean emptyDefault)`
  ensure last marked parameter on the stack is a primitive boolean if mark==stack size, we assume an empty expression or statement.
  `void`
  `doAsType(ClassNode targetType)`
  `void`
  `doGroovyCast(ClassNode targetType)`
  do Groovy cast for top level element
  `void`
  `doGroovyCast(Variable v)`
  `void`
  `dup()`
  duplicate top element
  `int`
  `getStackLength()`
  `ClassNode`
  `getTopOperand()`
  `org.objectweb.asm.Label`
  `jump(int ifIns)`
  `void`
  `jump(int ifIns, org.objectweb.asm.Label label)`
  `void`
  `load(ClassNode type, int idx)`
  `void`
  `loadOrStoreVariable(BytecodeVariable variable, boolean useReferenceDirectly)`
  `void`
  `pop()`
  remove operand stack top element using bytecode pop
  `void`
  `popDownTo(int elements)`
  `void`
  `push(ClassNode type)`
  push operand on stack
  `void`
  `pushBool(boolean value)`
  `void`
  `pushConstant(ConstantExpression expression)`
  load the constant on the operand stack.
  `void`
  `pushDynamicName(Expression name)`
  `void`
  `remove(int amount)`
  Remove amount elements from the operand stack, without using pop.
  `void`
  `replace(ClassNode type)`
  replace top level element with new element of given type
  `void`
  `replace(ClassNode type, int n)`
  replace n top level elements with new element of given type
  `void`
  `storeVar(BytecodeVariable variable)`
  `void`
  `swap()`
  swap two top level operands
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### OperandStack

    public OperandStack(WriterController controller)

- ## Method Details

  - ### getStackLength

    public int getStackLength()

  - ### popDownTo

    public void popDownTo(int elements)

  - ### castToBool

    public void castToBool(int mark, boolean emptyDefault)
    ensure last marked parameter on the stack is a primitive boolean if mark==stack size, we assume an empty expression or statement. was used and we will use the value given in emptyDefault as boolean if mark==stack.size()-1 the top element will be cast to boolean using Groovy truth. In other cases we throw a GroovyBugError

  - ### pop

    public void pop()
    remove operand stack top element using bytecode pop

  - ### jump

    public org.objectweb.asm.Label jump(int ifIns)

  - ### jump

    public void jump(int ifIns, org.objectweb.asm.Label label)

  - ### dup

    public void dup()
    duplicate top element

  - ### box

    public ClassNode box()

  - ### remove

    public void remove(int amount)
    Remove amount elements from the operand stack, without using pop. For example after a method invocation

  - ### push

    public void push(ClassNode type)
    push operand on stack

  - ### swap

    public void swap()
    swap two top level operands

  - ### replace

    public void replace(ClassNode type)
    replace top level element with new element of given type

  - ### replace

    public void replace(ClassNode type, int n)
    replace n top level elements with new element of given type

  - ### doGroovyCast

    public void doGroovyCast(ClassNode targetType)
    do Groovy cast for top level element

  - ### doGroovyCast

    public void doGroovyCast(Variable v)

  - ### doAsType

    public void doAsType(ClassNode targetType)

  - ### pushConstant

    public void pushConstant(ConstantExpression expression)
    load the constant on the operand stack.

  - ### pushDynamicName

    public void pushDynamicName(Expression name)

  - ### loadOrStoreVariable

    public void loadOrStoreVariable(BytecodeVariable variable, boolean useReferenceDirectly)

  - ### storeVar

    public void storeVar(BytecodeVariable variable)

  - ### load

    public void load(ClassNode type, int idx)

  - ### pushBool

    public void pushBool(boolean value)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getTopOperand

    public ClassNode getTopOperand()