Automatic conversion of units in a computer program
First Claim
Patent Images
1. A method of converting units in a computer program, said method comprising the steps of:
- (a1) accepting as input a unit identifier for each variable used in said computer program, wherein each unit identifier comprises one or more unit elements;
(a2) accepting as input a primary unit element from each group of unit elements;
(a3) accepting as input a relation between each of said unit elements and one of said groups of unit elements and a conversion factor to said primary unit element of said group of unit elements;
(d) identifying instances of said variables in said computer program;
(e) augmenting said instances of said variables with a corresponding one of said unit identifiers; and
(f) identifying, for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier of the respective group, multiplied with said conversion factor.
3 Assignments
0 Petitions
Accused Products
Abstract
A remedial method (200) and apparatus (100) is described, by which unit information can be documented in a computer program. A set of user-supplied precompiler directives is added to the computer program that is to be converted, in which a preferred set of units, called primary units, are prescribed. A precompiler tool performs a conversion of a unit to its corresponding unit in the preferred set of units.
46 Citations
13 Claims
-
1. A method of converting units in a computer program, said method comprising the steps of:
-
(a1) accepting as input a unit identifier for each variable used in said computer program, wherein each unit identifier comprises one or more unit elements;
(a2) accepting as input a primary unit element from each group of unit elements;
(a3) accepting as input a relation between each of said unit elements and one of said groups of unit elements and a conversion factor to said primary unit element of said group of unit elements;
(d) identifying instances of said variables in said computer program;
(e) augmenting said instances of said variables with a corresponding one of said unit identifiers; and
(f) identifying, for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier of the respective group, multiplied with said conversion factor. - View Dependent Claims (2, 3)
(h) dividing both sides of said assignment statement with the conversion factor(s) on the left hand side of the assignment statement.
-
-
3. The method according to claim 1, wherein said computer program includes at least one function, said method, for each function, comprising the further steps of:
-
(a4) accepting as input a unit identifier for said function;
(a5) accepting as input a unit identifier for each parameter of said function;
(b) in a function body of said function, converting units by;
(b1) identifying instances of said variables in said function body;
(b2) augmenting said instances of said variables with a corresponding one of said unit identifiers;
(b3) identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor;
(b4) for each assignment statement in said function body, dividing both sides of said assignment statement with the conversion factor(s) on the left hand side of the assignment statement; and
(b5) dividing a return statement of said function body with conversion factor(s) of said unit identifier for said function;
(c1) identifying instances of arguments in function calls of said function in said computer program;
(c2) augmenting said instances of said arguments with a corresponding one of said unit identifiers; and
(c3) identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor;
(g1) identifying instances of said function call in said computer program;
(g2) augmenting said instances of said function call with a corresponding one of said unit identifiers; and
(g3) identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor.
-
-
4. Apparatus for converting units in a computer program, said apparatus comprising:
- input means for;
accepting as input a unit identifier for each variable used in said computer program, wherein each unit identifier comprises one or more unit elements;
accepting as input a primary unit element from each group of unit elements; and
accepting as input a relation between each of said unit elements and one of said groups of unit elements and a conversion factor to said primary unit element of said group of unit elements;
means for identifying instances of said variables in said computer program;
means for augmenting said instances of said variables with a corresponding one of said unit identifiers; and
means for identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor. - View Dependent Claims (5, 6, 7)
means for dividing both sides of said assignment statement with the conversion factor(s) on the left hand side of the assignment statement.
- input means for;
-
6. The apparatus according to claim 4, wherein said computer program includes at least one function, said apparatus, for each function, further comprising:
-
said input means further;
accepting as input a unit identifier for said function; and
accepting as input a unit identifier for each parameter of said function;
means for converting units in a function body of said function;
means for identifying instances of arguments in function calls of said function in said computer program;
means for augmenting said instances of said arguments with a corresponding one of said unit identifiers; and
means for identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor;
means for identifying instances of said function call in said computer program;
means for augmenting said instances of said function call with a corresponding one of said unit identifiers; and
means for identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor.
-
-
7. The apparatus according to claim 6, wherein said means for converting units in said function body of said function comprises:
-
means for identifying instances of said variables in said function body;
means for augmenting said instances of said variables with a corresponding one of said unit identifiers;
means for identifying for each unit element, one of said groups of units and replacing said unit element with said primary unit identifier, multiplied with said conversion factor;
means for, for each assignment statement in said function body, dividing both sides of said assignment statement with the conversion factor(s) on the left hand side of the assignment statement; and
means for dividing a return statement of said function body with conversion factor(s) of said unit identifier for said function.
-
-
8. A computer program product, carried on a storage medium, for converting units in a subject computer program, comprising:
-
first program means for identifying instances of variables in said subject computer program;
second program means for augmenting said instances of said variables with a corresponding one of a set of unit identifiers; and
third program means for, for each unit element, identifying one of a groups of units to which it belongs, and replacing said unit element with a respective primary unit identifier multiplied with a respective conversion factor. - View Dependent Claims (9)
fourth program means for accepting, as input, said set of unit identifiers, said set of primary unit identifiers, a set of membership relationships between unit elements and said groups of elements, and said conversion factors.
-
-
10. A method for converting units in a subject computer program, comprising the steps of:
-
identifying instances of variables in said subject computer program;
augmenting said instances of said variables with a corresponding one of a set of unit identifiers; and
for each unit element, identifying one of a groups of units to which it belongs, and replacing said unit element with a respective primary unit identifier multiplied with a respective conversion factor. - View Dependent Claims (11)
accepting, as input, said set of unit identifiers, said set of primary unit identifiers, a set of membership relationships between unit elements and said groups of elements, and said conversion factors.
-
-
12. A precompiler for converting units in a subject computer program, comprising:
-
means for identifying instances of variables in said subject computer program;
means for augmenting said instances of said variables with a corresponding one of a set of unit identifiers; and
means for, for each unit element, identifying one of a groups of units to which it belongs, and replacing said unit element with a respective primary unit identifier multiplied with a respective conversion factor. - View Dependent Claims (13)
means for accepting, as input, said set of unit identifiers, said set of primary unit identifiers, a set of membership relationships between unit elements and said groups of elements, and said conversion factors.
-
Specification