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 29 package org.objectweb.asm; 30 31 /** 32 * Information about a class being parsed in a {@link ClassReader}. 33 * 34 * @author Eric Bruneton 35 */ 36 final class Context { 37 38 /** The prototypes of the attributes that must be parsed in this class. */ 39 Attribute[] attributePrototypes; 40 41 /** 42 * The options used to parse this class. One or more of {@link ClassReader#SKIP_CODE}, {@link 43 * ClassReader#SKIP_DEBUG}, {@link ClassReader#SKIP_FRAMES}, {@link ClassReader#EXPAND_FRAMES} or 44 * {@link ClassReader#EXPAND_ASM_INSNS}. 45 */ 46 int parsingOptions; 47 48 /** The buffer used to read strings in the constant pool. */ 49 char[] charBuffer; 50 51 // Information about the current method, i.e. the one read in the current (or latest) call 52 // to {@link ClassReader#readMethod()}. 53 54 /** The access flags of the current method. */ 55 int currentMethodAccessFlags; 56 57 /** The name of the current method. */ 58 String currentMethodName; 59 60 /** The descriptor of the current method. */ 61 String currentMethodDescriptor; 62 63 /** 64 * The labels of the current method, indexed by bytecode offset (only bytecode offsets for which a 65 * label is needed have a non null associated Label). 66 */ 67 Label[] currentMethodLabels; 68 69 // Information about the current type annotation target, i.e. the one read in the current 70 // (or latest) call to {@link ClassReader#readAnnotationTarget()}. 71 72 /** 73 * The target_type and target_info of the current type annotation target, encoded as described in 74 * {@link TypeReference}. 75 */ 76 int currentTypeAnnotationTarget; 77 78 /** The target_path of the current type annotation target. */ 79 TypePath currentTypeAnnotationTargetPath; 80 81 /** The start of each local variable range in the current local variable annotation. */ 82 Label[] currentLocalVariableAnnotationRangeStarts; 83 84 /** The end of each local variable range in the current local variable annotation. */ 85 Label[] currentLocalVariableAnnotationRangeEnds; 86 87 /** 88 * The local variable index of each local variable range in the current local variable annotation. 89 */ 90 int[] currentLocalVariableAnnotationRangeIndices; 91 92 // Information about the current stack map frame, i.e. the one read in the current (or latest) 93 // call to {@link ClassReader#readFrame()}. 94 95 /** The bytecode offset of the current stack map frame. */ 96 int currentFrameOffset; 97 98 /** 99 * The type of the current stack map frame. One of {@link Opcodes#F_FULL}, {@link 100 * Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or {@link Opcodes#F_SAME1}. 101 */ 102 int currentFrameType; 103 104 /** 105 * The number of local variable types in the current stack map frame. Each type is represented 106 * with a single array element (even long and double). 107 */ 108 int currentFrameLocalCount; 109 110 /** 111 * The delta number of local variable types in the current stack map frame (each type is 112 * represented with a single array element - even long and double). This is the number of local 113 * variable types in this frame, minus the number of local variable types in the previous frame. 114 */ 115 int currentFrameLocalCountDelta; 116 117 /** 118 * The types of the local variables in the current stack map frame. Each type is represented with 119 * a single array element (even long and double), using the format described in {@link 120 * MethodVisitor#visitFrame}. Depending on {@link #currentFrameType}, this contains the types of 121 * all the local variables, or only those of the additional ones (compared to the previous frame). 122 */ 123 Object[] currentFrameLocalTypes; 124 125 /** 126 * The number stack element types in the current stack map frame. Each type is represented with a 127 * single array element (even long and double). 128 */ 129 int currentFrameStackCount; 130 131 /** 132 * The types of the stack elements in the current stack map frame. Each type is represented with a 133 * single array element (even long and double), using the format described in {@link 134 * MethodVisitor#visitFrame}. 135 */ 136 Object[] currentFrameStackTypes; 137 } 138