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:51
027     * @production BooleanType : {@link PrimitiveType};
028    
029     */
030    public class BooleanType extends PrimitiveType implements Cloneable {
031      /**
032       * @aspect Java4PrettyPrint
033       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:277
034       */
035      public void prettyPrint(PrettyPrinter out) {
036        out.print("boolean");
037      }
038      /**
039       * @aspect Attributes
040       * @declaredat /home/jesper/git/extendj/java4/backend/Attributes.jrag:86
041       */
042      public int addConstant(ConstantPool p, Constant c)  { return p.addConstant(c.booleanValue() ? 1 : 0); }
043      /**
044       * @aspect CodeGenerationBinaryOperations
045       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:686
046       */
047      void logNot(CodeGeneration gen) { gen.emit(Bytecode.ICONST_1).emit(Bytecode.IXOR); }
048      /**
049       * @aspect CodeGenerationBinaryOperations
050       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:733
051       */
052      void bitand(CodeGeneration gen) {gen.emit(Bytecode.IAND);}
053      /**
054       * @aspect CodeGenerationBinaryOperations
055       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:738
056       */
057      void bitor(CodeGeneration gen) {gen.emit(Bytecode.IOR);}
058      /**
059       * @aspect CodeGenerationBinaryOperations
060       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:743
061       */
062      void bitxor(CodeGeneration gen) {gen.emit(Bytecode.IXOR);}
063      /**
064       * @aspect CodeGenerationBranch
065       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:792
066       */
067      public void branchEQ(CodeGeneration gen, int label)   { gen.emitCompare(Bytecode.IF_ICMPEQ, label); }
068      /**
069       * @aspect CodeGenerationBranch
070       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:801
071       */
072      public void branchNE(CodeGeneration gen, int label)   { gen.emitCompare(Bytecode.IF_ICMPNE, label); }
073      /**
074       * @aspect AnnotationsCodegen
075       * @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:214
076       */
077      public int addAnnotConstant(ConstantPool p, Constant c)  {
078        return addConstant(p, c);
079      }
080      /**
081       * @declaredat ASTNode:1
082       */
083      public BooleanType() {
084        super();
085      }
086      /**
087       * Initializes the child array to the correct size.
088       * Initializes List and Opt nta children.
089       * @apilevel internal
090       * @ast method
091       * @declaredat ASTNode:10
092       */
093      public void init$Children() {
094        children = new ASTNode[3];
095        setChild(new Opt(), 1);
096        setChild(new List(), 2);
097      }
098      /**
099       * @declaredat ASTNode:15
100       */
101      public BooleanType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) {
102        setChild(p0, 0);
103        setID(p1);
104        setChild(p2, 1);
105        setChild(p3, 2);
106      }
107      /**
108       * @declaredat ASTNode:21
109       */
110      public BooleanType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) {
111        setChild(p0, 0);
112        setID(p1);
113        setChild(p2, 1);
114        setChild(p3, 2);
115      }
116      /**
117       * @apilevel low-level
118       * @declaredat ASTNode:30
119       */
120      protected int numChildren() {
121        return 3;
122      }
123      /**
124       * @apilevel internal
125       * @declaredat ASTNode:36
126       */
127      public boolean mayHaveRewrite() {
128        return false;
129      }
130      /**
131       * @apilevel internal
132       * @declaredat ASTNode:42
133       */
134      public void flushAttrCache() {
135        super.flushAttrCache();
136        typeDescriptor_reset();
137        jvmName_reset();
138        boxed_reset();
139      }
140      /**
141       * @apilevel internal
142       * @declaredat ASTNode:51
143       */
144      public void flushCollectionCache() {
145        super.flushCollectionCache();
146      }
147      /**
148       * @apilevel internal
149       * @declaredat ASTNode:57
150       */
151      public void flushRewriteCache() {
152        super.flushRewriteCache();
153      }
154      /**
155       * @apilevel internal
156       * @declaredat ASTNode:63
157       */
158      public BooleanType clone() throws CloneNotSupportedException {
159        BooleanType node = (BooleanType) super.clone();
160        return node;
161      }
162      /**
163       * @apilevel internal
164       * @declaredat ASTNode:70
165       */
166      public BooleanType copy() {
167        try {
168          BooleanType node = (BooleanType) clone();
169          node.parent = null;
170          if (children != null) {
171            node.children = (ASTNode[]) children.clone();
172          }
173          return node;
174        } catch (CloneNotSupportedException e) {
175          throw new Error("Error: clone not supported for " + getClass().getName());
176        }
177      }
178      /**
179       * Create a deep copy of the AST subtree at this node.
180       * The copy is dangling, i.e. has no parent.
181       * @return dangling copy of the subtree at this node
182       * @apilevel low-level
183       * @deprecated Please use treeCopy or treeCopyNoTransform instead
184       * @declaredat ASTNode:89
185       */
186      @Deprecated
187      public BooleanType fullCopy() {
188        return treeCopyNoTransform();
189      }
190      /**
191       * Create a deep copy of the AST subtree at this node.
192       * The copy is dangling, i.e. has no parent.
193       * @return dangling copy of the subtree at this node
194       * @apilevel low-level
195       * @declaredat ASTNode:99
196       */
197      public BooleanType treeCopyNoTransform() {
198        BooleanType tree = (BooleanType) copy();
199        if (children != null) {
200          for (int i = 0; i < children.length; ++i) {
201            ASTNode child = (ASTNode) children[i];
202            if (child != null) {
203              child = child.treeCopyNoTransform();
204              tree.setChild(child, i);
205            }
206          }
207        }
208        return tree;
209      }
210      /**
211       * Create a deep copy of the AST subtree at this node.
212       * The subtree of this node is traversed to trigger rewrites before copy.
213       * The copy is dangling, i.e. has no parent.
214       * @return dangling copy of the subtree at this node
215       * @apilevel low-level
216       * @declaredat ASTNode:119
217       */
218      public BooleanType treeCopy() {
219        doFullTraversal();
220        return treeCopyNoTransform();
221      }
222      /**
223       * @apilevel internal
224       * @declaredat ASTNode:126
225       */
226      protected boolean is$Equal(ASTNode node) {
227        return super.is$Equal(node) && (tokenString_ID == ((BooleanType)node).tokenString_ID);    
228      }
229      /**
230       * Replaces the Modifiers child.
231       * @param node The new node to replace the Modifiers child.
232       * @apilevel high-level
233       */
234      public void setModifiers(Modifiers node) {
235        setChild(node, 0);
236      }
237      /**
238       * Retrieves the Modifiers child.
239       * @return The current node used as the Modifiers child.
240       * @apilevel high-level
241       */
242      @ASTNodeAnnotation.Child(name="Modifiers")
243      public Modifiers getModifiers() {
244        return (Modifiers) getChild(0);
245      }
246      /**
247       * Retrieves the Modifiers child.
248       * <p><em>This method does not invoke AST transformations.</em></p>
249       * @return The current node used as the Modifiers child.
250       * @apilevel low-level
251       */
252      public Modifiers getModifiersNoTransform() {
253        return (Modifiers) getChildNoTransform(0);
254      }
255      /**
256       * Replaces the lexeme ID.
257       * @param value The new value for the lexeme ID.
258       * @apilevel high-level
259       */
260      public void setID(String value) {
261        tokenString_ID = value;
262      }
263      /**
264       * JastAdd-internal setter for lexeme ID using the Beaver parser.
265       * @param symbol Symbol containing the new value for the lexeme ID
266       * @apilevel internal
267       */
268      public void setID(beaver.Symbol symbol) {
269        if (symbol.value != null && !(symbol.value instanceof String))
270        throw new UnsupportedOperationException("setID is only valid for String lexemes");
271        tokenString_ID = (String)symbol.value;
272        IDstart = symbol.getStart();
273        IDend = symbol.getEnd();
274      }
275      /**
276       * Retrieves the value for the lexeme ID.
277       * @return The value for the lexeme ID.
278       * @apilevel high-level
279       */
280      @ASTNodeAnnotation.Token(name="ID")
281      public String getID() {
282        return tokenString_ID != null ? tokenString_ID : "";
283      }
284      /**
285       * Replaces the optional node for the SuperClass child. This is the <code>Opt</code>
286       * node containing the child SuperClass, not the actual child!
287       * @param opt The new node to be used as the optional node for the SuperClass child.
288       * @apilevel low-level
289       */
290      public void setSuperClassOpt(Opt<Access> opt) {
291        setChild(opt, 1);
292      }
293      /**
294       * Replaces the (optional) SuperClass child.
295       * @param node The new node to be used as the SuperClass child.
296       * @apilevel high-level
297       */
298      public void setSuperClass(Access node) {
299        getSuperClassOpt().setChild(node, 0);
300      }
301      /**
302       * Check whether the optional SuperClass child exists.
303       * @return {@code true} if the optional SuperClass child exists, {@code false} if it does not.
304       * @apilevel high-level
305       */
306      public boolean hasSuperClass() {
307        return getSuperClassOpt().getNumChild() != 0;
308      }
309      /**
310       * Retrieves the (optional) SuperClass child.
311       * @return The SuperClass child, if it exists. Returns {@code null} otherwise.
312       * @apilevel low-level
313       */
314      public Access getSuperClass() {
315        return (Access) getSuperClassOpt().getChild(0);
316      }
317      /**
318       * Retrieves the optional node for the SuperClass child. This is the <code>Opt</code> node containing the child SuperClass, not the actual child!
319       * @return The optional node for child the SuperClass child.
320       * @apilevel low-level
321       */
322      @ASTNodeAnnotation.OptChild(name="SuperClass")
323      public Opt<Access> getSuperClassOpt() {
324        return (Opt<Access>) getChild(1);
325      }
326      /**
327       * Retrieves the optional node for child SuperClass. This is the <code>Opt</code> node containing the child SuperClass, not the actual child!
328       * <p><em>This method does not invoke AST transformations.</em></p>
329       * @return The optional node for child SuperClass.
330       * @apilevel low-level
331       */
332      public Opt<Access> getSuperClassOptNoTransform() {
333        return (Opt<Access>) getChildNoTransform(1);
334      }
335      /**
336       * Replaces the BodyDecl list.
337       * @param list The new list node to be used as the BodyDecl list.
338       * @apilevel high-level
339       */
340      public void setBodyDeclList(List<BodyDecl> list) {
341        setChild(list, 2);
342      }
343      /**
344       * Retrieves the number of children in the BodyDecl list.
345       * @return Number of children in the BodyDecl list.
346       * @apilevel high-level
347       */
348      public int getNumBodyDecl() {
349        return getBodyDeclList().getNumChild();
350      }
351      /**
352       * Retrieves the number of children in the BodyDecl list.
353       * Calling this method will not trigger rewrites.
354       * @return Number of children in the BodyDecl list.
355       * @apilevel low-level
356       */
357      public int getNumBodyDeclNoTransform() {
358        return getBodyDeclListNoTransform().getNumChildNoTransform();
359      }
360      /**
361       * Retrieves the element at index {@code i} in the BodyDecl list.
362       * @param i Index of the element to return.
363       * @return The element at position {@code i} in the BodyDecl list.
364       * @apilevel high-level
365       */
366      public BodyDecl getBodyDecl(int i) {
367        return (BodyDecl) getBodyDeclList().getChild(i);
368      }
369      /**
370       * Check whether the BodyDecl list has any children.
371       * @return {@code true} if it has at least one child, {@code false} otherwise.
372       * @apilevel high-level
373       */
374      public boolean hasBodyDecl() {
375        return getBodyDeclList().getNumChild() != 0;
376      }
377      /**
378       * Append an element to the BodyDecl list.
379       * @param node The element to append to the BodyDecl list.
380       * @apilevel high-level
381       */
382      public void addBodyDecl(BodyDecl node) {
383        List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
384        list.addChild(node);
385      }
386      /**
387       * @apilevel low-level
388       */
389      public void addBodyDeclNoTransform(BodyDecl node) {
390        List<BodyDecl> list = getBodyDeclListNoTransform();
391        list.addChild(node);
392      }
393      /**
394       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
395       * @param node The new node to replace the old list element.
396       * @param i The list index of the node to be replaced.
397       * @apilevel high-level
398       */
399      public void setBodyDecl(BodyDecl node, int i) {
400        List<BodyDecl> list = getBodyDeclList();
401        list.setChild(node, i);
402      }
403      /**
404       * Retrieves the BodyDecl list.
405       * @return The node representing the BodyDecl list.
406       * @apilevel high-level
407       */
408      @ASTNodeAnnotation.ListChild(name="BodyDecl")
409      public List<BodyDecl> getBodyDeclList() {
410        List<BodyDecl> list = (List<BodyDecl>) getChild(2);
411        return list;
412      }
413      /**
414       * Retrieves the BodyDecl list.
415       * <p><em>This method does not invoke AST transformations.</em></p>
416       * @return The node representing the BodyDecl list.
417       * @apilevel low-level
418       */
419      public List<BodyDecl> getBodyDeclListNoTransform() {
420        return (List<BodyDecl>) getChildNoTransform(2);
421      }
422      /**
423       * Retrieves the BodyDecl list.
424       * @return The node representing the BodyDecl list.
425       * @apilevel high-level
426       */
427      public List<BodyDecl> getBodyDecls() {
428        return getBodyDeclList();
429      }
430      /**
431       * Retrieves the BodyDecl list.
432       * <p><em>This method does not invoke AST transformations.</em></p>
433       * @return The node representing the BodyDecl list.
434       * @apilevel low-level
435       */
436      public List<BodyDecl> getBodyDeclsNoTransform() {
437        return getBodyDeclListNoTransform();
438      }
439      /**
440       * @aspect AutoBoxingCodegen
441       * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:33
442       */
443        void emitCastTo(CodeGeneration gen, TypeDecl type) {
444        if (type.unboxed() == this || type.isObject()) {
445          boxed().emitBoxingOperation(gen);
446        }
447      }
448      /**
449       * @attribute syn
450       * @aspect ConstantExpression
451       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:72
452       */
453      @ASTNodeAnnotation.Attribute
454      public Constant cast(Constant c) {
455        Constant cast_Constant_value = Constant.create(c.booleanValue());
456    
457        return cast_Constant_value;
458      }
459      /**
460       * @attribute syn
461       * @aspect ConstantExpression
462       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:178
463       */
464      @ASTNodeAnnotation.Attribute
465      public Constant andBitwise(Constant c1, Constant c2) {
466        Constant andBitwise_Constant_Constant_value = Constant.create(c1.booleanValue() & c2.booleanValue());
467    
468        return andBitwise_Constant_Constant_value;
469      }
470      /**
471       * @attribute syn
472       * @aspect ConstantExpression
473       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:186
474       */
475      @ASTNodeAnnotation.Attribute
476      public Constant xorBitwise(Constant c1, Constant c2) {
477        Constant xorBitwise_Constant_Constant_value = Constant.create(c1.booleanValue() ^ c2.booleanValue());
478    
479        return xorBitwise_Constant_Constant_value;
480      }
481      /**
482       * @attribute syn
483       * @aspect ConstantExpression
484       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:194
485       */
486      @ASTNodeAnnotation.Attribute
487      public Constant orBitwise(Constant c1, Constant c2) {
488        Constant orBitwise_Constant_Constant_value = Constant.create(c1.booleanValue() | c2.booleanValue());
489    
490        return orBitwise_Constant_Constant_value;
491      }
492      /**
493       * @attribute syn
494       * @aspect ConstantExpression
495       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:202
496       */
497      @ASTNodeAnnotation.Attribute
498      public Constant questionColon(Constant cond, Constant c1, Constant c2) {
499        Constant questionColon_Constant_Constant_Constant_value = Constant.create(cond.booleanValue() ? c1.booleanValue() : c2.booleanValue());
500    
501        return questionColon_Constant_Constant_Constant_value;
502      }
503      /**
504       * @attribute syn
505       * @aspect ConstantExpression
506       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:326
507       */
508      @ASTNodeAnnotation.Attribute
509      public boolean eqIsTrue(Expr left, Expr right) {
510        boolean eqIsTrue_Expr_Expr_value = left.isTrue() && right.isTrue() || left.isFalse() && right.isFalse();
511    
512        return eqIsTrue_Expr_Expr_value;
513      }
514      /**
515       * @attribute syn
516       * @aspect TypeAnalysis
517       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:203
518       */
519      @ASTNodeAnnotation.Attribute
520      public boolean isBoolean() {
521        boolean isBoolean_value = true;
522    
523        return isBoolean_value;
524      }
525      /**
526       * @attribute syn
527       * @aspect CodeGeneration
528       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:249
529       */
530      @ASTNodeAnnotation.Attribute
531      public byte arrayLoad() {
532        byte arrayLoad_value = Bytecode.BALOAD;
533    
534        return arrayLoad_value;
535      }
536      /**
537       * @attribute syn
538       * @aspect CodeGeneration
539       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:380
540       */
541      @ASTNodeAnnotation.Attribute
542      public byte arrayStore() {
543        byte arrayStore_value = Bytecode.BASTORE;
544    
545        return arrayStore_value;
546      }
547      /**
548       * @apilevel internal
549       */
550      protected boolean typeDescriptor_computed = false;
551      /**
552       * @apilevel internal
553       */
554      protected String typeDescriptor_value;
555      /**
556       * @apilevel internal
557       */
558      private void typeDescriptor_reset() {
559        typeDescriptor_computed = false;
560        typeDescriptor_value = null;
561      }
562      /**
563       * @attribute syn
564       * @aspect ConstantPoolNames
565       * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:77
566       */
567      @ASTNodeAnnotation.Attribute
568      public String typeDescriptor() {
569        ASTNode$State state = state();
570        if (typeDescriptor_computed) {
571          return typeDescriptor_value;
572        }
573        boolean intermediate = state.INTERMEDIATE_VALUE;
574        state.INTERMEDIATE_VALUE = false;
575        int num = state.boundariesCrossed;
576        boolean isFinal = this.is$Final();
577        typeDescriptor_value = "Z";
578        if (isFinal && num == state().boundariesCrossed) {
579          typeDescriptor_computed = true;
580        } else {
581        }
582        state.INTERMEDIATE_VALUE |= intermediate;
583    
584        return typeDescriptor_value;
585      }
586      /**
587       * @attribute syn
588       * @aspect CreateBCode
589       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:905
590       */
591      @ASTNodeAnnotation.Attribute
592      public int arrayPrimitiveTypeDescriptor() {
593        int arrayPrimitiveTypeDescriptor_value = 4;
594    
595        return arrayPrimitiveTypeDescriptor_value;
596      }
597      /**
598       * @apilevel internal
599       */
600      protected boolean jvmName_computed = false;
601      /**
602       * @apilevel internal
603       */
604      protected String jvmName_value;
605      /**
606       * @apilevel internal
607       */
608      private void jvmName_reset() {
609        jvmName_computed = false;
610        jvmName_value = null;
611      }
612      /**
613       * @attribute syn
614       * @aspect Java2Rewrites
615       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:36
616       */
617      @ASTNodeAnnotation.Attribute
618      public String jvmName() {
619        ASTNode$State state = state();
620        if (jvmName_computed) {
621          return jvmName_value;
622        }
623        boolean intermediate = state.INTERMEDIATE_VALUE;
624        state.INTERMEDIATE_VALUE = false;
625        int num = state.boundariesCrossed;
626        boolean isFinal = this.is$Final();
627        jvmName_value = "Z";
628        if (isFinal && num == state().boundariesCrossed) {
629          jvmName_computed = true;
630        } else {
631        }
632        state.INTERMEDIATE_VALUE |= intermediate;
633    
634        return jvmName_value;
635      }
636      /**
637       * @attribute syn
638       * @aspect Java2Rewrites
639       * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:68
640       */
641      @ASTNodeAnnotation.Attribute
642      public String primitiveClassName() {
643        String primitiveClassName_value = "Boolean";
644    
645        return primitiveClassName_value;
646      }
647      /**
648       * @apilevel internal
649       */
650      protected boolean boxed_computed = false;
651      /**
652       * @apilevel internal
653       */
654      protected TypeDecl boxed_value;
655      /**
656       * @apilevel internal
657       */
658      private void boxed_reset() {
659        boxed_computed = false;
660        boxed_value = null;
661      }
662      /**
663       * @attribute syn
664       * @aspect AutoBoxing
665       * @declaredat /home/jesper/git/extendj/java5/frontend/AutoBoxing.jrag:56
666       */
667      @ASTNodeAnnotation.Attribute
668      public TypeDecl boxed() {
669        ASTNode$State state = state();
670        if (boxed_computed) {
671          return boxed_value;
672        }
673        boolean intermediate = state.INTERMEDIATE_VALUE;
674        state.INTERMEDIATE_VALUE = false;
675        int num = state.boundariesCrossed;
676        boolean isFinal = this.is$Final();
677        boxed_value = lookupType("java.lang", "Boolean");
678        if (isFinal && num == state().boundariesCrossed) {
679          boxed_computed = true;
680        } else {
681        }
682        state.INTERMEDIATE_VALUE |= intermediate;
683    
684        return boxed_value;
685      }
686      /**
687       * @apilevel internal
688       */
689      public ASTNode rewriteTo() {
690        return super.rewriteTo();
691      }
692    }