SandMark version 2.0


sandmark.obfuscate.boolsplitter.dtree
Class OperandStack

java.lang.Object
  |
  +--sandmark.obfuscate.boolsplitter.dtree.OperandStack

public class OperandStack
extends java.lang.Object

OperandStack is used to simulate the JVM stack. A stack of expressions is maintained. OperandStack has methods to push and pop (both wide and non-wide) expressions, replace an expression at a given depth in the stack, peek into the stack, etc.

See Also:
Expr, Tree

Field Summary
(package private)  int height
           
(package private)  java.util.ArrayList stack
           
 
Constructor Summary
OperandStack()
          Constructor.
 
Method Summary
 Expr get(int index)
          Returns the expression at index from the bottom of the stack.
 int height()
           
 boolean isEmpty()
           
 Expr peek()
          Returns the expression at the top of the stack, but does not modify the stack.
 Expr peek(int depth)
          Get the expression that is depth expressions from the top of the stack, but do not modify the stack.
 Expr pop(EDU.purdue.cs.bloat.editor.Type type)
          Pops an operand off the stack.
 Expr pop1()
          Pops a non-wide expression off the stack.
 Expr[] pop2()
          Pops a (possibly) wide expression off of the stack and returns the result as an array of Expr.
 void push(Expr expr)
          Push an expression onto the stack.
 void replace(int depth, Expr expr)
          Replaces the expression that is depth expressions from the top of the stack.
 void set(int index, Expr expr)
          Sets the entry at a specified index from the bottom of the stack
 int size()
          Returns the number of expressions on the stack.
 java.lang.String toString()
          Returns a String represntation of this stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stack

java.util.ArrayList stack

height

int height
Constructor Detail

OperandStack

public OperandStack()
Constructor.

Method Detail

isEmpty

public boolean isEmpty()
Returns:
True, if the stack is empty.

pop

public Expr pop(EDU.purdue.cs.bloat.editor.Type type)
Pops an operand off the stack. Checks to make sure the top of the stack is of the expected Type.

Parameters:
type - The expected Type of the top of the stack
Returns:
Expression on the top of the stack

peek

public Expr peek()
Returns the expression at the top of the stack, but does not modify the stack.


set

public void set(int index,
                Expr expr)
Sets the entry at a specified index from the bottom of the stack

Parameters:
index - The position in the stack.
expr - The new value of the expression.

height

public int height()
Returns:
The number of elements in the stack.

replace

public void replace(int depth,
                    Expr expr)
Replaces the expression that is depth expressions from the top of the stack.

Parameters:
depth - The number of expressions from the top of the stack.
expr - The new expression

peek

public Expr peek(int depth)
Get the expression that is depth expressions from the top of the stack, but do not modify the stack.

Parameters:
depth - Number of expressions deep to get.
Returns:
The expression that is depth expression from the top of the stack.

pop1

public Expr pop1()
Pops a non-wide expression off the stack.


pop2

public Expr[] pop2()
Pops a (possibly) wide expression off of the stack and returns the result as an array of Expr. If the expression at the top of the stack is indeed wide, it is returned in element [0] of the array. If the expression at the top of the stack is not wide, the top two expressions are returned in the array as elements 0 and 1.


push

public void push(Expr expr)
Push an expression onto the stack.

See Also:
Type.stackHeight()

size

public int size()
Returns the number of expressions on the stack.


get

public Expr get(int index)
Returns the expression at index from the bottom of the stack.


toString

public java.lang.String toString()
Returns a String represntation of this stack.

Overrides:
toString in class java.lang.Object

SandMark version 2.0

Mon Jun 17 12:30:47 MST 2002