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     * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:105
027     * @production AssignSimpleExpr : {@link AssignExpr};
028    
029     */
030    public class AssignSimpleExpr extends AssignExpr implements Cloneable {
031      /**
032       * @aspect TypeCheck
033       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:67
034       */
035      public void typeCheck() {
036        if (!getDest().isVariable()) {
037          error("left hand side is not a variable");
038        } else if (!getSource().type().assignConversionTo(getDest().type(), getSource())
039            && !getSource().type().isUnknown()) {
040          errorf("can not assign %s of type %s a value of type %s",
041              getDest().prettyPrint(), getDest().type().typeName(), getSource().type().typeName());
042        }
043      }
044      /**
045       * Create bytecode for a simple assign expression.
046       * @aspect CreateBCode
047       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:324
048       */
049      public void createBCode(CodeGeneration gen) {
050        getDest().createAssignSimpleLoadDest(gen);
051        getSource().createBCode(gen);
052        getSource().type().emitAssignConvTo(gen, getDest().type()); // AssignConversion
053        if (needsPush()) {
054          getDest().createPushAssignmentResult(gen);
055        }
056        getDest().emitStore(gen);
057      }
058      /**
059       * @aspect UncheckedConversion
060       * @declaredat /home/jesper/git/extendj/java7/frontend/UncheckedConversion.jrag:53
061       */
062      public void checkWarnings() {
063        if (!withinSuppressWarnings("unchecked")) {
064          checkUncheckedConversion(getSource().type(), getDest().type());
065        }
066      }
067      /**
068       * @declaredat ASTNode:1
069       */
070      public AssignSimpleExpr() {
071        super();
072      }
073      /**
074       * Initializes the child array to the correct size.
075       * Initializes List and Opt nta children.
076       * @apilevel internal
077       * @ast method
078       * @declaredat ASTNode:10
079       */
080      public void init$Children() {
081        children = new ASTNode[2];
082      }
083      /**
084       * @declaredat ASTNode:13
085       */
086      public AssignSimpleExpr(Expr p0, Expr p1) {
087        setChild(p0, 0);
088        setChild(p1, 1);
089      }
090      /**
091       * @apilevel low-level
092       * @declaredat ASTNode:20
093       */
094      protected int numChildren() {
095        return 2;
096      }
097      /**
098       * @apilevel internal
099       * @declaredat ASTNode:26
100       */
101      public boolean mayHaveRewrite() {
102        return false;
103      }
104      /**
105       * @apilevel internal
106       * @declaredat ASTNode:32
107       */
108      public void flushAttrCache() {
109        super.flushAttrCache();
110      }
111      /**
112       * @apilevel internal
113       * @declaredat ASTNode:38
114       */
115      public void flushCollectionCache() {
116        super.flushCollectionCache();
117      }
118      /**
119       * @apilevel internal
120       * @declaredat ASTNode:44
121       */
122      public void flushRewriteCache() {
123        super.flushRewriteCache();
124      }
125      /**
126       * @apilevel internal
127       * @declaredat ASTNode:50
128       */
129      public AssignSimpleExpr clone() throws CloneNotSupportedException {
130        AssignSimpleExpr node = (AssignSimpleExpr) super.clone();
131        return node;
132      }
133      /**
134       * @apilevel internal
135       * @declaredat ASTNode:57
136       */
137      public AssignSimpleExpr copy() {
138        try {
139          AssignSimpleExpr node = (AssignSimpleExpr) clone();
140          node.parent = null;
141          if (children != null) {
142            node.children = (ASTNode[]) children.clone();
143          }
144          return node;
145        } catch (CloneNotSupportedException e) {
146          throw new Error("Error: clone not supported for " + getClass().getName());
147        }
148      }
149      /**
150       * Create a deep copy of the AST subtree at this node.
151       * The copy is dangling, i.e. has no parent.
152       * @return dangling copy of the subtree at this node
153       * @apilevel low-level
154       * @deprecated Please use treeCopy or treeCopyNoTransform instead
155       * @declaredat ASTNode:76
156       */
157      @Deprecated
158      public AssignSimpleExpr fullCopy() {
159        return treeCopyNoTransform();
160      }
161      /**
162       * Create a deep copy of the AST subtree at this node.
163       * The copy is dangling, i.e. has no parent.
164       * @return dangling copy of the subtree at this node
165       * @apilevel low-level
166       * @declaredat ASTNode:86
167       */
168      public AssignSimpleExpr treeCopyNoTransform() {
169        AssignSimpleExpr tree = (AssignSimpleExpr) copy();
170        if (children != null) {
171          for (int i = 0; i < children.length; ++i) {
172            ASTNode child = (ASTNode) children[i];
173            if (child != null) {
174              child = child.treeCopyNoTransform();
175              tree.setChild(child, i);
176            }
177          }
178        }
179        return tree;
180      }
181      /**
182       * Create a deep copy of the AST subtree at this node.
183       * The subtree of this node is traversed to trigger rewrites before copy.
184       * The copy is dangling, i.e. has no parent.
185       * @return dangling copy of the subtree at this node
186       * @apilevel low-level
187       * @declaredat ASTNode:106
188       */
189      public AssignSimpleExpr treeCopy() {
190        doFullTraversal();
191        return treeCopyNoTransform();
192      }
193      /**
194       * @apilevel internal
195       * @declaredat ASTNode:113
196       */
197      protected boolean is$Equal(ASTNode node) {
198        return super.is$Equal(node);    
199      }
200      /**
201       * Replaces the Dest child.
202       * @param node The new node to replace the Dest child.
203       * @apilevel high-level
204       */
205      public void setDest(Expr node) {
206        setChild(node, 0);
207      }
208      /**
209       * Retrieves the Dest child.
210       * @return The current node used as the Dest child.
211       * @apilevel high-level
212       */
213      @ASTNodeAnnotation.Child(name="Dest")
214      public Expr getDest() {
215        return (Expr) getChild(0);
216      }
217      /**
218       * Retrieves the Dest child.
219       * <p><em>This method does not invoke AST transformations.</em></p>
220       * @return The current node used as the Dest child.
221       * @apilevel low-level
222       */
223      public Expr getDestNoTransform() {
224        return (Expr) getChildNoTransform(0);
225      }
226      /**
227       * Replaces the Source child.
228       * @param node The new node to replace the Source child.
229       * @apilevel high-level
230       */
231      public void setSource(Expr node) {
232        setChild(node, 1);
233      }
234      /**
235       * Retrieves the Source child.
236       * @return The current node used as the Source child.
237       * @apilevel high-level
238       */
239      @ASTNodeAnnotation.Child(name="Source")
240      public Expr getSource() {
241        return (Expr) getChild(1);
242      }
243      /**
244       * Retrieves the Source child.
245       * <p><em>This method does not invoke AST transformations.</em></p>
246       * @return The current node used as the Source child.
247       * @apilevel low-level
248       */
249      public Expr getSourceNoTransform() {
250        return (Expr) getChildNoTransform(1);
251      }
252      /** The operator string used for pretty printing this expression. 
253       * @attribute syn
254       * @aspect PrettyPrintUtil
255       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:292
256       */
257      @ASTNodeAnnotation.Attribute
258      public String printOp() {
259        String printOp_value = "=";
260    
261        return printOp_value;
262      }
263      /**
264       * @attribute inh
265       * @aspect SuppressWarnings
266       * @declaredat /home/jesper/git/extendj/java7/frontend/SuppressWarnings.jrag:37
267       */
268      /**
269       * @attribute inh
270       * @aspect SuppressWarnings
271       * @declaredat /home/jesper/git/extendj/java7/frontend/SuppressWarnings.jrag:37
272       */
273      @ASTNodeAnnotation.Attribute
274      public boolean withinSuppressWarnings(String annot) {
275        boolean withinSuppressWarnings_String_value = getParent().Define_withinSuppressWarnings(this, null, annot);
276    
277        return withinSuppressWarnings_String_value;
278      }
279      /**
280       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:37
281       * @apilevel internal
282       */
283      public boolean Define_isDest(ASTNode caller, ASTNode child) {
284        if (caller == getDestNoTransform()) {
285          // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:39
286          return true;
287        }
288        else {
289          return super.Define_isDest(caller, child);
290        }
291      }
292      protected boolean canDefine_isDest(ASTNode caller, ASTNode child) {
293        return true;
294      }
295      /**
296       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:47
297       * @apilevel internal
298       */
299      public boolean Define_isSource(ASTNode caller, ASTNode child) {
300        if (caller == getDestNoTransform()) {
301          // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:49
302          return false;
303        }
304        else {
305          return super.Define_isSource(caller, child);
306        }
307      }
308      protected boolean canDefine_isSource(ASTNode caller, ASTNode child) {
309        return true;
310      }
311      /**
312       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethodsInference.jrag:58
313       * @apilevel internal
314       */
315      public TypeDecl Define_assignConvertedType(ASTNode caller, ASTNode child) {
316        if (caller == getSourceNoTransform()) {
317          // @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethodsInference.jrag:61
318          return getDest().type();
319        }
320        else {
321          return getParent().Define_assignConvertedType(this, caller);
322        }
323      }
324      protected boolean canDefine_assignConvertedType(ASTNode caller, ASTNode child) {
325        return true;
326      }
327      /**
328       * @apilevel internal
329       */
330      public ASTNode rewriteTo() {
331        return super.rewriteTo();
332      }
333    }