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