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

📄 frontendmain.jrag

📁 JDK1.4编译器前端
💻 JRAG
字号:
/* * The JastAdd Extensible Java Compiler (http://jastadd.org) is covered * by the modified BSD License. You should have received a copy of the * modified BSD license with this compiler. *  * Copyright (c) 2005-2008, Torbjorn Ekman * All rights reserved. */aspect FrontendMain {  public class Frontend {    protected Program program;    protected Frontend() {      ASTNode.reset(); // reset global state and possible debug info      program = new Program();    }    public boolean process(String[] args, BytecodeReader reader, JavaParser parser) {      program.initBytecodeReader(reader);      program.initJavaParser(parser);      initOptions();      processArgs(args);      Collection files = program.files();      if(program.hasOption("-version")) {        printVersion();        return false;      }      if(program.hasOption("-help") || files.isEmpty()) {        printUsage();        return false;      }      try {        for(Iterator iter = files.iterator(); iter.hasNext(); ) {          String name = (String)iter.next();          if(!new File(name).exists())            System.out.println("WARNING: file \"" + name + "\" does not exist");          program.addSourceFile(name);        }        for(Iterator iter = program.compilationUnitIterator(); iter.hasNext(); ) {          CompilationUnit unit = (CompilationUnit)iter.next();          if(unit.fromSource()) {            Collection errors = unit.parseErrors();            Collection warnings = new LinkedList();            // compute static semantic errors when there are no parse errors or             // the recover from parse errors option is specified            if(errors.isEmpty() || program.hasOption("-recover"))              unit.errorCheck(errors, warnings);            if(!errors.isEmpty()) {              processErrors(errors, unit);              return false;            }            else {              processWarnings(warnings, unit);              processNoErrors(unit);            }          }        }      } catch (Exception e) {        System.err.println(e.getMessage());        e.printStackTrace();      }      return true;    }    protected void initOptions() {      program.initOptions();      program.addKeyOption("-version");      program.addKeyOption("-print");      program.addKeyOption("-g");      program.addKeyOption("-g:none");      program.addKeyOption("-g:lines,vars,source");      program.addKeyOption("-nowarn");      program.addKeyOption("-verbose");      program.addKeyOption("-deprecation");      program.addKeyValueOption("-classpath");      program.addKeyValueOption("-sourcepath");      program.addKeyValueOption("-bootclasspath");      program.addKeyValueOption("-extdirs");      program.addKeyValueOption("-d");      program.addKeyValueOption("-encoding");      program.addKeyValueOption("-source");      program.addKeyValueOption("-target");      program.addKeyOption("-help");      program.addKeyOption("-O");      program.addKeyOption("-J-Xmx128M");      program.addKeyOption("-recover");    }    protected void processArgs(String[] args) {      program.addOptions(args);    }    protected void processErrors(Collection errors, CompilationUnit unit) {      System.out.println("Errors:");      for(Iterator iter2 = errors.iterator(); iter2.hasNext(); ) {        System.out.println(iter2.next());      }    }    protected void processWarnings(Collection warnings, CompilationUnit unit) {      for(Iterator iter2 = warnings.iterator(); iter2.hasNext(); ) {        System.out.println(iter2.next());      }    }    protected void processNoErrors(CompilationUnit unit) {    }    protected void printUsage() {      printVersion();      System.out.println(          "\n" + name() + "\n\n" +          "Usage: java " + name() + " <options> <source files>\n" +          "  -verbose                  Output messages about what the compiler is doing\n" +          "  -classpath <path>         Specify where to find user class files\n" +          "  -sourcepath <path>        Specify where to find input source files\n" +           "  -bootclasspath <path>     Override location of bootstrap class files\n" +           "  -extdirs <dirs>           Override location of installed extensions\n" +          "  -d <directory>            Specify where to place generated class files\n" +          "  -help                     Print a synopsis of standard options\n" +          "  -version                  Print version information\n"          );    }    protected void printVersion() {      System.out.println(name() + " " + url() + " Version " + version());    }    protected String name() {      return "Java1.4Frontend";    }    protected String url() {      return "(http://jastadd.cs.lth.se)";    }    protected String version() {      return "R20070504";    }  }}

⌨️ 快捷键说明

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