47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 package jdk.internal.org.objectweb.asm.signature; 60 61 import jdk.internal.org.objectweb.asm.Opcodes; 62 63 /** 64 * A visitor to visit a generic signature. The methods of this interface must be 65 * called in one of the three following orders (the last one is the only valid 66 * order for a {@link SignatureVisitor} that is returned by a method of this 67 * interface): <ul> <li><i>ClassSignature</i> = ( 68 * <tt>visitFormalTypeParameter</tt> 69 * <tt>visitClassBound</tt>? 70 * <tt>visitInterfaceBound</tt>* )* ( <tt>visitSuperClass</tt> 71 * <tt>visitInterface</tt>* )</li> 72 * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt> 73 * <tt>visitClassBound</tt>? 74 * <tt>visitInterfaceBound</tt>* )* ( <tt>visitParameterType</tt>* 75 * <tt>visitReturnType</tt> 76 * <tt>visitExceptionType</tt>* )</li> <li><i>TypeSignature</i> = 77 * <tt>visitBaseType</tt> | <tt>visitTypeVariable</tt> | 78 * <tt>visitArrayType</tt> | ( 79 * <tt>visitClassType</tt> <tt>visitTypeArgument</tt>* ( 80 * <tt>visitInnerClassType</tt> <tt>visitTypeArgument</tt>* )* 81 * <tt>visitEnd</tt> ) )</li> </ul> 82 * 83 * @author Thomas Hallgren 84 * @author Eric Bruneton 85 */ 86 public abstract class SignatureVisitor { 87 88 /** 89 * Wildcard for an "extends" type argument. 90 */ 91 public final static char EXTENDS = '+'; 92 93 /** 94 * Wildcard for a "super" type argument. 95 */ 96 public final static char SUPER = '-'; 97 98 /** 99 * Wildcard for a normal type argument. 100 */ 101 public final static char INSTANCEOF = '='; 102 103 /** 104 * The ASM API version implemented by this visitor. The value of this field 105 * must be one of {@link Opcodes#ASM4}. 106 */ 107 protected final int api; 108 109 /** 110 * Constructs a new {@link SignatureVisitor}. 111 * 112 * @param api the ASM API version implemented by this visitor. Must be one 113 * of {@link Opcodes#ASM4}. 114 */ 115 public SignatureVisitor(final int api) { 116 this.api = api; 117 } 118 119 /** 120 * Visits a formal type parameter. 121 * 122 * @param name the name of the formal parameter. 123 */ 124 public void visitFormalTypeParameter(String name) { 125 } 126 127 /** 128 * Visits the class bound of the last visited formal type parameter. 129 * 130 * @return a non null visitor to visit the signature of the class bound. 131 */ 132 public SignatureVisitor visitClassBound() { 133 return this; 134 } 135 136 /** 137 * Visits an interface bound of the last visited formal type parameter. 138 * 139 * @return a non null visitor to visit the signature of the interface bound. 140 */ 141 public SignatureVisitor visitInterfaceBound() { 142 return this; 174 * Visits the return type of the method. 175 * 176 * @return a non null visitor to visit the signature of the return type. 177 */ 178 public SignatureVisitor visitReturnType() { 179 return this; 180 } 181 182 /** 183 * Visits the type of a method exception. 184 * 185 * @return a non null visitor to visit the signature of the exception type. 186 */ 187 public SignatureVisitor visitExceptionType() { 188 return this; 189 } 190 191 /** 192 * Visits a signature corresponding to a primitive type. 193 * 194 * @param descriptor the descriptor of the primitive type, or 'V' for 195 * <tt>void</tt>. 196 */ 197 public void visitBaseType(char descriptor) { 198 } 199 200 /** 201 * Visits a signature corresponding to a type variable. 202 * 203 * @param name the name of the type variable. 204 */ 205 public void visitTypeVariable(String name) { 206 } 207 208 /** 209 * Visits a signature corresponding to an array type. 210 * 211 * @return a non null visitor to visit the signature of the array element 212 * type. 213 */ 214 public SignatureVisitor visitArrayType() { 215 return this; 216 } 217 218 /** 219 * Starts the visit of a signature corresponding to a class or interface 220 * type. 221 * 222 * @param name the internal name of the class or interface. 223 */ 224 public void visitClassType(String name) { 225 } 226 227 /** 228 * Visits an inner class. 229 * 230 * @param name the local name of the inner class in its enclosing class. 231 */ 232 public void visitInnerClassType(String name) { 233 } 234 235 /** 236 * Visits an unbounded type argument of the last visited class or inner 237 * class type. 238 */ 239 public void visitTypeArgument() { 240 } 241 242 /** 243 * Visits a type argument of the last visited class or inner class type. 244 * 245 * @param wildcard '+', '-' or '='. 246 * @return a non null visitor to visit the signature of the type argument. 247 */ 248 public SignatureVisitor visitTypeArgument(char wildcard) { 249 return this; 250 } 251 252 /** 253 * Ends the visit of a signature corresponding to a class or interface type. 254 */ 255 public void visitEnd() { 256 } 257 } | 47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 package jdk.internal.org.objectweb.asm.signature; 60 61 import jdk.internal.org.objectweb.asm.Opcodes; 62 63 /** 64 * A visitor to visit a generic signature. The methods of this interface must be 65 * called in one of the three following orders (the last one is the only valid 66 * order for a {@link SignatureVisitor} that is returned by a method of this 67 * interface): 68 * <ul> 69 * <li><i>ClassSignature</i> = ( <tt>visitFormalTypeParameter</tt> 70 * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* ( 71 * <tt>visitSuperClass</tt> <tt>visitInterface</tt>* )</li> 72 * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt> 73 * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* ( 74 * <tt>visitParameterType</tt>* <tt>visitReturnType</tt> 75 * <tt>visitExceptionType</tt>* )</li> 76 * <li><i>TypeSignature</i> = <tt>visitBaseType</tt> | 77 * <tt>visitTypeVariable</tt> | <tt>visitArrayType</tt> | ( 78 * <tt>visitClassType</tt> <tt>visitTypeArgument</tt>* ( 79 * <tt>visitInnerClassType</tt> <tt>visitTypeArgument</tt>* )* <tt>visitEnd</tt> 80 * ) )</li> 81 * </ul> 82 * 83 * @author Thomas Hallgren 84 * @author Eric Bruneton 85 */ 86 public abstract class SignatureVisitor { 87 88 /** 89 * Wildcard for an "extends" type argument. 90 */ 91 public final static char EXTENDS = '+'; 92 93 /** 94 * Wildcard for a "super" type argument. 95 */ 96 public final static char SUPER = '-'; 97 98 /** 99 * Wildcard for a normal type argument. 100 */ 101 public final static char INSTANCEOF = '='; 102 103 /** 104 * The ASM API version implemented by this visitor. The value of this field 105 * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. 106 */ 107 protected final int api; 108 109 /** 110 * Constructs a new {@link SignatureVisitor}. 111 * 112 * @param api 113 * the ASM API version implemented by this visitor. Must be one 114 * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. 115 */ 116 public SignatureVisitor(final int api) { 117 if (api != Opcodes.ASM4 && api != Opcodes.ASM5) { 118 throw new IllegalArgumentException(); 119 } 120 this.api = api; 121 } 122 123 /** 124 * Visits a formal type parameter. 125 * 126 * @param name 127 * the name of the formal parameter. 128 */ 129 public void visitFormalTypeParameter(String name) { 130 } 131 132 /** 133 * Visits the class bound of the last visited formal type parameter. 134 * 135 * @return a non null visitor to visit the signature of the class bound. 136 */ 137 public SignatureVisitor visitClassBound() { 138 return this; 139 } 140 141 /** 142 * Visits an interface bound of the last visited formal type parameter. 143 * 144 * @return a non null visitor to visit the signature of the interface bound. 145 */ 146 public SignatureVisitor visitInterfaceBound() { 147 return this; 179 * Visits the return type of the method. 180 * 181 * @return a non null visitor to visit the signature of the return type. 182 */ 183 public SignatureVisitor visitReturnType() { 184 return this; 185 } 186 187 /** 188 * Visits the type of a method exception. 189 * 190 * @return a non null visitor to visit the signature of the exception type. 191 */ 192 public SignatureVisitor visitExceptionType() { 193 return this; 194 } 195 196 /** 197 * Visits a signature corresponding to a primitive type. 198 * 199 * @param descriptor 200 * the descriptor of the primitive type, or 'V' for <tt>void</tt> 201 * . 202 */ 203 public void visitBaseType(char descriptor) { 204 } 205 206 /** 207 * Visits a signature corresponding to a type variable. 208 * 209 * @param name 210 * the name of the type variable. 211 */ 212 public void visitTypeVariable(String name) { 213 } 214 215 /** 216 * Visits a signature corresponding to an array type. 217 * 218 * @return a non null visitor to visit the signature of the array element 219 * type. 220 */ 221 public SignatureVisitor visitArrayType() { 222 return this; 223 } 224 225 /** 226 * Starts the visit of a signature corresponding to a class or interface 227 * type. 228 * 229 * @param name 230 * the internal name of the class or interface. 231 */ 232 public void visitClassType(String name) { 233 } 234 235 /** 236 * Visits an inner class. 237 * 238 * @param name 239 * the local name of the inner class in its enclosing class. 240 */ 241 public void visitInnerClassType(String name) { 242 } 243 244 /** 245 * Visits an unbounded type argument of the last visited class or inner 246 * class type. 247 */ 248 public void visitTypeArgument() { 249 } 250 251 /** 252 * Visits a type argument of the last visited class or inner class type. 253 * 254 * @param wildcard 255 * '+', '-' or '='. 256 * @return a non null visitor to visit the signature of the type argument. 257 */ 258 public SignatureVisitor visitTypeArgument(char wildcard) { 259 return this; 260 } 261 262 /** 263 * Ends the visit of a signature corresponding to a class or interface type. 264 */ 265 public void visitEnd() { 266 } 267 } |