001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
004    
005       Most Java files in this directory which are part of the Javafe AST
006       are automatically generated using the astgen comment (see
007       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
008       wish to modify AST classes or introduce new ones, modify
009       'hierarchy.j.'
010     */
011    
012    package escjava.ast;
013    
014    import java.util.Hashtable;
015    import java.util.Set;
016    import java.util.ArrayList;
017    
018    import javafe.ast.*;
019    import javafe.util.Assert;
020    import javafe.util.Location;
021    import escjava.ParsedRoutineSpecs;
022    
023    // Convention: unless otherwise noted, integer fields named "loc" refer
024    // to the location of the first character of the syntactic unit
025    
026    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
027    //# VisitorRoot javafe.ast.Visitor
028    
029    
030    public class RestoreFromCmd extends AssignCmd
031    {
032      // denotes RESTORE v FROM rhs
033      // which has the same effect as v := rhs
034      // but does not count "v" as a target
035    
036    
037    // Generated boilerplate constructors:
038    
039       /**
040        * Construct a raw RestoreFromCmd whose class invariant(s) have not
041        * yet been established.  It is the caller's job to
042        * initialize the returned node's fields so that any
043        * class invariants hold.
044        */
045       //@ requires I_will_establish_invariants_afterwards;
046       protected RestoreFromCmd() {}    //@ nowarn Invariant,NonNullInit;
047    
048    
049    // Generated boilerplate methods:
050    
051       public final int childCount() {
052          return 2;
053       }
054    
055       public final Object childAt(int index) {
056               /*throws IndexOutOfBoundsException*/
057          if (index < 0)
058             throw new IndexOutOfBoundsException("AST child index " + index);
059          int indexPre = index;
060    
061          int sz;
062    
063          if (index == 0) return this.v;
064          else index--;
065    
066          if (index == 0) return this.rhs;
067          else index--;
068    
069          throw new IndexOutOfBoundsException("AST child index " + indexPre);
070       }   //@ nowarn Exception;
071    
072       public final String toString() {
073          return "[RestoreFromCmd"
074             + " v = " + this.v
075             + " rhs = " + this.rhs
076             + "]";
077       }
078    
079       public final int getTag() {
080          return TagConstants.RESTOREFROMCMD;
081       }
082    
083       public final void accept(javafe.ast.Visitor v) { 
084          if (v instanceof Visitor) ((Visitor)v).visitRestoreFromCmd(this);
085       }
086    
087       public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
088          if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitRestoreFromCmd(this, o); else return null;
089       }
090    
091       public void check() {
092          super.check();
093          this.v.check();
094          this.rhs.check();
095       }
096    
097       //@ ensures \result != null;
098       public static RestoreFromCmd make(/*@ non_null @*/ VariableAccess v, /*@ non_null @*/ Expr rhs) {
099          //@ set I_will_establish_invariants_afterwards = true;
100          RestoreFromCmd result = new RestoreFromCmd();
101          result.v = v;
102          result.rhs = rhs;
103          return result;
104       }
105    }