1 /*
   2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.  Oracle designates this
   7  * particular file as subject to the "Classpath" exception as provided
   8  * by Oracle in the LICENSE file that accompanied this code.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /*
  26  * This file is available under and governed by the GNU General Public
  27  * License version 2 only, as published by the Free Software Foundation.
  28  * However, the following notice accompanied the original version of this
  29  * file:
  30  *
  31  * ASM: a very small and fast Java bytecode manipulation framework
  32  * Copyright (c) 2000-2011 INRIA, France Telecom
  33  * All rights reserved.
  34  *
  35  * Redistribution and use in source and binary forms, with or without
  36  * modification, are permitted provided that the following conditions
  37  * are met:
  38  * 1. Redistributions of source code must retain the above copyright
  39  *    notice, this list of conditions and the following disclaimer.
  40  * 2. Redistributions in binary form must reproduce the above copyright
  41  *    notice, this list of conditions and the following disclaimer in the
  42  *    documentation and/or other materials provided with the distribution.
  43  * 3. Neither the name of the copyright holders nor the names of its
  44  *    contributors may be used to endorse or promote products derived from
  45  *    this software without specific prior written permission.
  46  *
  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;
 143     }
 144 
 145     /**
 146      * Visits the type of the super class.
 147      *
 148      * @return a non null visitor to visit the signature of the super class
 149      *         type.
 150      */
 151     public SignatureVisitor visitSuperclass() {
 152         return this;
 153     }
 154 
 155     /**
 156      * Visits the type of an interface implemented by the class.
 157      *
 158      * @return a non null visitor to visit the signature of the interface type.
 159      */
 160     public SignatureVisitor visitInterface() {
 161         return this;
 162     }
 163 
 164     /**
 165      * Visits the type of a method parameter.
 166      *
 167      * @return a non null visitor to visit the signature of the parameter type.
 168      */
 169     public SignatureVisitor visitParameterType() {
 170         return this;
 171     }
 172 
 173     /**
 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 }