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 javafe.ast;
014
015 import javafe.util.Assert;
016 import javafe.util.Location;
017 import javafe.util.ErrorSet;
018
019 // Convention: unless otherwise noted, integer fields named "loc" refer
020 // to the location of the first character of the syntactic unit
021
022
023 /**
024 * Represents a class literal (Type . class)
025 */
026
027 public class ClassLiteral extends Expr
028 {
029 //@ invariant type.syntax;
030 public /*@ non_null @*/ Type type;
031
032 //@ invariant locDot != javafe.util.Location.NULL;
033 public int locDot;
034
035
036 //@ public represents startLoc <- type.getStartLoc();
037 public /*@ pure @*/ int getStartLoc() { return type.getStartLoc(); }
038
039 //@ also public normal_behavior
040 //@ ensures \result == locDot;
041 public /*@ pure @*/ int getEndLoc() { return locDot; }
042
043
044 // Generated boilerplate constructors:
045
046 //@ ensures this.type == type;
047 //@ ensures this.locDot == locDot;
048 protected ClassLiteral(/*@ non_null @*/ Type type, int locDot) {
049 super();
050 this.type = type;
051 this.locDot = locDot;
052 }
053
054 // Generated boilerplate methods:
055
056 public final int childCount() {
057 return 1;
058 }
059
060 public final Object childAt(int index) {
061 /*throws IndexOutOfBoundsException*/
062 if (index < 0)
063 throw new IndexOutOfBoundsException("AST child index " + index);
064 int indexPre = index;
065
066 int sz;
067
068 if (index == 0) return this.type;
069 else index--;
070
071 throw new IndexOutOfBoundsException("AST child index " + indexPre);
072 } //@ nowarn Exception;
073
074 public final /*@non_null*/String toString() {
075 return "[ClassLiteral"
076 + " type = " + this.type
077 + " locDot = " + this.locDot
078 + "]";
079 }
080
081 public final int getTag() {
082 return TagConstants.CLASSLITERAL;
083 }
084
085 public final void accept(Visitor v) { v.visitClassLiteral(this); }
086
087 public final Object accept(VisitorArgResult v, Object o) {return v.visitClassLiteral(this, o); }
088
089 public void check() {
090 super.check();
091 this.type.check();
092 }
093
094 //@ requires type.syntax;
095 //@ requires locDot != javafe.util.Location.NULL;
096 //@ ensures \result != null;
097 public static ClassLiteral make(/*@ non_null @*/ Type type, int locDot) {
098 ClassLiteral result = new ClassLiteral(type, locDot);
099 return result;
100 }
101 }