    001    package javafe.ast;
    002
    003    import java.util.HashMap;
    004    import java.util.Map;
    005
    006    import javafe.util.Location;
    007
    008    /** This class is not actually ever an element of an AST.
    009     *  It derives from ASTNode so that it can use the decoration
    010     *  capability, hence the abstract methods of ASTNode are
    011     *  simply implemented with stubs.
    012     *
    013     * @author David R. Cok
    014     */
    015    public class IdentifierNode extends ASTNode {
    016
    017        //@ non_null
    018        final static private Map map = new HashMap();
    019
    020        /** The wrapped Identifier */
    021        public Identifier id;
    022
    023        /**
    024         * Creates a IdentifierNode object given an Identifier
    025         * @param id The Identifier being wrapped
    026         * @return   The fresh IdentifierNode
    027         */
    028        //@ requires id != null;
    029        //@ ensures \result.id == id;
    030        //@ ensures \fresh(\result);
    031        static public IdentifierNode make(Identifier id) {
    032          IdentifierNode t = (IdentifierNode)map.get(id);
    033          if (t != null) return t;
    034          t = new IdentifierNode();
    035          t.id = id;
    036          map.put(id,t);
    037          return t;
    038        }
    039
    040        public int getStartLoc() { return Location.NULL; }
    041        public int childCount(){ return 0; }
    042        public Object childAt(int i) { return null; }
    043        public int getTag() { return 0; }
    044        public String toString() { return id.toString(); }
    045        public void accept(Visitor v) { }
    046        public Object accept(VisitorArgResult v, Object o)
    047            { return this; }
    048
    049    }