returnstmt.java

来自「JDK1.4编译器前端」· Java 代码 · 共 362 行 · 第 1/2 页

JAVA
362
字号

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 ReturnStmt extends Stmt implements Cloneable {
    public void flushCache() {        super.flushCache();        finallyList_visited = -1;        finallyList_computed = false;        finallyList_value = null;        isDAafter_Variable_visited = new java.util.HashMap(4);        isDAafter_Variable_values = null;        isDUafterReachedFinallyBlocks_Variable_visited = new java.util.HashMap(4);        isDUafterReachedFinallyBlocks_Variable_values = null;        isDAafterReachedFinallyBlocks_Variable_visited = new java.util.HashMap(4);        isDAafterReachedFinallyBlocks_Variable_values = null;        isDUafter_Variable_visited = new java.util.HashMap(4);        isDUafter_Variable_values = null;        canCompleteNormally_visited = -1;        canCompleteNormally_computed = false;        returnType_visited = -1;    }     @SuppressWarnings({"unchecked", "cast"})  public ReturnStmt clone() throws CloneNotSupportedException {        ReturnStmt node = (ReturnStmt)super.clone();        node.finallyList_visited = -1;        node.finallyList_computed = false;        node.finallyList_value = null;        node.isDAafter_Variable_visited = new java.util.HashMap(4);        node.isDAafter_Variable_values = null;        node.isDUafterReachedFinallyBlocks_Variable_visited = new java.util.HashMap(4);        node.isDUafterReachedFinallyBlocks_Variable_values = null;        node.isDAafterReachedFinallyBlocks_Variable_visited = new java.util.HashMap(4);        node.isDAafterReachedFinallyBlocks_Variable_values = null;        node.isDUafter_Variable_visited = new java.util.HashMap(4);        node.isDUafter_Variable_values = null;        node.canCompleteNormally_visited = -1;        node.canCompleteNormally_computed = false;        node.returnType_visited = -1;        node.in$Circle(false);        node.is$Final(false);    return node;    }     @SuppressWarnings({"unchecked", "cast"})  public ReturnStmt copy() {      try {          ReturnStmt node = (ReturnStmt)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 ReturnStmt fullCopy() {        ReturnStmt res = (ReturnStmt)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 BranchTarget.jrag at line 55  public void collectBranches(Collection c) {    c.add(this);  }    // Declared in NodeConstructors.jrag at line 62  public ReturnStmt(Expr expr) {    this(new Opt(expr));  }    // Declared in PrettyPrint.jadd at line 691  public void toString(StringBuffer s) {    s.append("return ");    if(hasResult()) {      getResult().toString(s);    }    s.append(";\n");  }    // Declared in java.ast at line 3    // Declared in java.ast line 217
    public ReturnStmt() {        super();
        setChild(new Opt(), 0);

    }    // Declared in java.ast at line 11
    // Declared in java.ast line 217    public ReturnStmt(Opt<Expr> p0) {        setChild(p0, 0);    }    // Declared in java.ast at line 15  protected int numChildren() {
    return 1;
  }    // Declared in java.ast at line 18
  public boolean mayHaveRewrite() { return false; }    // Declared in java.ast at line 2    // Declared in java.ast line 217    public void setResultOpt(Opt<Expr> opt) {        setChild(opt, 0);    }    // Declared in java.ast at line 6    public boolean hasResult() {        return getResultOpt().getNumChild() != 0;    }    // Declared in java.ast at line 10     @SuppressWarnings({"unchecked", "cast"})  public Expr getResult() {        return (Expr)getResultOpt().getChild(0);    }    // Declared in java.ast at line 14    public void setResult(Expr node) {        getResultOpt().setChild(node, 0);    }    // Declared in java.ast at line 17     @SuppressWarnings({"unchecked", "cast"})  public Opt<Expr> getResultOpt() {        return (Opt<Expr>)getChild(0);    }    // Declared in java.ast at line 21     @SuppressWarnings({"unchecked", "cast"})  public Opt<Expr> getResultOptNoTransform() {        return (Opt<Expr>)getChildNoTransform(0);    }    // Declared in GOP.jrag at line 197
     public void typeCheck() {
    if(hasResult() && !returnType().isVoid()) {
      if(!getResult().type().assignConversionTo(returnType(), getResult()))
        error("return value must be an instance of " + returnType().typeName() + " which " + getResult().type().typeName() + " is not");
    }
    if(enclosingBodyDecl() instanceof GranuleBody && !getResult().type().isBoolean())
       error("GranuleBody must retuan type boolean!");
    // 8.4.5 8.8.5
    if(returnType().isVoid() && hasResult())
      error("return stmt may not have an expression in void methods");
    // 8.4.5
    if(!returnType().isVoid() && !hasResult())
      error("return stmt must have an expression in non void methods");
    if(enclosingBodyDecl() instanceof InstanceInitializer || enclosingBodyDecl() instanceof StaticInitializer)
      error("Initializers may not return");

  }    protected int finallyList_visited = -1;    protected boolean finallyList_computed = false;    protected ArrayList finallyList_value;    // Declared in BranchTarget.jrag at line 186 @SuppressWarnings({"unchecked", "cast"})     public ArrayList finallyList() {        if(finallyList_computed)

⌨️ 快捷键说明

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