Source for gnu.classpath.jdwp.util.VariableTable

   1: /* VariableTable.java -- A class representing a Variable Table for a method
   2:    Copyright (C) 2005, 2007 Free Software Foundation
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: terms of your choice, provided that you also meet, for each linked
  32: independent module, the terms and conditions of the license of that
  33: module.  An independent module is a module which is not derived from
  34: or based on this library.  If you modify this library, you may extend
  35: this exception to your version of the library, but you are not
  36: obligated to do so.  If you do not wish to do so, delete this
  37: exception statement from your version. */
  38: 
  39: 
  40: package gnu.classpath.jdwp.util;
  41: 
  42: import java.io.DataOutputStream;
  43: import java.io.IOException;
  44: 
  45: /**
  46:  * A class representing a Variable Table for a method.
  47:  *
  48:  * @author Aaron Luchko <aluchko@redhat.com>
  49:  */
  50: public class VariableTable
  51: {
  52: 
  53:   private final int argCnt;
  54: 
  55:   private final int slots;
  56: 
  57:   private final long[] lineCI;
  58: 
  59:   private int[] slot;
  60: 
  61:   private int[] lengths;
  62: 
  63:   private String[] sigs;
  64: 
  65:   private String[] names;
  66: 
  67:   /**
  68:    * Make a new variable table with the given values.
  69:    *
  70:    * @param argCnt number of words used by arguments in this frame
  71:    * @param slots number of variables
  72:    * @param lineCI first code index of given variable (size slots)
  73:    * @param names name of given variable (size slots)
  74:    * @param sigs signature of given variable (size slots)
  75:    * @param lengths size of region where variable is active (size slots)
  76:    * @param slot index of variable in this frame (size slots)
  77:    */
  78:   public VariableTable(int argCnt, int slots, long lineCI[], String names[],
  79:                        String sigs[], int lengths[], int slot[])
  80:   {
  81:     this.argCnt = argCnt;
  82:     this.slots = slots;
  83:     this.lineCI = lineCI;
  84:     this.names = names;
  85:     this.sigs = sigs;
  86:     this.lengths = lengths;
  87:     this.slot = slot;
  88:   }
  89: 
  90:   /**
  91:    * Writes this line table to the given DataOutputStream.
  92:    *
  93:    * @param os the stream to write it to
  94:    * @throws IOException
  95:    */
  96:   public void write(DataOutputStream os) throws IOException
  97:   {
  98:     os.writeInt(argCnt);
  99:     os.writeInt(slots);
 100:     for (int i = 0; i < slots; i++)
 101:       {
 102:         os.writeLong(lineCI[i]);
 103:         JdwpString.writeString(os, names[i]);
 104:         JdwpString.writeString(os, sigs[i]);
 105:         os.writeInt(lengths[i]);
 106:         os.writeInt(slot[i]);
 107:       }
 108:   }
 109: 
 110: }