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

📄 program.java

📁 JDK1.4编译器后端
💻 JAVA
📖 第 1 页 / 共 5 页
字号:

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 Program extends ASTNode<ASTNode> implements Cloneable {
    public void flushCache() {        super.flushCache();        typeObject_computed = false;        typeObject_value = null;        typeCloneable_computed = false;        typeCloneable_value = null;        typeSerializable_computed = false;        typeSerializable_value = null;        typeBoolean_computed = false;        typeBoolean_value = null;        typeByte_computed = false;        typeByte_value = null;        typeShort_computed = false;        typeShort_value = null;        typeChar_computed = false;        typeChar_value = null;        typeInt_computed = false;        typeInt_value = null;        typeLong_computed = false;        typeLong_value = null;        typeFloat_computed = false;        typeFloat_value = null;        typeDouble_computed = false;        typeDouble_value = null;        typeString_computed = false;        typeString_value = null;        typeVoid_computed = false;        typeVoid_value = null;        typeNull_computed = false;        typeNull_value = null;        unknownType_computed = false;        unknownType_value = null;        hasPackage_String_values = null;        lookupType_String_String_values = null;        unknownConstructor_computed = false;        unknownConstructor_value = null;    }     @SuppressWarnings({"unchecked", "cast"})  public Program clone() throws CloneNotSupportedException {        Program node = (Program)super.clone();        node.typeObject_computed = false;        node.typeObject_value = null;        node.typeCloneable_computed = false;        node.typeCloneable_value = null;        node.typeSerializable_computed = false;        node.typeSerializable_value = null;        node.typeBoolean_computed = false;        node.typeBoolean_value = null;        node.typeByte_computed = false;        node.typeByte_value = null;        node.typeShort_computed = false;        node.typeShort_value = null;        node.typeChar_computed = false;        node.typeChar_value = null;        node.typeInt_computed = false;        node.typeInt_value = null;        node.typeLong_computed = false;        node.typeLong_value = null;        node.typeFloat_computed = false;        node.typeFloat_value = null;        node.typeDouble_computed = false;        node.typeDouble_value = null;        node.typeString_computed = false;        node.typeString_value = null;        node.typeVoid_computed = false;        node.typeVoid_value = null;        node.typeNull_computed = false;        node.typeNull_value = null;        node.unknownType_computed = false;        node.unknownType_value = null;        node.hasPackage_String_values = null;        node.lookupType_String_String_values = null;        node.unknownConstructor_computed = false;        node.unknownConstructor_value = null;        node.in$Circle(false);        node.is$Final(false);    return node;    }     @SuppressWarnings({"unchecked", "cast"})  public Program copy() {      try {          Program node = (Program)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 Program fullCopy() {        Program res = (Program)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 ClassPath.jrag at line 22  protected BytecodeReader bytecodeReader;    // Declared in ClassPath.jrag at line 23  public void initBytecodeReader(BytecodeReader r) { bytecodeReader = r; }    // Declared in ClassPath.jrag at line 24  protected JavaParser javaParser;    // Declared in ClassPath.jrag at line 25  public void initJavaParser(JavaParser p) { javaParser = p; }    // Declared in ClassPath.jrag at line 35  // add a filename to the list of source files to process  public void addSourceFile(String name) {    sourceFiles.addSourceFile(name);  }    // Declared in ClassPath.jrag at line 41  // iterate over all source files and demand-loaded compilation units  public Iterator compilationUnitIterator() {    initPaths();    return new Iterator() {      int index = 0;      public boolean hasNext() {        return index < getNumCompilationUnit() || !sourceFiles.isEmpty();      }      public Object next() {        if(getNumCompilationUnit() == index) {          String typename = (String)sourceFiles.keySet().iterator().next();          CompilationUnit u = getCompilationUnit(typename);          if(u != null) {            addCompilationUnit(u);            getCompilationUnit(getNumCompilationUnit()-1);          }          else            throw new Error("File " + typename + " not found");        }        return getCompilationUnit(index++);      }      public void remove() {        throw new UnsupportedOperationException();      }    };  }    // Declared in ClassPath.jrag at line 70    // get the input stream for a compilation unit specified using  // a canonical name. This is used by the bytecode reader to load  // nested types  public InputStream getInputStream(String name) {    initPaths();    try {      for(Iterator iter = classPath.iterator(); iter.hasNext(); ) {        PathPart part = (PathPart)iter.next();        if(part.selectCompilationUnit(name))          return part.is;      }    }    catch(IOException e) {    }    throw new Error("Could not find nested type " + name);  }    // Declared in ClassPath.jrag at line 88      // load a compilation unit from disc using the following rules:  //   1) specified on the command line  //   2) class file not older than source file  //   3) source file  public CompilationUnit getCompilationUnit(String name) {    initPaths();    try {      if(sourceFiles.selectCompilationUnit(name))        return sourceFiles.getCompilationUnit();      PathPart sourcePart = null;      PathPart classPart = null;      for(Iterator iter = sourcePath.iterator(); iter.hasNext() && sourcePart == null; ) {        PathPart part = (PathPart)iter.next();        if(part.selectCompilationUnit(name))          sourcePart = part;      }      for(Iterator iter = classPath.iterator(); iter.hasNext() && classPart == null; ) {        PathPart part = (PathPart)iter.next();        if(part.selectCompilationUnit(name))          classPart = part;      }            if(sourcePart != null && (classPart == null || classPart.age <= sourcePart.age)) {        CompilationUnit unit = sourcePart.getCompilationUnit();        int index = name.lastIndexOf('.');        if(index == -1)          return unit;        String pkgName = name.substring(0, index);        if(pkgName.equals(unit.getPackageDecl()))          return unit;      }      if(classPart != null) {        CompilationUnit unit = classPart.getCompilationUnit();        int index = name.lastIndexOf('.');        if(index == -1)          return unit;        String pkgName = name.substring(0, index);        if(pkgName.equals(unit.getPackageDecl()))          return unit;      }      return null;    }    catch(IOException e) {    }    return null;  }    // Declared in ClassPath.jrag at line 132    // is there a package named name on the path  public boolean isPackage(String name) {    if(sourceFiles.hasPackage(name))      return true;    for(Iterator iter = classPath.iterator(); iter.hasNext(); ) {      PathPart part = (PathPart)iter.next();      if(part.hasPackage(name))        return true;    }    for(Iterator iter = sourcePath.iterator(); iter.hasNext(); ) {      PathPart part = (PathPart)iter.next();      if(part.hasPackage(name))        return true;    }    return false;  }    // Declared in ClassPath.jrag at line 162  private boolean pathsInitialized = false;    // Declared in ClassPath.jrag at line 163  private java.util.ArrayList classPath;    // Declared in ClassPath.jrag at line 164  private java.util.ArrayList sourcePath;    // Declared in ClassPath.jrag at line 165  private FileNamesPart sourceFiles = new FileNamesPart(this);    // Declared in ClassPath.jrag at line 167  public void pushClassPath(String name) {    PathPart part = PathPart.createSourcePath(name, this);    if(part != null) {      sourcePath.add(part);      System.out.println("Pushing source path " + name);    }    else      throw new Error("Could not push source path " + name);    part = PathPart.createClassPath(name, this);    if(part != null) {      classPath.add(part);      System.out.println("Pushing class path " + name);    }  }    // Declared in ClassPath.jrag at line 181  public void popClassPath() {    if(sourcePath.size() > 0)      sourcePath.remove(sourcePath.size()-1);    if(classPath.size() > 0)      classPath.remove(classPath.size()-1);  }    // Declared in ClassPath.jrag at line 188  public void initPaths() {    if(!pathsInitialized) {      pathsInitialized = true;      //System.err.println("Initializing class paths");            ArrayList classPaths = new ArrayList();      ArrayList sourcePaths = new ArrayList();            String[] bootclasspaths;      if(Program.hasValueForOption("-bootclasspath"))        bootclasspaths = Program.getValueForOption("-bootclasspath").split(File.pathSeparator);      else        bootclasspaths = System.getProperty("sun.boot.class.path").split(File.pathSeparator);      for(int i = 0; i < bootclasspaths.length; i++) {        classPaths.add(bootclasspaths[i]);        //System.err.println("Adding classpath " + bootclasspaths[i]);      }            String[] extdirs;      if(Program.hasValueForOption("-extdirs"))        extdirs = Program.getValueForOption("-extdirs").split(File.pathSeparator);      else        extdirs = System.getProperty("java.ext.dirs").split(File.pathSeparator);      for(int i = 0; i < extdirs.length; i++) {        classPaths.add(extdirs[i]);        //System.err.println("Adding classpath " + extdirs[i]);      }      String[] userClasses = null;      if(Program.hasValueForOption("-classpath"))        userClasses = Program.getValueForOption("-classpath").split(File.pathSeparator);      else {        String s = System.getProperty("java.class.path");        if(s != null && s.length() > 0) {          s = s + File.pathSeparator + "."; // TODO; This should not be necessary          userClasses = s.split(File.pathSeparator);        }        else          userClasses = ".".split(File.pathSeparator);      }      if(!Program.hasValueForOption("-sourcepath")) {        for(int i = 0; i < userClasses.length; i++) {          classPaths.add(userClasses[i]);          sourcePaths.add(userClasses[i]);          //System.err.println("Adding classpath/sourcepath " + userClasses[i]);        }      }      else {        for(int i = 0; i < userClasses.length; i++) {          classPaths.add(userClasses[i]);          //System.err.println("Adding classpath " + userClasses[i]);        }        userClasses = Program.getValueForOption("-sourcepath").split(File.pathSeparator);        for(int i = 0; i < userClasses.length; i++) {          sourcePaths.add(userClasses[i]);          //System.err.println("Adding sourcepath " + userClasses[i]);        }      }              classPath = new ArrayList();      sourcePath = new ArrayList();            for(Iterator iter = classPaths.iterator(); iter.hasNext(); ) {        String s = (String)iter.next();        PathPart part = PathPart.createClassPath(s, this);        if(part != null) {          classPath.add(part);          //System.out.println("Adding classpath " + s);        }        else if(Program.verbose())          System.out.println("Warning: Could not use " + s + " as class path");      }      for(Iterator iter = sourcePaths.iterator(); iter.hasNext(); ) {        String s = (String)iter.next();        PathPart part = PathPart.createSourcePath(s, this);        if(part != null) {          sourcePath.add(part);          //System.out.println("Adding sourcepath " + s);        }        else if(Program.verbose())          System.out.println("Warning: Could not use " + s + " as source path");      }    }  }

⌨️ 快捷键说明

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