本文整理汇总了Java中soot.tagkit.Tag类的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tag类属于soot.tagkit包,在下文中一共展示了Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeContextServiceId
import soot.tagkit.Tag; //导入依赖的package包/类
private Set<String> computeContextServiceId() {
Set<String> ids = new HashSet<String>();
SootClass contextClass = Scene.v().getSootClass("android.content.Context"); // "android.content.Context");
for (SootField sf : contextClass.getFields()) {
if (!(sf.getName().endsWith("SERVICE"))) {
continue;
}
for (Tag t : sf.getTags()) {
if (t instanceof StringConstantValueTag) {
StringConstantValueTag stringval = (StringConstantValueTag) t;
String id = stringval.getStringValue();
System.out.println("add service id '" + id + "'");
ids.add(id);
}
}
}
return ids;
}
示例2: getAttributeResourceId
import soot.tagkit.Tag; //导入依赖的package包/类
/**
* Returns the Android resource Id of the attribute which has the given name.
*
* @param name the attribute's name.
* @return the resource Id defined by Android or -1 if the attribute does not exist.
* @see android.R.attr
*/
public static int getAttributeResourceId(String name) {
// try to get attribute's resource Id from Androids R class. Since we
// don't want a hard-coded reference to the Android classes, we maintain
// our own list.
if (name.equals("name"))
return resId_name;
else if (name.equals("maxSdkVersion"))
return resId_maxSdkVersion;
else if (name.equals("minSdkVersion"))
return resId_minSdkVersion;
else if (name.equals("onClick"))
return resId_onClick;
// If we couldn't find the value, try to find Android's R class in Soot
SootClass rClass = Scene.v().forceResolve("android.R$attr", SootClass.BODIES);
if (!rClass.declaresFieldByName(name))
return -1;
SootField idField = rClass.getFieldByName(name);
for (Tag t : idField.getTags())
if (t instanceof IntegerConstantValueTag) {
IntegerConstantValueTag cvt = (IntegerConstantValueTag) t;
return cvt.getIntValue();
}
return -1;
}
示例3: buildMethodParameterAnnotations
import soot.tagkit.Tag; //导入依赖的package包/类
private Set<Annotation> buildMethodParameterAnnotations(SootMethod m,
final int paramIdx) {
Set<String> skipList = new HashSet<String>();
Set<Annotation> annotations = buildCommonAnnotations(m, skipList);
for (Tag t : m.getTags()) {
if (t.getName().equals("VisibilityParameterAnnotationTag")) {
VisibilityParameterAnnotationTag vat = (VisibilityParameterAnnotationTag)t;
List<ImmutableAnnotation> visibilityItems = buildVisibilityParameterAnnotationTag
(vat, skipList, paramIdx);
annotations.addAll(visibilityItems);
}
}
return annotations;
}
示例4: printAllTags
import soot.tagkit.Tag; //导入依赖的package包/类
public void printAllTags(PrintWriter writer){
this.writerOut = writer;
if (tags != null) {
Iterator<Tag> it = tags.iterator();
while (it.hasNext()){
printAttributeTag(it.next());
}
}
if (vbAttrs != null) {
Iterator<PosColorAttribute> vbIt = vbAttrs.iterator();
while (vbIt.hasNext()){
PosColorAttribute attr = vbIt.next();
if (attr.hasColor()){
startPrintValBoxAttr();
printSourcePositionAttr(attr.javaStartPos(), attr.javaEndPos());
printJimplePositionAttr(attr.jimpleStartPos(), attr.jimpleEndPos());
//printColorAttr(attr.color().red(), attr.color().green(), attr.color().blue(), attr.color().fg());
endPrintValBoxAttr();
}
}
}
}
示例5: parseFieldTags
import soot.tagkit.Tag; //导入依赖的package包/类
public static LinkedList<SootAnnotations.Annotation> parseFieldTags(SootField sf) {
List<Tag> tags = sf.getTags();
LinkedList<SootAnnotations.Annotation> annot = null;
for (Tag t : tags) {
if (t instanceof VisibilityAnnotationTag) {
if (annot!=null) {
throw new RuntimeException("Bug in parseFieldTags");
}
annot = parseAnnotations((VisibilityAnnotationTag)t);
} else if (t instanceof SignatureTag) {
//TODO: do we want to do something with that?
} else if (t instanceof StringConstantValueTag) {
} else if (t instanceof IntegerConstantValueTag) {
} else {
Log.debug("Unimplemented Tag found: "+t.getName());
}
}
if (annot == null) annot = new LinkedList<SootAnnotations.Annotation>();
return annot;
}
示例6: parseParameterAnnotations
import soot.tagkit.Tag; //导入依赖的package包/类
public static LinkedList<LinkedList<SootAnnotations.Annotation>> parseParameterAnnotations(SootMethod m) {
LinkedList<LinkedList<SootAnnotations.Annotation>> pannot = new LinkedList<LinkedList<SootAnnotations.Annotation>>();
for (Tag t : m.getTags()) {
if (t instanceof VisibilityParameterAnnotationTag) {
VisibilityParameterAnnotationTag tag = (VisibilityParameterAnnotationTag)t;
if (tag.getVisibilityAnnotations().size() != m.getParameterCount()) {
throw new RuntimeException("number of tags does not match number of params ... I did not understand this part!");
}
for (VisibilityAnnotationTag va : tag.getVisibilityAnnotations()) {
pannot.add(parseAnnotations(va));
}
}
}
return pannot;
}
示例7: parseAnnotations
import soot.tagkit.Tag; //导入依赖的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);
}
示例8: parseAnnotations
import soot.tagkit.Tag; //导入依赖的package包/类
public void parseAnnotations(SootField f, int indx){
Set<String> annotationName = LogicBloxAnnotExporter.annotationName;
Map<Integer, List<Trio<String, String, String>>> fieldAnnot = LogicBloxAnnotExporter.fieldAnnot;
if(fieldAnnot.containsKey(indx))
return;
List<Trio<String, String, String>> annots = new ArrayList<Trio<String, String, String>>();
for(Tag t : f.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));
}
}
}
}
fieldAnnot.put(indx, annots);
}
示例9: toXMLAttrsString
import soot.tagkit.Tag; //导入依赖的package包/类
@Override
public String toXMLAttrsString(Unit u) {
// this piece of code seems to be copied from DomE.java
// which does not make much sense here
SootMethod m = SootUtilities.getMethod(u);
// JAssignStmt as = (JAssignStmt)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 = ((LineNumberTag)u.getTag("LineNumberTag")).getLineNumber();
int mIdx = domM.indexOf(m);
return "file=\"" + file + "\" " + "Mid=\"M" + mIdx + "\" ";
// return "file=\"" + file + "\" " + "line=\"" + line + "\" " +
// "Mid=\"M" + mIdx + "\"" ;
// " rdwr=\"" + ((SootUtilities.isFieldStore(as) || SootUtilities.isStaticPut(as) ||
// SootUtilities.isStoreInst(as)) ? "Wr" : "Rd") + "\"";
}
示例10: extractJUnitTestsHelper
import soot.tagkit.Tag; //导入依赖的package包/类
protected List<SootMethod> extractJUnitTestsHelper(SootClass cl) {
//System.out.println("prepare cl " + cl + ", tag_sz=" + cl.getTags().size() + ", cl.tags" + cl.getTags());
ArrayList<SootMethod> testMethods = new ArrayList<SootMethod>();
Iterator<SootMethod> it = cl.methodIterator();
while (it.hasNext()) {
SootMethod m = it.next();
//System.out.println("method:" + m + ", isPublic:" + m.isPublic() +", isNative:" + m.isNative() + ", tags: " + m.getTags());
boolean found = false;
for(soot.tagkit.Tag tg : m.getTags()) {
if(!found && tg instanceof soot.tagkit.VisibilityAnnotationTag) {
VisibilityAnnotationTag vat = (VisibilityAnnotationTag) tg;
for( AnnotationTag at : vat.getAnnotations()) {
//System.out.println("type: " + at.getType());
if(at.getType().equals("Lorg/junit/Test;")) {
found = true;
break;
}
}
}
}
if(found) testMethods.add(m);
}
return testMethods;
}
示例11: parseFieldTags
import soot.tagkit.Tag; //导入依赖的package包/类
public static LinkedList<SootAnnotations.Annotation> parseFieldTags(SootField sf) {
List<Tag> tags = sf.getTags();
LinkedList<SootAnnotations.Annotation> annot = null;
for (Tag t : tags) {
if (t instanceof VisibilityAnnotationTag) {
if (annot!=null) {
throw new RuntimeException("Bug in parseFieldTags");
}
annot = parseAnnotations((VisibilityAnnotationTag)t);
} else if (t instanceof SignatureTag) {
//TODO: do we want to do something with that?
} else if (t instanceof StringConstantValueTag) {
} else if (t instanceof IntegerConstantValueTag) {
} else {
Log.error("Unimplemented Tag found: "+t.getName());
}
}
if (annot == null) annot = new LinkedList<SootAnnotations.Annotation>();
return annot;
}
示例12: getFileName
import soot.tagkit.Tag; //导入依赖的package包/类
private static String getFileName(SootClass sc) {
if (sc.hasOuterClass() && sc.getOuterClass()!=sc)
return getFileName(sc.getOuterClass());
String filename = null;
for (Tag t_ : sc.getTags()) {
if (t_ instanceof SourceFileTag) {
filename = ((SourceFileTag) t_).getSourceFile();
if (((SourceFileTag) t_).getAbsolutePath() != null) {
filename = ((SourceFileTag) t_).getAbsolutePath();
}
break;
} else if (t_ instanceof SourceLnNamePosTag) {
filename = ((SourceLnNamePosTag) t_).getFileName();
// don't break, mybe there is still a source file tag.
}
}
return filename;
}
示例13: isAtomicAnnotated
import soot.tagkit.Tag; //导入依赖的package包/类
public static boolean isAtomicAnnotated(SootMethod method)
{
Tag tag=method.getTag("VisibilityAnnotationTag");
if (tag == null)
return false;
VisibilityAnnotationTag visibilityAnnotationTag=(VisibilityAnnotationTag)tag;
List<AnnotationTag> annotations=visibilityAnnotationTag.getAnnotations();
for (AnnotationTag annotationTag: annotations)
if (annotationTag.getType().endsWith("/"+ATOMIC_METHOD_ANNOTATION+";"))
return true;
return false;
}
示例14: extractContractRaw
import soot.tagkit.Tag; //导入依赖的package包/类
private String extractContractRaw()
{
Tag tag=module.getTag("VisibilityAnnotationTag");
if (tag == null)
return null;
VisibilityAnnotationTag visibilityAnnotationTag=(VisibilityAnnotationTag) tag;
List<AnnotationTag> annotations=visibilityAnnotationTag.getAnnotations();
for (AnnotationTag annotationTag: annotations)
if (annotationTag.getType().endsWith("/"+CONTRACT_ANNOTATION+";")
&& annotationTag.getNumElems() == 1
&& annotationTag.getElemAt(0) instanceof AnnotationStringElem
&& annotationTag.getElemAt(0).getName().equals("clauses"))
{
AnnotationStringElem e=(AnnotationStringElem)annotationTag.getElemAt(0);
return e.getValue();
}
return null;
}
示例15: setFullyQualifiedName
import soot.tagkit.Tag; //导入依赖的package包/类
private void setFullyQualifiedName(Unit u) {
Tag fqn = u.getTag("Fully Qualified Name");
if (fqn != null) {
String fullyQualifiedName = new String(fqn.getValue());
this.fullyQualifiedName = fullyQualifiedName;
} else {
System.out.println("WARN fqn tag not found on unit " + u);
}
}