001    /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */
002    package AST;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.*;
007    import beaver.*;
008    import java.util.ArrayList;
009    import java.util.zip.*;
010    import java.io.*;
011    import java.io.FileNotFoundException;
012    import java.util.Collection;
013    /**
014     * @production PlusExpr : {@link Unary};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:140
017     */
018    public class PlusExpr extends Unary implements Cloneable {
019      /**
020       * @apilevel low-level
021       */
022      public void flushCache() {
023      }
024      /**
025       * @apilevel internal
026       */
027      public void flushCollectionCache() {
028      }
029      /**
030       * @apilevel internal
031       */
032      @SuppressWarnings({"unchecked", "cast"})
033      public PlusExpr clone() throws CloneNotSupportedException {
034        PlusExpr node = (PlusExpr)super.clone();
035        node.type_computed = false;
036        node.type_value = null;
037        node.in$Circle(false);
038        node.is$Final(false);
039        return node;
040      }
041    /**
042     * @apilevel internal
043     */
044      @SuppressWarnings({"unchecked", "cast"})
045    public PlusExpr copy() {
046      
047      try {
048        PlusExpr node = (PlusExpr) clone();
049        node.parent = null;
050        if(children != null)
051          node.children = (ASTNode[]) children.clone();
052        
053        return node;
054      } catch (CloneNotSupportedException e) {
055        throw new Error("Error: clone not supported for " + getClass().getName());
056      }
057      
058    }/**
059     * Create a deep copy of the AST subtree at this node.
060     * The copy is dangling, i.e. has no parent.
061     * @return dangling copy of the subtree at this node
062     * @apilevel low-level
063     */
064      @SuppressWarnings({"unchecked", "cast"})
065    public PlusExpr fullCopy() {
066      
067      PlusExpr tree = (PlusExpr) copy();
068      if (children != null) {
069        for (int i = 0; i < children.length; ++i) {
070          
071          ASTNode child = (ASTNode) children[i];
072          if(child != null) {
073            child = child.fullCopy();
074            tree.setChild(child, i);
075          }
076        }
077      }
078      return tree;
079      
080    }  /**
081       * @ast method 
082       * @aspect TypeCheck
083       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:269
084       */
085      public void typeCheck() {
086        if(!getOperand().type().isNumericType())
087          error("unary plus only operates on numeric types");
088      }
089      /**
090       * @ast method 
091       * @aspect CodeGenerationBinaryOperations
092       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:1019
093       */
094      void emitOperation(CodeGeneration gen)   { }
095      /**
096       * @ast method 
097       * @aspect AutoBoxingCodegen
098       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/AutoBoxingCodegen.jrag:304
099       */
100      public void createBCode(CodeGeneration gen) { boxingGen(gen); }
101      /**
102       * @ast method 
103       * 
104       */
105      public PlusExpr() {
106        super();
107    
108    
109      }
110      /**
111       * Initializes the child array to the correct size.
112       * Initializes List and Opt nta children.
113       * @apilevel internal
114       * @ast method
115       * @ast method 
116       * 
117       */
118      public void init$Children() {
119        children = new ASTNode[1];
120      }
121      /**
122       * @ast method 
123       * 
124       */
125      public PlusExpr(Expr p0) {
126        setChild(p0, 0);
127      }
128      /**
129       * @apilevel low-level
130       * @ast method 
131       * 
132       */
133      protected int numChildren() {
134        return 1;
135      }
136      /**
137       * @apilevel internal
138       * @ast method 
139       * 
140       */
141      public boolean mayHaveRewrite() {
142        return false;
143      }
144      /**
145       * Replaces the Operand child.
146       * @param node The new node to replace the Operand child.
147       * @apilevel high-level
148       * @ast method 
149       * 
150       */
151      public void setOperand(Expr node) {
152        setChild(node, 0);
153      }
154      /**
155       * Retrieves the Operand child.
156       * @return The current node used as the Operand child.
157       * @apilevel high-level
158       * @ast method 
159       * 
160       */
161      public Expr getOperand() {
162        return (Expr)getChild(0);
163      }
164      /**
165       * Retrieves the Operand child.
166       * <p><em>This method does not invoke AST transformations.</em></p>
167       * @return The current node used as the Operand child.
168       * @apilevel low-level
169       * @ast method 
170       * 
171       */
172      public Expr getOperandNoTransform() {
173        return (Expr)getChildNoTransform(0);
174      }
175      /**
176       * @attribute syn
177       * @aspect ConstantExpression
178       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:91
179       */
180      public Constant constant() {
181        ASTNode$State state = state();
182        try {  return type().plus(getOperand().constant());  }
183        finally {
184        }
185      }
186      /**
187       * @attribute syn
188       * @aspect ConstantExpression
189       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:336
190       */
191      public boolean isConstant() {
192        ASTNode$State state = state();
193        try {  return getOperand().isConstant();  }
194        finally {
195        }
196      }
197      /**
198       * @attribute syn
199       * @aspect PrettyPrint
200       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:376
201       */
202      public String printPreOp() {
203        ASTNode$State state = state();
204        try {  return "+";  }
205        finally {
206        }
207      }
208      /**
209       * @apilevel internal
210       */
211      protected boolean type_computed = false;
212      /**
213       * @apilevel internal
214       */
215      protected TypeDecl type_value;
216      /**
217       * @attribute syn
218       * @aspect TypeAnalysis
219       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:315
220       */
221      @SuppressWarnings({"unchecked", "cast"})
222      public TypeDecl type() {
223        if(type_computed) {
224          return type_value;
225        }
226          ASTNode$State state = state();
227      int num = state.boundariesCrossed;
228      boolean isFinal = this.is$Final();
229        type_value = type_compute();
230      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
231            return type_value;
232      }
233      /**
234       * @apilevel internal
235       */
236      private TypeDecl type_compute() {  return getOperand().type().unaryNumericPromotion();  }
237      /**
238       * @apilevel internal
239       */
240      public ASTNode rewriteTo() {
241        return super.rewriteTo();
242      }
243    }