1 cananian 1.1.2.4 // Pointer.java, created Sat Mar 27 17:05:09 1999 by duncan 2 cananian 1.1.2.3 // Copyright (C) 1998 Duncan Bryce <duncan@lcs.mit.edu> 3 cananian 1.1.2.3 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 duncan 1.1.2.1 package harpoon.Interpret.Tree; 5 duncan 1.1.2.1 6 duncan 1.1.2.1 import harpoon.Util.Tuple; 7 duncan 1.1.2.1 8 duncan 1.1.2.1 /** 9 duncan 1.1.2.1 * The <code>Pointer</code> class is used to represent 10 duncan 1.1.2.1 * all pointers in the Tree interpreter. Pointers in the Tree interpreter 11 duncan 1.1.2.1 * are represented by a base, plus some optional offset. The base can 12 duncan 1.1.2.1 * be a <code>Label</code>, an <code>ArrayRef</code>, or an 13 duncan 1.1.2.1 * <code>ObjectRef</code>. 14 duncan 1.1.2.1 * 15 duncan 1.1.2.1 * @author Duncan Bryce <duncan@lcs.mit.edu> 16 cananian 1.2 * @version $Id: Pointer.java,v 1.2 2002/02/25 21:06:01 cananian Exp $ 17 duncan 1.1.2.1 */ 18 duncan 1.1.2.1 abstract class Pointer extends Tuple { 19 duncan 1.1.2.2 public static final int ARRAY_PTR = 0; 20 duncan 1.1.2.2 public static final int CLAZ_PTR = 1; 21 duncan 1.1.2.2 public static final int CONST_PTR = 2; 22 duncan 1.1.2.2 public static final int FIELD_PTR = 3; 23 duncan 1.1.2.2 public static final int IFACE_PTR = 4; 24 duncan 1.1.2.2 public static final int STRING_PTR = 5; 25 duncan 1.1.2.2 public static final int UNDEF_PTR = 6; 26 duncan 1.1.2.2 27 duncan 1.1.2.1 28 duncan 1.1.2.1 protected Pointer(Object[] tuple) { 29 duncan 1.1.2.1 super(tuple); 30 duncan 1.1.2.1 } 31 duncan 1.1.2.1 32 duncan 1.1.2.1 /** Adds the specified offset to the offset of this <code>Pointer</code>, 33 duncan 1.1.2.1 * and returns the new <code>Pointer</code>. */ 34 duncan 1.1.2.1 abstract public Pointer add(long offset); 35 duncan 1.1.2.1 36 duncan 1.1.2.1 /** Returns the base of this <code>Pointer</code>. */ 37 duncan 1.1.2.1 abstract public Object getBase(); 38 duncan 1.1.2.1 39 duncan 1.1.2.1 /** Returns the offset of this <code>Pointer</code>. */ 40 duncan 1.1.2.1 abstract public long getOffset(); 41 duncan 1.1.2.1 42 duncan 1.1.2.1 /** Dereferences this <code>Pointer</code> and returns the resulting value. 43 duncan 1.1.2.1 */ 44 duncan 1.1.2.1 abstract Object getValue(); 45 duncan 1.1.2.1 46 duncan 1.1.2.1 /** Returns true if this <code>Pointer</code> is a pointer constant. */ 47 duncan 1.1.2.1 abstract public boolean isConst(); 48 duncan 1.1.2.1 49 duncan 1.1.2.1 /** Returns true if this <code>Pointer</code> is a derived pointer. */ 50 duncan 1.1.2.1 abstract public boolean isDerived(); 51 duncan 1.1.2.2 52 duncan 1.1.2.2 /** Returns an integer enumeration of the kind of this Pointer. The 53 duncan 1.1.2.2 enumerated values are public fields of the <code>Pointer</code> class. 54 duncan 1.1.2.2 */ 55 duncan 1.1.2.2 abstract public int kind(); 56 duncan 1.1.2.1 57 duncan 1.1.2.1 /** Updates the value at the location pointed to by this 58 duncan 1.1.2.1 * <code>Pointer</code>. */ 59 duncan 1.1.2.1 abstract void updateValue(Object obj); 60 duncan 1.1.2.1 } 61 duncan 1.1.2.1 62 duncan 1.1.2.1 63 duncan 1.1.2.1 64 duncan 1.1.2.1 65 cananian 1.2