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 BitwiseExpr : {@link Binary};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:166
017     */
018    public abstract class BitwiseExpr extends Binary 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 BitwiseExpr clone() throws CloneNotSupportedException {
034        BitwiseExpr node = (BitwiseExpr)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       * @ast method 
043       * @aspect TypeCheck
044       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:192
045       */
046      public void typeCheck() {
047        TypeDecl left = getLeftOperand().type();
048        TypeDecl right = getRightOperand().type();
049        if(left.isIntegralType() && right.isIntegralType())
050          return;
051        else if(left.isBoolean() && right.isBoolean())
052          return;
053        else
054          error(left.typeName() + " is not compatible with " + right.typeName());
055      }
056      /**
057       * @ast method 
058       * 
059       */
060      public BitwiseExpr() {
061        super();
062    
063    
064      }
065      /**
066       * Initializes the child array to the correct size.
067       * Initializes List and Opt nta children.
068       * @apilevel internal
069       * @ast method
070       * @ast method 
071       * 
072       */
073      public void init$Children() {
074        children = new ASTNode[2];
075      }
076      /**
077       * @ast method 
078       * 
079       */
080      public BitwiseExpr(Expr p0, Expr p1) {
081        setChild(p0, 0);
082        setChild(p1, 1);
083      }
084      /**
085       * @apilevel low-level
086       * @ast method 
087       * 
088       */
089      protected int numChildren() {
090        return 2;
091      }
092      /**
093       * @apilevel internal
094       * @ast method 
095       * 
096       */
097      public boolean mayHaveRewrite() {
098        return false;
099      }
100      /**
101       * Replaces the LeftOperand child.
102       * @param node The new node to replace the LeftOperand child.
103       * @apilevel high-level
104       * @ast method 
105       * 
106       */
107      public void setLeftOperand(Expr node) {
108        setChild(node, 0);
109      }
110      /**
111       * Retrieves the LeftOperand child.
112       * @return The current node used as the LeftOperand child.
113       * @apilevel high-level
114       * @ast method 
115       * 
116       */
117      public Expr getLeftOperand() {
118        return (Expr)getChild(0);
119      }
120      /**
121       * Retrieves the LeftOperand child.
122       * <p><em>This method does not invoke AST transformations.</em></p>
123       * @return The current node used as the LeftOperand child.
124       * @apilevel low-level
125       * @ast method 
126       * 
127       */
128      public Expr getLeftOperandNoTransform() {
129        return (Expr)getChildNoTransform(0);
130      }
131      /**
132       * Replaces the RightOperand child.
133       * @param node The new node to replace the RightOperand child.
134       * @apilevel high-level
135       * @ast method 
136       * 
137       */
138      public void setRightOperand(Expr node) {
139        setChild(node, 1);
140      }
141      /**
142       * Retrieves the RightOperand child.
143       * @return The current node used as the RightOperand child.
144       * @apilevel high-level
145       * @ast method 
146       * 
147       */
148      public Expr getRightOperand() {
149        return (Expr)getChild(1);
150      }
151      /**
152       * Retrieves the RightOperand child.
153       * <p><em>This method does not invoke AST transformations.</em></p>
154       * @return The current node used as the RightOperand child.
155       * @apilevel low-level
156       * @ast method 
157       * 
158       */
159      public Expr getRightOperandNoTransform() {
160        return (Expr)getChildNoTransform(1);
161      }
162      /**
163       * @apilevel internal
164       */
165      protected boolean type_computed = false;
166      /**
167       * @apilevel internal
168       */
169      protected TypeDecl type_value;
170      /**
171       * @attribute syn
172       * @aspect TypeAnalysis
173       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:350
174       */
175      @SuppressWarnings({"unchecked", "cast"})
176      public TypeDecl type() {
177        if(type_computed) {
178          return type_value;
179        }
180          ASTNode$State state = state();
181      int num = state.boundariesCrossed;
182      boolean isFinal = this.is$Final();
183        type_value = type_compute();
184      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
185            return type_value;
186      }
187      /**
188       * @apilevel internal
189       */
190      private TypeDecl type_compute() {
191        if(getLeftOperand().type().isIntegralType() && getRightOperand().type().isIntegralType())
192          // 15.22.1
193          return getLeftOperand().type().binaryNumericPromotion(getRightOperand().type());
194        else if(getLeftOperand().type().isBoolean() && getRightOperand().type().isBoolean())
195          // 15.22.2
196          return typeBoolean();
197        return unknownType();
198      }
199      /**
200       * @apilevel internal
201       */
202      public ASTNode rewriteTo() {
203        return super.rewriteTo();
204      }
205    }