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