1 cananian 1.1.2.1 // THROW.java, created Sat Aug 8 11:10:56 1998 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.Quads; 5 cananian 1.1.2.1 6 cananian 1.1.2.7 import harpoon.ClassFile.HCodeElement; 7 cananian 1.1.2.1 import harpoon.Temp.Temp; 8 cananian 1.1.2.1 import harpoon.Temp.TempMap; 9 cananian 1.1.2.2 import harpoon.Util.Util; 10 cananian 1.1.2.2 11 cananian 1.1.2.1 /** 12 cananian 1.1.2.5 * <code>THROW</code> represents a <Code>throw</code> statement. 13 cananian 1.1.2.1 * 14 cananian 1.1.2.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 15 cananian 1.5 * @version $Id: THROW.java,v 1.5 2002/04/11 04:00:35 cananian Exp $ 16 cananian 1.1.2.1 */ 17 cananian 1.1.2.1 public class THROW extends Quad { 18 cananian 1.1.2.1 /* The exception object to throw. */ 19 cananian 1.1.2.2 protected Temp throwable; 20 cananian 1.1.2.1 21 cananian 1.1.2.2 /** Creates a <code>THROW</code> representing a exception 22 cananian 1.1.2.2 * throw statement. 23 cananian 1.1.2.2 * @param throwable 24 cananian 1.1.2.2 * the <code>Temp</code> containing the exception object 25 cananian 1.1.2.2 * to throw. Should be a subclass of 26 cananian 1.1.2.2 * <code>java.lang.Throwable</code>. 27 cananian 1.1.2.2 */ 28 cananian 1.1.2.4 public THROW(QuadFactory qf, HCodeElement source, Temp throwable) { 29 cananian 1.1.2.4 super(qf, source, 1, 1 /* one successor, the footer node. */); 30 cananian 1.1.2.1 this.throwable = throwable; 31 cananian 1.3.2.1 assert throwable!=null; 32 cananian 1.1.2.1 } 33 cananian 1.1.2.2 /** Returns the <code>Temp</code> containing the exception object to 34 cananian 1.1.2.2 * throw. */ 35 cananian 1.1.2.2 public Temp throwable() { return throwable; } 36 cananian 1.1.2.1 37 cananian 1.1.2.1 /** Returns all the Temps used by this Quad. 38 cananian 1.1.2.1 * @return the <code>throwable</code> field. */ 39 cananian 1.1.2.1 public Temp[] use() { return new Temp[] { throwable }; } 40 cananian 1.1.2.1 41 cananian 1.1.2.3 public int kind() { return QuadKind.THROW; } 42 cananian 1.1.2.3 43 cananian 1.1.2.6 public Quad rename(QuadFactory qqf, TempMap defMap, TempMap useMap) { 44 cananian 1.1.2.6 return new THROW(qqf, this, map(useMap, throwable)); 45 cananian 1.1.2.3 } 46 cananian 1.1.2.6 /** Rename all used variables in this Quad according to a mapping. 47 cananian 1.1.2.6 * @deprecated does not preserve immutability. */ 48 cananian 1.1.2.3 void renameUses(TempMap tm) { 49 cananian 1.1.2.1 throwable = tm.tempMap(throwable); 50 cananian 1.1.2.1 } 51 cananian 1.1.2.6 /** Rename all defined variables in this Quad according to a mapping. 52 cananian 1.1.2.6 * @deprecated does not preserve immutability. */ 53 cananian 1.1.2.3 void renameDefs(TempMap tm) { 54 cananian 1.1.2.1 } 55 cananian 1.1.2.1 56 cananian 1.1.2.8 public void accept(QuadVisitor v) { v.visit(this); } 57 cananian 1.5 public <T> T accept(QuadValueVisitor<T> v) { return v.visit(this); } 58 cananian 1.1.2.1 59 cananian 1.1.2.1 /** Returns human-readable representation of this Quad. */ 60 cananian 1.1.2.1 public String toString() { 61 cananian 1.1.2.1 return "THROW " + throwable; 62 cananian 1.1.2.1 } 63 cananian 1.2 }