Go to the previous, next section.

File Set Entries

File set entries are implemented by the file_set_entry class. The file_set_entry_list class is also defined to hold the file set entries in the file set. A file set entry records the input and output streams for a source file. Either the input or output streams could be empty. The name method returns the name of the input file, if it exists. Otherwise it returns the name of the output file. The parent method returns the file set which contains the file set entry.

The file set entry also contains the file symbol table. See section File Symbol Tables. The file symbol table holds the symbols and types declared within the scope of the file. This includes variables and functions declared with static linkage and types that are only visible within the file. The file symbol table is accessed using the symtab method.

The file set entry class provides an iterator to visit all of the procedures that are defined in the input file. Note that this does not include procedures that are declared but whose bodies are defined elsewhere. The reset_proc_iter method resets the iterator to the first procedure. The next_proc method returns the next procedure in the input file.

The following code reads each procedure in the given file set entry, calls the function process_proc on the procedure, and then writes it out.

void process_file (file_set_entry *fse)
{
    proc_sym *psym;

    fse->reset_proc_iter();
    while (psym = fse->next_proc()) {
        psym->read_proc();

        process_procedure(psym);

        psym->write_proc(fse);
        psym->flush_proc();
    }
}

Go to the previous, next section.