Syntactical change-resistant code generation
AssigneeThe MathWorks, Inc.
InventorEbrahim M. Mestchian
Life of this patent
Estimating the term…
Abstract
Systems and methods for syntactical change-resistant code generation are described. A code generator can generate syntactical change-resistant code from original code and new code, where the new code may be intended as a replacement or update for the original code. The code generator can determine, for code portions and/or sub-portions of the new code, whether or not semantic, syntactic, and structural differences from the original code exist. The code generator can generate the syntactical change-resistant code to leverage and include in the syntactical change-resistant code portions and sub-portions of the original code that have been used and tested, so as to improve reliability of the syntactical change-resistant code.
Claims23
A computer-implemented method comprising:
- receiving, by one or more processors, first code and second code, where the second code is an updated version of the first code;
- and
- generating, by the one or more processors, third code that is semantically equivalent, at least in part, to the second code, the generating comprising:
- identifying, by the one or more processors, a first portion of the second code that is syntactically and structurally equivalent to a first portion of the first code, and a second portion of the second code that is syntactically or structurally different from a second portion of the first code;
- identifying, by the one or more processors, within the second portion of the second code, a first sub-portion that is semantically different from a first sub-portion of the second portion of the first code, the first sub-portions of the first and second code being syntactically or structurally different;
- identifying, by the one or more processors, within the second portion of the second code, a second sub-portion that is semantically equivalent to a second sub-portion of the second portion of the first code, the second sub-portions of the first and second code being syntactically or structurally different;
- generating the third code, by the one or more processors, that includes the second sub-portion of the first code in the third code;
- analyzing A. the second sub-portions of the second portion of the first and second code or B. the first portions of the first and second code to derive information about syntactic changes and/or structural changes between the second sub-portions,
- and
- generating the third code, by the one or more processors, that includes one or more portions of the first sub-portion of the second code in the third code at one or more locations within the third code based on the information derived.
A system comprising:
- at least one processor;
- and
- at least one non-transitory computer-readable medium containing instructions that, when executed by the at least one processor, cause the system to perform operations comprising:
- receiving first code and second code, where the second code is an updated version of the first code;
- and
- generating third code that is semantically equivalent to the second code, the generating comprising:
- identifying a first portion of the second code that is syntactically and structurally equivalent to a first portion of the first code, and a second portion of the second code that is syntactically or structurally different from a second portion of the first code;
- identifying within the second portion of the second code, a first sub-portion that is semantically different from a first sub-portion of the second portion of the first code, the first sub-portions of the first and second code being syntactically or structurally different;
- identifying within the second portion of the second code, a second sub-portion that is semantically equivalent to a second sub-portion of the second portion of the first code, the second sub-portions of the first and second code being syntactically or structurally different;
- including the second sub-portion of the first code in the third code;
- partitioning the first sub-portion of the second code into multiple slices, the partitioning being based on including the second sub-portion of the first code in the third code;
- and
- including the multiple slices of the first sub-portion of the second code in the third code at one or more locations within the third code.
A non-transitory computer readable medium, comprising:
- instructions that, when executed by at least one processor, cause a system to perform operations comprising:
- receiving first code and second code, where the second code is an updated version of the first code;
- and
- generating third code that is semantically equivalent to the second code, the generating comprising:
- identifying a first portion of the second code that is syntactically and structurally equivalent to a first portion of the first code, and a second portion of the second code that is syntactically or structurally different from a second portion of the first code;
- identifying within the second portion of the second code, a first sub-portion that is semantically different from a first sub-portion of the second portion of the first code, the first sub-portions of the first and second code being syntactically or structurally different;
- identifying within the second portion of the second code, a second sub-portion that is semantically equivalent to a second sub-portion of the second portion of the first code, the second sub-portions of the first and second code being syntactically or structurally different;
- including the second sub-portion of the first code in the third code;
- partitioning the first sub-portion of the second code into multiple slices, the partitioning being based on including the second sub-portion of the first code in the third code;
- and
- including the multiple slices of the first sub-portion of the second code in the third code at one or more locations within the third code.
A computer-implemented method comprising:
- receiving, by one or more processors, first code and second code, where the second code is an updated version of the first code;
- and
- generating, by the one or more processors, third code that is semantically equivalent, at least in part, to the second code, the generating comprising:
- identifying, by the one or more processors, a first portion of the second code that contains one or both of syntactic and structural differences from a first portion of the first code;
- identifying, by the one or more processors, within the first portion of the second code, a first sub-portion that is semantically different from a first sub-portion of the first portion of the first code;
- identifying, by the one or more processors, within the first portion of the second code, a second sub-portion that is semantically equivalent to a second sub-portion of the first portion of the first code, the second sub-portions of the first and second code being syntactically or structurally different;
- partitioning, by the one or more processors, the first sub-portion of the second code into one or more slices;
- including, by the one or more processors, the second sub-portion of the first code in the third code;
- and
- including, by the one or more processors, the one or more slices of the first sub-portion of the second code in the third code.
Dependencies are inferred from the claim text.