Incremental compilation of C++ programs

Data processing: software development – installation – and managem – Software program development tool – Translation of code

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C717S152000, C717S152000, C717S152000, C717S152000, C717S152000, C717S152000

Reexamination Certificate

active

06182281

ABSTRACT:

FIELD OF THE INVENTION
The present invention is directed to a technique permitting incremental compilation of C++ programs.
BACKGROUND OF THE INVENTION
C++ is an object-oriented programming language in which programs are created using a set of language tools, abstraction and constructs that support a particular form of user-defined types, called “classes”. Each such type associates a collection of declared data with a set of operations on that data. Variables, or instances, of such types in the running programs are called objects.
Classes can be related to one another by inheritance. The properties, behaviors, data, and operations of a parent, or “base”, class may be inherited without modification by some child, or “derived” class, or the behaviors, properties, and operations may be selectively refined under control of the programmer. When defining a derived class, one may start by building on an existing base class which is similar to the one to be created. The derived class inherits the implementation and behavior of the base class, except as modified by amendments detailed in the derived class definition. Several classes can inherit the behaviors of a common parent, and a derived class may inherit from more than one base class. A member function is a function or operation defined as a behaviour of some user-defined type where that type participates in a hierarchy of other types.
A feature of C++ programming is that it is text-based, and its classes are stored in separate files. Class declarations are usually split up into 2 files: a header file with extension “.h” or “.hpp” that contains the class declaration with the member fields and the member function headers, and a body file with extension “.C” or “.cpp” that contains the bodies of the member functions.
In conventional C++ programming, the header files contain important preprocessor directives and forward declarations, the latter providing the declaration ordering to ensure that every name is declared before it is used. Header files are inserted into the source file through the use of the preprocessor directive
#include
.
However, forward declarations must be manually prepared by the programmer; writing, organizing and maintaining header files (through program revisions) takes considerable programmer time and thought. As a result, mistakes in header files are a frequent source of compile errors.
Header files are also a major source of long program build times in C++ programming. As programmers increasingly exploit C++ classes, the cost of repeatedly reprocessing header files often dominates total compilation time. One result has been the introduction of pre-compiled header files, now supported by most commercial C++ compilers, to counter this problem.
The idea of providing for selective compilation has been addressed at varying levels of granularity. For example, UK Patent No. 2 130 406 B of Reiffen, titled Computer System with Real-time Compilation, discusses a system that partially compiles while the user is editing the source program. The compiler compiles up to a “pause location” in the source defined by the editor and then waits. When the user has made changes up to a point where the editor thinks the compiler can process more, it updates the “pause location” and the compiler does a bit more work. However, this compiler still compiles the source code from start to finish in order. If the user changes the source before the “pause location”, the editor tells the compiler to re-initialize and start compiling from the start of source down to the new “pause location”.
In C++ compilers, techniques for implementing a form of incremental compilation have been developed, in which a tool called “make” determines which files need to be recompiled by locating those files with time stamps after the last compilation, and then directing the compiler to compile the necessary files. However, conventional C++ compilers that effect file-based batch processing must read the declarations in order, and often read through thousands of lines of unchanged code in a file, or in the header files that the file includes, before processing a changed declaration. (Any file that includes a modified header file must be recompiled, whether or not the modification affects any definition in that file.) Also, the programmer needs to tell “make” about file-level dependencies, and this dependency information must be maintained as the system being developed evolves. While there are tools to maintain the dependencies automatically, they are very slow and, consequently, are not consistently used, leading to errors in the dependency information, and ultimately, problems during recompilation.
Therefore, a system which provided for incremental compilation of changes to C++ programs, effected at top-level declaration incrementality, would greatly reduce compilation time during program development and maintenance.
Also, entirely eliminating the need for forward declarations in C++ programming would provide a major improvement in programmer productivity by eliminating the work involved in preparing the header files initially and correcting errors identified during compilation. An enhancement to the compiler is necessary to dispense with the requirement for the ordering provided in the forward declarations.
SUMMARY OF THE INVENTION
It is an object of the present invention to provide a means for parsing a C++ program during compilation that dispenses with the requirement for forward declarations or other ordering of the defining declarations, and dispenses with the requirement on the programmer to maintain file-level dependency information during program editing.
It is also an object of the present invention to provide a system that can compile and link small changes in C++ programs rather than complete source files, that is, a system for incremental programming.
A further object of the present invention is to provide a means for creating a whole-program representation that will persist through multiple parsing passes of the compiler.
Accordingly, the present invention provides a method for compiling a C++ program in source code that consists of making an initial sweep of the source code, one declaration at a time, to obtain the declarations. Any declaration for which not all identifiers are known in said initial sweep are set aside, and at least one subsequent sweep of the source code is made to obtain definitions for the declarations set aside from the initial sweep.
Preferably, the declarations are saved to a program representation following each sweep of the source code, and the program representation persists between compilations.
The invention also provides a method for parsing a program in C++ source code without ordering or forward declarations, or without header files. In this method, the parsing is done directly of top level declarations.
In a further embodiment, the present invention provides a method for compiling a C++ source code program in an enhanced compiler effecting lexical analysis to tokenize the source code program, parsing and semantic analysis to produce an intermediate representation of the source code program. The improvement of the invention consists of parsing the tokenized source code program through multiple parsing passes, each pass accumulating information to parse declarations in the source code program from program definitions. Preferably, in the initial pass, only type declarations for the tokenized source code program are parsed, and in subsequent passes, information about type names, variables and functions in the source code program is accumulated.
The present invention is also directed to a compiler adpated to compile programs written in C++ source code. The compiler includes a parser adapted to extract definitions for declarations used in the programs directly from the source code by effecting multiple parsing sweeps of the source code. Preferably, th

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Incremental compilation of C++ programs does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Incremental compilation of C++ programs, we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Incremental compilation of C++ programs will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-2437680

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.