import Location; import java.io.PrintWriter; /** * A temporary location used only during initial translation. Eventually, * temporaries need to be on the stack or in registers. * Part of the amazingly abstract assembly language. * * @author Samuel A. Rebelsky * @version 1.0 of April 2001 */ public class Temp implements Location { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** * The number assigned to the temporary. Permits us to determine * whether two temporaries are the same or different. */ protected int number; /** * The counter used for temporaries so that each one has a * different number. */ protected static int count; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Build a new constant with specified value. */ public Temp() { this.number = count++; } // Temp() // +------------------+-------------------------------------------------- // | Location Methods | // +------------------+ /** * Print the temporary. */ public void print(PrintWriter out) { out.print("T" + this.number); } // print(PrintWriter) } // class Temp