001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package EDU.purdue.cs.bloat.reflect;
022:
023: /**
024: * LocalDebugInfo is used to map a local variable index in a range of
025: * instructions to a local in the original Java source file. In addition,
026: * LocalDebugInfo keeps track of a local variable's name and type (as indices
027: * into the constant pool) and which number local variable is being represented.
028: * Instances of <tt>file.LocalVariableTable</tt> consist of an array of
029: * LocalDebugInfo.
030: *
031: * @see EDU.purdue.cs.bloat.file.LocalVariableTable
032: *
033: * @author Nate Nystrom (<a
034: * href="mailto:nystrom@cs.purdue.edu">nystrom@cs.purdue.edu</a>)
035: */
036: public class LocalDebugInfo {
037: private int startPC;
038:
039: private int length;
040:
041: private int nameIndex;
042:
043: private int typeIndex;
044:
045: private int index;
046:
047: /**
048: * Constructor.
049: *
050: * @param startPC
051: * The start PC of the live range of the variable.
052: * @param length
053: * The length of the live range of the variable.
054: * @param nameIndex
055: * The index into the constant pool of the name of the variable.
056: * @param typeIndex
057: * The index into the constant pool of the type descriptor of the
058: * variable.
059: * @param index
060: * The index of this variable into the local variable array for
061: * the method.
062: */
063: public LocalDebugInfo(final int startPC, final int length,
064: final int nameIndex, final int typeIndex, final int index) {
065: this .startPC = startPC;
066: this .length = length;
067: this .nameIndex = nameIndex;
068: this .typeIndex = typeIndex;
069: this .index = index;
070: }
071:
072: /**
073: * Get the start PC of the live range of the variable.
074: *
075: * @return The start PC of the live range of the variable.
076: */
077: public int startPC() {
078: return startPC;
079: }
080:
081: /**
082: * Get the length of the live range of the variable.
083: *
084: * @return The length of the live range of the variable.
085: */
086: public int length() {
087: return length;
088: }
089:
090: /**
091: * Get the index into the constant pool of the name of the variable.
092: *
093: * @return The index into the constant pool of the name of the variable.
094: */
095: public int nameIndex() {
096: return nameIndex;
097: }
098:
099: /**
100: * Get the index into the constant pool of the type descriptor of the
101: * variable.
102: *
103: * @return The index into the constant pool of the type descriptor of the
104: * variable.
105: */
106: public int typeIndex() {
107: return typeIndex;
108: }
109:
110: /**
111: * Get the index of this variable into the local variable array for the
112: * method.
113: *
114: * @return The index of this variable into the local variable array for the
115: * method.
116: */
117: public int index() {
118: return index;
119: }
120:
121: public Object clone() {
122: return (new LocalDebugInfo(this .startPC, this .length,
123: this .nameIndex, this .typeIndex, this .index));
124: }
125:
126: /**
127: * Returns a string representation of the attribute.
128: */
129: public String toString() {
130: return "(local #" + index + " pc=" + startPC + ".."
131: + (startPC + length) + " name=" + nameIndex + " desc="
132: + typeIndex + ")";
133: }
134: }
|