Skip to content

Commit 4cc7a8d

Browse files
raintungmbenz89
authored andcommitted
add local variable
1 parent ba6576c commit 4cc7a8d

File tree

2 files changed

+89
-89
lines changed

2 files changed

+89
-89
lines changed

src/main/java/soot/asm/MethodBuilder.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import soot.tagkit.AnnotationDefaultTag;
4444
import soot.tagkit.AnnotationTag;
4545
import soot.tagkit.VisibilityAnnotationTag;
46-
import soot.tagkit.VisibilityParameterAnnotationTag;
4746
import soot.tagkit.VisibilityLocalVariableAnnotationTag;
47+
import soot.tagkit.VisibilityParameterAnnotationTag;
4848

4949
/**
5050
* Soot method builder.
@@ -96,30 +96,30 @@ public void visitAttribute(Attribute attr) {
9696
}
9797

9898
@Override
99-
public AnnotationVisitor visitLocalVariableAnnotation(final int typeRef, final TypePath typePath,
100-
final Label[] start, final Label[] end, final int[] index, final String descriptor, final boolean visible) {
101-
final VisibilityAnnotationTag vat = new VisibilityAnnotationTag(
102-
visible ? AnnotationConstants.RUNTIME_VISIBLE : AnnotationConstants.RUNTIME_INVISIBLE);
103-
if (visible) {
104-
if (visibleLocalVarAnnotations == null) {
105-
visibleLocalVarAnnotations = new ArrayList<VisibilityAnnotationTag>(2);
106-
}
107-
visibleLocalVarAnnotations.add(vat);
108-
} else {
109-
if (invisibleLocalVarAnnotations == null) {
110-
invisibleLocalVarAnnotations = new ArrayList<VisibilityAnnotationTag>(2);
111-
}
112-
invisibleLocalVarAnnotations.add(vat);
113-
}
114-
return new AnnotationElemBuilder() {
115-
@Override
116-
public void visitEnd() {
117-
AnnotationTag annotTag = new AnnotationTag(desc, elems);
118-
vat.addAnnotation(annotTag);
119-
}
120-
};
99+
public AnnotationVisitor visitLocalVariableAnnotation(final int typeRef, final TypePath typePath, final Label[] start,
100+
final Label[] end, final int[] index, final String descriptor, final boolean visible) {
101+
final VisibilityAnnotationTag vat
102+
= new VisibilityAnnotationTag(visible ? AnnotationConstants.RUNTIME_VISIBLE : AnnotationConstants.RUNTIME_INVISIBLE);
103+
if (visible) {
104+
if (visibleLocalVarAnnotations == null) {
105+
visibleLocalVarAnnotations = new ArrayList<VisibilityAnnotationTag>(2);
106+
}
107+
visibleLocalVarAnnotations.add(vat);
108+
} else {
109+
if (invisibleLocalVarAnnotations == null) {
110+
invisibleLocalVarAnnotations = new ArrayList<VisibilityAnnotationTag>(2);
111+
}
112+
invisibleLocalVarAnnotations.add(vat);
113+
}
114+
return new AnnotationElemBuilder() {
115+
@Override
116+
public void visitEnd() {
117+
AnnotationTag annotTag = new AnnotationTag(desc, elems);
118+
vat.addAnnotation(annotTag);
119+
}
120+
};
121121
}
122-
122+
123123
@Override
124124
public AnnotationVisitor visitParameterAnnotation(int parameter, final String desc, boolean visible) {
125125
VisibilityAnnotationTag vat;
@@ -236,22 +236,22 @@ public void visitEnd() {
236236
}
237237
method.addTag(tag);
238238
}
239-
if (visibleLocalVarAnnotations != null) {
240-
VisibilityLocalVariableAnnotationTag tag
241-
= new VisibilityLocalVariableAnnotationTag(visibleLocalVarAnnotations.size(), AnnotationConstants.RUNTIME_VISIBLE);
242-
for (VisibilityAnnotationTag vat : visibleLocalVarAnnotations) {
243-
tag.addVisibilityAnnotation(vat);
244-
}
245-
method.addTag(tag);
246-
}
247-
if (invisibleLocalVarAnnotations != null) {
248-
VisibilityLocalVariableAnnotationTag tag
249-
= new VisibilityLocalVariableAnnotationTag(visibleLocalVarAnnotations.size(), AnnotationConstants.RUNTIME_INVISIBLE);
250-
for (VisibilityAnnotationTag vat : invisibleLocalVarAnnotations) {
251-
tag.addVisibilityAnnotation(vat);
252-
}
253-
method.addTag(tag);
254-
}
239+
if (visibleLocalVarAnnotations != null) {
240+
VisibilityLocalVariableAnnotationTag tag
241+
= new VisibilityLocalVariableAnnotationTag(visibleLocalVarAnnotations.size(), AnnotationConstants.RUNTIME_VISIBLE);
242+
for (VisibilityAnnotationTag vat : visibleLocalVarAnnotations) {
243+
tag.addVisibilityAnnotation(vat);
244+
}
245+
method.addTag(tag);
246+
}
247+
if (invisibleLocalVarAnnotations != null) {
248+
VisibilityLocalVariableAnnotationTag tag = new VisibilityLocalVariableAnnotationTag(visibleLocalVarAnnotations.size(),
249+
AnnotationConstants.RUNTIME_INVISIBLE);
250+
for (VisibilityAnnotationTag vat : invisibleLocalVarAnnotations) {
251+
tag.addVisibilityAnnotation(vat);
252+
}
253+
method.addTag(tag);
254+
}
255255
if (method.isConcrete()) {
256256
method.setSource(
257257
new AsmMethodSource(maxLocals, instructions, localVariables, tryCatchBlocks, scb.getKlass().moduleName));
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package soot.tagkit;
2+
23
/*-
34
* #%L
45
* Soot - a J*va Optimization Framework
@@ -21,62 +22,61 @@
2122
* #L%
2223
*/
2324
/**
24-
* Represents the visibility of an annotation attribute attached to method local variable.
25-
* Only mark the local variable tag different with{@link soot.tagkit.VisibilityParameterAnnotationTag}
25+
* Represents the visibility of an annotation attribute attached to method local variable. Only mark the local variable tag
26+
* different with{@link soot.tagkit.VisibilityParameterAnnotationTag}
2627
*
2728
* @author raintung.li
2829
*
2930
*/
3031

