Program rewrite device, storage medium, and program rewrite method
A program rewrite method executed by a computer, the method includes rewriting a program to output a first output group by performing operations for a first variable among a plurality of variables with a plurality of data types; rewriting the program to output a second output group by performing operations for a second variable among the plurality of variables with a plurality of data types; identifying, from the first output group and the second output group, a third output group that satisfied a predetermined criterion as a result of executing the rewritten programs; determining a data type that corresponds to the third output group as a use data type; and outputting a program in which the use data type is set for each of the plurality of variables.
1. A program rewrite device, comprising:
a memory; and
a processor coupled to the memory and the processor configured to:
rewrite a program to output a first output group by performing operations for a first variable among a plurality of variables with a plurality of data types,
rewrite the program to output a second output group by performing operations for a second variable among the plurality of variables with a plurality of data types,
identify, from the first output group and the second output group, a third output group that satisfied that calculation results of the first variable obtained from the first output group and the second variable obtained from the second output group fall within a predetermined error range as a result of executing the rewritten programs,
determine a data type that corresponds to the third output group as a use data type,
output a program in which the use data type is set for each of the plurality of variables,
rewrite the program to perform condition branch determination with a plurality of data types,
rewrite the program to be able to copy an execution process to two execution processes on a true branch side and on a false branch side in a case of executing the program after the condition branch determination, and
rewrite the program to stop use of a data type in which the condition branch determination becomes false in the process on the true branch side, and to stop use of a data type in which the condition branch determination becomes true in the process on the false branch side.
2. The program rewrite device according to claim 1 , wherein the processor configured to:
change a name of a function at a call position according to the use data type at the call position of the function; and
output the program to which the function is added in accordance with the name of the function.
3. A non-transitory computer-readable storage medium storing a program that causes a computer to execute a process, the process comprising:
rewriting a program to output a first output group by performing operations for a first variable among a plurality of variables with a plurality of data types;
rewriting the program to output a second output group by performing operations for a second variable among the plurality of variables with a plurality of data types;
identifying, from the first output group and the second output group, a third output group that satisfied that calculation results of the first variable obtained from the first output group and the second variable obtained from the second output croup fall within a predetermined error range as a result of executing the rewritten programs;
determining a data type that corresponds to the third output group as a use data type;
outputting a program in which the use data type is set for each of the plurality of variables;
rewriting the program to perform condition branch determination with a plurality of data types;
rewriting the program to be able to copy an execution process to two execution processes on a true branch side and on a false branch side in a case of executing the program after the condition branch determination; and
rewriting the program to stop use of a data type in which the condition branch determination becomes false in the process on the true branch side, and to stop use of a data type in which the condition branch determination becomes true in the process on the false branch side.
4. A program rewrite method executed by a computer, the method comprising:
rewriting a program to output a first output group by performing operations for a first variable among a plurality of variables with a plurality of data types;
rewriting the program to output a second output group by performing operations for a second variable among the plurality of variables with a plurality of data types;
identifying, from the first output group and the second output group, a third output group that satisfied that calculation results of the first variable obtained from the first output group and the second variable obtained from the second output group fall within a predetermined error range as a result of executing the rewritten programs;
determining a data type that corresponds to the third output group as a use data type;
outputting a program in which the use data type is set for each of the plurality of variables;
rewriting the program to perform condition branch determination with a plurality of data types;
rewriting the program to be able to copy an execution process to two execution processes on a true branch side and on a false branch side in a case of executing the program after the condition branch determination; and
rewriting the program to stop use of a data type in which the condition branch determination becomes false in the process on the true branch side, and to stop use of a data type in which the condition branch determination becomes true in the process on the false branch side.
5. The program rewrite method according to claim 4 , wherein the method comprising:
changing a name of a function at a call position according to a situation of the use data type at the call position of the function; and
outputting the program to which the function is added in accordance with the name of the function.