Exemplo n.º 1
0
 protected void initOptions() {
   Options options = program.options();
   options.initOptions();
   options.addKeyOption("-version");
   options.addKeyOption("-print");
   options.addKeyOption("-g");
   options.addKeyOption("-g:none");
   options.addKeyOption("-g:lines,vars,source");
   options.addKeyOption("-nowarn");
   options.addKeyOption("-verbose");
   options.addKeyOption("-deprecation");
   options.addKeyValueOption("-classpath");
   options.addKeyValueOption("-cp");
   options.addKeyValueOption("-sourcepath");
   options.addKeyValueOption("-bootclasspath");
   options.addKeyValueOption("-extdirs");
   options.addKeyValueOption("-d");
   options.addKeyValueOption("-encoding");
   options.addKeyValueOption("-source");
   options.addKeyValueOption("-target");
   options.addKeyOption("-help");
   options.addKeyOption("-O");
   options.addKeyOption("-J-Xmx128M");
   options.addKeyOption("-recover");
 }
Exemplo n.º 2
0
  public boolean process(String[] args, BytecodeReader reader, JavaParser parser) {
    program.initBytecodeReader(reader);
    program.initJavaParser(parser);

    initOptions();
    processArgs(args);

    Collection files = program.options().files();

    if (program.options().hasOption("-version")) {
      printVersion();
      return false;
    }
    if (program.options().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.err.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.options().hasOption("-recover"))
            unit.errorCheck(errors, warnings);
          if (!errors.isEmpty()) {
            processErrors(errors, unit);
            return false;
          } else {
            if (!warnings.isEmpty()) processWarnings(warnings, unit);
            processNoErrors(unit);
          }
        }
      }
    } catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
    }
    return true;
  }
Exemplo n.º 3
0
 protected Frontend() {
   program = new Program();
   program.state().reset();
 }
Exemplo n.º 4
0
 protected void processArgs(String[] args) {
   program.options().addOptions(args);
 }