Hi, The attached files add support for the "SourceFile" attribute to Soot. I've found a need for this and thought others might too. I hope that the way I've implemented it is correct. Please commit to CVS if desired. The patch also includes a couple of other minor additions & fixes. The patch was generated vs. soot-2.0.1. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Halloo Communications * http://www.halloo.com
Attachment:
SourceFileTag.java
Description: application/java
diff -ur xx/soot-2.0.1/soot/src/soot/coffi/Util.java soot-2.0.1/soot/src/soot/coffi/Util.java --- xx/soot-2.0.1/soot/src/soot/coffi/Util.java Wed Jun 18 07:17:17 2003 +++ soot-2.0.1/soot/src/soot/coffi/Util.java Sun Nov 30 14:45:49 2003 @@ -36,6 +36,7 @@ import java.util.*; import java.io.*; import soot.baf.*; +import soot.tagkit.*; import soot.*; @@ -508,6 +509,16 @@ methodInfo.jmethod.setSource(new CoffiMethodSource(coffiClass, methodInfo)); } + // Set "SourceFile" attribute tag + for(int i = 0; i < coffiClass.attributes_count; i++) + { + if(!(coffiClass.attributes[i] instanceof SourceFile_attribute)) + continue; + SourceFile_attribute attr = (SourceFile_attribute)coffiClass.attributes[i]; + bclass.addTag(new SourceFileTag( + ((CONSTANT_Utf8_info)(coffiClass.constant_pool[attr.sourcefile_index])).convert())); + break; + } } diff -ur xx/soot-2.0.1/soot/src/soot/tagkit/BytecodeOffsetTag.java soot-2.0.1/soot/src/soot/tagkit/BytecodeOffsetTag.java --- xx/soot-2.0.1/soot/src/soot/tagkit/BytecodeOffsetTag.java Wed Jun 18 07:17:17 2003 +++ soot-2.0.1/soot/src/soot/tagkit/BytecodeOffsetTag.java Sun Nov 30 14:17:45 2003 @@ -49,7 +49,7 @@ return "BytecodeOffsetTag"; } - /** Returns the offset in a two byte array. + /** Returns the offset in a four byte array. */ public byte [] getValue() { byte [] v = new byte[4]; @@ -58,6 +58,12 @@ v[2] = (byte) ((offset >> 8) % 256);; v[3] = (byte) (offset % 256); return v; + } + + /** Returns the offset as an int. + */ + public int getBytecodeOffset() { + return offset; } /** Returns the offset in a string. diff -ur xx/soot-2.0.1/soot/src/soot/tagkit/LineNumberTag.java soot-2.0.1/soot/src/soot/tagkit/LineNumberTag.java --- xx/soot-2.0.1/soot/src/soot/tagkit/LineNumberTag.java Wed Jun 18 07:17:17 2003 +++ soot-2.0.1/soot/src/soot/tagkit/LineNumberTag.java Sun Nov 30 14:17:08 2003 @@ -49,6 +49,11 @@ return v; } + public int getLineNumber() + { + return line_number; + } + public String toString() { return ""+line_number;