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 SubstExpr extends GCExpr
032 {
033 public /*@ non_null @*/ GenericVarDecl var;
034
035 public /*@ non_null @*/ Expr val;
036
037 public /*@ non_null @*/ Expr target;
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.var == var;
048 //@ ensures this.val == val;
049 //@ ensures this.target == target;
050 protected SubstExpr(int sloc, int eloc, /*@ non_null @*/ GenericVarDecl var, /*@ non_null @*/ Expr val, /*@ non_null @*/ Expr target) {
051 super(sloc, eloc);
052 this.var = var;
053 this.val = val;
054 this.target = target;
055 }
056
057 // Generated boilerplate methods:
058
059 public final int childCount() {
060 return 3;
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.var;
072 else index--;
073
074 if (index == 0) return this.val;
075 else index--;
076
077 if (index == 0) return this.target;
078 else index--;
079
080 throw new IndexOutOfBoundsException("AST child index " + indexPre);
081 } //@ nowarn Exception;
082
083 public final /*@non_null*/String toString() {
084 return "[SubstExpr"
085 + " sloc = " + this.sloc
086 + " eloc = " + this.eloc
087 + " var = " + this.var
088 + " val = " + this.val
089 + " target = " + this.target
090 + "]";
091 }
092
093 public final int getTag() {
094 return TagConstants.SUBSTEXPR;
095 }
096
097 public final void accept(javafe.ast.Visitor v) {
098 if (v instanceof Visitor) ((Visitor)v).visitSubstExpr(this);
099 }
100
101 public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
102 if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitSubstExpr(this, o); else return null;
103 }
104
105 public void check() {
106 super.check();
107 this.var.check();
108 this.val.check();
109 this.target.check();
110 }
111
112 //@ ensures \result != null;
113 public static SubstExpr make(int sloc, int eloc, /*@ non_null @*/ GenericVarDecl var, /*@ non_null @*/ Expr val, /*@ non_null @*/ Expr target) {
114 SubstExpr result = new SubstExpr(sloc, eloc, var, val, target);
115 return result;
116 }
117 }