Skip to content

Commit 5b14666

Browse files
committed
Merge pull request #13 from lrytz/asm
LGTM
2 parents 70d6674 + 6ea5622 commit 5b14666

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+28030
-6
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
name := "dotty"
33

4-
scalaVersion in Global := "2.11.0-M7"
4+
scalaVersion in Global := "2.11.0-M8"
55

66
version in Global := "0.1-SNAPSHOT"
77

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/***
2+
* ASM: a very small and fast Java bytecode manipulation framework
3+
* Copyright (c) 2000-2011 INRIA, France Telecom
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* 3. Neither the name of the copyright holders nor the names of its
15+
* contributors may be used to endorse or promote products derived from
16+
* this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28+
* THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
package dotty.tools.asm;
31+
32+
/**
33+
* A visitor to visit a Java annotation. The methods of this class must be
34+
* called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |
35+
* <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.
36+
*
37+
* @author Eric Bruneton
38+
* @author Eugene Kuleshov
39+
*/
40+
public abstract class AnnotationVisitor {
41+
42+
/**
43+
* The ASM API version implemented by this visitor. The value of this field
44+
* must be one of {@link Opcodes#ASM4}.
45+
*/
46+
protected final int api;
47+
48+
/**
49+
* The annotation visitor to which this visitor must delegate method calls.
50+
* May be null.
51+
*/
52+
protected AnnotationVisitor av;
53+
54+
/**
55+
* Constructs a new {@link AnnotationVisitor}.
56+
*
57+
* @param api
58+
* the ASM API version implemented by this visitor. Must be one
59+
* of {@link Opcodes#ASM4}.
60+
*/
61+
public AnnotationVisitor(final int api) {
62+
this(api, null);
63+
}
64+
65+
/**
66+
* Constructs a new {@link AnnotationVisitor}.
67+
*
68+
* @param api
69+
* the ASM API version implemented by this visitor. Must be one
70+
* of {@link Opcodes#ASM4}.
71+
* @param av
72+
* the annotation visitor to which this visitor must delegate
73+
* method calls. May be null.
74+
*/
75+
public AnnotationVisitor(final int api, final AnnotationVisitor av) {
76+
if (api != Opcodes.ASM4) {
77+
throw new IllegalArgumentException();
78+
}
79+
this.api = api;
80+
this.av = av;
81+
}
82+
83+
/**
84+
* Visits a primitive value of the annotation.
85+
*
86+
* @param name
87+
* the value name.
88+
* @param value
89+
* the actual value, whose type must be {@link Byte},
90+
* {@link Boolean}, {@link Character}, {@link Short},
91+
* {@link Integer} , {@link Long}, {@link Float}, {@link Double},
92+
* {@link String} or {@link Type} or OBJECT or ARRAY sort. This
93+
* value can also be an array of byte, boolean, short, char, int,
94+
* long, float or double values (this is equivalent to using
95+
* {@link #visitArray visitArray} and visiting each array element
96+
* in turn, but is more convenient).
97+
*/
98+
public void visit(String name, Object value) {
99+
if (av != null) {
100+
av.visit(name, value);
101+
}
102+
}
103+
104+
/**
105+
* Visits an enumeration value of the annotation.
106+
*
107+
* @param name
108+
* the value name.
109+
* @param desc
110+
* the class descriptor of the enumeration class.
111+
* @param value
112+
* the actual enumeration value.
113+
*/
114+
public void visitEnum(String name, String desc, String value) {
115+
if (av != null) {
116+
av.visitEnum(name, desc, value);
117+
}
118+
}
119+
120+
/**
121+
* Visits a nested annotation value of the annotation.
122+
*
123+
* @param name
124+
* the value name.
125+
* @param desc
126+
* the class descriptor of the nested annotation class.
127+
* @return a visitor to visit the actual nested annotation value, or
128+
* <tt>null</tt> if this visitor is not interested in visiting this
129+
* nested annotation. <i>The nested annotation value must be fully
130+
* visited before calling other methods on this annotation
131+
* visitor</i>.
132+
*/
133+
public AnnotationVisitor visitAnnotation(String name, String desc) {
134+
if (av != null) {
135+
return av.visitAnnotation(name, desc);
136+
}
137+
return null;
138+
}
139+
140+
/**
141+
* Visits an array value of the annotation. Note that arrays of primitive
142+
* types (such as byte, boolean, short, char, int, long, float or double)
143+
* can be passed as value to {@link #visit visit}. This is what
144+
* {@link ClassReader} does.
145+
*
146+
* @param name
147+
* the value name.
148+
* @return a visitor to visit the actual array value elements, or
149+
* <tt>null</tt> if this visitor is not interested in visiting these
150+
* values. The 'name' parameters passed to the methods of this
151+
* visitor are ignored. <i>All the array values must be visited
152+
* before calling other methods on this annotation visitor</i>.
153+
*/
154+
public AnnotationVisitor visitArray(String name) {
155+
if (av != null) {
156+
return av.visitArray(name);
157+
}
158+
return null;
159+
}
160+
161+
/**
162+
* Visits the end of the annotation.
163+
*/
164+
public void visitEnd() {
165+
if (av != null) {
166+
av.visitEnd();
167+
}
168+
}
169+
}

0 commit comments

Comments
 (0)