jreversepro.runtime
Class JOperandStack

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<E>
              extended by java.util.Stack<Operand>
                  extended by jreversepro.runtime.JOperandStack
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Operand>, java.util.Collection<Operand>, java.util.List<Operand>, java.util.RandomAccess, KeyWords, OperandConstants

public class JOperandStack
extends java.util.Stack<Operand>
implements KeyWords, OperandConstants

Operand Stack is the abstraction of the Java Method Operand Stack. The variables are pushed to and popped from, this stack.

Author:
Karthik Kumar.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface jreversepro.common.KeyWords
ANY, BOOLEAN, BREAK, BYTE, CASE, CHAR, CLASS, CLASS_STRING, CLINIT, CLOSE_BRACKET, COND_AND, COND_NOT, COND_OR, CONTINUE, DEFAULT, DEFAULT_PACKAGE, DOUBLE, EQUALTO, FALSE, FLOAT, FOREIGN_CLASS, FOREIGN_OBJ, GOTO, INIT, INSTANCEOF, INT, INTERFACE, JVM_BOOLEAN, JVM_CHAR, JVM_VOID, LANG_OBJECT, LENGTH, LONG, NEW, NULL, OPEN_BRACKET, OPR_EQ, OPR_GE, OPR_GT, OPR_LE, OPR_LT, OPR_NE, OPR_NOT, REFERENCE, RET_ADDR, RETURN, SHORT, SPACE, STATIC, SUPER, SWITCH, THIS, THISCLASS, THROW, TRUE, VOID
 
Fields inherited from interface jreversepro.runtime.OperandConstants
L_ADD, L_BITAND, L_BITOR, L_BITXOR, L_CAST, L_COMMA, L_DIV, L_EVAL, L_INDEX, L_LOGAND, L_LOGEQ, L_LOGIOF, L_LOGNEQ, L_LOGOR, L_LOGREL, L_MOD, L_MUL, L_REF, L_SHIFT, L_SUB, L_TERN, L_UNARY, VALUE
 
Constructor Summary
JOperandStack()
          Empty constructor
 
Method Summary
 void addConstant(java.lang.String constant)
          Adds a new constant.
 java.util.List<java.lang.String> getConstants()
           
 java.lang.String getConstantValues()
          Returns the values of the constants serialized such that it corresponds to java syntax code too.
 boolean isTopDatatypeForeign()
          Lets us know if the top data type is foreign.
 void mergeTopTwo()
          Merges the top two contents of the operand stack.
 void push(int value, java.lang.String datatype, int precedence)
           
 void push(java.lang.String value, java.lang.String datatype, int precedence)
           
 void removeAllConstants()
          Deletes all the constants that were stored in the vector already.
 java.lang.String topDatatype()
           
 
Methods inherited from class java.util.Stack
empty, peek, pop, push, search
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

JOperandStack

public JOperandStack()
Empty constructor

Method Detail

addConstant

public void addConstant(java.lang.String constant)
Adds a new constant.

Parameters:
constant - New Constant to be added to the vector.

removeAllConstants

public void removeAllConstants()
Deletes all the constants that were stored in the vector already.


getConstants

public java.util.List<java.lang.String> getConstants()
Returns:
List of constants that were stored.

getConstantValues

public java.lang.String getConstantValues()
Returns the values of the constants serialized such that it corresponds to java syntax code too.

Returns:
Constant values.

push

public void push(java.lang.String value,
                 java.lang.String datatype,
                 int precedence)
Parameters:
value - Value of the Operand - Stack element. The Value is String.
datatype - Datatype of the stack element.
precedence - precedence of the stack element.

push

public void push(int value,
                 java.lang.String datatype,
                 int precedence)
Parameters:
value - Value of the Operand - Stack element. The Value is int.
datatype - Datatype of the stack element.
precedence - precedence of the stack element.

topDatatype

public java.lang.String topDatatype()
Returns:
Returns the data type of the topmost content of the stack.

isTopDatatypeForeign

public boolean isTopDatatypeForeign()
Lets us know if the top data type is foreign. Mainly this method is necessary when we have a operand loaded onto the stack from outside. ( Eg: an argument to the exception handler of the exception type ).

Returns:
true, if the top type is foreign. false. otherwise.

mergeTopTwo

public void mergeTopTwo()
                 throws RevEngineException
Merges the top two contents of the operand stack. Eg, if the stack contents are ab String cd String ( in reverse order - stack top first )., On merging it becomes abcd String ( in reverse order - stack top first )., The precondition is that the datatypes of first top two elements ought to be the same. Then only this is valid.

Throws:
RevEngineException - Thrown when there are less than 2 elements in the stack.


Submit Feedback to akkumar@users.sourceforge.net