import java.io.PrintWriter; import Instruction; /** * A label in AAAL, the amazingly abstract assembly language. * Listed as an instruction when it's not really, but what's a * little bit of semantics among friends. * * @author Samuel A. Rebelsky * @version 1.0 of April 2001 */ public class Label implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The text used for the label. */ protected String label; /** A count of the automatically-generated labels. */ protected static int count = 0; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Build a new label with specified name. */ public Label(String name) { this.label = name; } // Label(String) /** * Build a new label with an automatically-generated name. */ public Label() { this("Label_" + (count++)); } // Label() // +---------------------+----------------------------------------------- // | Instruction Methods | // +---------------------+ /** * Print the instruction. */ public void print(PrintWriter out) { out.println(label + ":"); } // print(PrintWriter) } // class Label