SmPL Patch Generation with Default Value Specifier
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing program rewriting tools, such as patches, face limitations in specifying flexible and powerful editing content and characterizing application locations, particularly when variable definitions are involved, leading to inefficiencies and increased computational complexity.
Innovation Solution
A method using a default value specifier in SmPL (Semantic Patch) to dynamically add or use variable declarations based on their presence or absence in the rewrite target program, allowing for more intuitive and efficient code editing.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of manufacture
If a patch uses traditional diff format with line-unit editing specification, then the editing content can be specified in a simple format, but the characterization of application location is limited to matching specific character strings, reducing flexibility when variable names differ
Solution Approach 1:
The invention introduces meta-variables that can represent different variable names dynamically. Instead of matching specific character strings, the patch uses parameter substitution where meta-variables capture and replace different variable identifiers, allowing the same editing pattern to apply across multiple locations with different variable names.
Solution Approach 2:
The patch format achieves multi-functionality by enabling a single editing specification to work across different variable names and contexts. The meta-variable mechanism allows one patch to serve multiple purposes by adapting to different variable identifiers, eliminating the need for separate patches for each variable name variation.
2Adaptability or versatility
If a program rewriting tool uses control flow-based matching to enable flexible editing specification, then the adaptability in characterizing application locations is improved, but the device complexity and computational overhead increase
Solution Approach 1:
The invention introduces meta-variables as an intermediary layer between the patch specification and the actual code. These meta-variables act as placeholders that are resolved during patch application, simplifying the matching process by abstracting away the need for complex control flow analysis while maintaining flexibility in variable name matching.
Solution Approach 2:
The patch specification is segmented into distinct components: the editing pattern, the meta-variable declarations, and the application rules. This segmentation allows each component to be processed independently, reducing the overall computational complexity while maintaining the flexibility to match different variable names.
3Reliability
If all patterns of variable names are explicitly defined in diff format, then complete coverage of rewriting cases is achieved, but the quantity of editing content specification becomes unrealistic
Solution Approach 1:
Instead of explicitly defining each variable name pattern separately, the invention creates a single template using meta-variables that can be copied and applied to multiple variable names. The meta-variable acts as a reusable pattern that automatically adapts to different variable identifiers, dramatically reducing the quantity of specification needed while maintaining complete coverage.
Data Source
AI summary
A computer executes an input procedure of inputting a patch including an operator not defined in SmPL and having a variable name id for which a default value is specified, a type T of id, and an id default value t as arguments, and a description using SmPL, and a rewrite target program, and a generation procedure of generating a patch indicating, by using SmPL, that a variable declaration statement for substituting a computation result of t into the T-type variable id is added to the rewrite target program when the T-type variable is not defined in the rewrite target program, and generating a patch in which id in the description is replaced with the variable when the T-type variable is defined in the rewrite target program, thereby improving efficiency related to rewriting of a program.


