KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > LocalVarEntry


1 /**
2  * This is an entry to be used as part of a LocalVarTableAttr.
3  * It defines the scope and location of a local variable for a method
4  * and is used while debugging.
5  */

6
7 package jas;
8
9 import java.io.*;
10
11 public class LocalVarEntry
12 {
13   Label start, end;
14   CP name, sig;
15   int slot;
16
17   /**
18    * Create local variable scope information that can be used
19    * while debugging.
20    * @param startLabel beginning of scope for variable
21    * @param endLabel end of scope for variable
22    * @param name name of variable
23    * @param sig signature for variable
24    * @param slot index of the local variable in the local variables
25    * registers of the VM where its value can be found
26    */

27   public LocalVarEntry
28   (Label startLabel, Label endLabel, String JavaDoc name, String JavaDoc sig, int slot)
29   {
30     start = startLabel;
31     end = endLabel;
32     this.name = new AsciiCP(name);
33     this.sig = new AsciiCP(sig);
34     this.slot = slot;
35   }
36
37   /**
38    * Create local variable scope information that can be used
39    * while debugging.
40    * @param startLabel beginning of scope for variable
41    * @param endLabel end of scope for variable
42    * @param name CP to be associated as name of variable
43    * @param sig CP to be associated as signature for variable
44    * @param slot The index of the local variable in the local
45    * variables part of the VM where its value can be found
46    */

47   public LocalVarEntry
48   (Label startLabel, Label endLabel, CP name, CP sig, int slot)
49   {
50     start = startLabel;
51     end = endLabel;
52     this.name = name;
53     this.sig = sig;
54     this.slot = slot;
55   }
56
57   void resolve(ClassEnv e)
58   { e.addCPItem(name); e.addCPItem(sig); }
59
60   void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
61     throws IOException, jasError
62   {
63     start.writeOffset(ce, null, out);
64     end.writeOffset(ce, start, out); // This is the *length*,
65
// not another offset
66

67     out.writeShort(e.getCPIndex(name));
68     out.writeShort(e.getCPIndex(sig));
69     out.writeShort((short)slot);
70   }
71 }
72
Popular Tags