1 // ASM: a very small and fast Java bytecode manipulation framework 2 // Copyright (c) 2000-2011 INRIA, France Telecom 3 // All rights reserved. 4 // 5 // Redistribution and use in source and binary forms, with or without 6 // modification, are permitted provided that the following conditions 7 // are met: 8 // 1. Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // 2. Redistributions in binary form must reproduce the above copyright 11 // notice, this list of conditions and the following disclaimer in the 12 // documentation and/or other materials provided with the distribution. 13 // 3. Neither the name of the copyright holders nor the names of its 14 // contributors may be used to endorse or promote products derived from 15 // this software without specific prior written permission. 16 // 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 // THE POSSIBILITY OF SUCH DAMAGE. 28 package org.objectweb.asm.tree; 29 30 import org.objectweb.asm.MethodVisitor; 31 32 /** 33 * A node that represents a local variable declaration. 34 * 35 * @author Eric Bruneton 36 */ 37 public class LocalVariableNode { 38 39 /** The name of a local variable. */ 40 public String name; 41 42 /** The type descriptor of this local variable. */ 43 public String desc; 44 45 /** The signature of this local variable. May be {@literal null}. */ 46 public String signature; 47 48 /** The first instruction corresponding to the scope of this local variable (inclusive). */ 49 public LabelNode start; 50 51 /** The last instruction corresponding to the scope of this local variable (exclusive). */ 52 public LabelNode end; 53 54 /** The local variable's index. */ 55 public int index; 56 57 /** 58 * Constructs a new {@link LocalVariableNode}. 59 * 60 * @param name the name of a local variable. 61 * @param descriptor the type descriptor of this local variable. 62 * @param signature the signature of this local variable. May be {@literal null}. 63 * @param start the first instruction corresponding to the scope of this local variable 64 * (inclusive). 65 * @param end the last instruction corresponding to the scope of this local variable (exclusive). 66 * @param index the local variable's index. 67 */ LocalVariableNode( final String name, final String descriptor, final String signature, final LabelNode start, final LabelNode end, final int index)68 public LocalVariableNode( 69 final String name, 70 final String descriptor, 71 final String signature, 72 final LabelNode start, 73 final LabelNode end, 74 final int index) { 75 this.name = name; 76 this.desc = descriptor; 77 this.signature = signature; 78 this.start = start; 79 this.end = end; 80 this.index = index; 81 } 82 83 /** 84 * Makes the given visitor visit this local variable declaration. 85 * 86 * @param methodVisitor a method visitor. 87 */ accept(final MethodVisitor methodVisitor)88 public void accept(final MethodVisitor methodVisitor) { 89 methodVisitor.visitLocalVariable( 90 name, desc, signature, start.getLabel(), end.getLabel(), index); 91 } 92 } 93