⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addexpr.java

📁 JDK1.4编译器前端
💻 JAVA
字号:

package AST;
import java.util.HashSet;import java.util.LinkedHashSet;import java.io.FileNotFoundException;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;public class AddExpr extends AdditiveExpr implements Cloneable {
    public void flushCache() {        super.flushCache();        constant_visited = -1;        printOp_visited = -1;        type_visited = -1;        type_computed = false;        type_value = null;    }     @SuppressWarnings({"unchecked", "cast"})  public AddExpr clone() throws CloneNotSupportedException {        AddExpr node = (AddExpr)super.clone();        node.constant_visited = -1;        node.printOp_visited = -1;        node.type_visited = -1;        node.type_computed = false;        node.type_value = null;        node.in$Circle(false);        node.is$Final(false);    return node;    }     @SuppressWarnings({"unchecked", "cast"})  public AddExpr copy() {      try {          AddExpr node = (AddExpr)clone();          if(children != null) node.children = (ASTNode[])children.clone();          return node;      } catch (CloneNotSupportedException e) {      }      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");      return null;    }     @SuppressWarnings({"unchecked", "cast"})  public AddExpr fullCopy() {        AddExpr res = (AddExpr)copy();        for(int i = 0; i < getNumChildNoTransform(); i++) {          ASTNode node = getChildNoTransform(i);          if(node != null) node = node.fullCopy();          res.setChild(node, i);        }        return res;    }    // Declared in TypeCheck.jrag at line 172    // 15.18  public void typeCheck() {    TypeDecl left = getLeftOperand().type();    TypeDecl right = getRightOperand().type();    if(!left.isString() && !right.isString())      super.typeCheck();    else if(left.isVoid())      error("The type void of the left hand side is not numeric");    else if(right.isVoid())      error("The type void of the right hand side is not numeric");  }    // Declared in java.ast at line 3    // Declared in java.ast line 161
    public AddExpr() {        super();

    }    // Declared in java.ast at line 10
    // Declared in java.ast line 161    public AddExpr(Expr p0, Expr p1) {        setChild(p0, 0);        setChild(p1, 1);    }    // Declared in java.ast at line 15  protected int numChildren() {
    return 2;
  }    // Declared in java.ast at line 18
  public boolean mayHaveRewrite() { return false; }    // Declared in java.ast at line 2    // Declared in java.ast line 153    public void setLeftOperand(Expr node) {        setChild(node, 0);    }    // Declared in java.ast at line 5    public Expr getLeftOperand() {        return (Expr)getChild(0);    }    // Declared in java.ast at line 9    public Expr getLeftOperandNoTransform() {        return (Expr)getChildNoTransform(0);    }    // Declared in java.ast at line 2    // Declared in java.ast line 153    public void setRightOperand(Expr node) {        setChild(node, 1);    }    // Declared in java.ast at line 5    public Expr getRightOperand() {        return (Expr)getChild(1);    }    // Declared in java.ast at line 9    public Expr getRightOperandNoTransform() {        return (Expr)getChildNoTransform(1);    }    protected int constant_visited = -1;    // Declared in ConstantExpression.jrag at line 121 @SuppressWarnings({"unchecked", "cast"})     public Constant constant() {        if(constant_visited == boundariesCrossed)            throw new RuntimeException("Circular definition of attr: constant in class: ");        constant_visited = boundariesCrossed;        Constant constant_value = constant_compute();        constant_visited = -1;        return constant_value;    }    private Constant constant_compute() {  return type().add(getLeftOperand().constant(), getRightOperand().constant());  }    protected int printOp_visited = -1;    // Declared in PrettyPrint.jadd at line 420 @SuppressWarnings({"unchecked", "cast"})     public String printOp() {        if(printOp_visited == boundariesCrossed)            throw new RuntimeException("Circular definition of attr: printOp in class: ");        printOp_visited = boundariesCrossed;        String printOp_value = printOp_compute();        printOp_visited = -1;        return printOp_value;    }    private String printOp_compute() {  return " + ";  }    protected int type_visited = -1;    // Declared in TypeAnalysis.jrag at line 328 @SuppressWarnings({"unchecked", "cast"})     public TypeDecl type() {        if(type_computed)            return type_value;        if(type_visited == boundariesCrossed)            throw new RuntimeException("Circular definition of attr: type in class: ");        type_visited = boundariesCrossed;        int num = boundariesCrossed;        boolean isFinal = this.is$Final();        type_value = type_compute();        if(isFinal && num == boundariesCrossed)            type_computed = true;        type_visited = -1;        return type_value;    }    private TypeDecl type_compute() {    TypeDecl left = getLeftOperand().type();    TypeDecl right = getRightOperand().type();    if(!left.isString() && !right.isString())      return super.type();    else {      if(left.isVoid() || right.isVoid())        return unknownType();      // pick the string type      return left.isString() ? left : right;    }  }public ASTNode rewriteTo() {    return super.rewriteTo();}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -