示例#1
0
文件: incrmnt.cpp 项目: prog012/jikes
//
// Check whether or not there are files to be recompiled.
//
bool Control::IncrementalRecompilation()
{
    //
    // Empty out the type lookup table so that it does not continue
    // to point to a type that is deleted here.
    //
    type_table.SetEmpty();

    SymbolSet candidates(input_java_file_set.Size() +
                         input_class_file_set.Size() +
                         recompilation_file_set.Size());

    if (! recompilation_file_set.IsEmpty())
        candidates = recompilation_file_set;
    else
    {
        Ostream out;
        out.StandardOutput();
        out << endl << "Incremental: Enter to continue or q + Enter to quit: "
            << flush;

        char ch;
        // See if the user types Q or presses enter/escape or sends an EOF
        while (1) {
            cin.get(ch);
            if (cin.eof() || (ch == U_q) || (ch == U_Q)) {
                return false;
            }
            if ((ch == U_ESCAPE) || (ch == U_LINE_FEED)) {
                break;
            }
        }

        candidates = input_java_file_set;
        candidates.Union(input_class_file_set);
    }

    if (!candidates.IsEmpty())
    {
        TypeDependenceChecker dependence_checker(this, candidates,
                                                 type_trash_bin);
        dependence_checker.PartialOrder();

        //
        // Compute the initial set of files that need to be recompiled. Place
        // them in recompilation_file_set.
        //
        RereadDirectories();

        ComputeRecompilationSet(dependence_checker);
    }

    //
    // Starting with the initial recompilation_file_set, complete the
    // computation of the set of files that need to be recompiled. (Add all
    // new files to recompilation_file_set). Also, complete the computation of
    // type_trash_set, the set of files that should be removed from the
    // database as they will be recompiled.
    //
    fprintf(stderr, "%s", (recompilation_file_set.IsEmpty() &&
                           expired_file_set.IsEmpty()
                           ? "\nnothing changed...\n" : "\nok...\n"));
    fflush(stderr);
    return true;
}