Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// ASM: a very small and fast Java bytecode manipulation framework
// Copyright (c) 2000-2011 INRIA, France Telecom
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holders nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
package scala.tools.asm.tree;
import java.util.ArrayList;
import java.util.List;
import scala.tools.asm.AnnotationVisitor;
import scala.tools.asm.Attribute;
import scala.tools.asm.ClassVisitor;
import scala.tools.asm.ConstantDynamic;
import scala.tools.asm.Handle;
import scala.tools.asm.Label;
import scala.tools.asm.MethodVisitor;
import scala.tools.asm.Opcodes;
import scala.tools.asm.Type;
import scala.tools.asm.TypePath;
/**
* A node that represents a method.
*
* @author Eric Bruneton
*/
public class MethodNode extends MethodVisitor {
/**
* The method's access flags (see {@link Opcodes}). This field also indicates if the method is
* synthetic and/or deprecated.
*/
public int access;
/** The method's name. */
public String name;
/** The method's descriptor (see {@link Type}). */
public String desc;
/** The method's signature. May be {@literal null}. */
public String signature;
/** The internal names of the method's exception classes (see {@link Type#getInternalName()}). */
public List exceptions;
/** The method parameter info (access flags and name). */
public List parameters;
/** The runtime visible annotations of this method. May be {@literal null}. */
public List visibleAnnotations;
/** The runtime invisible annotations of this method. May be {@literal null}. */
public List invisibleAnnotations;
/** The runtime visible type annotations of this method. May be {@literal null}. */
public List visibleTypeAnnotations;
/** The runtime invisible type annotations of this method. May be {@literal null}. */
public List invisibleTypeAnnotations;
/** The non standard attributes of this method. May be {@literal null}. */
public List attrs;
/**
* The default value of this annotation interface method. This field must be a {@link Byte},
* {@link Boolean}, {@link Character}, {@link Short}, {@link Integer}, {@link Long}, {@link
* Float}, {@link Double}, {@link String} or {@link Type}, or an two elements String array (for
* enumeration values), a {@link AnnotationNode}, or a {@link List} of values of one of the
* preceding types. May be {@literal null}.
*/
public Object annotationDefault;
/**
* The number of method parameters than can have runtime visible annotations. This number must be
* less or equal than the number of parameter types in the method descriptor (the default value 0
* indicates that all the parameters described in the method descriptor can have annotations). It
* can be strictly less when a method has synthetic parameters and when these parameters are
* ignored when computing parameter indices for the purpose of parameter annotations (see
* https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18).
*/
public int visibleAnnotableParameterCount;
/**
* The runtime visible parameter annotations of this method. These lists are lists of {@link
* AnnotationNode} objects. May be {@literal null}.
*/
public List[] visibleParameterAnnotations;
/**
* The number of method parameters than can have runtime invisible annotations. This number must
* be less or equal than the number of parameter types in the method descriptor (the default value
* 0 indicates that all the parameters described in the method descriptor can have annotations).
* It can be strictly less when a method has synthetic parameters and when these parameters are
* ignored when computing parameter indices for the purpose of parameter annotations (see
* https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18).
*/
public int invisibleAnnotableParameterCount;
/**
* The runtime invisible parameter annotations of this method. These lists are lists of {@link
* AnnotationNode} objects. May be {@literal null}.
*/
public List[] invisibleParameterAnnotations;
/** The instructions of this method. */
public InsnList instructions;
/** The try catch blocks of this method. */
public List tryCatchBlocks;
/** The maximum stack size of this method. */
public int maxStack;
/** The maximum number of local variables of this method. */
public int maxLocals;
/** The local variables of this method. May be {@literal null} */
public List localVariables;
/** The visible local variable annotations of this method. May be {@literal null} */
public List visibleLocalVariableAnnotations;
/** The invisible local variable annotations of this method. May be {@literal null} */
public List invisibleLocalVariableAnnotations;
/** Whether the accept method has been called on this object. */
private boolean visited;
/**
* Constructs an uninitialized {@link MethodNode}. Subclasses must not use this
* constructor. Instead, they must use the {@link #MethodNode(int)} version.
*
* @throws IllegalStateException If a subclass calls this constructor.
*/
public MethodNode() {
this(/* latest api = */ Opcodes.ASM9);
if (getClass() != MethodNode.class) {
throw new IllegalStateException();
}
}
/**
* Constructs an uninitialized {@link MethodNode}.
*
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
* ASM}x values in {@link Opcodes}.
*/
public MethodNode(final int api) {
super(api);
this.instructions = new InsnList();
}
/**
* Constructs a new {@link MethodNode}. Subclasses must not use this constructor. Instead,
* they must use the {@link #MethodNode(int, int, String, String, String, String[])} version.
*
* @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if
* the method is synthetic and/or deprecated.
* @param name the method's name.
* @param descriptor the method's descriptor (see {@link Type}).
* @param signature the method's signature. May be {@literal null}.
* @param exceptions the internal names of the method's exception classes (see {@link
* Type#getInternalName()}). May be {@literal null}.
* @throws IllegalStateException If a subclass calls this constructor.
*/
public MethodNode(
final int access,
final String name,
final String descriptor,
final String signature,
final String[] exceptions) {
this(/* latest api = */ Opcodes.ASM9, access, name, descriptor, signature, exceptions);
if (getClass() != MethodNode.class) {
throw new IllegalStateException();
}
}
/**
* Constructs a new {@link MethodNode}.
*
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
* ASM}x values in {@link Opcodes}.
* @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if
* the method is synthetic and/or deprecated.
* @param name the method's name.
* @param descriptor the method's descriptor (see {@link Type}).
* @param signature the method's signature. May be {@literal null}.
* @param exceptions the internal names of the method's exception classes (see {@link
* Type#getInternalName()}). May be {@literal null}.
*/
public MethodNode(
final int api,
final int access,
final String name,
final String descriptor,
final String signature,
final String[] exceptions) {
super(api);
this.access = access;
this.name = name;
this.desc = descriptor;
this.signature = signature;
this.exceptions = Util.asArrayList(exceptions);
if ((access & Opcodes.ACC_ABSTRACT) == 0) {
this.localVariables = new ArrayList<>(5);
}
this.tryCatchBlocks = new ArrayList<>();
this.instructions = new InsnList();
}
// -----------------------------------------------------------------------------------------------
// Implementation of the MethodVisitor abstract class
// -----------------------------------------------------------------------------------------------
@Override
public void visitParameter(final String name, final int access) {
if (parameters == null) {
parameters = new ArrayList<>(5);
}
parameters.add(new ParameterNode(name, access));
}
@Override
@SuppressWarnings("serial")
public AnnotationVisitor visitAnnotationDefault() {
return new AnnotationNode(
new ArrayList