001    // -*- mode: java -*-
002    /* Copyright 2000, 2001, Compaq Computer Corporation */
003    
004    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
005    
006       Most Java files in this directory which are part of the Javafe AST
007       are automatically generated using the astgen comment (see
008       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
009       wish to modify AST classes or introduce new ones, modify
010       'hierarchy.j.'
011     */
012    
013    package escjava.ast;
014    
015    import java.util.Hashtable;
016    import java.util.Set;
017    import java.util.ArrayList;
018    
019    import javafe.ast.*;
020    import javafe.util.Assert;
021    import javafe.util.Location;
022    import escjava.ParsedRoutineSpecs;
023    
024    // Convention: unless otherwise noted, integer fields named "loc" refer
025    // to the location of the first character of the syntactic unit
026    
027    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
028    //# VisitorRoot javafe.ast.Visitor
029    
030    
031    public class LabelExpr extends GCExpr
032    {
033      public boolean positive;
034    
035      public /*@ non_null @*/ Identifier label;
036    
037      public /*@ non_null @*/ Expr expr;
038    
039    
040      //@ public represents startLoc <- sloc; //FIXME should not have to repeat this (because its in GCExpr)
041    
042    
043    // Generated boilerplate constructors:
044    
045      //@ ensures this.sloc == sloc;
046      //@ ensures this.eloc == eloc;
047      //@ ensures this.positive == positive;
048      //@ ensures this.label == label;
049      //@ ensures this.expr == expr;
050      protected LabelExpr(int sloc, int eloc, boolean positive, /*@ non_null @*/ Identifier label, /*@ non_null @*/ Expr expr) {
051         super(sloc, eloc);
052         this.positive = positive;
053         this.label = label;
054         this.expr = expr;
055      }
056    
057    // Generated boilerplate methods:
058    
059      public final int childCount() {
060         return 2;
061      }
062    
063      public final Object childAt(int index) {
064              /*throws IndexOutOfBoundsException*/
065         if (index < 0)
066            throw new IndexOutOfBoundsException("AST child index " + index);
067         int indexPre = index;
068    
069         int sz;
070    
071         if (index == 0) return this.label;
072         else index--;
073    
074         if (index == 0) return this.expr;
075         else index--;
076    
077         throw new IndexOutOfBoundsException("AST child index " + indexPre);
078      }   //@ nowarn Exception;
079    
080      public final /*@non_null*/String toString() {
081         return "[LabelExpr"
082            + " sloc = " + this.sloc
083            + " eloc = " + this.eloc
084            + " positive = " + this.positive
085            + " label = " + this.label
086            + " expr = " + this.expr
087            + "]";
088      }
089    
090      public final int getTag() {
091         return TagConstants.LABELEXPR;
092      }
093    
094      public final void accept(javafe.ast.Visitor v) { 
095        if (v instanceof Visitor) ((Visitor)v).visitLabelExpr(this);
096      }
097    
098      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
099        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitLabelExpr(this, o); else return null;
100      }
101    
102      public void check() {
103         super.check();
104         this.label.check();
105         this.expr.check();
106      }
107    
108      //@ ensures \result != null;
109      public static LabelExpr make(int sloc, int eloc, boolean positive, /*@ non_null @*/ Identifier label, /*@ non_null @*/ Expr expr) {
110         LabelExpr result = new LabelExpr(sloc, eloc, positive, label, expr);
111         return result;
112      }
113    }