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:
dolby-oss 2007-01-08 14:53:10 +00:00
parent fbe230b164
commit f3f4a25a20
3 changed files with 28 additions and 1 deletions

View File

@ -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;
}

View File

@ -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.
*/

View File

@ -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");
}
}