joaoarthurbm / designwizard

DesignWizard (https://sites.google.com/site/designwizardhomepage/) supports automated inspection of Java programs in a higher level than ASM bytecode manipulator.
Other
17 stars 8 forks source link

Add the extraction of local variables as a LOAD relation. #47

Closed tacianosilva closed 8 years ago

tacianosilva commented 8 years ago

The lack of local variable extraction caused a failure to return the getEntitiesUsedBy() method of MethodNode class. For example, the code 1 and 2 below the use of information LocalVariable class is not extracted.

Code Example 1

/**
 * Tests the local variable extraction (with cast in local variable).
 */
public void castLocalVariable() {
    LocalVariable var = null;
    if (true) {
        var = (LocalVariable) getObject(); // returns an Object class
    }
    System.out.println("Local Variavle: " + var);
}

Code Example 2

/**
 * Tests the local variable extraction (with assignment in local variable).
 */
public void assignmentLocalVariable() {
    LocalVariable var = null;
    if (true) {
        var = getLocalVariable(); // returns a LocalVariable class
    }
    System.out.println("Local Variavle: " + var);
}

An implementation of the extraction of local variables in the FactsExtractionMethodVisitor.visitLocalVariable() as a LOAD relation to represent the relation between this method and the class of the local variable.

The addition of this feature will cause some impact on getCalleeEntities() methods. @joaoarthurbm, Is there any reason not to have this feature?