Compiling Alternative Source Code Based on a Metafunction
First Claim
1. A method comprising:
- replacing a call of a function in source code with a body of the function inline in the source code, wherein the body of the function comprises a call to a metafunction, first alternative source code, and second alternative source code;
evaluating the metafunction during compilation of the source code to determine whether a compile-time environment attribute of the source code is true; and
if the compile-time environment attribute is true, compiling the first alternative source code into object code, wherein the first alternative source code relies on truth of the compile-time environment attribute.
0 Assignments
0 Petitions
Accused Products
Abstract
In an embodiment, a function call in source code is replaced inline with a body of the function. The body of the function includes a call to a metafunction, first alternative source code, and second alternative source code. The metafunction is evaluated to determine whether a compile-time environment attribute is true. If the compile-time environment attribute is true, the first alternative source code is compiled into object code, where the first alternative source code relies on truth of the compile-time environment attribute. If the compile-time environment attribute is false, the second alternative source code is compiled into the object code, where the second alternative source code does not rely on the truth of the compile-time environment attribute. For example, in an embodiment, the first alternative source code accesses an argument via an address of the argument while the second alternative source code copies the argument to a temporary variable and accesses the argument via the temporary variable. In this way, generated object code may be specialized based on a compile-time environment attribute.
19 Citations
20 Claims
-
1. A method comprising:
-
replacing a call of a function in source code with a body of the function inline in the source code, wherein the body of the function comprises a call to a metafunction, first alternative source code, and second alternative source code;
evaluating the metafunction during compilation of the source code to determine whether a compile-time environment attribute of the source code is true; and
if the compile-time environment attribute is true, compiling the first alternative source code into object code, wherein the first alternative source code relies on truth of the compile-time environment attribute. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A signal-bearing medium encoded with instructions, wherein the instructions when executed comprise:
-
replacing a call of a function in source code with a body of the function inline in the source code, wherein the body of the function comprises a call to a metafunction, first alternative source code, and second alternative source code;
evaluating the metafunction during compilation of the source code to determine whether a compile-time environment attribute of the source code is true;
if the compile-time environment attribute is true, compiling the first alternative source code into object code, wherein the first alternative source code relies on truth of the compile-time environment attribute; and
if the compile-time environment attribute is false, compiling the second alternative source code into the object code, wherein the second alternative source code does not rely on the truth of the compile-time environment attribute. - View Dependent Claims (12, 13, 14, 15)
-
-
16. A method for configuring a computer, comprising:
-
configuring the computer to replace a call of a function in source code with a body of the function inline in the source code, wherein the body of the function comprises a call to a metafunction, first alternative source code, and second alternative source code;
configuring the computer to evaluate the metafunction during compilation of the source code to determine whether a compile-time environment attribute of the source code is true;
configuring the computer to, if the compile-time environment attribute is true, compile the first alternative source code into object code, wherein the first alternative source code relies on truth of the compile-time environment attribute; and
configuring the computer to, if the compile-time environment attribute is false, compile the second alternative source code into the object code, wherein the second alternative source code does not rely on the truth of the compile-time environment attribute. - View Dependent Claims (17, 18, 19, 20)
-
Specification