constructoraccess.java

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

JAVA
500
字号

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 ConstructorAccess extends Access implements Cloneable {
    public void flushCache() {        super.flushCache();        decls_computed = false;        decls_value = null;        decl_computed = false;        decl_value = null;        type_computed = false;        type_value = null;    }     @SuppressWarnings({"unchecked", "cast"})  public ConstructorAccess clone() throws CloneNotSupportedException {        ConstructorAccess node = (ConstructorAccess)super.clone();        node.decls_computed = false;        node.decls_value = null;        node.decl_computed = false;        node.decl_value = null;        node.type_computed = false;        node.type_value = null;        node.in$Circle(false);        node.is$Final(false);    return node;    }     @SuppressWarnings({"unchecked", "cast"})  public ConstructorAccess copy() {      try {          ConstructorAccess node = (ConstructorAccess)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 ConstructorAccess fullCopy() {        ConstructorAccess res = (ConstructorAccess)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 ExceptionHandling.jrag at line 97  public void exceptionHandling() {    for(int i = 0; i < decl().getNumException(); i++) {      TypeDecl exceptionType = decl().getException(i).type();      if(!handlesException(exceptionType))        error("" + this + " may throw uncaught exception " + exceptionType.fullName());    }  }    // Declared in ExceptionHandling.jrag at line 244    // 8.8.4 (8.4.4)  protected boolean reachedException(TypeDecl catchType) {    for(int i = 0; i < decl().getNumException(); i++) {      TypeDecl exceptionType = decl().getException(i).type();      if(catchType.mayCatch(exceptionType))        return true;    }    return super.reachedException(catchType);  }    // Declared in NameCheck.jrag at line 112  public void nameCheck() {    super.nameCheck();    if(decls().isEmpty())      error("no constructor named " + this);    if(decls().size() > 1 && validArgs()) {      error("several most specific constructors for " + this);      for(Iterator iter = decls().iterator(); iter.hasNext(); ) {        error("         " + ((ConstructorDecl)iter.next()).signature());      }    }  }    // Declared in PrettyPrint.jadd at line 486  public void toString(StringBuffer s) {    s.append(name());    s.append("(");    if(getNumArg() > 0) {      getArg(0).toString(s);      for(int i = 1; i < getNumArg(); i++) {        s.append(", ");        getArg(i).toString(s);      }    }    s.append(")");  }    // Declared in CreateBCode.jrag at line 582  public void createBCode(CodeGeneration gen) {    ConstructorDecl c = decl();    int index = 0;    // this    gen.emitLoadReference(index++);    // this$0    if(c.needsEnclosing())      gen.emitLoadReference(index++);    if(c.needsSuperEnclosing())      gen.emitLoadReference(index++);    // args    for (int i = 0; i < getNumArg(); ++i) {      getArg(i).createBCode(gen);      getArg(i).type().emitCastTo(gen, decl().getParameter(i).type()); // MethodInvocationConversion    }    if(decl().isPrivate() && decl().hostType() != hostType()) {      gen.emit(Bytecode.ACONST_NULL);      decl().createAccessor().emitInvokeConstructor(gen);    }    else {      decl().emitInvokeConstructor(gen);    }  }    // Declared in InnerClasses.jrag at line 439  // add val$name as arguments to the constructor  protected boolean addEnclosingVariables = true;    // Declared in InnerClasses.jrag at line 440  public void addEnclosingVariables() {    if(!addEnclosingVariables) return;    addEnclosingVariables = false;    decl().addEnclosingVariables();    for(Iterator iter = decl().hostType().enclosingVariables().iterator(); iter.hasNext(); ) {      Variable v = (Variable)iter.next();      getArgList().add(new VarAccess("val$" + v.name()));    }  }    // Declared in Transformations.jrag at line 137  // remote collection / demand driven creation of accessor  public void transformation() {    // this$val    addEnclosingVariables();    // touch accessorIndex go force creation of private constructorAccessor    if(decl().isPrivate() && decl().hostType() != hostType()) {      decl().createAccessor();    }    super.transformation();  }    // Declared in java.ast at line 3    // Declared in java.ast line 18
    public ConstructorAccess() {        super();
        setChild(new List(), 0);

    }    // Declared in java.ast at line 11
    // Declared in java.ast line 18    public ConstructorAccess(String p0, List<Expr> p1) {        setID(p0);        setChild(p1, 0);    }    // Declared in java.ast at line 17    // Declared in java.ast line 18    public ConstructorAccess(beaver.Symbol p0, List<Expr> p1) {        setID(p0);        setChild(p1, 0);    }    // Declared in java.ast at line 22  protected int numChildren() {
    return 1;
  }    // Declared in java.ast at line 25
  public boolean mayHaveRewrite() { return false; }    // Declared in java.ast at line 2    // Declared in java.ast line 18    private String tokenString_ID;    // Declared in java.ast at line 3    public void setID(String value) {        tokenString_ID = value;    }    // Declared in java.ast at line 6    public int IDstart;    // Declared in java.ast at line 7    public int IDend;    // Declared in java.ast at line 8    public void setID(beaver.Symbol symbol) {        if(symbol.value != null && !(symbol.value instanceof String))          throw new UnsupportedOperationException("setID is only valid for String lexemes");        tokenString_ID = (String)symbol.value;        IDstart = symbol.getStart();        IDend = symbol.getEnd();    }    // Declared in java.ast at line 15    public String getID() {        return tokenString_ID != null ? tokenString_ID : "";    }    // Declared in java.ast at line 2    // Declared in java.ast line 18    public void setArgList(List<Expr> list) {        setChild(list, 0);    }    // Declared in java.ast at line 6    private int getNumArg = 0;    // Declared in java.ast at line 7    public int getNumArg() {        return getArgList().getNumChild();

⌨️ 快捷键说明

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