01: // Copyright (c) 1997 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.bytecode;
05:
06: import java.io.*;
07:
08: /** An abstracted "variable", inherited by Field and Variable. */
09:
10: public class Location {
11: protected String name;
12: protected Type type;
13: int name_index; /* Index in constant table, or 0 if un-assigned */
14: int signature_index; /* Index in constant table, or 0 if un-assigned */
15:
16: public final String getName() {
17: return name;
18: }
19:
20: public final void setName(String name) {
21: this .name = name;
22: }
23:
24: public final void setName(int name_index, ConstantPool constants) {
25: if (name_index <= 0)
26: name = null;
27: else {
28: CpoolUtf8 nameConstant = (CpoolUtf8) constants.getForced(
29: name_index, ConstantPool.UTF8);
30: name = nameConstant.string;
31: }
32: this .name_index = name_index;
33: }
34:
35: public final Type getType() {
36: return type;
37: }
38:
39: public final void setType(Type type) {
40: this .type = type;
41: }
42:
43: public final String getSignature() {
44: return type.getSignature();
45: }
46:
47: public void setSignature(int signature_index, ConstantPool constants) {
48: CpoolUtf8 sigConstant = (CpoolUtf8) constants.getForced(
49: signature_index, ConstantPool.UTF8);
50: this.signature_index = signature_index;
51: type = Type.signatureToType(sigConstant.string);
52: }
53: }
|