KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > bytecode > Location


1 // Copyright (c) 1997 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.bytecode;
5
6 /** An abstracted "variable", inherited by Field and Variable. */
7
8 public class Location {
9   protected String JavaDoc name;
10   protected Type type;
11   int name_index; /* Index in constant table, or 0 if un-assigned */
12   int signature_index; /* Index in constant table, or 0 if un-assigned */
13
14   public final String JavaDoc getName ()
15   {
16     return name;
17   }
18
19   public final void setName (String JavaDoc name)
20   {
21     this.name = name;
22   }
23
24   public final void setName(int name_index, ConstantPool constants)
25   {
26     if (name_index <= 0)
27       name = null;
28     else
29       {
30     CpoolUtf8 nameConstant = (CpoolUtf8)
31       constants.getForced(name_index, ConstantPool.UTF8);
32     name = nameConstant.string;
33       }
34     this.name_index = name_index;
35   }
36
37   public final Type getType()
38   {
39     return type;
40   }
41
42   public final void setType(Type type)
43   {
44     this.type = type;
45   }
46
47   public final String JavaDoc getSignature () { return type.getSignature (); }
48
49   public void setSignature (int signature_index, ConstantPool constants)
50   {
51     CpoolUtf8 sigConstant = (CpoolUtf8)
52       constants.getForced(signature_index, ConstantPool.UTF8);
53     this.signature_index = signature_index;
54     type = Type.signatureToType(sigConstant.string);
55   }
56 }
57
Popular Tags