when it is available, add source position info to IR printing
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@527 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
fbe230b164
commit
f3f4a25a20
|
@ -91,6 +91,23 @@ public class ShrikeIRFactory implements IRFactory {
|
|||
DeadAssignmentElimination.perform(this);
|
||||
}
|
||||
|
||||
protected String instructionPosition(int instructionIndex) {
|
||||
try {
|
||||
int bcIndex =
|
||||
((ShrikeCTMethodWrapper) method).getBytecodeIndex(instructionIndex);
|
||||
int lineNumber =
|
||||
((ShrikeCTMethodWrapper) method).getLineNumber(bcIndex);
|
||||
|
||||
if (lineNumber == -1) {
|
||||
return "";
|
||||
} else {
|
||||
return "(line " + lineNumber + ")";
|
||||
}
|
||||
} catch (InvalidClassFileException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public SSA2LocalMap getLocalMap() {
|
||||
return localMap;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,13 @@ public class SyntheticIR extends IR {
|
|||
return symbolTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns "", as synthetic IRs have no line numbers right now.
|
||||
*/
|
||||
protected String instructionPosition(int instructionIndex) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns null, as synthetic IRs have no local names right now.
|
||||
*/
|
||||
|
|
|
@ -133,6 +133,8 @@ public abstract class IR {
|
|||
return toString(null);
|
||||
}
|
||||
|
||||
protected abstract String instructionPosition(int instructionIndex);
|
||||
|
||||
/**
|
||||
* Create a string representation, with decoration for each variable
|
||||
*
|
||||
|
@ -171,8 +173,9 @@ public abstract class IR {
|
|||
for (int j = start; j <= end; j++) {
|
||||
if (instructions[j] != null) {
|
||||
StringBuffer x = new StringBuffer(j + " " + instructions[j].toString(symbolTable, d));
|
||||
StringStuff.padWithSpaces(x, 35);
|
||||
StringStuff.padWithSpaces(x, 45);
|
||||
result.append(x);
|
||||
result.append(instructionPosition(j));
|
||||
result.append("\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue