本文整理汇总了Java中soot.tagkit.LineNumberTag类的典型用法代码示例。如果您正苦于以下问题:Java LineNumberTag类的具体用法?Java LineNumberTag怎么用?Java LineNumberTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineNumberTag类属于soot.tagkit包,在下文中一共展示了LineNumberTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalTransform
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
protected void internalTransform(Body b, String phaseName, Map<String,String> options) {
System.out.println("Printing Line Numbers for: " + b.getMethod().getSignature());
PatchingChain<Unit> units = b.getUnits(); // get the method code
Iterator<Unit> it = units.iterator();
while (it.hasNext()) { // for each jimple statement or baf instruction
Unit u = (Unit)it.next();
if (u.hasTag("LineNumberTag")) { // see if a LineNumberTag exists (it will if you use -keep-line-number)
LineNumberTag tag = (LineNumberTag)u.getTag(("LineNumberTag"));
System.out.println(u + " has Line Number: " + tag.getLineNumber()); // print out the unit and line number
} else {
System.out.println(u + " has no Line Number");
}
}
System.out.println("\n");
}
示例2: parseAnnotations
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
public void parseAnnotations(Unit u, int indx){
Set<String> annotationName = LogicBloxAnnotExporter.annotationName;
Map<Integer, List<Trio<String, String, String>>> pgmPtAnnot = LogicBloxAnnotExporter.pgmPtAnnot;
if(pgmPtAnnot.containsKey(indx))
return;
List<Trio<String, String, String>> annots = new ArrayList<Trio<String, String, String>>();
for(Tag t : u.getTags()){
if(t instanceof VisibilityAnnotationTag){
Map<String,List<Pair<String,String>>> parsed = SootUtilities.parseVisibilityAnnotationTag((VisibilityAnnotationTag)t);
for(String annotName : parsed.keySet()){
annotationName.add(annotName);
List<Pair<String,String>> keyValues = parsed.get(annotName);
for(Pair<String,String> p : keyValues){
annots.add(new Trio<String,String,String>(annotName,p.val0,p.val1));
}
}
}else if(t instanceof LineNumberTag){
LineNumberTag lnt = (LineNumberTag)t;
annotationName.add("LineNumberTag");
annots.add(new Trio<String,String,String>("LineNumberTag","LineNumber",Integer.toString(lnt.getLineNumber())) );
}
}
pgmPtAnnot.put(indx, annots);
}
示例3: getLineNumFromSoot
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
public int getLineNumFromSoot() {
Stmt context = null;
if (mRootSink != null) {
context = mRootSink.getContext();
} else if (mRootSource != null) {
context = mRootSource.getContext();
}
if (context == null) {
System.err.println("Context was not obtained neither from Sink nor from Source.");
return -1;
}
if (context.hasTag("LineNumberTag")) {
return ((LineNumberTag)context.getTag("LineNumberTag")).getLineNumber();
}
return -1;
}
示例4: highlightJavaSource
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
/**
* Highlights units in java source.
* @param unit The unit which needs to be highlighted.
*/
public void highlightJavaSource(VFUnit unit) {
try {
ServiceUtil.getService(DataModel.class).filterGraph(new ArrayList<VFNode>(), false, true, null);
} catch (Exception e) {
e.printStackTrace();
}
LineNumberTag ln = (LineNumberTag) unit.getUnit().getTag("LineNumberTag");
String className = unit.getVfMethod().getVfClass().getSootClass().getName();
if (ln != null) {
highLightJavaSourceCode(ln.getLineNumber(), className);
}
}
示例5: getSelectedUnit
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
/**
* This function filters the units of a class according to the function name and class name and content.
* We need to filter this based on methods, because different function might contain similar lines of code and
* hence their contents will be similar.
* @param className The name of the class.
* @param document The document which the user is currently interacting with
* @param content The contents of the document.
* @param lineNumber The linenumber on which the user has right-clicked.
* @return Map of filtered unit and the function it belongs to.
*/
private HashMap<VFUnit, VFMethod> getSelectedUnit(String className, IDocument document, int lineNumber) {
DataModel dataModel = ServiceUtil.getService(DataModel.class);
HashMap<VFUnit, VFMethod> map = new HashMap<VFUnit, VFMethod>();
for (VFClass vfClass : dataModel.listClasses()) {
if (vfClass.getSootClass().getShortJavaStyleName().equals(className)) {
List<VFMethod> vfMethods = vfClass.getMethods();
Map<String, Integer> methodLines = getMethodLineNumbers(document, vfMethods);
Collection<Integer> allMethodLines = methodLines.values();
List<Integer> lesserThanCuurent = allMethodLines.stream().filter(x -> x.intValue() < lineNumber).collect(Collectors.toList());
int toBeCompared = lesserThanCuurent.get(lesserThanCuurent.size() - 1);
for (VFMethod method : vfMethods) {
int methodLine = methodLines.getOrDefault(method.getSootMethod().getDeclaration(), 0);
if (methodLine != 0 && toBeCompared == methodLine) {
for (VFUnit unit : method.getUnits()) {
LineNumberTag ln = (LineNumberTag) unit.getUnit().getTag("LineNumberTag");
if (ln != null && ln.getLineNumber() == lineNumber + 1) {
map.put(unit, method);
}
}
}
}
}
}
return map;
}
示例6: toString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder sb = new StringBuilder(sink == null
? accessPath.toString() : sink.toString());
if (sink != null && sink.hasTag("LineNumberTag"))
sb.append(" on line ").append(((LineNumberTag)sink.getTag("LineNumberTag")).getLineNumber());
return sb.toString();
}
示例7: toString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toString(){
StringBuilder sb = new StringBuilder(source.toString());
if (source.hasTag("LineNumberTag"))
sb.append(" on line ").append(((LineNumberTag) source.getTag("LineNumberTag")).getLineNumber());
return sb.toString();
}
示例8: getLineNumber
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
private static int getLineNumber(Stmt s) {
Iterator ti = s.getTags().iterator();
while (ti.hasNext()) {
Object o = ti.next();
if (o instanceof LineNumberTag)
return Integer.parseInt(o.toString());
}
return -1;
}
示例9: addTags
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
/**
* Tag the passed host with: - this instructions line number (if one is set)
* - the original bytecode offset
*
* @param host
* the host to tag
*/
protected void addTags(Host host) {
if (lineNumber != -1) {
host.addTag(new LineNumberTag(lineNumber));
host.addTag(new SourceLineNumberTag(lineNumber));
}
host.addTag(new BytecodeOffsetTag(codeAddress));
}
示例10: getJavaLnOfHost
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
private int getJavaLnOfHost(Host h){
Iterator<Tag> it = h.getTags().iterator();
while (it.hasNext()){
Tag t = it.next();
if (t instanceof SourceLnPosTag) {
return ((SourceLnPosTag)t).startLn();
}
else if (t instanceof LineNumberTag){
return (new Integer(((LineNumberTag)t).toString())).intValue();
}
}
return 0;
}
示例11: getJavaLnOfHost
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
private int getJavaLnOfHost(Host h){
Iterator<Tag> it = h.getTags().iterator();
while (it.hasNext()){
Tag t = it.next();
//G.v().out.println(t.getClass().toString());
if (t instanceof SourceLnPosTag) {
//G.v().out.println("t is LineNumberTag");
return ((SourceLnPosTag)t).startLn();
}
else if (t instanceof LineNumberTag){
return (new Integer(((LineNumberTag)t).toString())).intValue();
}
}
return 0;
}
示例12: toXMLAttrsString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toXMLAttrsString(Object o) {
if (o instanceof Unit) {
Unit u = (Unit) o;
Type t = getType(u);
String type = (t != null) ? t.toString() : "null";
SootMethod m = SootUtilities.getMethod(u);
//String file = ((SourceFileTag)m.getDeclaringClass().getTags().get(0)).getSourceFile();
List<Tag> tags = m.getDeclaringClass().getTags();
String file = null;
for(Tag x : tags) {
if( x instanceof SourceFileTag) {
file = ((SourceFileTag)x).getSourceFile();
break;
}
}
int line = -1; // ((LineNumberTag)u.getTag("LineNumberTag")).getLineNumber();
Tag tg = u.getTag("LineNumberTag");
if(tg != null && tg instanceof LineNumberTag) {
line = ((LineNumberTag) tg).getLineNumber();
}
int mIdx = domM.indexOf(m);
return "file=\"" + file + "\" " + "line=\"" + line + "\" " +
"Mid=\"M" + mIdx + "\"" + " type=\"" + type + "\"";
}
return "";
}
示例13: toXMLAttrsString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toXMLAttrsString(Unit u) {
SootMethod m = SootUtilities.getMethod(u);
String file = ((SourceFileTag)m.getDeclaringClass().getTags().get(0)).getSourceFile();
int line = ((LineNumberTag)u.getTag("LineNumberTag")).getLineNumber();
int mIdx = domM.indexOf(m);
return "file=\"" + file + "\" " + "line=\"" + line + "\" " + "Mid=\"M" + mIdx + "\"";
//return "";
}
示例14: toXMLAttrsString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toXMLAttrsString(Unit u) {
SootMethod m = SootUtilities.getMethod(u);
//String file = ((SourceFileTag)m.getDeclaringClass().getTags().get(0)).getSourceFile();
LineNumberTag tag = (LineNumberTag)u.getTag("LineNumberTag");
int line = -1;
if(tag != null) line = tag.getLineNumber();
//int line = ((LineNumberTag)u.getTag("LineNumberTag")).getLineNumber();
int mIdx = domM.indexOf(m);
//return "file=\"" + file + "\" " + "line=\"" + line + "\" " + "Mid=\"M" + mIdx + "\"";
return "line=\"" + line + "\" " + "Mid=\"M" + mIdx + "\"";
}
示例15: toXMLAttrsString
import soot.tagkit.LineNumberTag; //导入依赖的package包/类
@Override
public String toXMLAttrsString(Unit o) {
SootMethod m = SootUtilities.getMethod(o);
String file = ((SourceFileTag)m.getDeclaringClass().getTags().get(0)).getSourceFile();
int line = ((LineNumberTag)o.getTag("LineNumberTag")).getLineNumber();
int mIdx = domM.indexOf(m);
return "file=\"" + file + "\" " + "line=\"" + line + "\" " + "Mid=\"M" + mIdx + "\"";
}