/** search for tag named <code>aName</code> */ private int searchForTag(String aName) { if (mTagList == null) { return -1; } int i = 0; Iterator<Tag> it = mTagList.iterator(); while (it.hasNext()) { Tag tag = it.next(); if (tag != null && tag.getName().equals(aName)) { return i; } i++; } return -1; }
/** Generates Jasmin Value String */ @Override public String getJasminValue(Map<Unit, String> instToLabel) { // some benchmarks fail because of the returned string larger than // the possible buffer size. StringBuffer buf = new StringBuffer(); if (mTags.size() != mUnits.size()) { throw new RuntimeException("Sizes must match!"); } Iterator<Tag> tagIt = mTags.iterator(); Iterator<Unit> unitIt = mUnits.iterator(); while (tagIt.hasNext()) { Unit unit = unitIt.next(); Tag tag = tagIt.next(); buf.append("%" + instToLabel.get(unit) + "%" + new String(Base64.encode((tag).getValue()))); } return buf.toString(); }
while (vit.hasNext()) { Tag t = (Tag) vit.next(); if (t.getName().equals("VisibilityAnnotationTag")) { emit(getVisibilityAnnotationAttr((VisibilityAnnotationTag) t)); if (t.getName().equals("VisibilityParameterAnnotationTag")) { emit(getVisibilityParameterAnnotationAttr((VisibilityParameterAnnotationTag) t)); Tag tag = (Tag) it.next(); if (tag instanceof Attribute) { emit(".method_attribute " + tag.getName() + " \"" + new String(Base64.encode(tag.getValue())) + "\"");
private Set<Annotation> buildFieldAnnotations(SootField f) { Set<String> skipList = new HashSet<String>(); Set<Annotation> annotations = buildCommonAnnotations(f, skipList); for (Tag t : f.getTags()) { if (t.getName().equals("VisibilityAnnotationTag")) { List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag((VisibilityAnnotationTag) t, skipList); annotations.addAll(visibilityItems); } } return annotations; }
/** * Returns all method parameter annotations (or null) for a specific parameter * * @param m * the method * @param paramIdx * the parameter index * @return the annotations (or null) */ private Set<Annotation> buildMethodParameterAnnotations(SootMethod m, final int paramIdx) { Set<String> skipList = null; Set<Annotation> annotations = null; for (Tag t : m.getTags()) { if (t.getName().equals("VisibilityParameterAnnotationTag")) { VisibilityParameterAnnotationTag vat = (VisibilityParameterAnnotationTag) t; if (skipList == null) { skipList = new HashSet<String>(); annotations = new HashSet<Annotation>(); } List<ImmutableAnnotation> visibilityItems = buildVisibilityParameterAnnotationTag(vat, skipList, paramIdx); annotations.addAll(visibilityItems); } } return annotations; }
private Set<Annotation> buildMethodAnnotations(SootMethod m) { Set<String> skipList = new HashSet<String>(); Set<Annotation> annotations = buildCommonAnnotations(m, skipList); for (Tag t : m.getTags()) { if (t.getName().equals("VisibilityAnnotationTag")) { List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag((VisibilityAnnotationTag) t, skipList); annotations.addAll(visibilityItems); } } List<SootClass> exceptionList = m.getExceptionsUnsafe(); if (exceptionList != null && !exceptionList.isEmpty()) { List<ImmutableEncodedValue> valueList = new ArrayList<ImmutableEncodedValue>(exceptionList.size()); for (SootClass exceptionClass : exceptionList) { valueList.add(new ImmutableTypeEncodedValue(DexType.toDalvikICAT(exceptionClass.getName()).replace(".", "/"))); } ImmutableArrayEncodedValue valueValue = new ImmutableArrayEncodedValue(valueList); ImmutableAnnotationElement valueElement = new ImmutableAnnotationElement("value", valueValue); Set<ImmutableAnnotationElement> elements = Collections.singleton(valueElement); ImmutableAnnotation ann = new ImmutableAnnotation(AnnotationVisibility.SYSTEM, "Ldalvik/annotation/Throws;", elements); annotations.add(ann); } return annotations; }
if (t.getName().equals("VisibilityAnnotationTag")) { List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag((VisibilityAnnotationTag) t, skipList); annotations.addAll(visibilityItems);
emit(".code_attribute " + t.getName() + " \"" + ((JasminAttribute) t).getJasminValue(unitToLabel) + "\"");
Tag tag = it.next(); if (tag instanceof Attribute) { emit(".class_attribute " + tag.getName() + " \"" + new String(Base64.encode(((Attribute) tag).getValue())) + "\""); while (vit.hasNext()) { Tag t = (Tag) vit.next(); if (t.getName().equals("VisibilityAnnotationTag")) { emit(getVisibilityAnnotationAttr((VisibilityAnnotationTag) t)); while (vfit.hasNext()) { Tag t = (Tag) vfit.next(); if (t.getName().equals("VisibilityAnnotationTag")) { fieldString += getVisibilityAnnotationAttr((VisibilityAnnotationTag) t); Tag tag = (Tag) attributeIt.next(); if (tag instanceof Attribute) { emit(".field_attribute " + tag.getName() + " \"" + new String(Base64.encode(((Attribute) tag).getValue())) + "\"");
StringAttribute sa = new StringAttribute(t.toString(), t.getName()); addText(sa);
/** search for tag named <code>aName</code> */ private int searchForTag(String aName) { int i = 0; Iterator<Tag> it = mTagList.iterator(); while(it.hasNext()) { Tag tag = it.next(); if(tag.getName().equals(aName)) return i; i++; } return -1; }
/** search for tag named <code>aName</code> */ private int searchForTag(String aName) { int i = 0; Iterator<Tag> it = mTagList.iterator(); while(it.hasNext()) { Tag tag = it.next(); if(tag.getName().equals(aName)) return i; i++; } return -1; }
/** * Copy all the tags of {from} to {to}, if {to} already contain the copied tag, * then overwrite it. * * @param from * @param to */ protected static void copyTags(Unit from, Unit to) { List<Tag> tags = from.getTags(); for (Tag tag : tags) { to.removeTag(tag.getName()); // exception?? to.addTag(tag); } }
/** * Copy all the tags of {from} to {to}, if {to} already contain the copied tag, then overwrite it. * * @param from * @param to */ public static void copyTags(Unit from, Unit to) { List<Tag> tags = from.getTags(); for (Tag tag : tags) { to.removeTag(tag.getName()); //exception?? to.addTag(tag); } } }