001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * @ast node
026     * @production Opt : {@link ASTNode};
027    
028     */
029    public class Opt<T extends ASTNode> extends ASTNode<T> implements Cloneable {
030      /** Pretty-print Opt nodes only if they are not empty. 
031       * @aspect PrettyPrintUtil
032       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:66
033       */
034      public void prettyPrint(PrettyPrinter out) {
035        if (getNumChild() > 0) {
036          getChild(0).prettyPrint(out);
037        }
038      }
039      /**
040       * @declaredat ASTNode:1
041       */
042      public Opt() {
043        super();
044      }
045      /**
046       * Initializes the child array to the correct size.
047       * Initializes List and Opt nta children.
048       * @apilevel internal
049       * @ast method
050       * @declaredat ASTNode:10
051       */
052      public void init$Children() {
053      }
054      /**
055       * @declaredat ASTNode:12
056       */
057      public Opt(T opt) {
058        setChild(opt, 0);
059      }
060      /**
061       * @apilevel internal
062       * @declaredat ASTNode:18
063       */
064      public boolean mayHaveRewrite() {
065        return false;
066      }
067      /**
068       * @apilevel internal
069       * @declaredat ASTNode:24
070       */
071      public void flushAttrCache() {
072        super.flushAttrCache();
073      }
074      /**
075       * @apilevel internal
076       * @declaredat ASTNode:30
077       */
078      public void flushCollectionCache() {
079        super.flushCollectionCache();
080      }
081      /**
082       * @apilevel internal
083       * @declaredat ASTNode:36
084       */
085      public void flushRewriteCache() {
086        super.flushRewriteCache();
087      }
088      /**
089       * @apilevel internal
090       * @declaredat ASTNode:42
091       */
092      public Opt<T> clone() throws CloneNotSupportedException {
093        Opt node = (Opt) super.clone();
094        return node;
095      }
096      /**
097       * @apilevel internal
098       * @declaredat ASTNode:49
099       */
100      public Opt<T> copy() {
101        try {
102          Opt node = (Opt) clone();
103          node.parent = null;
104          if (children != null) {
105            node.children = (ASTNode[]) children.clone();
106          }
107          return node;
108        } catch (CloneNotSupportedException e) {
109          throw new Error("Error: clone not supported for " + getClass().getName());
110        }
111      }
112      /**
113       * Create a deep copy of the AST subtree at this node.
114       * The copy is dangling, i.e. has no parent.
115       * @return dangling copy of the subtree at this node
116       * @apilevel low-level
117       * @deprecated Please use treeCopy or treeCopyNoTransform instead
118       * @declaredat ASTNode:68
119       */
120      @Deprecated
121      public Opt<T> fullCopy() {
122        return treeCopyNoTransform();
123      }
124      /**
125       * Create a deep copy of the AST subtree at this node.
126       * The copy is dangling, i.e. has no parent.
127       * @return dangling copy of the subtree at this node
128       * @apilevel low-level
129       * @declaredat ASTNode:78
130       */
131      public Opt<T> treeCopyNoTransform() {
132        Opt tree = (Opt) copy();
133        if (children != null) {
134          for (int i = 0; i < children.length; ++i) {
135            ASTNode child = (ASTNode) children[i];
136            if (child != null) {
137              child = child.treeCopyNoTransform();
138              tree.setChild(child, i);
139            }
140          }
141        }
142        return tree;
143      }
144      /**
145       * Create a deep copy of the AST subtree at this node.
146       * The subtree of this node is traversed to trigger rewrites before copy.
147       * The copy is dangling, i.e. has no parent.
148       * @return dangling copy of the subtree at this node
149       * @apilevel low-level
150       * @declaredat ASTNode:98
151       */
152      public Opt<T> treeCopy() {
153        doFullTraversal();
154        return treeCopyNoTransform();
155      }
156      /**
157       * @apilevel internal
158       * @declaredat ASTNode:105
159       */
160      protected boolean is$Equal(ASTNode node) {
161        return super.is$Equal(node);    
162      }
163      /**
164       * @apilevel internal
165       */
166      public ASTNode rewriteTo() {
167        return super.rewriteTo();
168      }
169    }