org.apache.commons.javaflow.bytecode.transformation.bcel.analyser
Class OperandStack

java.lang.Object
  extended by org.apache.commons.javaflow.bytecode.transformation.bcel.analyser.OperandStack

public class OperandStack
extends java.lang.Object

This class implements a stack used for symbolic JVM stack simulation. [It's used an an operand stack substitute.] Elements of this stack are org.apache.bcel.generic.Type objects. WARNING! These classes are a fork of the bcel verifier.

Version:
$Id: OperandStack.java 480487 2006-11-29 08:54:42Z bayard $
Author:
Enver Haase

Constructor Summary
OperandStack(int maxStack)
          Creates an empty stack with a maximum of maxStack slots.
OperandStack(int maxStack, org.apache.bcel.generic.ObjectType obj)
          Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.
 
Method Summary
 void clear()
          Clears the stack.
protected  java.lang.Object clone()
          Returns a deep copy of this object; that means, the clone operates on a new stack.
 boolean equals(java.lang.Object o)
          Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.
 OperandStack getClone()
          Returns a (typed!) clone of this.
 void initializeObject(UninitializedObjectType u)
          Replaces all occurences of u in this OperandStack instance with an "initialized" ObjectType.
 boolean isEmpty()
          Returns true IFF this OperandStack is empty.
 int maxStack()
          Returns the number of stack slots this stack can hold.
 void merge(OperandStack s)
          Merges another stack state into this instance's stack state.
 org.apache.bcel.generic.Type peek()
          Returns the element on top of the stack.
 org.apache.bcel.generic.Type peek(int i)
          Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned.
 org.apache.bcel.generic.Type pop()
          Returns the element on top of the stack.
 org.apache.bcel.generic.Type pop(int i)
          Pops i elements off the stack.
 void push(org.apache.bcel.generic.Type type)
          Pushes a Type object onto the stack.
 int size()
          Returns the size of this OperandStack; that means, how many Type objects there are.
 int slotsUsed()
          Returns the number of stack slots used.
 java.lang.String toString()
          Returns a String representation of this OperandStack instance.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperandStack

public OperandStack(int maxStack)
Creates an empty stack with a maximum of maxStack slots.


OperandStack

public OperandStack(int maxStack,
                    org.apache.bcel.generic.ObjectType obj)
Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.

Method Detail

clone

protected java.lang.Object clone()
Returns a deep copy of this object; that means, the clone operates on a new stack. However, the Type objects on the stack are shared.

Overrides:
clone in class java.lang.Object

clear

public void clear()
Clears the stack.


equals

public boolean equals(java.lang.Object o)
Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.

Overrides:
equals in class java.lang.Object

getClone

public OperandStack getClone()
Returns a (typed!) clone of this.

See Also:
clone()

isEmpty

public boolean isEmpty()
Returns true IFF this OperandStack is empty.


maxStack

public int maxStack()
Returns the number of stack slots this stack can hold.


peek

public org.apache.bcel.generic.Type peek()
Returns the element on top of the stack. The element is not popped off the stack!


peek

public org.apache.bcel.generic.Type peek(int i)
Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned. The element is not popped off the stack!


pop

public org.apache.bcel.generic.Type pop()
Returns the element on top of the stack. The element is popped off the stack.


pop

public org.apache.bcel.generic.Type pop(int i)
Pops i elements off the stack. ALWAYS RETURNS "null"!!!


push

public void push(org.apache.bcel.generic.Type type)
Pushes a Type object onto the stack.


size

public int size()
Returns the size of this OperandStack; that means, how many Type objects there are.


slotsUsed

public int slotsUsed()
Returns the number of stack slots used.

See Also:
maxStack()

toString

public java.lang.String toString()
Returns a String representation of this OperandStack instance.

Overrides:
toString in class java.lang.Object

merge

public void merge(OperandStack s)
Merges another stack state into this instance's stack state. See the Java Virtual Machine Specification, Second Edition, page 146: 4.9.2 for details.


initializeObject

public void initializeObject(UninitializedObjectType u)
Replaces all occurences of u in this OperandStack instance with an "initialized" ObjectType.



Copyright 2004-2008 The Apache Software Foundation. All Rights Reserved.