1. Field of the Invention
The present invention generally relates to Fortran type descriptors that can be used to describe dynamic types of objects such as polymorphic entities during runtime of an executable file, and more particularly, to systems and methods that uniquely define each type descriptor within an executable file or shared library to allow for the determination of how the dynamic type of one object relates to that of another by comparing type descriptor addresses of the objects while allowing for the lazy loading of shared libraries.
2. Relevant Background
The 2003 standard of Fortran (“Fortran 2003”) introduced the use of polymorphic entities for use in scientific and technical programming. Generally, a polymorphic entity is a data entity that can assume differing types during program execution or runtime. The type of a data entity at a particular point during execution of a program is its “dynamic type.” In practice, a polymorphic entity is declared to be of a certain type by using the CLASS keyword in place of the TYPE keyword, and it is then able to take any of a number of types during execution. Representative polymorphic entities include allocatable variables (in which case its dynamic type is whatever it is allocated to be), pointers (in which case its dynamic type is that of its target), and dummy arguments (in which case its dynamic type is that of the actual argument). Polymorphic entities allow code to be written for objects of a given type and used later for objects of an extended type. An entity is said to be type compatible with entities of the same declared type or of any declared type that is an extension of its declared type.
Fortran 2003 also introduced a number of new operations (e.g., functions) that can be performed on polymorphic entities at runtime. For instance, “SAME_TYPE_AS(A,B)” returns “TRUE” if objects A and B have the same dynamic type, “EXTENDS_TYPE_OF(A,MOLD)” returns “TRUE” if the dynamic type of object A is an extension type of the dynamic type of object MOLD, and the “SELECT TYPE” operation selects for execution at most one of its constituent blocks depending on the dynamic type of a variable or expression. Programmers can design executables to take different actions or perform different functions at runtime based on results of one or more of these operations.
In any case, the Fortran compiler generates code (e.g., object files) to keep track of the dynamic type of each polymorphic entity at run time. The dynamic type of each of these variables is represented by a data structure called a “type descriptor” which describes the name of the dynamic type, the context of the dynamic type, the ancestor types of the dynamic type, and the like. Often, a shared object (i.e., shared library) is generated including a list of type descriptors or type descriptor definitions to which the polymorphic entities of one or more object files or subsequently generated dynamic executables can point or reference (e.g., via identifiers, pointers, etc.). The new operations discussed above utilize the type descriptors in varying manners depending upon the particular operation.
For instance, one manner (the “string-compare” method) compares one or more strings of the type descriptors (e.g., type name) and/or contexts (e.g., name of module in which type descriptor resides in shared library) of two polymorphic entities to determine if the polymorphic entities have the same dynamic type. Another manner (the “hash-value compare” method) computes hash values from the type names in the type descriptors of two polymorphic entities (e.g., using any appropriate hash function with each type name as a key). For instance, polymorphic entities may be declared to have the same dynamic type upon the matching of hash values and different dynamic types upon the non-matching of hash values. A further manner (the “unique type descriptor” method) determines and compares the addresses of the type descriptors in memory to determine whether the dynamic types are the same.