コード例 #1
1
ファイル: Shell.java プロジェクト: dbremner/fortress
  /** 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
ファイル: Shell.java プロジェクト: dbremner/fortress
 public static void useCompilerLibraries() {
   setExtendsObjectPreDesugaring(true);
   setAssignmentPreDesugaring(false);
   setAssignmentDesugaring(true);
   WellKnownNames.useCompilerLibraries();
   Types.useCompilerLibraries();
 }
コード例 #3
0
ファイル: Shell.java プロジェクト: dbremner/fortress
 public static void useInterpreterLibraries() {
   setExtendsObjectPreDesugaring(false);
   setAssignmentPreDesugaring(false);
   setAssignmentDesugaring(true);
   setCompiledExprDesugaring(false);
   WellKnownNames.useFortressLibraries();
   Types.useFortressLibraries();
 }
コード例 #4
0
ファイル: Shell.java プロジェクト: dbremner/fortress
  /** 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);
    }
  }
コード例 #5
0
  /* (non-Javadoc)
   * @see junit.framework.TestCase#setUp()
   */
  @Override
  protected void setUp() throws Exception {
    Shell.setPhaseOrder(PhaseOrder.interpreterPhaseOrder);
    Shell.setScala(false);
    fssFiles = new String[4];
    fsiFiles = new String[3];

    fssFiles[0] = "TestCompiledEnvironments";
    fssFiles[1] = "TestCompiledImports";
    fssFiles[2] = "TestCompiledNestedImports";
    fssFiles[3] = WellKnownNames.fortressLibrary();

    for (String fssFile : fssFiles) {
      compileTestProgram(fssFile + ".fss");
    }
    testCompiledEnv = SimpleClassLoader.loadEnvironment(fssFiles[0], false);
    testCompiledImportEnv = SimpleClassLoader.loadEnvironment(fssFiles[1], false);
    testCompiledNestedImportEnv = SimpleClassLoader.loadEnvironment(fssFiles[2], false);
    testLibraryEnv = SimpleClassLoader.loadEnvironment(fssFiles[3], false);

    fsiFiles[0] = "AsciiVal";
    fsiFiles[1] = "a.b.NestedOne";
    fsiFiles[2] = "a.b.c.d.NestedTwo";
  }