expr.java

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

JAVA
784
字号

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 abstract class Expr extends ASTNode<ASTNode> implements Cloneable {
    public void flushCache() {        super.flushCache();        false_label_computed = false;        true_label_computed = false;    }     @SuppressWarnings({"unchecked", "cast"})  public Expr clone() throws CloneNotSupportedException {        Expr node = (Expr)super.clone();        node.false_label_computed = false;        node.true_label_computed = false;        node.in$Circle(false);        node.is$Final(false);    return node;    }    // Declared in LookupType.jrag at line 373      public SimpleSet keepAccessibleTypes(SimpleSet oldSet) {    SimpleSet newSet = SimpleSet.emptySet;    TypeDecl hostType = hostType();    for(Iterator iter = oldSet.iterator(); iter.hasNext(); ) {      TypeDecl t = (TypeDecl)iter.next();      if((hostType != null && t.accessibleFrom(hostType)) || (hostType == null && t.accessibleFromPackage(hostPackage())))        newSet = newSet.add(t);    }    return newSet;  }    // Declared in LookupVariable.jrag at line 164  // remove fields that are not accessible when using this Expr as qualifier  public SimpleSet keepAccessibleFields(SimpleSet oldSet) {    SimpleSet newSet = SimpleSet.emptySet;    for(Iterator iter = oldSet.iterator(); iter.hasNext(); ) {      Variable v = (Variable)iter.next();      if(v instanceof FieldDeclaration) {        FieldDeclaration f = (FieldDeclaration)v;        if(mayAccess(f))          newSet = newSet.add(f);      }    }    return newSet;  }    // Declared in LookupVariable.jrag at line 187  private boolean mayAccess(FieldDeclaration f) {    if(f.isPublic())       return true;    else if(f.isProtected()) {      if(f.hostPackage().equals(hostPackage()))        return true;      TypeDecl C = f.hostType();      TypeDecl S = hostType().subclassWithinBody(C);      TypeDecl Q = type();      if(S == null)        return false;      if(f.isInstanceVariable() && !isSuperAccess())        return Q.instanceOf(S);      return true;    }    else if(f.isPrivate())      return f.hostType().topLevelType() == hostType().topLevelType();    else      return f.hostPackage().equals(hostType().hostPackage());  }    // Declared in ResolveAmbiguousNames.jrag at line 99  public Dot qualifiesAccess(Access access) {    Dot dot = new Dot(this, access);    dot.lastDot = dot;    return dot;  }    // Declared in CodeGeneration.jrag at line 701    // emit store  public void emitStore(CodeGeneration gen) { error("emitStore called with " + getClass().getName()); }    // Declared in CodeGeneration.jrag at line 1021  // emit the desired operation on the operand(s) on the stack  void emitOperation(CodeGeneration gen) {error();}    // Declared in CreateBCode.jrag at line 200  protected boolean needsPush() {    ASTNode n = getParent();    while(n instanceof ParExpr)      n = n.getParent();    return !(n instanceof ExprStmt);  }    // Declared in CreateBCode.jrag at line 332  // load left hand side of destination in a simple assign expression  public void createAssignSimpleLoadDest(CodeGeneration gen) {  }    // Declared in CreateBCode.jrag at line 346    // duplicate top value on stack and store below destination element  public void createPushAssignmentResult(CodeGeneration gen) {  }    // Declared in CreateBCode.jrag at line 364    // load left hand side of destination in a compound assign expression  public void createAssignLoadDest(CodeGeneration gen) {  }    // Declared in CreateBCode.jrag at line 1010  protected void emitBooleanCondition(CodeGeneration gen) {    emitEvalBranch(gen);    int end_label = hostType().constantPool().newLabel();    gen.addLabel(false_label());    BooleanLiteral.push(gen, false);    gen.emitGoto(end_label);    gen.changeStackDepth(-1); // discard false from stack depth computation    gen.addLabel(true_label());    BooleanLiteral.push(gen, true);    gen.addLabel(end_label);  }    // Declared in CreateBCode.jrag at line 1048    public void emitEvalBranch(CodeGeneration gen) {    if(isTrue())      gen.emitGoto(true_label());    else if(isFalse())      gen.emitGoto(false_label());    else {      createBCode(gen);      gen.emitCompare(Bytecode.IFNE, true_label());      gen.emitGoto(false_label());      //gen.emitCompare(Bytecode.IFEQ, false_label());      //gen.emitGoto(true_label());    }  }    // Declared in java.ast at line 3    // Declared in java.ast line 97
    public Expr() {        super();

    }    // Declared in java.ast at line 9
  protected int numChildren() {
    return 0;
  }    // Declared in java.ast at line 12
  public boolean mayHaveRewrite() { return false; }    // Declared in TypeAnalysis.jrag at line 277 @SuppressWarnings({"unchecked", "cast"})     public abstract TypeDecl type();    // Declared in ConstantExpression.jrag at line 98 @SuppressWarnings({"unchecked", "cast"})     public Constant constant() {        Constant constant_value = constant_compute();        return constant_value;    }    private Constant constant_compute() {    throw new UnsupportedOperationException("ConstantExpression operation constant" +      " not supported for type " + getClass().getName());   }    // Declared in ConstantExpression.jrag at line 228 @SuppressWarnings({"unchecked", "cast"})     public boolean isPositive() {        boolean isPositive_value = isPositive_compute();        return isPositive_value;    }    private boolean isPositive_compute() {  return false;  }    // Declared in ConstantExpression.jrag at line 438 @SuppressWarnings({"unchecked", "cast"})     public boolean representableIn(TypeDecl t) {        boolean representableIn_TypeDecl_value = representableIn_compute(t);        return representableIn_TypeDecl_value;    }    private boolean representableIn_compute(TypeDecl t) {	  	if (!type().isByte() && !type().isChar() && !type().isShort() && !type().isInt()) {  		return false;  	}  	if (t.isByte())  		return constant().intValue() >= Byte.MIN_VALUE && constant().intValue() <= Byte.MAX_VALUE;  	if (t.isChar())  		return constant().intValue() >= Character.MIN_VALUE && constant().intValue() <= Character.MAX_VALUE;  	if (t.isShort())  		return constant().intValue() >= Short.MIN_VALUE && constant().intValue() <= Short.MAX_VALUE;    if(t.isInt())       return constant().intValue() >= Integer.MIN_VALUE && constant().intValue() <= Integer.MAX_VALUE;	  return false;  }    // Declared in ConstantExpression.jrag at line 466 @SuppressWarnings({"unchecked", "cast"})     public boolean isConstant() {        boolean isConstant_value = isConstant_compute();        return isConstant_value;    }    private boolean isConstant_compute() {  return false;  }    // Declared in ConstantExpression.jrag at line 495 @SuppressWarnings({"unchecked", "cast"})     public boolean isTrue() {        boolean isTrue_value = isTrue_compute();        return isTrue_value;    }    private boolean isTrue_compute() {  return isConstant() && type() instanceof BooleanType && constant().booleanValue();  }    // Declared in ConstantExpression.jrag at line 496 @SuppressWarnings({"unchecked", "cast"})     public boolean isFalse() {        boolean isFalse_value = isFalse_compute();        return isFalse_value;    }    private boolean isFalse_compute() {  return isConstant() && type() instanceof BooleanType && !constant().booleanValue();  }    // Declared in DefiniteAssignment.jrag at line 58 @SuppressWarnings({"unchecked", "cast"})     public Variable varDecl() {        Variable varDecl_value = varDecl_compute();        return varDecl_value;    }    private Variable varDecl_compute() {  return null;  }    // Declared in DefiniteAssignment.jrag at line 340 @SuppressWarnings({"unchecked", "cast"})     public boolean isDAafterFalse(Variable v) {        boolean isDAafterFalse_Variable_value = isDAafterFalse_compute(v);        return isDAafterFalse_Variable_value;    }    private boolean isDAafterFalse_compute(Variable v) {  return isTrue() || isDAbefore(v);  }    // Declared in DefiniteAssignment.jrag at line 342 @SuppressWarnings({"unchecked", "cast"})     public boolean isDAafterTrue(Variable v) {        boolean isDAafterTrue_Variable_value = isDAafterTrue_compute(v);        return isDAafterTrue_Variable_value;    }    private boolean isDAafterTrue_compute(Variable v) {  return isFalse() || isDAbefore(v);  }    // Declared in DefiniteAssignment.jrag at line 345 @SuppressWarnings({"unchecked", "cast"})     public boolean isDAafter(Variable v) {        boolean isDAafter_Variable_value = isDAafter_compute(v);        return isDAafter_Variable_value;    }    private boolean isDAafter_compute(Variable v) {  return (isDAafterFalse(v) && isDAafterTrue(v)) || isDAbefore(v);  }    // Declared in DefiniteAssignment.jrag at line 782 @SuppressWarnings({"unchecked", "cast"})     public boolean isDUafterFalse(Variable v) {        boolean isDUafterFalse_Variable_value = isDUafterFalse_compute(v);        return isDUafterFalse_Variable_value;    }    private boolean isDUafterFalse_compute(Variable v) {    if(isTrue())      return true;    return isDUbefore(v);  }    // Declared in DefiniteAssignment.jrag at line 788 @SuppressWarnings({"unchecked", "cast"})     public boolean isDUafterTrue(Variable v) {        boolean isDUafterTrue_Variable_value = isDUafterTrue_compute(v);        return isDUafterTrue_Variable_value;    }    private boolean isDUafterTrue_compute(Variable v) {    if(isFalse())      return true;    return isDUbefore(v);  }    // Declared in DefiniteAssignment.jrag at line 798 @SuppressWarnings({"unchecked", "cast"})     public boolean isDUafter(Variable v) {        boolean isDUafter_Variable_value = isDUafter_compute(v);        return isDUafter_Variable_value;    }    private boolean isDUafter_compute(Variable v) {  return (isDUafterFalse(v) && isDUafterTrue(v)) || isDUbefore(v);  }    // Declared in LookupConstructor.jrag at line 32 @SuppressWarnings({"unchecked", "cast"})     public SimpleSet mostSpecificConstructor(Collection constructors) {        SimpleSet mostSpecificConstructor_Collection_value = mostSpecificConstructor_compute(constructors);        return mostSpecificConstructor_Collection_value;    }    private SimpleSet mostSpecificConstructor_compute(Collection constructors) {    SimpleSet maxSpecific = SimpleSet.emptySet;    for(Iterator iter = constructors.iterator(); iter.hasNext(); ) {      ConstructorDecl decl = (ConstructorDecl)iter.next();      if(applicableAndAccessible(decl)) {        if(maxSpecific.isEmpty())          maxSpecific = maxSpecific.add(decl);        else {          if(decl.moreSpecificThan((ConstructorDecl)maxSpecific.iterator().next()))            maxSpecific = SimpleSet.emptySet.add(decl);          else if(!((ConstructorDecl)maxSpecific.iterator().next()).moreSpecificThan(decl))            maxSpecific = maxSpecific.add(decl);        }      }    }    return maxSpecific;  }    // Declared in LookupConstructor.jrag at line 50 @SuppressWarnings({"unchecked", "cast"})     public boolean applicableAndAccessible(ConstructorDecl decl) {        boolean applicableAndAccessible_ConstructorDecl_value = applicableAndAccessible_compute(decl);        return applicableAndAccessible_ConstructorDecl_value;    }    private boolean applicableAndAccessible_compute(ConstructorDecl decl) {  return false;  }    // Declared in LookupType.jrag at line 83 @SuppressWarnings({"unchecked", "cast"})     public boolean hasQualifiedPackage(String packageName) {        boolean hasQualifiedPackage_String_value = hasQualifiedPackage_compute(packageName);        return hasQualifiedPackage_String_value;    }    private boolean hasQualifiedPackage_compute(String packageName) {  return false;  }    // Declared in LookupType.jrag at line 342 @SuppressWarnings({"unchecked", "cast"})     public SimpleSet qualifiedLookupType(String name) {        SimpleSet qualifiedLookupType_String_value = qualifiedLookupType_compute(name);        return qualifiedLookupType_String_value;    }    private SimpleSet qualifiedLookupType_compute(String name) {  return keepAccessibleTypes(type().memberTypes(name));  }    // Declared in LookupVariable.jrag at line 146 @SuppressWarnings({"unchecked", "cast"})     public SimpleSet qualifiedLookupVariable(String name) {        SimpleSet qualifiedLookupVariable_String_value = qualifiedLookupVariable_compute(name);        return qualifiedLookupVariable_String_value;    }    private SimpleSet qualifiedLookupVariable_compute(String name) {    if(type().accessibleFrom(hostType()))      return keepAccessibleFields(type().memberFields(name));    return SimpleSet.emptySet;  }    // Declared in QualifiedNames.jrag at line 25 @SuppressWarnings({"unchecked", "cast"})     public String packageName() {        String packageName_value = packageName_compute();        return packageName_value;    }    private String packageName_compute() {  return "";  }    // Declared in QualifiedNames.jrag at line 62 @SuppressWarnings({"unchecked", "cast"})     public String typeName() {        String typeName_value = typeName_compute();        return typeName_value;    }    private String typeName_compute() {  return "";  }    // Declared in ResolveAmbiguousNames.jrag at line 13 @SuppressWarnings({"unchecked", "cast"})     public boolean isTypeAccess() {        boolean isTypeAccess_value = isTypeAccess_compute();        return isTypeAccess_value;    }    private boolean isTypeAccess_compute() {  return false;  }

⌨️ 快捷键说明

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