1 pnkfelix 1.1.2.1 // InstrEdge.java, created Fri Aug 27 18:43:54 1999 by pnkfelix 2 pnkfelix 1.1.2.1 // Copyright (C) 1999 Felix S. Klock II <pnkfelix@mit.edu> 3 pnkfelix 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 pnkfelix 1.1.2.1 package harpoon.IR.Assem; 5 pnkfelix 1.1.2.1 6 duncan 1.1.2.5 import harpoon.IR.Properties.CFGEdge; 7 duncan 1.1.2.5 import harpoon.IR.Properties.CFGraphable; 8 pnkfelix 1.1.2.1 9 pnkfelix 1.1.2.1 /** 10 pnkfelix 1.1.2.1 * <code>InstrEdge</code> is an object representing an edge between 11 pnkfelix 1.1.2.1 * two <code>Instr</code>s. 12 pnkfelix 1.1.2.1 * 13 pnkfelix 1.1.2.1 * @author Felix S. Klock II <pnkfelix@mit.edu> 14 cananian 1.5 * @version $Id: InstrEdge.java,v 1.5 2003/05/09 16:35:26 cananian Exp $ 15 pnkfelix 1.1.2.1 */ 16 cananian 1.4 public class InstrEdge extends CFGEdge<Instr,InstrEdge> { 17 pnkfelix 1.1.2.1 18 pnkfelix 1.1.2.1 public final Instr from; 19 pnkfelix 1.1.2.1 public final Instr to; 20 pnkfelix 1.1.2.1 21 pnkfelix 1.1.2.1 /** Creates a <code>InstrEdge</code> representing 22 pnkfelix 1.1.2.1 <nobr> < from, to > </nobr>. 23 pnkfelix 1.1.2.1 */ 24 pnkfelix 1.1.2.1 public InstrEdge(Instr from, Instr to) { 25 pnkfelix 1.1.2.1 this.from = from; 26 pnkfelix 1.1.2.1 this.to = to; 27 pnkfelix 1.1.2.1 } 28 pnkfelix 1.1.2.1 29 cananian 1.5 public Instr to() { return to; } 30 cananian 1.5 public Instr from() { return from; } 31 pnkfelix 1.1.2.2 32 pnkfelix 1.1.2.2 public boolean equals(Object o) { 33 pnkfelix 1.1.2.2 try { 34 pnkfelix 1.1.2.2 InstrEdge ie = (InstrEdge) o; 35 pnkfelix 1.1.2.2 return ie.to.equals(this.to) && 36 pnkfelix 1.1.2.2 ie.from.equals(this.from); 37 pnkfelix 1.1.2.2 } catch (ClassCastException e) { 38 pnkfelix 1.1.2.2 return false; 39 pnkfelix 1.1.2.2 } 40 pnkfelix 1.1.2.3 } 41 pnkfelix 1.1.2.3 public int hashCode() { 42 pnkfelix 1.1.2.3 return to.hashCode() ^ from.hashCode(); 43 pnkfelix 1.1.2.3 } 44 pnkfelix 1.1.2.3 public String toString() { 45 pnkfelix 1.1.2.4 return "InstrEdge:<\""+from+"\", \""+to+"\">"+ 46 pnkfelix 1.1.2.3 " (<"+from.hashCode()+", "+to.hashCode()+">)"; 47 pnkfelix 1.1.2.2 } 48 cananian 1.2 }