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

Quick Search    Search Deep

jreversepro.revengine
Class JBranchEntry  view JBranchEntry download JBranchEntry.java

java.lang.Object
  extended byjreversepro.revengine.JBranchEntry
All Implemented Interfaces:
BranchConstants, jreversepro.common.KeyWords, jreversepro.runtime.OperandConstants

public class JBranchEntry
extends java.lang.Object
implements jreversepro.common.KeyWords, BranchConstants, jreversepro.runtime.OperandConstants

JBranchEntry refers to a single conditional BranchEntry only.


Field Summary
(package private)  jreversepro.reflect.method.JBlockObject block
          The JBlockObject associated with this JBranchEntry
(package private)  jreversepro.reflect.JMethod method
          The method corresponding to the code being processed
(package private)  int nextPc
          nextPc is the NextPc of the branch entry.
(package private)  java.lang.String operator
          Operator
(package private)  java.lang.String opr1
          Operand 1
(package private)  java.lang.String opr2
          Operand 2.
(package private)  int startPc
          startPc is the start of the branch entry
(package private)  int targetPc
          targetPc is the targetPc of the branch entry
(package private)  int type
          type of the branch type
(package private)  boolean written
          Written flag - to signify if the branch has been written on the source code.
 
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.revengine.BranchConstants
TYPE_BRANCH, TYPE_CASE, TYPE_CATCH, TYPE_CATCH_ANY, TYPE_DO_WHILE, TYPE_ELSE, TYPE_ELSE_IF, TYPE_GOTO, TYPE_IF, TYPE_INVALID, TYPE_JSR, TYPE_RET, TYPE_SWITCH, TYPE_SYNC, TYPE_TRY, TYPE_TRY_ANY, TYPE_WHILE
 
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
JBranchEntry(jreversepro.reflect.JMethod method, int startPc, int targetPc, int type)
           
JBranchEntry(jreversepro.reflect.JMethod method, int startPc, int nextPc, int targetPc, int type, java.lang.String opr1, java.lang.String opr2, java.lang.String operator)
           
 
Method Summary
 boolean appendEndBlockStmt(JDecompiler decomp, jreversepro.runtime.JOperandStack jos)
          Appends end block statement for a branch entry.
 void appendStartBlockStmtX(JDecompiler decomp)
          Append the code for the beginning of a block
(package private)  boolean collate()
          Collates a single statement , depending on if it is a IF / WHILE statement.
 void complementOperator()
          Complements the conditional operator of the branch
 void convertToWhile()
          This is invoked under the following circumstances.
 boolean doesContain(int aPc)
          Returns if the given Pc is enclosed in the mentioned block
 boolean doesStartWith(int rhsStartPc)
          This method checks if this particular branch block starts with the given Pc.
private  java.lang.String getComplementOperator(java.lang.String rhs)
          Returns the complementary operator of the given operator.
private  java.lang.String getCondition(boolean complement)
          Given the index to the entry in the BranchTable , this returns the condition .
 int getEndBlockPc()
           
 java.lang.String getExpression()
          Trims the expression for a condition here.
 int getNextPc()
           
 java.lang.String getOpr1()
           
 int getStartBlockPc()
           
 int getStartExecPc()
           
 int getStartPc()
           
 int getTargetPc()
           
 int getType()
           
 boolean independent()
          Lets us know if the block is independent.
 boolean isWhile()
          Returns if the branch mentioned can be a TYPE_WHILE.
 void resetWrittenFlag()
          Resets the written flag
 void rewriteCondition(JBranchEntry nextEntry, java.lang.String conditionType, boolean complement)
          This merges the current condition represented by the current JBranchEntry.
 void setEndBlockPc(int aNewPc)
          Sets the end pc of this block.
 void setNextPc(int nextPc)
          Setter method for NextPc.
 void setOpr1(java.lang.String opr1)
           
 void setOpr2(java.lang.String opr2)
           
 void setStartPc(int startPc)
           
 void setTargetPc(int targetPc)
           
 void setType(int type)
          Setter method for type.
 void setWrittenFlag()
          Sets the written flag.
 java.lang.String toString()
          Convert this Object to a human-readable String.
(package private)  void writeCase(boolean case1, boolean ifstat, JBranchEntry entryB)
          Case 1:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startPc

int startPc
startPc is the start of the branch entry


targetPc

int targetPc
targetPc is the targetPc of the branch entry


nextPc

int nextPc
nextPc is the NextPc of the branch entry.


type

int type
type of the branch type


opr1

java.lang.String opr1
Operand 1


opr2

