1 cananian 1.1.2.1  // LABEL.java, created Wed Jan 13 21:14:57 1999 by cananian
 2 cananian 1.1.2.8  // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
 3 cananian 1.1.2.8  // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 cananian 1.1.2.1  package harpoon.IR.Tree;
 5 cananian 1.1.2.1  
 6 cananian 1.1.2.3  import harpoon.ClassFile.HCodeElement;
 7 cananian 1.1.2.15 import harpoon.Temp.TempMap;
 8 cananian 1.1.2.1  import harpoon.Temp.Label;
 9 cananian 1.1.2.3  import harpoon.Util.Util;
10 cananian 1.1.2.1  
11 cananian 1.1.2.1  /**
12 cananian 1.1.2.1   * <code>LABEL</code> objects define the constant value of the given
13 cananian 1.1.2.1   * label to be the current machine code address.  This is like a label
14 cananian 1.1.2.1   * definition in assembly language.  The value <code>NAME(Label l)</code>
15 cananian 1.1.2.1   * may be the target of jumps, calls, etc.
16 cananian 1.1.2.1   * 
17 cananian 1.1.2.1   * @author  C. Scott Ananian <cananian@alumni.princeton.edu>, based on
18 cananian 1.1.2.1   *          <i>Modern Compiler Implementation in Java</i> by Andrew Appel.
19 cananian 1.4       * @version $Id: LABEL.java,v 1.4 2002/04/10 03:05:45 cananian Exp $
20 cananian 1.1.2.1   */
21 cananian 1.1.2.10 public class LABEL extends Stm implements harpoon.ClassFile.HDataElement { 
22 cananian 1.1.2.1      /** The symbolic name to define. */
23 cananian 1.1.2.1      public final Label label;
24 cananian 1.1.2.9      /** Flag indicating whether the label should be exported.
25 cananian 1.1.2.9       *  Only exported labels are visible from other classes and the
26 cananian 1.1.2.9       *  runtime.  Unexported labels *may* be visible from other methods
27 cananian 1.1.2.9       *  in the same class, but are not required to be. */
28 cananian 1.1.2.9      public final boolean exported;
29 cananian 1.1.2.1      /** Constructor. */
30 cananian 1.1.2.3      public LABEL(TreeFactory tf, HCodeElement source,
31 cananian 1.1.2.9                   Label label, boolean exported) {
32 cananian 1.1.2.14         super(tf, source, 0);
33 cananian 1.1.2.3          this.label=label;
34 cananian 1.1.2.9          this.exported=exported;
35 cananian 1.3.2.1          assert label!=null;
36 cananian 1.1.2.3      }
37 duncan   1.1.2.12 
38 duncan   1.1.2.6      public int kind() { return TreeKind.LABEL; }
39 duncan   1.1.2.6  
40 duncan   1.1.2.7      public Stm build(TreeFactory tf, ExpList kids) {
41 cananian 1.3.2.1          assert kids==null;
42 cananian 1.1.2.9          return new LABEL(tf, this, label, exported);
43 cananian 1.1.2.1      }
44 duncan   1.1.2.2      /** Accept a visitor */
45 cananian 1.1.2.11     public void accept(TreeVisitor v) { v.visit(this); }
46 duncan   1.1.2.4  
47 cananian 1.1.2.15     public Tree rename(TreeFactory tf, TempMap tm, CloneCallback cb) {
48 cananian 1.1.2.16         return cb.callback(this, new LABEL(tf, this, this.label, exported), tm);
49 andyb    1.1.2.5      }
50 andyb    1.1.2.5  
51 andyb    1.1.2.5      public String toString() {
52 andyb    1.1.2.5          return "LABEL("+label+")";
53 duncan   1.1.2.4      }
54 cananian 1.1.2.1  }
55 cananian 1.2