IP Library Granted Patent US 7,624,385
Granted Patent B2
US 7,624,385 · App. 11/093,530 · Granted Nov 24, 2009

Method for handling preprocessing in source code transformation

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 7,624,385
App. No.
11/093,530
Granted
Nov 24, 2009
Kind
B2
Abstract

A method for handling preprocessing in source code transformation creates a semantically correct view of a program being transformed. This semantically correct view is called a transformed form and it is capable of being parsed with a regular grammar. The original use of preprocessing macros is determined, including their relationship to the transformed form and the preprocessing is reconstructed in the modified source code.

Claims (65)

1. A method for handling preprocessing in source code transformation, comprising:

deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;

parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;

performing an AST-based transformation on the AST form to produce a modified AST form; and

reconditioning the modified AST form to produce a modified source code conforming to the original source code style, the reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation.

2. The method of claim 1 , wherein the produced modified source code is semantically correct.

3. The method of claim 1 , wherein the deconditioning further comprises:

slicing the original source code into a plurality of slices, wherein the slicing comprises masking out selected conditional directives of the original source code.

4. The method of claim 3 , wherein the slicing further comprises:

masking out lines within conditional directives of the original source code that are false.

5. The method of claim 3 , wherein the reconditioning further comprises:

unmasking the selected conditional directives.

6. The method of claim 3 , wherein the modified source code includes a plurality of transformed slices generated using the plurality of slices and wherein the reconditioning further comprises:

merging the plurality of the transformed slices into a single unified version.

7. The method of claim 1 , wherein the deconditioning further comprises:

expanding macros in the original source code; and

annotating respectively the original source code with expansion meta-data tags to indicate the expanded macros.

8. The method of claim 7 , wherein the reconditioning further comprises:

reducing the expanded macros using the expansion meta-data tags.

9. The method of claim 8 , wherein the reducing the expanded macros includes using a regular expression to match on the expanded macros and replace macro parameters, including when macro parameter values have been modified.

10. The method of claim 1 , wherein the deconditioning further comprises:

removing line continuations in the original source code; and

annotating the original source code with splits meta-data indicating line splits corresponding to the removed line continuation.

11. The method of claim 10 , wherein the reconditioning further comprises:

reconstructing the line continuations in the modified source code according to the splits meta-data line break tags.

12. The method of claim 1 , wherein the parsing further comprises:

generating the annotations in the AST form to represent meta-data tags generated in the original source code by the deconditioning.

13. The method of claim 12 , wherein the performing the AST-based transformation further comprises:

processing the annotations to re-produce the meta-data tags in the modified AST form.

14. The method of claim 13 , wherein the reconditioning further comprises:

processing the meta-data tags to produce the modified source.

15. A system for handling preprocessing in source code transformation, the system comprising:

a memory for storing:

a deconditioning component for deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;

a parser component for parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;

a transformation engine component for performing an AST-based transformation on the AST form to produce a modified AST form; and

a reconditioning component for reconditioning the modified AST form to produce a modified source code conforming to the original source code style, the reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation; and

a processor adapted to execute the components stored in the memory to produce the modified source code based on the original source code.

16. The system of claim 15 , wherein the deconditioning component further provides for:

masking out selected conditional directives of the original source code;

expanding macros in the original source code;

annotating the original source code with expansion meta-data tags to indicate the expanded macros;

removing line continuations in the original source code; and

annotating the original source code with splits meta-data indicating line splits corresponding the removed line continuation.

17. The system of claim 16 , wherein the reconditioning component further provides for:

unmasking the selected conditional directives;

reducing the expanded macros using the expansion meta-data tags; and

reconstructing the line continuations in the modified source code according to the splits meta-data line break tags.

18. A computer-readable storage medium having instructions stored thereon which, when executed by a processor, perform a method for handling preprocessing in source code transformation, the method comprising:

deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;

parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;

performing an AST-based transformation on the AST form to produce a modified AST form; and

reconditioning the modified AST form to produce a modified source code conforming to the original source code style, reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation.

19. The computer readable storage medium of claim 18 , further comprising:

generating the annotations in the AST form to represent meta-data tags generated in the original source code by the deconditioning, wherein the performing the AST-based transformation further comprises processing the annotations to re-produce the meta-data tags in the modified AST form, and wherein the reconditioning further processing the meta-data tags to produce the modified source.

20. The computer readable storage medium of claim 18 , wherein the deconditioning further comprises:

masking out selected conditional directives of the original source code;

expanding macros in the original source code;

annotating the original source code with expansion meta-data tags to indicate the expanded macros;

removing line continuations in the original source code; and

annotating the original source code with splits meta-data indicating line splits corresponding the removed line continuation.

21. The computer readable storage medium of claim 20 , wherein the reconditioning further comprises:

unmasking the selected conditional directives;

reducing the expanded macros using the expansion meta-data tags; and

reconstructing the line continuations in the modified source code according to the splits meta-data line break tags.

Assignments (3)
NUNC PRO TUNC ASSIGNMENT Recorded Oct 8, 2019
From: NOKIA OF AMERICA CORPORATION
To: ALCATEL LUCENT
Reel/Frame 050668/0829 →
CHANGE OF NAME Recorded Sep 24, 2019
From: ALCATEL-LUCENT USA INC.
To: NOKIA OF AMERICA CORPORATION
Reel/Frame 050476/0085 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 25, 2014
From: ALCATEL LUCENT
To: SOUND VIEW INNOVATIONS, LLC
Reel/Frame 033416/0763 →