Replaceable classes and virtual constructors for object-oriented programming languages
First Claim
1. A method of constructing a computer program developed with an object-oriented programming language, the method comprising:
- declaring a base class as replaceable in a first source file;
invoking, in the first source file, an operator to create an object of the base class;
compiling the first source file into a first module, including emitting an instruction to create an object of the base class in response to the invoking of the operator to create in the first source file;
defining a replacement class inheriting from the base class in a second source file;
instructing in the second source file to replace the base class with the replacement class to cause creation of an object of the replacement class when the instruction in the first module to create an object of the base class is executed during program execution, the program execution occurring after the compiling of the first source file, the creation of the object of the replacement class occurring without recompiling the first source file;
compiling the second source file into a second module; and
combining the first and second modules in an executable program.
2 Assignments
0 Petitions
Accused Products
Abstract
An extension of object-oriented programming languages enables the use of replaceable classes and virtual constructors, thereby allowing existing code that creates objects of a base class to be reusable for creating instances of a new class derived from the base class. A base class intended to be replaceable later is declared to be replaceable. In the case of a compiled language, the programming code defining and using the base class is compiled into a reusable module. Later, a new class derived from the base class is identified as a replacement for the base class and is used in new programming code that uses the existing reusable module. The replacement relationship between the old base class and the new class is registered. During execution of the program, when the old code of the reusable module indicates the creation of an object of the base class, the registered replacement information is referenced. If the old class is to be replaced with the new class, the creation information for the new class is passed instead so that an object of the new class is created. The class replacement may be implemented with compiled and interpreted programming languages. When a compiled language is used, the class replacement may be implemented with new compiler-supported features that emit data for class replacement into the .obj files, but may also be implemented without requiring changes to existing compilers.
41 Citations
12 Claims
-
1. A method of constructing a computer program developed with an object-oriented programming language, the method comprising:
-
declaring a base class as replaceable in a first source file;
invoking, in the first source file, an operator to create an object of the base class;
compiling the first source file into a first module, including emitting an instruction to create an object of the base class in response to the invoking of the operator to create in the first source file;
defining a replacement class inheriting from the base class in a second source file;
instructing in the second source file to replace the base class with the replacement class to cause creation of an object of the replacement class when the instruction in the first module to create an object of the base class is executed during program execution, the program execution occurring after the compiling of the first source file, the creation of the object of the replacement class occurring without recompiling the first source file;
compiling the second source file into a second module; and
combining the first and second modules in an executable program. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A method of constructing source code in an object-oriented programming language, comprising the steps of:
-
declaring a base class as replaceable in a first source file;
defining a replacement class inheriting from the base class in a second source file;
declaring in the second source file that the replacement class is a replacement for the base class;
entering in the second source file an instruction to replace the base class with the replacement class during program execution, the program execution to occur after a compiling of the first source file, the replacing to occur without recompiling the first source file. - View Dependent Claims (9)
-
-
10. A computer-readable medium having computer-executable instructions to perform a method for compiling a source listing in an object-oriented programming language into an executable module, the method comprising:
-
upon reading a statement in the source listing defining a first class as replaceable, emitting into the executable module a creation information block for the first class;
upon reading a statement in the source listing defining a second class inheriting from the first class as a replacement for the first class, emitting into the executable module a creation information block for the second class;
upon reading an instruction in the source listing to replace the first class with the second class, emitting an instruction to store a class replacement record for the first and second classes in a class replacement registration list; and
upon reading an instruction in the source listing to create an object of the first class, emitting into the executable module;
an instruction to search the class replacement registration list and to return a pointer to the creation information block for the second class if a class replacement record for the first and second classes is found and otherwise to return a pointer to the creation information block for the first class; and
an instruction to create, during program execution, an object according to the creation information block pointed to by the returned pointer, the program execution to occur after a compiling of the source listing, the creation of the object according to the creation information block to occur without recompiling the source listing. - View Dependent Claims (11, 12)
-
Specification