示例#1
1
  /** Compile a file. If you want a dump then give -out somefile. */
  public static int compilerPhases(List<String> args, Option<String> out, String phase)
      throws UserError, InterruptedException, IOException, RepositoryError {
    int return_code = 0;
    if (args.size() == 0) {
      throw new UserError("The " + phase + " command must be given a file.");
    }
    String s = args.get(0);
    List<String> rest = args.subList(1, args.size());

    if (s.startsWith("-")) {
      if (s.equals("-debug")) {
        rest = Debug.parseOptions(rest);
      } else if (s.equals("-out") && !rest.isEmpty()) {
        out = Option.<String>some(rest.get(0));
        rest = rest.subList(1, rest.size());
      } else if (s.equals("-compiler-lib")) {
        WellKnownNames.useCompilerLibraries();
        Types.useCompilerLibraries();
      } else if (s.equals("-typecheck-java")) {
        setScala(false);
      } else if (s.equals("-coercion")) {
        setTestCoercion(true);
      } else invalidFlag(s, phase);
      return_code = compilerPhases(rest, out, phase);
    } else {
      return_code = compileWithErrorHandling(s, out, false);
    }
    return return_code;
  }
示例#2
0
 public static void useCompilerLibraries() {
   setExtendsObjectPreDesugaring(true);
   setAssignmentPreDesugaring(false);
   setAssignmentDesugaring(true);
   WellKnownNames.useCompilerLibraries();
   Types.useCompilerLibraries();
 }
示例#3
0
 public static void useInterpreterLibraries() {
   setExtendsObjectPreDesugaring(false);
   setAssignmentPreDesugaring(false);
   setAssignmentDesugaring(true);
   setCompiledExprDesugaring(false);
   WellKnownNames.useFortressLibraries();
   Types.useFortressLibraries();
 }
示例#4
0
  /** Run a file through the Fortress interpreter. */
  private static void walk(List<String> args) throws UserError, IOException, Throwable {
    if (args.size() == 0) {
      throw new UserError("Need a file to run through the Fortress interpreter.");
    }
    String s = args.get(0);
    List<String> rest = args.subList(1, args.size());

    if (s.startsWith("-")) {
      if (s.equals("-debug")) {
        rest = Debug.parseOptions(rest);
      } else if (s.equals("-compiler-lib")) {
        WellKnownNames.useCompilerLibraries();
        Types.useCompilerLibraries();
      } else invalidFlag(s, "walk");

      walk(rest);
    } else {
      walk(s, rest);
    }
  }