use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class AnnotationsTest method join.
private String join(List<AnnotationTag> annotations) {
StringBuilder sb = new StringBuilder();
List<String> l = new ArrayList<>();
for (AnnotationTag tag : annotations) {
String type = tag.getType();
type = type.substring(type.lastIndexOf('$') + 1, type.length() - 1);
l.add(type);
}
Collections.sort(l);
for (String type : l) {
if (sb.length() > 0) {
sb.append(" ");
}
sb.append("@" + type);
}
return sb.toString();
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method addRuntimeVisibleParameterAnnotation.
public static void addRuntimeVisibleParameterAnnotation(SootMethod method, int paramIndex, String annotationType) {
if (!hasParameterAnnotation(method, paramIndex, annotationType)) {
VisibilityAnnotationTag tag = getOrCreateRuntimeVisibilityAnnotationTag(method, paramIndex);
tag.addAnnotation(new AnnotationTag(annotationType, 0));
}
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method getParameterAnnotations.
public static List<AnnotationTag>[] getParameterAnnotations(SootMethod method, Visibility visibility) {
@SuppressWarnings("unchecked") ArrayList<AnnotationTag>[] result = new ArrayList[method.getParameterCount()];
for (int i = 0; i < result.length; i++) {
result[i] = new ArrayList<>();
}
for (Tag tag : method.getTags()) {
if (tag instanceof VisibilityParameterAnnotationTag) {
if (visibility == Visibility.Any || ((VisibilityParameterAnnotationTag) tag).getKind() == visibility.ordinal()) {
ArrayList<VisibilityAnnotationTag> l = ((VisibilityParameterAnnotationTag) tag).getVisibilityAnnotations();
if (l != null) {
int i = 0;
for (VisibilityAnnotationTag t : l) {
ArrayList<AnnotationTag> annotations = t.getAnnotations();
if (annotations != null) {
result[i].addAll(annotations);
}
i++;
}
}
}
}
}
return result;
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method addRuntimeVisibleAnnotation.
public static void addRuntimeVisibleAnnotation(Host host, String annotationType) {
if (!hasAnnotation(host, annotationType)) {
VisibilityAnnotationTag tag = getOrCreateRuntimeVisibilityAnnotationTag(host);
tag.addAnnotation(new AnnotationTag(annotationType, 0));
}
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method copyParameterAnnotations.
private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) {
List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]);
List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]);
for (int i = start; i < end; i++) {
toAnnos[i + shift].addAll(fromAnnos[i]);
}
for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext(); ) {
Tag tag = it.next();
if (tag instanceof VisibilityParameterAnnotationTag) {
if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) {
it.remove();
}
}
}
VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility);
for (List<AnnotationTag> annos : toAnnos) {
VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility);
for (AnnotationTag anno : annos) {
vaTag.addAnnotation(anno);
}
vpaTag.addVisibilityAnnotation(vaTag);
}
toMethod.addTag(vpaTag);
}
Aggregations