1 cananian 1.1.2.3 // ConstantLong.java, created Mon Jan 18 22:44:37 1999 by cananian
 2 cananian 1.1.2.1 // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 cananian 1.1.2.1 package harpoon.IR.RawClass;
 5 cananian 1.1.2.1 
 6 cananian 1.1.2.1 /** 
 7 cananian 1.1.2.1  * The <code>CONSTANT_Long_info</code> structure represents eight-byte
 8 cananian 1.1.2.1  * integer numeric constants.
 9 cananian 1.1.2.1  * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
10 cananian 1.3      * @version $Id: ConstantLong.java,v 1.3 2003/09/05 21:45:16 cananian Exp $
11 cananian 1.1.2.1  * @see "The Java Virtual Machine Specification, section 4.4.5"
12 cananian 1.1.2.1  * @see Constant
13 cananian 1.1.2.1  * @see ConstantDouble
14 cananian 1.1.2.1  */
15 cananian 1.1.2.1 public class ConstantLong extends ConstantValue {
16 cananian 1.1.2.1   /** The value of the <code>long</code> constant. */
17 cananian 1.1.2.1   public long val;
18 cananian 1.1.2.1   
19 cananian 1.1.2.1   /** Constructor. */
20 cananian 1.1.2.1   ConstantLong(ClassFile parent, ClassDataInputStream in) 
21 cananian 1.1.2.1     throws java.io.IOException {
22 cananian 1.1.2.1     super(parent);
23 cananian 1.1.2.1     val = in.readLong();
24 cananian 1.1.2.1   }
25 cananian 1.1.2.1   /** Constructor. */
26 cananian 1.1.2.1   public ConstantLong(ClassFile parent, long val) { 
27 cananian 1.1.2.1     super(parent);
28 cananian 1.1.2.1     this.val = val; 
29 cananian 1.1.2.1   }
30 cananian 1.3       public int entrySize() { return 2; }
31 cananian 1.1.2.1 
32 cananian 1.1.2.1   /** Write to a bytecode file. */
33 cananian 1.1.2.1   public void write(ClassDataOutputStream out) throws java.io.IOException {
34 cananian 1.1.2.1     out.write_u1(CONSTANT_Long);
35 cananian 1.1.2.1     out.writeLong(val);
36 cananian 1.1.2.1   }
37 cananian 1.1.2.1 
38 cananian 1.1.2.1   /** Returns the value of this constant. */
39 cananian 1.1.2.1   public long longValue() { return val; }
40 cananian 1.1.2.1   /** Returns the value of this constant, wrapped as a 
41 cananian 1.1.2.1    *  <code>java.lang.Long</code>. */
42 cananian 1.1.2.1   public Object value() { return new Long(val); }
43 cananian 1.1.2.1 
44 cananian 1.1.2.1   /** Create a human-readable representation of this constant. */
45 cananian 1.1.2.1   public String toString() {
46 cananian 1.1.2.1     return "CONSTANT_Long: "+longValue();
47 cananian 1.1.2.1   }
48 cananian 1.2     }