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:168
027     * @production LogicalExpr : {@link Binary};
028    
029     */
030    public abstract class LogicalExpr extends Binary implements Cloneable {
031      /**
032       * @aspect TypeCheck
033       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:250
034       */
035      public void typeCheck() {
036        if (!getLeftOperand().type().isBoolean()) {
037          errorf("%s is not boolean", getLeftOperand().type().typeName());
038        }
039        if (!getRightOperand().type().isBoolean()) {
040          errorf("%s is not boolean", getRightOperand().type().typeName());
041        }
042      }
043      /**
044       * @aspect CreateBCode
045       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1048
046       */
047      public void createBCode(CodeGeneration gen) { emitBooleanCondition(gen); }
048      /**
049       * @declaredat ASTNode:1
050       */
051      public LogicalExpr() {
052        super();
053      }
054      /**
055       * Initializes the child array to the correct size.
056       * Initializes List and Opt nta children.
057       * @apilevel internal
058       * @ast method
059       * @declaredat ASTNode:10
060       */
061      public void init$Children() {
062        children = new ASTNode[2];
063      }
064      /**
065       * @declaredat ASTNode:13
066       */
067      public LogicalExpr(Expr p0, Expr p1) {
068        setChild(p0, 0);
069        setChild(p1, 1);
070      }
071      /**
072       * @apilevel low-level
073       * @declaredat ASTNode:20
074       */
075      protected int numChildren() {
076        return 2;
077      }
078      /**
079       * @apilevel internal
080       * @declaredat ASTNode:26
081       */
082      public boolean mayHaveRewrite() {
083        return false;
084      }
085      /**
086       * @apilevel internal
087       * @declaredat ASTNode:32
088       */
089      public void flushAttrCache() {
090        super.flushAttrCache();
091        type_reset();
092      }
093      /**
094       * @apilevel internal
095       * @declaredat ASTNode:39
096       */
097      public void flushCollectionCache() {
098        super.flushCollectionCache();
099      }
100      /**
101       * @apilevel internal
102       * @declaredat ASTNode:45
103       */
104      public void flushRewriteCache() {
105        super.flushRewriteCache();
106      }
107      /**
108       * @apilevel internal
109       * @declaredat ASTNode:51
110       */
111      public LogicalExpr clone() throws CloneNotSupportedException {
112        LogicalExpr node = (LogicalExpr) super.clone();
113        return node;
114      }
115      /**
116       * Create a deep copy of the AST subtree at this node.
117       * The copy is dangling, i.e. has no parent.
118       * @return dangling copy of the subtree at this node
119       * @apilevel low-level
120       * @deprecated Please use treeCopy or treeCopyNoTransform instead
121       * @declaredat ASTNode:62
122       */
123      @Deprecated
124      public abstract LogicalExpr fullCopy();
125      /**
126       * Create a deep copy of the AST subtree at this node.
127       * The copy is dangling, i.e. has no parent.
128       * @return dangling copy of the subtree at this node
129       * @apilevel low-level
130       * @declaredat ASTNode:70
131       */
132      public abstract LogicalExpr treeCopyNoTransform();
133      /**
134       * Create a deep copy of the AST subtree at this node.
135       * The subtree of this node is traversed to trigger rewrites before copy.
136       * The copy is dangling, i.e. has no parent.
137       * @return dangling copy of the subtree at this node
138       * @apilevel low-level
139       * @declaredat ASTNode:78
140       */
141      public abstract LogicalExpr treeCopy();
142      /**
143       * Replaces the LeftOperand child.
144       * @param node The new node to replace the LeftOperand child.
145       * @apilevel high-level
146       */
147      public void setLeftOperand(Expr node) {
148        setChild(node, 0);
149      }
150      /**
151       * Retrieves the LeftOperand child.
152       * @return The current node used as the LeftOperand child.
153       * @apilevel high-level
154       */
155      @ASTNodeAnnotation.Child(name="LeftOperand")
156      public Expr getLeftOperand() {
157        return (Expr) getChild(0);
158      }
159      /**
160       * Retrieves the LeftOperand child.
161       * <p><em>This method does not invoke AST transformations.</em></p>
162       * @return The current node used as the LeftOperand child.
163       * @apilevel low-level
164       */
165      public Expr getLeftOperandNoTransform() {
166        return (Expr) getChildNoTransform(0);
167      }
168      /**
169       * Replaces the RightOperand child.
170       * @param node The new node to replace the RightOperand child.
171       * @apilevel high-level
172       */
173      public void setRightOperand(Expr node) {
174        setChild(node, 1);
175      }
176      /**
177       * Retrieves the RightOperand child.
178       * @return The current node used as the RightOperand child.
179       * @apilevel high-level
180       */
181      @ASTNodeAnnotation.Child(name="RightOperand")
182      public Expr getRightOperand() {
183        return (Expr) getChild(1);
184      }
185      /**
186       * Retrieves the RightOperand child.
187       * <p><em>This method does not invoke AST transformations.</em></p>
188       * @return The current node used as the RightOperand child.
189       * @apilevel low-level
190       */
191      public Expr getRightOperandNoTransform() {
192        return (Expr) getChildNoTransform(1);
193      }
194      /**
195       * @apilevel internal
196       */
197      protected boolean type_computed = false;
198      /**
199       * @apilevel internal
200       */
201      protected TypeDecl type_value;
202      /**
203       * @apilevel internal
204       */
205      private void type_reset() {
206        type_computed = false;
207        type_value = null;
208      }
209      /**
210       * @attribute syn
211       * @aspect TypeAnalysis
212       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:302
213       */
214      @ASTNodeAnnotation.Attribute
215      public TypeDecl type() {
216        ASTNode$State state = state();
217        if (type_computed) {
218          return type_value;
219        }
220        boolean intermediate = state.INTERMEDIATE_VALUE;
221        state.INTERMEDIATE_VALUE = false;
222        int num = state.boundariesCrossed;
223        boolean isFinal = this.is$Final();
224        type_value = typeBoolean();
225        if (isFinal && num == state().boundariesCrossed) {
226          type_computed = true;
227        } else {
228        }
229        state.INTERMEDIATE_VALUE |= intermediate;
230    
231        return type_value;
232      }
233      /**
234       * @apilevel internal
235       */
236      public ASTNode rewriteTo() {
237        return super.rewriteTo();
238      }
239    }