java.lang.String opr2
Operand 2.


operator

java.lang.String operator
Operator


written

boolean written
Written flag - to signify if the branch has been written on the source code.


method

jreversepro.reflect.JMethod method
The method corresponding to the code being processed


block

jreversepro.reflect.method.JBlockObject block
The JBlockObject associated with this JBranchEntry

Constructor Detail

JBranchEntry

public JBranchEntry(jreversepro.reflect.JMethod method,
                    int startPc,
                    int targetPc,
                    int type)

JBranchEntry

public JBranchEntry(jreversepro.reflect.JMethod method,
                    int startPc,
                    int nextPc,
                    int targetPc,
                    int type,
                    java.lang.String opr1,
                    java.lang.String opr2,
                    java.lang.String operator)
Method Detail

setWrittenFlag

public void setWrittenFlag()
Sets the written flag.


resetWrittenFlag

public void resetWrittenFlag()
Resets the written flag


isWhile

public boolean isWhile()
Returns if the branch mentioned can be a TYPE_WHILE. One indication of a while loop is that the startPc > targetPc.


getStartPc

public int getStartPc()

getTargetPc

public int getTargetPc()

getNextPc

public int getNextPc()

getType

public final int getType()

getOpr1

public java.lang.String getOpr1()

setNextPc

public void setNextPc(int nextPc)
Setter method for NextPc.


setTargetPc

public void setTargetPc(int targetPc)

setStartPc

public void setStartPc(int startPc)

setType

public void setType(int type)
Setter method for type.


setOpr1

public void setOpr1(java.lang.String opr1)

setOpr2

public void setOpr2(java.lang.String opr2)

convertToWhile

public void convertToWhile()
This is invoked under the following circumstances. First this is recognized as a 'if' branch. Then afterwards recognized as 'while' branch.


complementOperator

public void complementOperator()
Complements the conditional operator of the branch


writeCase

void writeCase(boolean case1,
               boolean ifstat,
               JBranchEntry entryB)
Case 1:


a: x y z
b: y p1 p2
z:

This means either a 'IF OR ' or and 'WHILE AND' between the statements.
Now the row 'b' is invalidated , and contents of a become
a: x p1 p2
The Operands are also changed accordingly. Case 2:


a: x y z
b: y p1 z OR
a: x y z
z: .....
b: y p1 p2

This means either a 'IF AND' or 'WHILE OR' between the statements.
+ Now the row 'b' is invalidated , and contents of a become
a: x p1 p2
The Operands are also changed accordingly.



collate

boolean collate()
Collates a single statement , depending on if it is a IF / WHILE statement.


doesStartWith

public boolean doesStartWith(int rhsStartPc)
                      throws RevEngineException
This method checks if this particular branch block starts with the given Pc.


independent

public boolean independent()
Lets us know if the block is independent. When we say independent, we refer to blocks that can start on its own, Examples of the same - if, while, try, do..while. switch Examples of dependent branch blocks are . else_if , else, catch each dependent on one of the independent block for is existence


doesContain

public boolean doesContain(int aPc)
                    throws RevEngineException
Returns if the given Pc is enclosed in the mentioned block


getStartBlockPc

public int getStartBlockPc()
                    throws RevEngineException

getEndBlockPc

public int getEndBlockPc()
                  throws RevEngineException

getStartExecPc

public int getStartExecPc()
                   throws RevEngineException

appendStartBlockStmtX

public final void appendStartBlockStmtX(JDecompiler decomp)
Append the code for the beginning of a block


appendEndBlockStmt

public final boolean appendEndBlockStmt(JDecompiler decomp,
                                        jreversepro.runtime.JOperandStack jos)
Appends end block statement for a branch entry.


rewriteCondition

public void rewriteCondition(JBranchEntry nextEntry,
                             java.lang.String conditionType,
                             boolean complement)
This merges the current condition represented by the current JBranchEntry.


setEndBlockPc

public void setEndBlockPc(int aNewPc)
Sets the end pc of this block.


getCondition

private java.lang.String getCondition(boolean complement)
Given the index to the entry in the BranchTable , this returns the condition .

For example , if an entry has
4: i 3 != .
Then getCondition(4,true) yields i != 3 and
getCondition(4,false) yields i == 3

.


getComplementOperator

private java.lang.String getComplementOperator(java.lang.String rhs)
Returns the complementary operator of the given operator.


getExpression

public java.lang.String getExpression()
Trims the expression for a condition here. For eg, an expression of the form - if ( a == true ) is converted to 'a' ( just 'a' ). These small modifications improve the readability of the code.


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()).