private void addSourceFileTag(soot.SootClass sc) { if (fileName == null && zipFileName == null) { return; } soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { tag = (soot.tagkit.SourceFileTag) sc.getTag("SourceFileTag"); } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } // Sets sourceFile only when it hasn't been set before if (tag.getSourceFile() == null) { String name = zipFileName == null ? new File(fileName).getName() : new File(zipFileName).getName(); tag.setSourceFile(name); } }
/** * Writes out the information stored in the tags associated with the given statement * * @param builder * The builder used to generate the Dalvik method implementation * @param stmt * The statement for which to write out the tags */ protected void writeTagsForStatement(MethodImplementationBuilder builder, Stmt stmt) { List<Tag> tags = stmt.getTags(); for (Tag t : tags) { if (t instanceof LineNumberTag) { LineNumberTag lnt = (LineNumberTag) t; builder.addLineNumber(lnt.getLineNumber()); } else if (t instanceof SourceFileTag) { SourceFileTag sft = (SourceFileTag) t; builder.addSetSourceFile(new ImmutableStringReference(sft.getSourceFile())); } } }
if (c.hasTag("SourceFileTag")) { SourceFileTag sft = (SourceFileTag) c.getTag("SourceFileTag"); sourceFile = sft.getSourceFile();
String srcName = ((SourceFileTag) sootClass.getTag("SourceFileTag")).getSourceFile();
/** * Emits the bytecode for the complete class */ protected void generateByteCode() { generateClassHeader(); // Retrieve information about the source of the class if (sc.hasTag("SourceFileTag") && !Options.v().no_output_source_file_attribute()) { String srcName = ((SourceFileTag) sc.getTag("SourceFileTag")).getSourceFile(); cv.visitSource(srcName, null); // TODO Correct value for the debug // argument } // Retrieve information about outer class if present if (sc.hasOuterClass() || sc.hasTag("EnclosingMethodTag") || sc.hasTag("OuterClassTag")) { generateOuterClassReference(); } // Retrieve information about annotations generateAnnotations(cv, sc); // Retrieve information about attributes generateAttributes(); // Retrieve information about inner classes generateInnerClassReferences(); // Generate fields generateFields(); // Generate methods generateMethods(); cv.visitEnd(); }
private String findFileName(List<Tag> tags) { String fileName = null; for (Tag tag : tags) { if (tag instanceof SourceFileTag) { SourceFileTag t = (SourceFileTag) tag; if (t.getAbsolutePath() != null) { fileName = t.getAbsolutePath(); } else { if (t.getSourceFile() != null) { fileName = t.getSourceFile(); } } } else { // System.err.println("Unprocessed tag " + tag.getClass() + " - // " + tag); } } return fileName; }