Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jreversepro.runtime
Class JSymbolTable  view JSymbolTable download JSymbolTable.java

java.lang.Object
  extended byjreversepro.runtime.JSymbolTable
All Implemented Interfaces:
jreversepro.common.KeyWords

public class JSymbolTable
extends java.lang.Object
implements jreversepro.common.KeyWords

JSymbolTable - Symbol Table of a method containing local variables only.


Field Summary
static int ARG_INDEX
          Index of the argument into the symbol table.
(package private)  int basicIndex
          basicIndex here.
(package private)  jreversepro.reflect.JImport imports
          Imported Classes here.
(package private) static java.util.List keywords
          List of keywords in the language
(package private)  int maxArgs
          Maximum args in that symbol count mentioned in maxSymbols
(package private)  int maxSymbols
          Maximum number of symbols that can be in the table at any given time
(package private)  java.util.Map symbols
          Map of the Symbols - Key - local variable index - java.lang.Integer Value - List of JLocalEntry.
(package private)  java.util.Map symNames
          Key - Symbol Name Value - JLocalEntry.
 
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
 
Constructor Summary
JSymbolTable(jreversepro.reflect.JMethod rhsMethod, jreversepro.reflect.JImport imports)
           
 
Method Summary
private  void addEntry(int aVarIndex, int aStoreIndex, java.lang.String aDatatype, boolean aDeclared)
          Adds a new entry to the localsymboltable.
 void addReference(int aVarIndex, java.lang.String aDatatype, int aIndex)
          This method primarily keeps track of the last line that references the variable represented by aVarIndex and the datatype aDataType.
 void assignDataType(int aVarIndex, java.lang.String aDatatype, int aVarStore, boolean aDeclared)
          Adds a new datatype to the symboltable dynamically .
 java.lang.String declare(int aVarIndex, int aInsIndex)
          Declares a variable represented by aVarIndex and aInsIndex and returns its datatype.
 java.util.List defineVariable(int endOfBranch)
          Given the endOfBranch of a branch, this method returns a List of strings, of the form They represent the variables that are to be declared before we enter into the branch whose endOfBranch is given as argument.
private  java.lang.String genName(java.lang.String aType, int aVarIndex)
          Generates an name for the type and the variableIndex.
private  java.lang.String genUniqueName(java.lang.String name, int aVarIndex)
          Generate Unique name for the variables.
 java.lang.String getDataType(int aVarIndex, int aInsIndex)
           
static java.util.List getKeyWordsList()
           
private  JLocalEntry getMatchingEntry(int aVarIndex, int aInsIndex)
           
 int getMaxSymbols()
           
 java.lang.String getName(int aVarIndex, int aInsIndex)
           
private  void loadSymbols(java.util.List aArgs, int startIndex)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void touchVariable(java.lang.String aVarName, java.lang.String aNewType)
          Touch variable is basically assigning a new datatype in place of the old one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

symbols

java.util.Map symbols
Map of the Symbols - Key - local variable index - java.lang.Integer Value - List of JLocalEntry. since for the same localvariable index more than one datatype may exist.


symNames

java.util.Map symNames
Key - Symbol Name Value - JLocalEntry.


keywords

static java.util.List keywords
List of keywords in the language


maxSymbols

int maxSymbols
Maximum number of symbols that can be in the table at any given time


maxArgs

int maxArgs
Maximum args in that symbol count mentioned in maxSymbols


basicIndex

int basicIndex
basicIndex here.


imports

jreversepro.reflect.JImport imports
Imported Classes here.


ARG_INDEX

public static final int ARG_INDEX
Index of the argument into the symbol table.

See Also:
Constant Field Values
Constructor Detail

JSymbolTable

public JSymbolTable(jreversepro.reflect.JMethod rhsMethod,
                    jreversepro.reflect.JImport imports)
Method Detail

getMaxSymbols

public int getMaxSymbols()

loadSymbols

private void loadSymbols(java.util.List aArgs,
                         int startIndex)

assignDataType

public void assignDataType(int aVarIndex,
                           java.lang.String aDatatype,
                           int aVarStore,
                           boolean aDeclared)
Adds a new datatype to the symboltable dynamically . Parameters required are the


addReference

public void addReference(int aVarIndex,
                         java.lang.String aDatatype,
                         int aIndex)
This method primarily keeps track of the last line that references the variable represented by aVarIndex and the datatype aDataType. Please note that this referencing is essential to define the variables correctly, neither too early, nor too late. Also this is not necessary for arguments, but more necessary for localvariables whose declarations are inside the method code block.


defineVariable

public java.util.List defineVariable(int endOfBranch)
Given the endOfBranch of a branch, this method returns a List of strings, of the form They represent the variables that are to be declared before we enter into the branch whose endOfBranch is given as argument.


touchVariable

public void touchVariable(java.lang.String aVarName,
                          java.lang.String aNewType)
Touch variable is basically assigning a new datatype in place of the old one. This arises especially in the following case: Say, we see List list = new Vector(); list.add("sz"); On seeing new Vector() we conclude the var type is of type Vector. On seeing list.add("sz") we 'touch' it saying that the type is now List and not Vector.


getName

public java.lang.String getName(int aVarIndex,
                                int aInsIndex)
                         throws jreversepro.revengine.RevEngineException

getDataType

public java.lang.String getDataType(int aVarIndex,
                                    int aInsIndex)
                             throws jreversepro.revengine.RevEngineException

declare

public final java.lang.String declare(int aVarIndex,
                                      int aInsIndex)
                               throws jreversepro.revengine.RevEngineException
Declares a variable represented by aVarIndex and aInsIndex and returns its datatype.


getMatchingEntry

private JLocalEntry getMatchingEntry(int aVarIndex,
                                     int aInsIndex)

addEntry

private void addEntry(int aVarIndex,
                      int aStoreIndex,
                      java.lang.String aDatatype,
                      boolean aDeclared)
Adds a new entry to the localsymboltable.


genName

private java.lang.String genName(java.lang.String aType,
                                 int aVarIndex)
Generates an name for the type and the variableIndex.


genUniqueName

private java.lang.String genUniqueName(java.lang.String name,
                                       int aVarIndex)
Generate Unique name for the variables.


getKeyWordsList

public static java.util.List getKeyWordsList()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).