Type system for representing and checking consistency of heterogeneous program components during the process of compilation
First Claim
1. A method of type-checking a code segment written in a programming language comprising:
- translating the code segment from the programming language to one or more representations of a typed intermediate language, wherein the one or more representations of the typed intermediate language are capable of representing programs written in a plurality of different source languages, and wherein the one or more representations comprise a first object having a known type, and wherein the translating comprises;
determining that the first object will be type-checked as an unknown type, andbased on the determining, designating the first object as having the unknown type by dropping the known type of the first object and replacing the known type with the unknown type; and
type-checking the one or more representations based on a rule set, wherein;
the rule set comprises rules for type-checking the type designated as the unknown type,the unknown type indicates that an element of the representation is of a type that is not known, andthe first object is type-checked as having an unknown type, based on the designating.
2 Assignments
0 Petitions
Accused Products
Abstract
A representation of types, type-checker, method and compiler are provided for checking consistency in various forms of an intermediate language. Specifically, the typed intermediate language is suitable for use in representing programs written in multiple (heterogeneous) source languages including typed and untyped languages, loosely and strongly typed languages, and languages with and without garbage collection. An unknown type representation indicates that an element of the intermediate language is associated with an unknown type. A method of type-checking a code segment written in a programming language is provided using a rule set that contains rules for type-checking an unknown type. The unknown type allows for selectively retaining type information as the compilation process continues and allows multiple programming languages to be type-checked by the same type system.
117 Citations
27 Claims
-
1. A method of type-checking a code segment written in a programming language comprising:
translating the code segment from the programming language to one or more representations of a typed intermediate language, wherein the one or more representations of the typed intermediate language are capable of representing programs written in a plurality of different source languages, and wherein the one or more representations comprise a first object having a known type, and wherein the translating comprises; determining that the first object will be type-checked as an unknown type, and based on the determining, designating the first object as having the unknown type by dropping the known type of the first object and replacing the known type with the unknown type; and type-checking the one or more representations based on a rule set, wherein; the rule set comprises rules for type-checking the type designated as the unknown type, the unknown type indicates that an element of the representation is of a type that is not known, and the first object is type-checked as having an unknown type, based on the designating. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
9. A method of selectively retaining type information during compilation in a code segment written in a programming language, the method comprising:
-
translating the code segment from the programming language to one or more intermediate language representations; for each intermediate language representation, determining whether to retain type information for one or more elements of the intermediate language representation, wherein the one or more intermediate language representations include one or more elements having a known type; based on the determination, associating at least one of the one or more elements of the intermediate language representation with a type, designated as an unknown type, indicating the element can be of any type; and type-checking the one or more intermediate language representations based on a rule set, wherein the rule set comprises rules for type-checking the type designated as the unknown type. - View Dependent Claims (10, 11, 12, 13, 14, 15)
-
-
16. A method of translating types associated with a plurality of programming languages to types of an intermediate language, the method comprising:
replacing the types associated with the plurality of programming languages with the types of the intermediate language, wherein; at least one of the plurality of programming languages is non-type-safe, the types of the intermediate language comprise plural programming language specific primitive types associated with the plurality of programming languages and a type designated as an unknown type, the type designated as the unknown type has size information associated with it, at least one of the plural programming language specific primitive types is replaced with the unknown type, and the size information comprises size information of a machine representation of the type designated as the unknown type.
-
17. A computer system for type-checking an intermediate representation of source code in a compiler comprising:
-
a computer-readable storage medium containing one or more types associated with elements of the intermediate representation, wherein at least one of the types, designated as an unknown type, indicates an element can be of any type; a computer-readable storage medium containing one or more rule sets comprising rules associated with the type, designated as the unknown type, indicating an element can be of any type; and a type-checker module, wherein the type-checker is configured for applying the one or more rule sets to the elements of the intermediate representation, wherein the type-checker module selectively retains type information for some elements of the intermediate representation and selectively does not retain type information for at least one element of the intermediate representation by replacing a known type associated with the at least one element with the type, designated as the unknown type, indicating the at least one element can be of any type, wherein the type-checker is configured to apply the one or more rule sets after the replacing the known type with the unknown type. - View Dependent Claims (18, 19, 20, 21, 22, 23, 24)
-
-
25. A method of representing types in an intermediate language comprising:
-
defining a plurality of types to be associated with elements of the intermediate language, wherein one of the plurality of types indicates that an element of the intermediate language is associated with a type designated as an unknown type; wherein the type indicating that an element of the intermediate language is associated with the type designated as the unknown type has a size associated with it, wherein the size represents size of a machine representation of the type designated as the unknown type; wherein an element of the intermediate language that was previously associated with a known type is associated with the type designated as the unknown type; wherein the rule set further comprises rules for dropping type information for one or more elements of the representation by changing the known type of the one or more elements to the type designated as an unknown type. - View Dependent Claims (26, 27)
-
Specification