3132
public class VisibilityLocalVariableAnnotationTag extends VisibilityParameterAnnotationTag {
32-
33-
public VisibilityLocalVariableAnnotationTag(int num, int kind) {
34-
super(num, kind);
35-
}
3633

37-
// should also print here number of annotations and perhaps the annotations themselves
38-
public String toString() {
39-
int num_var = getVisibilityAnnotations()!=null ? getVisibilityAnnotations().size(): 0;
40-
StringBuffer sb = new StringBuffer(
41-
"Visibility LocalVariable Annotation: num Annotation: " + num_var + " kind: " + getKind());
42-
if (num_var > 0) {
43-
for (VisibilityAnnotationTag tag : getVisibilityAnnotations()) {
44-
sb.append("\n");
45-
if (tag != null) {
46-
sb.append(tag.toString());
47-
}
48-
}
49-
}
50-
sb.append("\n");
51-
return sb.toString();
52-
}
53-
34+
public VisibilityLocalVariableAnnotationTag(int num, int kind) {
35+
super(num, kind);
36+
}
37+
38+
// should also print here number of annotations and perhaps the annotations themselves
39+
public String toString() {
40+
int num_var = getVisibilityAnnotations() != null ? getVisibilityAnnotations().size() : 0;
41+
StringBuffer sb
42+
= new StringBuffer("Visibility LocalVariable Annotation: num Annotation: " + num_var + " kind: " + getKind());
43+
if (num_var > 0) {
44+
for (VisibilityAnnotationTag tag : getVisibilityAnnotations()) {
45+
sb.append("\n");
46+
if (tag != null) {
47+
sb.append(tag.toString());
48+
}
49+
}
50+
}
51+
sb.append("\n");
52+
return sb.toString();
53+
}
54+
55+
/**
56+
* Returns Local Variable tag name
57+
*
58+
* @return string
59+
*/
60+
public String getName() {
61+
return "VisibilityLocalVariableAnnotationTag";
62+
}
63+
64+
/**
65+
* Returns Local Variable tag info
66+
*
67+
* @return string
68+
*/
69+
public String getInfo() {
70+
return "VisibilityLocalVariableAnnotation";
71+
}
5472

55-
/**
56-
* Returns Local Variable tag name
57-
*
58-
* @return string
59-
*/
60-
public String getName() {
61-
return "VisibilityLocalVariableAnnotationTag";
62-
}
63-
64-
/**
65-
* Returns Local Variable tag info
66-
*
67-
* @return string
68-
*/
69-
public String getInfo() {
70-
return "VisibilityLocalVariableAnnotation";
71-
}
72-
73-
/**
74-
* VisibilityLocalVariableAnnotationTag not support
75-
*
76-
* @return
77-
*/
78-
public byte[] getValue() {
79-
throw new RuntimeException("VisibilityLocalVariableAnnotationTag has no value for bytecode");
80-
}
73+
/**
74+
* VisibilityLocalVariableAnnotationTag not support
75+
*
76+
* @return
77+
*/
78+
public byte[] getValue() {
79+
throw new RuntimeException("VisibilityLocalVariableAnnotationTag has no value for bytecode");
80+
}
8181

8282
}

0 commit comments

Comments
 (0)