Typed intermediate language support for languages with multiple inheritance
AssigneeMicrosoft Corporation
InventorJuan Chen
Life of this patent
Estimating the term…
Abstract
A typed intermediate representation of source code written in a language that supports multiple inheritance is presented. The typed intermediate representation uses paths to represent objects embedded in other objects. For each class, an exact record type represents layout of complete objects of that class. An approximated record type describes layout of inner objects when the runtime types of the objects are statically unknown. Address arithmetic is represented by special instructions and type-checked to ensure proper pointer adjustment. Types are also given to “this” pointers of methods within classes. These “this” pointer types refer to the paths associated with the object.
Claims19
A computer implemented method for generating a typed intermediate representation of a computer program, the computer program supporting virtual inheritance and multiple inheritance, the method comprising:
- receiving a source code representation of the computer program in an object-oriented language, the source code representation comprising code portions related to defining one or more classes;
- and
- based on the source code representation, generating the typed intermediate representation of the computer program by generating an exact class representation of at least one of the one or more classes defined in the source code, the exact class representation including a unique representation of all superclasses of the class.
At least one computer-readable medium having stored thereon a typed intermediate representation of a computer program, the computer program written in a language which allows multiple inheritance and virtual inheritance, the typed intermediate representation comprising:
- an exact record type which comprises a substantially exact representation of a runtime object of at least one of one or more classes defined in a source code representation of the computer program, including at least two distinct inheritance paths from the class to a superclass, the superclass inherited at least twice;
- and
- an approximated record type comprising substantially all inheritance paths from at least one non-virtually inherited superclasses of the class to all superclasses inherited by the non-virtually inherited superclass.
A computer system for generating a typed intermediate representation of a computer program, the computer system comprising:
- a compiler operable for generating the typed intermediate representation from a source code representation of the computer program, wherein the source code representation comprises definitions of one or more classes, at least one class including at least one virtually-inherited superclass;
- the compiler further comprising:
- an exact record type generator, which generates a representation of a runtime object of the class, the representation comprising the displacements from at least one class which inherits the virtual class and the virtual class;
- and
- an approximated record type generator, which generates a representation of a runtime object of the class when an exact runtime type of the object is not known.
Dependencies are inferred from the claim text.