WO2016189721A1 - ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム - Google Patents

ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム Download PDF

Info

Publication number
WO2016189721A1
WO2016189721A1 PCT/JP2015/065354 JP2015065354W WO2016189721A1 WO 2016189721 A1 WO2016189721 A1 WO 2016189721A1 JP 2015065354 W JP2015065354 W JP 2015065354W WO 2016189721 A1 WO2016189721 A1 WO 2016189721A1
Authority
WO
WIPO (PCT)
Prior art keywords
source code
corresponding range
symbol execution
code
change
Prior art date
Application number
PCT/JP2015/065354
Other languages
English (en)
French (fr)
Inventor
良太 塚本
田村 孝之
原田 雅史
Original Assignee
三菱電機株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 三菱電機株式会社 filed Critical 三菱電機株式会社
Priority to PCT/JP2015/065354 priority Critical patent/WO2016189721A1/ja
Publication of WO2016189721A1 publication Critical patent/WO2016189721A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs

Definitions

  • the present invention relates to a technique for evaluating source code, and more particularly to a technique for evaluating equivalence of two source codes.
  • Patent Document 1 As a technique for evaluating the equivalence of two source codes, there are a technique disclosed in Patent Document 1 and a technique disclosed in Patent Document 2.
  • the contents of processing are expressed as a tree structure by analyzing the source code, and when the tree structures of the two source codes match, it is determined that the two source codes are equivalent.
  • symbol execution is performed on two source codes, and when the results of symbol execution of the two source codes match, it is determined that the two source codes are equivalent.
  • Refactoring is a technique for improving maintainability by changing the internal structure of source code without changing the behavior of the program.
  • a common code is often shared with a method (also called a subroutine, a procedure, or a function in some programming languages), and such code sharing involves a change in the tree structure.
  • an equivalent source code may be determined to be unequal.
  • the main object of the present invention is to solve the above-mentioned problems, and when the operations on the elements outside the program are changed, the order of the operations on the elements outside the program in the source code before the change and the source code after the change
  • the main purpose is to accurately evaluate whether or not the order of operations on elements outside the program matches.
  • the source code evaluation apparatus is: From the second source code divided into a plurality of code blocks obtained by changing the first source code divided into a plurality of code blocks, the same code block as any one of the first source codes A code block corresponding to a changed part from the first source code is extracted as a second corresponding range, and the same code block as the second corresponding range is extracted from the first source code.
  • a corresponding range extraction unit that extracts the first corresponding range;
  • a symbol execution unit that performs symbol execution on the first corresponding range and the second corresponding range;
  • a recording unit for recording an identification value for identifying an operation on an element outside the second corresponding range every time an operation on the element outside the second corresponding range appears in the symbol execution of the second corresponding range;
  • a comparison unit that compares the recording order of the identification value in the symbol execution of the first corresponding range by the recording unit and the recording order of the identification value in the symbol execution of the second corresponding range by the recording unit; Have.
  • the changed portion from the first source code that is the source code before the change is extracted as the second corresponding range from the second source code that is the changed source code, and the first corresponding source code is extracted from the first source code.
  • the same code block as the two corresponding ranges is extracted as the first corresponding range.
  • the changed source code when an operation on an element outside the program is changed, the changed part is extracted as the second corresponding range, and the same code block as the second corresponding range is the first code block. Extracted as a corresponding range.
  • each time an operation for an element outside the first corresponding range appears in the symbol execution of the first corresponding range an identification value for identifying the operation for the element outside the first corresponding range is recorded.
  • an identification value for identifying the operation for the element outside the second corresponding range is recorded. Therefore, an identification value is recorded if an operation on an element outside the program appears in the symbol execution of the first corresponding range, and an identification value is recorded if an operation on the element outside the program appears in the second execution of the symbol in the corresponding range.
  • the recording order of the identification values in the symbol execution of the first corresponding range is compared with the recording order of the identification values in the symbol execution of the second corresponding range. Therefore, according to the present invention, it is possible to accurately evaluate whether or not the order of operations on elements outside the program in the source code before change matches the order of operations on elements outside the program in the source code after change. Can do.
  • FIG. 3 is a diagram illustrating a functional configuration example of the source code evaluation device according to the first embodiment.
  • FIG. 6 is a diagram showing a modification example of source code according to the first embodiment.
  • FIG. 6 is a diagram showing an example of a processing flow of a source code equivalence evaluation flow control unit according to the first embodiment.
  • FIG. 4 is a diagram illustrating a processing example of lexical analysis of a lexical / syntax analyzing unit according to the first embodiment.
  • FIG. 6 is a diagram illustrating a processing example of syntax analysis of a lexical / syntax analyzing unit according to the first embodiment. The figure which shows the process example (source code before a change) of the source code structure difference extraction part which concerns on Embodiment 1.
  • FIG. 1 shows the process example (source code before a change) of the source code structure difference extraction part which concerns on Embodiment 1.
  • FIG. 4 is a process flowchart of a duplicate code block extraction unit according to the first embodiment.
  • FIG. FIG. 4 is a diagram illustrating a processing example of a symbol execution unit according to the first embodiment.
  • FIG. 4 is a diagram illustrating a processing example of a symbol execution unit according to the first embodiment.
  • FIG. 3 is a diagram illustrating a processing flowchart of a comparison unit according to the first embodiment.
  • FIG. 3 is a diagram illustrating a hardware configuration example of the source code evaluation device according to the first embodiment.
  • FIG. *** Explanation of configuration *** FIG. 1 shows a functional configuration example of a source code evaluation apparatus 1 according to this embodiment.
  • the source code evaluation apparatus 1 acquires the source code 101 before change and the source code 102 after change, and evaluates equivalence between the source code 101 before change and the source code 102 after change. Then, the source code evaluation device 1 outputs an equivalence evaluation result between the pre-change source code 101 and the post-change source code 102 as a source code equivalence evaluation result list 501.
  • the pre-change source code 101 is a pre-change source code and is divided into a plurality of code blocks.
  • a code block is a group of arbitrary instruction sequences.
  • the pre-change source code 101 corresponds to an example of a first source code.
  • the post-change source code 102 is a source code obtained by changing the pre-change source code 101 by refactoring.
  • the changed source code 102 is also divided into a plurality of code blocks.
  • the post-change source code 102 corresponds to an example of a second source code.
  • the source code equivalence evaluation flow control unit 201 controls an evaluation flow for evaluating equivalence between the source code 101 before change and the source code 102 after change. More specifically, the source code equivalence evaluation flow control unit 201 includes a lexical / syntactic analysis unit 301, a source code structure difference extraction unit 302, a code clone extraction unit 303, a duplicate code block extraction unit 304, and a symbol execution target. The generator 401, the symbol execution unit 402, and the comparison unit 403 are controlled.
  • the corresponding range extraction unit 300 performs lexical analysis and syntax analysis of the source code 101 before change and the source code 102 after change. Then, the corresponding range extraction unit 300 is the same code block as any one of the code blocks of the source code 101 before the change from the source code 102 after the change in which the lexical analysis and the syntax analysis are performed, and the source code 101 before the change
  • the code block corresponding to the changed part is extracted as a second corresponding range.
  • the corresponding range extraction unit 300 extracts the same code block as the second corresponding range as the first corresponding range from the pre-change source code 101 that has been subjected to the lexical analysis and the syntax analysis.
  • the operation of the corresponding range extraction unit 300 corresponds to an example of a corresponding range extraction process.
  • the correspondence range extraction unit 300 includes a lexical / syntax analysis unit 301, a source code structure difference extraction unit 302, a code clone extraction unit 303, and a duplicate code block extraction unit 304. Details of the lexical / syntax analyzing unit 301, the source code structure difference extracting unit 302, the code clone extracting unit 303, and the duplicate code block extracting unit 304 will be described below.
  • the lexical / syntax analyzing unit 301 performs lexical analysis and syntactic analysis of the source code 101 before change and the source code 102 after change.
  • the source code structure difference extraction unit 302 extracts the difference between the source code 101 before change after lexical analysis and syntax analysis and the source code 102 after change after lexical analysis and syntax analysis.
  • the code clone extraction unit 303 extracts a common part between the source code 101 before change after lexical analysis and syntax analysis and the source code 102 after change after lexical analysis and syntax analysis.
  • the duplicate code block extraction unit 304 performs lexical analysis and syntax analysis on the code block in which the changed portion extracted by the source code structure difference extraction unit 302 and the common portion extracted by the code clone extraction unit 303 overlap. Extracted from the source code 102 after the change. Further, the duplicate code block extraction unit 304 extracts the same code block as the code block extracted from the changed source code 102 after lexical analysis and syntax analysis, from the unmodified source code 101 after lexical analysis and syntax analysis. The code block extracted from the pre-change source code 101 after the lexical analysis and syntax analysis by the duplicate code block extraction unit 304 is the first corresponding range.
  • the code block extracted from the changed source code 102 after the lexical analysis and the syntax analysis by the duplicate code block extraction unit 304 is the second corresponding range. Further, the duplicate code block extraction unit 304 extracts the upper code block on which the code block in the first corresponding range depends from the pre-change source code 101 after the lexical analysis and syntax analysis. Further, the duplicate code block extraction unit 304 extracts the upper code block on which the code block in the second corresponding range depends from the changed source code 102 after the lexical analysis and the syntax analysis.
  • the symbol execution target generation unit 401 generates a code block (referred to as a first external operation code block) in which an operation (for example, calling an external method) for an element outside the first corresponding range is described from the first corresponding range. Extract.
  • the symbol execution target generation unit 401 includes a code block (referred to as a second external operation code block) in which an operation (for example, calling an external method) for an element outside the second corresponding range is described from the second corresponding range. ).
  • the symbol execution unit 402 performs symbol execution on the first corresponding range and the upper code block.
  • the symbol execution unit 402 executes symbol execution of the first corresponding range and the upper code blocks until symbol execution of all the first external operation code blocks is performed.
  • the symbol execution unit 402 executes symbol execution on the second corresponding range and the upper code block.
  • the symbol execution unit 402 executes symbol execution of the second corresponding range and the upper code block until symbol execution of all the second external operation code blocks is performed.
  • the operation of the symbol execution unit 402 corresponds to an example of symbol execution processing.
  • the recording unit 404 records an element outside the first corresponding range every time an operation is performed on the element outside the first corresponding range in the symbol execution of the first corresponding range (a first external operation code block appears).
  • the identification value for identifying the operation for is recorded. If the operation on the element outside the first corresponding range is an external method call, the recording unit 404 records an argument used for calling the external method (code outside the first corresponding range) as an identification value. Further, the recording unit 404 records a return value in the symbol execution of the first corresponding range.
  • the recording unit 404 is outside the second corresponding range every time an operation on an element outside the second corresponding range appears in the symbol execution of the second corresponding range (a second external operation code block appears). An identification value for identifying an operation on the element is recorded.
  • the recording unit 404 records an argument used for calling the external method (code outside the second corresponding range) as an identification value. Further, the recording unit 404 records the return value in the symbol execution of the second corresponding range.
  • the operation of the recording unit 404 corresponds to an example of recording processing.
  • the comparison unit 403 compares the recording order of the identification values in the symbol execution of the first corresponding range by the recording unit 404 with the recording order of the identification values in the symbol execution of the second corresponding range by the recording unit 404. Further, the comparison unit 403 compares the return value of the first corresponding range in the symbol execution recorded by the recording unit 404 with the return value of the second corresponding range in the symbol execution.
  • the comparison unit 403 compares the comparison result of the recording order of the identification value in the symbol execution of the first corresponding range and the recording order of the identification value in the symbol execution of the second corresponding range, and the first correspondence range
  • a source code equivalence evaluation result list 501 is generated that shows a comparison result between a return value in symbol execution and a return value in symbol execution in the second corresponding range.
  • the comparison unit 403 outputs a source code equivalence evaluation result list 501.
  • the operation of the comparison unit 403 corresponds to an example of comparison processing.
  • FIG. 2 shows an example of the source code 101 before change and the source code 102 after change.
  • FIG. 2 shows a source code 101 before change and a source code 102 after change of a certain source code (project-a / src1.xxx).
  • the pre-change source code 101 includes a func1 method and a func2 method.
  • the code for argument check is described in duplicate in each method.
  • the code for argument check is separated into the func3 method and the func4 method, and the func1 method and the func2 method are changed so as to call the func3 method and the func4 method.
  • FIG. 3 shows a processing flow of the source code equivalence evaluation flow control unit 201.
  • the source code equivalence evaluation flow control unit 201 transfers the pre-change source code 101 and the post-change source code 102 to the lexical / syntax analysis unit 301.
  • the source code equivalence evaluation flow control unit 201 acquires the source code before change (normalization) 202 and the source code after change (normalization) 203 from the lexical / syntax analysis unit 301.
  • the pre-change source code (normalization) 202 is the pre-change source code 101 after lexical analysis and syntax analysis by the lexical / syntax analysis unit 301.
  • the changed source code (normalization) 203 is the changed source code 102 after lexical analysis and syntactic analysis by the lexical / syntax analyzing unit 301.
  • the source code equivalence evaluation flow control unit 201 transfers the pre-change source code (normalization) 202 and the post-change source code (normalization) 203 to the source code structure difference extraction unit 302.
  • the source code equivalence evaluation flow control unit 201 acquires the source code structure difference extraction result 204 from the source code structure difference extraction unit 302.
  • the source code structure difference extraction result 204 is a difference between the source code before change (normalization) 202 and the source code after change (normalization) 203.
  • the source code equivalence evaluation flow control unit 201 transfers the pre-change source code (normalization) 202 and the post-change source code (normalization) 203 to the code clone extraction unit 303. Then, the source code equivalence evaluation flow control unit 201 acquires the code clone extraction result 205 from the code clone extraction unit 303.
  • the code clone extraction result 205 is a common part between the pre-change source code (normalized) 202 and the post-change source code (normalized) 203.
  • the source code equivalence evaluation flow control unit 201 duplicates the pre-change source code (normalization) 202, the post-change source code (normalization) 203, the source code structure difference extraction result 204, and the code clone extraction result 205. Transfer to the block extraction unit 304. Then, the source code equivalence evaluation flow control unit 201 acquires the source code before change (overlapping range) 206 and the source code after change (overlapping range) 207 from the duplicate code block extraction unit 304.
  • the pre-change source code (overlapping range) 206 is composed of a duplicate code block (first corresponding range) in the pre-change source code (normalization) 202 and an upper code block.
  • the after-change source code (overlapping range) 207 is composed of an overlapping code block (second corresponding range) in the after-change source code (normalization) 203 and an upper code block.
  • the source code equivalence evaluation flow control unit 201 acquires the source code before change (symbol execution target) 208 and the source code after change (symbol execution target) 209 from the symbol execution target generation unit 401.
  • the pre-change source code (symbol execution target) 208 information specifying the first external operation code block is added to the pre-change source code (overlapping range) 206.
  • the changed source code (symbol execution target) 209 information for specifying the second external operation code block is added to the changed source code (overlapping range) 207.
  • the source code equivalence evaluation flow control unit 201 transfers the pre-change source code (symbol execution target) 208 and the post-change source code (symbol execution target) 209 to the symbol execution unit 402. Then, the source code equivalence evaluation flow control unit 201 acquires a symbol execution result (before change) 210 and a symbol execution result (after change) 211 from the symbol execution unit 402.
  • the symbol execution result (before change) 210 shows the result of the symbol execution for the source code before change (symbol execution target) 208 in the symbol execution unit 402.
  • the symbol execution result (before change) 210 shows the content recorded by the recording unit 404 in the symbol execution for the source code (target for symbol execution) 208 before change in the symbol execution unit 402.
  • the symbol execution result (after change) 211 indicates the result of the symbol execution for the source code after change (symbol execution target) 209 in the symbol execution unit 402. More specifically, the symbol execution result (after change) 211 shows the contents recorded by the recording unit 404 in the symbol execution for the source code (symbol execution target) 209 after change by the symbol execution unit 402.
  • the source code equivalence evaluation flow control unit 201 transfers the symbol execution result (before change) 210 and the symbol execution result (after change) 211 to the comparison unit 403.
  • the source code equivalence evaluation flow control unit 201 acquires the source code equivalence evaluation result list 501 from the comparison unit 403. Then, the source code equivalence evaluation flow control unit 201 presents the source code equivalence evaluation result list 501 to the user of the source code evaluation apparatus 1.
  • FIG. 4 and 5 show an operation example of the lexical / syntax analyzing unit 301.
  • FIG. FIG. 4 shows a processing example of lexical analysis of the lexical / syntax analyzing unit 301.
  • FIG. 5 shows an example of parsing processing performed by the lexical / syntax analyzing unit 301.
  • the lexical / syntax analyzing unit 301 performs lexical analysis and syntax analysis of the source code to analyze the structure of the source code. Lexical analysis is processing that analyzes the sequence of characters in the source code and breaks down the source code into the smallest meaningful units.
  • FIG. 4 shows a processing example of the lexical analysis of the first line of the source code 101 before change.
  • the first int is a method definition return value
  • the next func1 is a method definition identifier
  • the source code is broken down into the smallest meaningful units.
  • the decomposed minimum unit includes information on the original character string (for example, int), position (for example, the first character in the first line of project-a / src1.xxx), and type (for example, method definition return value type). It is.
  • Parsing is a process of interpreting the result of lexical analysis and structuring the source code into a tree structure.
  • FIG. 5 shows an example of processing for parsing the source code 101 before change.
  • the lexical / syntax analyzing unit 301 outputs the pre-change source code (normalization) 202 as a result of the lexical analysis and the syntax analysis for the pre-change source code 101. Further, the lexical / syntax analyzing unit 301 outputs the changed source code (normalized) 203 as a result of the lexical analysis and the syntax analysis for the changed source code 102.
  • Reference Document 1 A specific method of lexical analysis and syntax analysis is disclosed in Reference Document 1, for example.
  • the lexical / syntax analyzing unit 301 is realized by a method disclosed in Reference 1, for example. Reference 1: ANTLR (http://www.antlr.org/)
  • FIG. 6 and 7 show processing examples of the source code structure difference extraction unit 302.
  • FIG. 6 shows a source code (before normalization) 202 before change which is the source code 101 before change after lexical analysis and syntax analysis.
  • FIG. 7 shows the changed source code (normalized) 203 which is the changed source code 102 after lexical analysis and syntax analysis.
  • a code block surrounded by a thick frame is a difference between the source code before change (normalization) 202 and the source code after change (normalization) 203, and corresponds to the source code structure difference extraction result 204. .
  • the source code structure difference extraction unit 302 compares the source code before change (normalization) 202 and the source code after change (normalization) 203, and from the source code after change (normalization) 203, the source code before change (normal) The change part from 202 is extracted.
  • the source code structure difference extraction unit 302 refers to the type information obtained by the lexical and syntax analysis unit 301 and compares the source code before change (normalization) 202 and the source code after change (normalization) 203. .
  • FIG. 8 and 9 show a processing example of the code clone extraction unit 303.
  • FIG. FIG. 8 shows an unmodified source code (normalized) 202 which is the unmodified source code 101 after lexical analysis and syntax analysis.
  • FIG. 9 shows the changed source code (normalized) 203 which is the changed source code 102 after lexical analysis and syntax analysis.
  • code blocks (Clone1, Clone2, Clone3, and Clone4) surrounded by a thick frame of broken lines and solid lines are pre-change source code (normalized) 202 and post-change source code (normalized) 203. And corresponds to the code clone extraction result 205.
  • the code clone extraction unit 303 compares the source code before change (normalization) 202 with the source code after change (normalization) 203, and the source code before change (normalization) 202 and the source code after change (normalization) 203. Code blocks that are common to both are extracted.
  • the code clone extraction unit 303 refers to the type information obtained by the lexical / syntax analysis unit 301 and compares the source code before change (normalization) 202 with the source code after change (normalization) 203. Unlike the comparison in the source code structure difference extraction unit 302, the code clone extraction unit 303 performs comparison between code blocks belonging to different tree structures.
  • a pair of Clone 1 belongs to different tree structures in the source code (normalization) 202 before change and the source code (normalization) 203 after change.
  • a specific method of code clone extraction is disclosed in Reference Document 2, for example.
  • the code clone extraction unit 303 is realized by the method disclosed in Reference Document 2, for example.
  • FIG. 10 is a flowchart showing an operation example of the duplicate code block extraction unit 304.
  • the duplicate code block extraction unit 304 extracts a code block in which the source code structure difference extraction result 204 and the code clone extraction result 205 overlap from the changed source code (normalization) 203 (S0101).
  • the code block extracted in S001 corresponds to the second corresponding range.
  • the code block “Call print (msg)” and “throw Call error (msg)” at the bottom are extracted.
  • the duplicate code block extraction unit 304 extracts a code block corresponding to the code block extracted in S0101 from the pre-change source code (normalization) 202 (S0102).
  • the code block extracted in S002 corresponds to the first corresponding range.
  • the code block “Call print (msg)” and “throw Call error (msg)” are extracted in S001, the code block “Call print (msg)” is obtained from the source code (normalization) 202 before change in FIG. And “throw Call error (msg)” are extracted.
  • the duplicate code block extraction unit 304 derives the dependency relationship between the code block (second correspondence range) extracted in S0101 and the dependency relationship between the code block (first correspondence range) extracted in S0102 (S0103). ). That is, the duplicate code block extraction unit 304 sequentially extracts the code blocks of the upper layer in the tree structure of the code block extracted in S0101 on the changed source code (normalization) 203. In addition, the duplicate code block extraction unit 304 sequentially extracts the code blocks in the upper hierarchy in the tree structure of the code block extracted in S0102 on the source code (normalization) 202 before the change. Note that the duplicate code block extraction unit 304 refers to the type information (method call or the like) to derive the code block dependency.
  • the duplicate code block extraction unit 304 starts the processing from the source code (normalization) 202 and the source code (normalization) 203 after the change based on the dependency derived in S0103.
  • a block is extracted (S0104). That is, the duplicate code block extraction unit 304 extracts the starting point code block that is the starting point of the processing described in the first corresponding range by the source code (normalization) 202 before the change. Further, the duplicate code block extraction unit 304 extracts the source code block that is the starting point of the processing described in the second corresponding range by using the changed source code (normalization) 203.
  • the duplicate code block extraction unit 304 outputs the code blocks extracted in S0101 to S0104 as the pre-change source code (overlap range) 206 and the post-change source code (overlap range) 207 (S0105). That is, the duplicate code block extraction unit 304 calculates the code block (first corresponding range) extracted in S0102 and the upper code block extracted in S0103 and S0104 for the code block (first corresponding range). The source code before change (overlapping range) 206 is output. In addition, the duplicate code block extraction unit 304 obtains the code block (second correspondence range) extracted in S0101 and the upper code block extracted in S0103 and S0104 with respect to the code block (second correspondence range). , And output as changed source code (overlapping range) 207.
  • FIG. 11 is a flowchart showing an operation example of the symbol execution target generation unit 401.
  • the symbol execution target generation unit 401 corresponds to the code block group extracted by the duplicate code block extraction unit 304 in the pre-change source code (normalization) 202 and the post-change source code (normalization) 203.
  • a code block group is extracted (S0201). That is, the symbol execution target generation unit 401 extracts a code block group corresponding to the pre-change source code (overlapping range) 206 in the pre-change source code (normalization) 202. Further, the symbol execution target generation unit 401 extracts a code block group corresponding to the changed source code (overlapping range) 207 in the changed source code (normalization) 203.
  • the symbol execution target generation unit 401 extracts an external operation code block from the code block group extracted in S0201 (S0202). That is, the symbol execution target generation unit 401 includes a first external operation code block in which an operation (for example, method call) for an element outside the first execution target range is described in the pre-change source code (normalization) 202. Extract. In addition, the symbol execution target generation unit 401 includes a second external operation code block in which an operation (for example, a method call) for an element outside the second execution target range is described in the changed source code (normalization) 203. Extract.
  • the symbol execution target generation unit 401 adds information specifying the first external operation code block to the source code (overlapping range) 206 before change, and generates a source code (symbol execution target) 208 before change. In addition, the symbol execution target generation unit 401 adds information specifying the second external operation code block to the changed source code (overlapping range) 207 to generate the changed source code (symbol execution target) 209.
  • FIG. 12 and 13 show processing examples of the symbol execution unit 402.
  • FIG. 12 and 13 show processing examples of the symbol execution unit 402.
  • FIG. 12 shows an outline of symbol execution processing.
  • Symbol execution is a process of computing the input to a program as a symbol instead of a specific value according to the description of the source code.
  • the symbol execution unit 402 executes symbol execution for all code blocks included in each of the source code before change (symbol execution target) 208 and the source code after change (symbol execution target) 209. However, in the symbol execution of the external operation code block (the first external operation code block and the second external operation code block) extracted by the symbol execution target generation unit 401, the symbol execution unit 402 performs an operation on an external element.
  • An identification value for example, method call argument
  • symbol execution of an operation for example, method call
  • FIG. 13 shows a processing example of the symbol execution unit 402 for the source code before change (symbol execution target) 208 and the source code after change (symbol execution target) 209.
  • the code block indicated by reference numeral 2090 in the changed source code (symbol execution target) 209 corresponds to a second external operation code block.
  • the recording unit 404 sequentially records the result of symbol execution for the source code (symbol execution target) 208 before the change, and sequentially records the result of symbol execution for the source code (symbol execution target) 209 after the change.
  • the recording unit 404 also records the return value of the pre-change source code (symbol execution target) 208 (corresponding to “return y” and “return z + 1” in FIG. 2).
  • the recording unit 404 also records the return value of the changed source code (symbol execution target) 209 (corresponding to “return y” and “return z + 1” in FIG. 2).
  • the symbol execution unit 402 sends the symbol execution result of each source code recorded in the recording unit 404 to the source code equivalence evaluation flow control unit 201 as a symbol execution result (before change) 210 and a symbol execution result (after change) 211. Output.
  • the symbol execution result (before change) 210 identification values (external method call arguments) in the first external operation code are described in the order of appearance of the first external operation code, and the source code before change (symbol execution target) 208 The return value of is described.
  • the symbol execution result (after change) 211 describes the identification value (external method call argument) in the second external operation code in the order of appearance of the second external operation code, and the changed source code (symbol execution target) ) A return value of 209 is described.
  • FIG. 14 is a flowchart illustrating an operation example of the comparison unit 403.
  • the comparison unit 403 compares the symbol execution result (before change) 210 with the symbol execution result (after change) 211 (S0301). More specifically, the comparison unit 403 describes the order of identification values (external method call arguments) described in the symbol execution result (before change) 210 and the symbol execution result (after change) 211. Compare the order of identification values (external method call arguments). Also, the comparison unit 403 compares the return value described in the symbol execution result (before change) 210 with the return value described in the symbol execution result (after change) 211.
  • the comparison unit 403 describes the order of identification values (external method call arguments) described in the symbol execution result (before change) 210 and the symbol execution result (after change) 211.
  • the order of the identification values (call arguments of the external method) matches, and the return value described in the symbol execution result (before change) 210 and the return value described in the symbol execution result (after change) 211 are When they match, it is evaluated that the source code 101 before change and the source code 102 after change are equivalent.
  • the comparison unit 403 evaluates that the source code 101 before change and the source code 102 after change are unequal.
  • the comparison unit 403 outputs a source code equivalence evaluation result list 501 in which the comparison results of all the code blocks obtained in S0301 and the evaluation results of equivalence obtained in S0302 are indicated (S0303). .
  • the difference between the source code before the change and the source code after the change and the overlapping range of the common part of the source code before the change and the source code after the change are changed from the source code before the change. Extract after each source code. Then, symbol execution is performed for each of the overlapping range of the source code before the change and the overlapping range of the source code after the change. Further, identification values such as calling arguments outside the overlapping range are recorded in order, and the recording order of identifiers in the source code before change is compared with the recording order of identifiers in the source code after change.
  • the order of the operations on the elements outside the program in the source code before change and the program in the source code after change It is possible to accurately evaluate whether or not the order of operations with respect to the outside elements matches.
  • the equivalence is evaluated after associating the overlapping range of the source code before the change with the overlapping range of the source code after the change, and the evaluation result is output. For this reason, the part which is not equivalent between the source code before change and the source code after change can be specified easily.
  • symbol execution is performed only in the overlapping range of the difference between the source code before the change and the source code after the change, and the common part of the source code before the change and the source code after the change. For this reason, according to this Embodiment, calculation load can be suppressed.
  • the source code is converted into a format independent of the programming language by normalizing the source code by lexical analysis and syntax analysis. For this reason, according to the present embodiment, even if the source code before change and the source code after change are created in different programming languages, the equivalence between the source code before change and the source code after change can be evaluated. .
  • the source code evaluation apparatus 1 is a computer.
  • the source code evaluation device 1 includes hardware such as a processor 901, an auxiliary storage device 902, a memory 903, a communication device 904, an input interface 905, and a display interface 906.
  • the processor 901 is connected to other hardware via the signal line 910, and controls these other hardware.
  • the input interface 905 is connected to the input device 907.
  • the display interface 906 is connected to the display 908.
  • the processor 901 is an IC (Integrated Circuit) that performs processing.
  • the processor 901 is, for example, a CPU (Central Processing Unit), a DSP (Digital Signal Processor), or a GPU (Graphics Processing Unit).
  • the auxiliary storage device 902 is, for example, a ROM (Read Only Memory), a flash memory, or an HDD (Hard Disk Drive).
  • the memory 903 is, for example, a RAM (Random Access Memory).
  • the recording unit 404 illustrated in FIG. 1 is realized by the auxiliary storage device 902 or the memory 903.
  • the communication device 904 includes a receiver 9041 that receives data and a transmitter 9042 that transmits data.
  • the communication device 904 is, for example, a communication chip or a NIC (Network Interface Card).
  • the input interface 905 is a port to which the cable 911 of the input device 907 is connected.
  • the input interface 905 is, for example, a USB (Universal Serial Bus) terminal.
  • the display interface 906 is a port to which the cable 912 of the display 908 is connected.
  • the display interface 906 is, for example, a USB terminal or an HDMI (registered trademark) (High Definition Multimedia Interface) terminal.
  • the input device 907 is, for example, a mouse, a keyboard, or a touch panel.
  • the display 908 is, for example, an LCD (Liquid Crystal Display).
  • the auxiliary storage device 902 includes a source code equivalence evaluation flow control unit 201, a lexical / syntax analysis unit 301, a source code structure difference extraction unit 302, a code clone extraction unit 303, a duplicate code block extraction unit 304, a symbol Execution target generation unit 401, symbol execution unit 402, comparison unit 403 (hereinafter, source code equivalence evaluation flow control unit 201, lexical / syntax analysis unit 301, source code structure difference extraction unit 302, code clone extraction unit 303, duplicate code
  • a program for realizing the function of the block extraction unit 304, the symbol execution target generation unit 401, the symbol execution unit 402, and the comparison unit 403 is collectively referred to as “unit”) is stored.
  • This program is loaded into the memory 903, read into the processor 901, and executed by the processor 901. Further, the auxiliary storage device 902 also stores an OS (Operating System). Then, at least a part of the OS is loaded into the memory 903, and the processor 901 executes a program that realizes the function of “unit” while executing the OS.
  • the source code evaluation apparatus 1 may include a plurality of processors 901. A plurality of processors 901 may execute a program for realizing the function of “unit” in cooperation with each other.
  • information, data, signal values, and variable values indicating the processing results of “unit” are stored in the memory 903, the auxiliary storage device 902, or a register or cache memory in the processor 901.
  • circuitry may be provided as “circuitry”. Further, “part” may be read as “circuit”, “process”, “procedure”, or “processing”. “Circuit” and “Circuitry” include not only the processor 901 but also other types of processing circuits such as a logic IC or GA (Gate Array) or ASIC (Application Specific Integrated Circuit) or FPGA (Field-Programmable Gate Array). It is a concept to include.
  • GA Gate Array
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • 1 source code evaluation device 101 source code before change, 102 source code after change, 201 source code equivalence evaluation flow control unit, 202 source code before change (normalization), 203 source code after change (normalization), 204 source Code structure difference extraction result, 205 code clone extraction result, 206 source code before change (overlapping range), 207 source code after change (overlapping range), 208 source code before change (symbol execution target), 209 source code after change (symbol) Execution target), 210 symbol execution result (before change), 211 symbol execution result (after change), 300 corresponding range extraction unit, 301 lexical / syntax analysis unit, 302 source code structure difference extraction unit, 303 code clone extraction unit, 304 Duplicate code block extraction unit, 401 Execution object generation unit, 402 symbols execution unit, 403 comparison unit, 404 recording unit, a list 501 source code equality evaluation results.

Abstract

対応範囲抽出部(300)は、変更後ソースコード(102)から、変更前ソースコード(101)のいずれかのコードブロックと同一のコードブロックであって変更前ソースコードからの変更部分に該当するコードブロックを第2の対応範囲として抽出し、変更前ソースコードから、第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出する。記号実行部(402)は、第1の対応範囲と第2の対応範囲に記号実行を行う。記録部(404)は、第1の対応範囲の記号実行で第1の対応範囲外の要素への操作が出現すると、第1の対応範囲外の要素への操作の識別値を記録し、第2の対応範囲の記号実行で第2の対応範囲外の要素への操作が出現すると、第2の対応範囲外の要素への操作の識別値を記録する。比較部(403)は、第1の対応範囲の記号実行での識別値の記録順序と第2の対応範囲の記号実行での識別値の記録順序とを比較する。

Description

ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム
 本発明は、ソースコードを評価する技術に関し、特に2つのソースコードの等価性を評価する技術に関する。
 2つのソースコードの等価性を評価する技術として、特許文献1に開示の技術と特許文献2に開示の技術がある。
 特許文献1の技術では、ソースコードを解析して処理の内容を木構造として表現し、2つのソースコードの木構造が一致する場合に、2つのソースコードが等価であると判定する。
 また、特許文献2の技術では、2つのソースコードに記号実行を行い、2つのソースコードの記号実行の結果が一致する場合に、2つのソースコードが等価であると判定する。
特開平10-63536号公報 特開2014-126985号公報
 リファクタリングは、プログラムの振る舞いを変えずにソースコードの内部構造を変更し、保守性などを改善する手法である。
 変更前ソースコードと、リファクタリングによる変更後ソースコードの等価性を評価する場合に、特許文献1による木構造の比較では、等価な2つのソースコードでも多くの場合に不等価と判定されるという課題がある。
 リファクタリングでは、共通するコードをメソッド(プログラム言語によってはサブルーチン、プロシージャ、関数ともいう)に共通化する作業が多く、このようなコードの共通化は木構造の変更を伴うため、特許文献1による木構造の比較では、等価なソースコードも不等価と判断されることがある。
 特許文献2による記号実行の結果での評価では、リファクタリングにより木構造が変更になる場合でも、等価な2つのソースコードを等価と評価することができる。
 一方で、特許文献2の方法では、2つのソースコードにそれぞれ、プログラム外の要素に対する操作(例えば、データベースからのデータの読出し又はデータベースへのデータの書き込み)が複数含まれている場合に、2つのソースコードの間で、プログラム外の要素に対する操作の順序が一致するか否かを正確に評価できないという課題がある。
 つまり、変更前ソースコードにおけるプログラム外の要素に対する操作の順序と変更後ソースコードにおけるプログラム外の要素に対する操作の順序とが一致しない場合は、変更前ソースコードと変更後ソースコードは不等価と判定されることが望ましいが、特許文献2の方法では、変更前ソースコードと変更後ソースコードとが等価と判定されてしまう。
 本発明は、上記の課題を解決することを主な目的とし、プログラム外の要素に対する操作が変更されている場合に、変更前ソースコードにおけるプログラム外の要素に対する操作の順序と、変更後ソースコードにおけるプログラム外の要素に対する操作の順序とが一致するか否かを正確に評価することを主な目的とする。
 本発明に係るソースコード評価装置は、
 複数のコードブロックに分割される第1のソースコードが変更されて得られた複数のコードブロックに分割される第2のソースコードから、前記第1のソースコードのいずれかのコードブロックと同一のコードブロックであって前記第1のソースコードからの変更部分に該当するコードブロックを第2の対応範囲として抽出し、前記第1のソースコードから、前記第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出する対応範囲抽出部と、
 前記第1の対応範囲と前記第2の対応範囲とに記号実行を行う記号実行部と、
 前記第1の対応範囲の記号実行で前記第1の対応範囲外の要素に対する操作が出現する度に、前記第1の対応範囲外の要素に対する操作を識別するための識別値を記録し、前記第2の対応範囲の記号実行で前記第2の対応範囲外の要素に対する操作が出現する度に、前記第2の対応範囲外の要素に対する操作を識別するための識別値を記録する記録部と、
 前記記録部による前記第1の対応範囲の記号実行での識別値の記録順序と、前記記録部による前記第2の対応範囲の記号実行での識別値の記録順序とを比較する比較部とを有する。
 本発明では、変更後ソースコードである第2のソースコードから、変更前ソースコードである第1のソースコードからの変更部分が第2の対応範囲として抽出され、第1のソースコードから、第2の対応範囲と同一のコードブロックが第1の対応範囲として抽出される。
 このため、変更後ソースコードにおいて、プログラム外の要素に対する操作が変更されている場合は、当該変更部分が第2の対応範囲として抽出され、第2の対応範囲と同一のコードブロックが第1の対応範囲として抽出される。
 また、本発明では、第1の対応範囲の記号実行で第1の対応範囲外の要素に対する操作が出現する度に、第1の対応範囲外の要素に対する操作を識別するための識別値を記録し、第2の対応範囲の記号実行で第2の対応範囲外の要素に対する操作が出現する度に、第2の対応範囲外の要素に対する操作を識別するための識別値を記録する。
 このため、第1の対応範囲の記号実行でプログラム外の要素に対する操作が出現すれば識別値が記録され、第2の対応範囲の記号実行でプログラム外の要素に対する操作が出現すれば識別値が記録される。
 そして、本発明では、第1の対応範囲の記号実行での識別値の記録順序と、第2の対応範囲の記号実行での識別値の記録順序とを比較する。
 このため、本発明によれば、変更前ソースコードにおけるプログラム外の要素に対する操作の順序と、変更後ソースコードにおけるプログラム外の要素に対する操作の順序とが一致するか否かを正確に評価することができる。
実施の形態1に係るソースコード評価装置の機能構成例を示す図。 実施の形態1に係るソースコードの変更例を示す図。 実施の形態1に係るソースコード等価性評価フロー制御部の処理フローの例を示す図。 実施の形態1に係る字句・構文解析部の字句解析の処理例を示す図。 実施の形態1に係る字句・構文解析部の構文解析の処理例を示す図。 実施の形態1に係るソースコード構造差分抽出部の処理例(変更前ソースコード)を示す図。 実施の形態1に係るソースコード構造差分抽出部の処理例(変更後ソースコード)を示す図。 実施の形態1に係るコードクローン抽出部の処理例(変更前ソースコード)を示す図。 実施の形態1に係るコードクローン抽出部の処理例(変更後ソースコード)を示す図。 実施の形態1に係る重複コードブロック抽出部の処理フローチャートを示す図。 実施の形態1に係る記号実行対象生成部の処理フローチャートを示す図。 実施の形態1に係る記号実行部の処理例を示す図。 実施の形態1に係る記号実行部の処理例を示す図。 実施の形態1に係る比較部の処理フローチャートを示す図。 実施の形態1に係るソースコード評価装置のハードウェア構成例を示す図。
 実施の形態1.
***構成の説明***
 図1は、本実施の形態に係るソースコード評価装置1の機能構成例を示す。
 ソースコード評価装置1は、変更前ソースコード101と変更後ソースコード102を取得し、変更前ソースコード101と変更後ソースコード102との等価性を評価する。
 そして、ソースコード評価装置1は、変更前ソースコード101と変更後ソースコード102との等価性の評価結果をソースコード等価性評価結果一覧501として出力する。
 変更前ソースコード101は、変更前のソースコードであり、複数のコードブロックに分割される。
 コードブロックは、任意の命令列のまとまりである。
 変更前ソースコード101は、第1のソースコードの例に相当する。
 変更後ソースコード102は、リファクタリングにより、変更前ソースコード101が変更されて得られたソースコードである。
 変更後ソースコード102も、複数のコードブロックに分割される。
 変更後ソースコード102は、第2のソースコードの例に相当する。
 ソースコード等価性評価フロー制御部201は、変更前ソースコード101と変更後ソースコード102との等価性を評価するための評価フローを制御する。
 より具体的には、ソースコード等価性評価フロー制御部201は、後述する字句・構文解析部301、ソースコード構造差分抽出部302、コードクローン抽出部303、重複コードブロック抽出部304、記号実行対象生成部401、記号実行部402及び比較部403を制御する。
 対応範囲抽出部300は、変更前ソースコード101及び変更後ソースコード102の字句解析及び構文解析を行う。
 そして、対応範囲抽出部300は、字句解析及び構文解析が行われた変更後ソースコード102から、変更前ソースコード101のいずれかのコードブロックと同一のコードブロックであって、変更前ソースコード101からの変更部分に該当するコードブロックを第2の対応範囲として抽出する。
 また、対応範囲抽出部300は、字句解析及び構文解析が行われた変更前ソースコード101から、第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出する。
 対応範囲抽出部300の動作は、対応範囲抽出処理の例に相当する。
 対応範囲抽出部300は、図1に示すように、字句・構文解析部301、ソースコード構造差分抽出部302、コードクローン抽出部303及び重複コードブロック抽出部304で構成される。
 以下にて、字句・構文解析部301、ソースコード構造差分抽出部302、コードクローン抽出部303及び重複コードブロック抽出部304の詳細を説明する。
 字句・構文解析部301は、変更前ソースコード101及び変更後ソースコード102の字句解析及び構文解析を行う。
 ソースコード構造差分抽出部302は、字句解析及び構文解析後の変更前ソースコード101と、字句解析及び構文解析後の変更後ソースコード102との差分を抽出する。
 コードクローン抽出部303は、字句解析及び構文解析後の変更前ソースコード101と、字句解析及び構文解析後の変更後ソースコード102との共通部分を抽出する。
 重複コードブロック抽出部304は、ソースコード構造差分抽出部302で抽出された変更部分と、コードクローン抽出部303で抽出された共通部分とが重複しているコードブロックを、字句解析及び構文解析後の変更後ソースコード102から抽出する。
 更に、重複コードブロック抽出部304は、字句解析及び構文解析後の変更後ソースコード102から抽出したコードブロックと同一のコードブロックを、字句解析及び構文解析後の変更前ソースコード101から抽出する。
 重複コードブロック抽出部304により、字句解析及び構文解析後の変更前ソースコード101から抽出されたコードブロックは、第1の対応範囲である。
 重複コードブロック抽出部304により、字句解析及び構文解析後の変更後ソースコード102から抽出されたコードブロックは、第2の対応範囲である。
 更に、重複コードブロック抽出部304は、第1の対応範囲のコードブロックが依存している上位のコードブロックを、字句解析及び構文解析後の変更前ソースコード101から抽出する。
 また、重複コードブロック抽出部304は、第2の対応範囲のコードブロックが依存している上位のコードブロックを、字句解析及び構文解析後の変更後ソースコード102から抽出する。
 記号実行対象生成部401は、第1の対応範囲から、第1の対応範囲外の要素に対する操作(例えば、外部メソッドの呼び出し)が記述されるコードブロック(第1の外部操作コードブロックという)を抽出する。
 また、記号実行対象生成部401は、第2の対応範囲から、第2の対応範囲外の要素に対する操作(例えば、外部メソッドの呼び出し)が記述されるコードブロック(第2の外部操作コードブロックという)を抽出する。
 記号実行部402は、第1の対応範囲及び上位のコードブロックに記号実行を行う。
 記号実行部402は、全ての第1の外部操作コードブロックの記号実行が行われるまで、第1の対応範囲及び上位のコードブロックの記号実行を行う。
 また、記号実行部402は、第2の対応範囲及び上位のコードブロックに記号実行を行う。
 記号実行部402は、全ての第2の外部操作コードブロックの記号実行が行われるまで、第2の対応範囲及び上位のコードブロックの記号実行を行う。
 記号実行部402の操作は、記号実行処理の例に相当する。
 記録部404は、第1の対応範囲の記号実行で第1の対応範囲外の要素に対する操作が出現する(第1の外部操作コードブロックが出現する)度に、第1の対応範囲外の要素に対する操作を識別するための識別値を記録する。
 第1の対応範囲外の要素に対する操作が外部メソッドの呼び出しであれば、記録部404は、外部メソッド(第1の対応範囲外のコード)の呼び出しに用いる引数を、識別値として記録する。
 更に、記録部404は、第1の対応範囲の記号実行での戻り値を記録する。
 また、記録部404は、第2の対応範囲の記号実行で第2の対応範囲外の要素に対する操作が出現する(第2の外部操作コードブロックが出現する)度に、第2の対応範囲外の要素に対する操作を識別するための識別値を記録する。
 第2の対応範囲外の要素に対する操作が外部メソッドの呼び出しであれば、記録部404は、外部メソッド(第2の対応範囲外のコード)の呼び出しに用いる引数を、識別値として記録する。
 更に、記録部404は、第2の対応範囲の記号実行での戻り値を記録する。
 記録部404の動作は、記録処理の例に相当する。
 比較部403は、記録部404による第1の対応範囲の記号実行での識別値の記録順序と、記録部404による第2の対応範囲の記号実行での識別値の記録順序とを比較する。
 また、比較部403は、記録部404により記録された、第1の対応範囲の記号実行での戻り値と、第2の対応範囲の記号実行での戻り値とを比較する。
 そして、比較部403は、第1の対応範囲の記号実行での識別値の記録順序と第2の対応範囲の記号実行での識別値の記録順序との比較結果と、第1の対応範囲の記号実行での戻り値と第2の対応範囲の記号実行での戻り値との比較結果とが示されるソースコード等価性評価結果一覧501を生成する。
 そして、比較部403は、ソースコード等価性評価結果一覧501を出力する。
 比較部403の動作は、比較処理の例に相当する。
***動作の説明***
 次に、本実施の形態に係るソースコード評価装置1の動作例を説明する。
 以下で説明するソースコード評価装置1の動作例は、ソースコード評価方法及びソースコード評価プログラムでの処理例に相当する。
 図2は、変更前ソースコード101と変更後ソースコード102の例を示す。
 図2では、あるソースコード(project-a/src1.xxx)の変更前ソースコード101と変更後ソースコード102を示している。
 変更前ソースコード101は、func1メソッド、func2メソッドで構成されている。
 変更前ソースコード101では、符号1010で示すように、各メソッドにおいて、引数チェックためのコードが重複して記述されている。
 変更後ソースコード102では、引数チェックのためのコードをfunc3メソッドとfunc4メソッドに分離し、func1メソッドとfunc2メソッドがfunc3メソッドとfunc4メソッドを呼び出すように変更している。
 図3は、ソースコード等価性評価フロー制御部201の処理フローを示す。
 まず、ソースコード等価性評価フロー制御部201は、変更前ソースコード101と変更後ソースコード102を字句・構文解析部301に転送する。
 そして、ソースコード等価性評価フロー制御部201は、字句・構文解析部301から変更前ソースコード(正規化)202と変更後ソースコード(正規化)203を取得する。
 変更前ソースコード(正規化)202は、字句・構文解析部301による字句解析及び構文解析後の変更前ソースコード101である。
 変更後ソースコード(正規化)203は、字句・構文解析部301による字句解析及び構文解析後の変更後ソースコード102である。
 次に、ソースコード等価性評価フロー制御部201は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203をソースコード構造差分抽出部302に転送する。
 そして、ソースコード等価性評価フロー制御部201は、ソースコード構造差分抽出部302からソースコード構造差分抽出結果204を取得する。
 ソースコード構造差分抽出結果204は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203との差分である。
 次に、ソースコード等価性評価フロー制御部201は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203をコードクローン抽出部303に転送する。
 そして、ソースコード等価性評価フロー制御部201は、コードクローン抽出部303からコードクローン抽出結果205を取得する。
 コードクローン抽出結果205は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203との共通部分である。
 次に、ソースコード等価性評価フロー制御部201は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203とソースコード構造差分抽出結果204とコードクローン抽出結果205を重複コードブロック抽出部304に転送する。
 そして、ソースコード等価性評価フロー制御部201は、重複コードブロック抽出部304から、変更前ソースコード(重複範囲)206と変更後ソースコード(重複範囲)207を取得する。
 変更前ソースコード(重複範囲)206は、変更前ソースコード(正規化)202内の重複コードブロック(第1の対応範囲)と上位のコードブロックで構成される。
 変更後ソースコード(重複範囲)207は、変更後ソースコード(正規化)203内の重複コードブロック(第2の対応範囲)と上位のコードブロックで構成される。
 次に、ソースコード等価性評価フロー制御部201は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203と変更前ソースコード(重複範囲)206と変更後ソースコード(重複範囲)207を記号実行対象生成部401に転送する。
 そして、ソースコード等価性評価フロー制御部201は、記号実行対象生成部401から、変更前ソースコード(記号実行対象)208と変更後ソースコード(記号実行対象)209を取得する。
 変更前ソースコード(記号実行対象)208では、変更前ソースコード(重複範囲)206に、第1の外部操作コードブロックを特定する情報が付加されている。
 変更後ソースコード(記号実行対象)209では、変更後ソースコード(重複範囲)207に、第2の外部操作コードブロックを特定する情報が付加されている。
 次に、ソースコード等価性評価フロー制御部201は、変更前ソースコード(記号実行対象)208と変更後ソースコード(記号実行対象)209を記号実行部402に転送する。
 そして、ソースコード等価性評価フロー制御部201は、記号実行部402から、記号実行結果(変更前)210と記号実行結果(変更後)211を取得する。
 記号実行結果(変更前)210には、記号実行部402での変更前ソースコード(記号実行対象)208に対する記号実行の結果が示される。
 より具体的には、記号実行結果(変更前)210には、記号実行部402での変更前ソースコード(記号実行対象)208に対する記号実行において記録部404により記録された内容が示される。
 記号実行結果(変更後)211には、記号実行部402での変更後ソースコード(記号実行対象)209に対する記号実行の結果が示される。
 より具体的には、記号実行結果(変更後)211には、記号実行部402での変更後ソースコード(記号実行対象)209に対する記号実行において記録部404により記録された内容が示される。
 次に、ソースコード等価性評価フロー制御部201は、記号実行結果(変更前)210と記号実行結果(変更後)211を比較部403に転送する。
 そして、ソースコード等価性評価フロー制御部201は、比較部403から、ソースコード等価性評価結果一覧501を取得する。
 そして、ソースコード等価性評価フロー制御部201は、ソースコード等価性評価結果一覧501を、ソースコード評価装置1のユーザに提示する。
 図4及び図5は、字句・構文解析部301の動作例を示す。
 図4は、字句・構文解析部301の字句解析の処理例を示す。
 図5は、字句・構文解析部301の構文解析の処理例を示す。
 前述したように、字句・構文解析部301はソースコードの字句解析と構文解析を行いソースコードの構造を解析する。
 字句解析とは、ソースコード中の文字の並びを解析し、ソースコードを、意味を持つ最も小さな単位に分解する処理である。
 図4は、変更前ソースコード101の1行目の字句解析の処理例を示す。
 字句解析では、最初のintはメソッド定義戻り値、次のfunc1はメソッド定義識別子というようにソースコードを意味を持つ最も小さな単位に分解する。
 分解された最小単位には、元の文字列(例えばint)と位置(例えばproject-a/src1.xxxの1行目の1文字目)と型(例えばメソッド定義戻り値型)の情報が含まれる。
 構文解析とは、字句解析の結果を解釈し、ソースコードを木構造に構造化する処理である。
 図5は、変更前ソースコード101の構文解析の処理例を示す。
 構文解析では、字句解析により分解された単位情報に含まれる型の情報を解釈し、コードブロック間に親子関係を形成して、ソースコードを木構造化する。
 字句・構文解析部301は、変更前ソースコード101に対する字句解析及び構文解析の結果として、変更前ソースコード(正規化)202を出力する。
 また、字句・構文解析部301は、変更後ソースコード102に対する字句解析及び構文解析の結果として、変更後ソースコード(正規化)203を出力する。
 なお、字句解析及び構文解析の具体的な方法は、例えば、参考文献1に開示されている。
 字句・構文解析部301は、例えば参考文献1に開示の方法により実現される。
 参考文献1:ANTLR(http://www.antlr.org/)
 図6及び図7はソースコード構造差分抽出部302の処理例を示す。
 図6は、字句解析及び構文解析後の変更前ソースコード101である変更前ソースコード(正規化)202を示す。
 図7は、字句解析及び構文解析後の変更後ソースコード102である変更後ソースコード(正規化)203を示す。
 図7において、太枠で囲まれているコードブロックが、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203との差分であり、ソースコード構造差分抽出結果204に相当する。
 ソースコード構造差分抽出部302は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203とを比較し、変更後ソースコード(正規化)203から、変更前ソースコード(正規化)202からの変更部分を抽出する。
 ソースコード構造差分抽出部302は、字句・構文解析部301により得られた型の情報を参照して、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203とを比較する。
 図8及び図9は、コードクローン抽出部303の処理例を示す。
 図8は、字句解析及び構文解析後の変更前ソースコード101である変更前ソースコード(正規化)202を示す。
 図9は、字句解析及び構文解析後の変更後ソースコード102である変更後ソースコード(正規化)203を示す。
 図8及び図9において、破線や実線の太枠で囲まれているコードブロック(Clone1、Clone2、Clone3、Clone4)が、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203との共通部分であり、コードクローン抽出結果205に相当する。
 コードクローン抽出部303は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203とを比較し、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203との間で共通しているコードブロックを抽出する。
 コードクローン抽出部303は、字句・構文解析部301により得られた型の情報を参照して、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203とを比較する。
 コードクローン抽出部303では、ソースコード構造差分抽出部302における比較と異なり、異なる木構造に属するコードブロック間でも比較を行う。
 例えば、Clone1のペアは、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203で異なる木構造に属している。
 なお、コードクローン抽出の具体的な方法は、例えば、参考文献2に開示されている。
 コードクローン抽出部303は、例えば参考文献2に開示の方法により実現される。
 参考文献2:PMD(http://pmd.sourceforge.net/)
 図10は、重複コードブロック抽出部304の動作例を示すフローチャートである。
 まず、重複コードブロック抽出部304は、ソースコード構造差分抽出結果204とコードクローン抽出結果205とが重複しているコードブロックを、変更後ソースコード(正規化)203から抽出する(S0101)。
 S001で抽出されるコードブロックが、第2の対応範囲に相当する。
 図7及び図9の例では、最下段にあるコードブロック「Call print(msg)」と「throw Call error(msg)」とが抽出される。
 次に、重複コードブロック抽出部304は、S0101で抽出されたコードブロックに対応するコードブロックを、変更前ソースコード(正規化)202から抽出する(S0102)。
 S002で抽出されるコードブロックが、第1の対応範囲に相当する。
 S001においてコードブロック「Call print(msg)」と「throw Call error(msg)」とが抽出された場合は、図8の変更前ソースコード(正規化)202から、コードブロック「Call print(msg)」と「throw Call error(msg)」とが抽出される。
 次に、重複コードブロック抽出部304は、S0101で抽出したコードブロック(第2の対応範囲)の依存関係と、S0102で抽出したコードブロック(第1の対応範囲)の依存関係を導出する(S0103)。
 つまり、重複コードブロック抽出部304は、変更後ソースコード(正規化)203上で、S0101で抽出したコードブロックの木構造における上位階層のコードブロックを順に抽出する。
 また、重複コードブロック抽出部304は、変更前ソースコード(正規化)202上で、S0102で抽出したコードブロックの木構造における上位階層のコードブロックを順に抽出する。
 なお、重複コードブロック抽出部304は、型の情報(メソッド呼び出し等)を参照してコードブロックの依存関係を導出する。
 次に、重複コードブロック抽出部304は、S0103で導出した依存関係に基づき、変更前ソースコード(正規化)202及び変更後ソースコード(正規化)203のそれぞれで、処理の起点となる起点コードブロックを抽出する(S0104)。
 つまり、重複コードブロック抽出部304は、変更前ソースコード(正規化)202で、第1の対応範囲で記述されている処理の起点となる起点コードブロックを抽出する。
 また、重複コードブロック抽出部304は、変更後ソースコード(正規化)203で、第2の対応範囲で記述されている処理の起点となる起点コードブロックを抽出する。
 次に、重複コードブロック抽出部304は、S0101~S0104で抽出したコードブロックを、変更前ソースコード(重複範囲)206及び変更後ソースコード(重複範囲)207として出力する(S0105)。
 つまり、重複コードブロック抽出部304は、S0102で抽出したコードブロック(第1の対応範囲)と、当該コードブロック(第1の対応範囲)に対してS0103及びS0104で抽出した上位のコードブロックとを、変更前ソースコード(重複範囲)206として出力する。
 また、重複コードブロック抽出部304は、S0101で抽出したコードブロック(第2の対応範囲)と、当該コードブロック(第2の対応範囲)に対してS0103及びS0104で抽出した上位のコードブロックとを、変更後ソースコード(重複範囲)207として出力する。
 図11は、記号実行対象生成部401の動作例を示すフローチャートである。
 記号実行対象生成部401は、変更前ソースコード(正規化)202と変更後ソースコード(正規化)203において、重複コードブロック抽出部304で抽出したコードブロック群に対応する。
 コードブロック群を抽出する(S0201)。
 つまり、記号実行対象生成部401は、変更前ソースコード(正規化)202において変更前ソースコード(重複範囲)206に対応するコードブロック群を抽出する。
 また、記号実行対象生成部401は、変更後ソースコード(正規化)203において変更後ソースコード(重複範囲)207に対応するコードブロック群を抽出する。
 次に、記号実行対象生成部401は、S0201で抽出したコードブロック群内で、外部操作コードブロックを抽出する(S0202)。
 つまり、記号実行対象生成部401は、変更前ソースコード(正規化)202において、第1の実行対象範囲外の要素に対する操作(例えば、メソッド呼び出し)が記述される第1の外部操作コードブロックを抽出する。
 また、記号実行対象生成部401は、変更後ソースコード(正規化)203において、第2の実行対象範囲外の要素に対する操作(例えば、メソッド呼び出し)が記述される第2の外部操作コードブロックを抽出する。
 そして、記号実行対象生成部401は、変更前ソースコード(重複範囲)206に、第1の外部操作コードブロックを特定する情報を付加し、変更前ソースコード(記号実行対象)208を生成する。
 また、記号実行対象生成部401は、変更後ソースコード(重複範囲)207に、第2の外部操作コードブロックを特定する情報を付加し、変更後ソースコード(記号実行対象)209を生成する。
 図12及び図13は、記号実行部402の処理例を示す。
 図12は、記号実行の処理概要を示す。
 記号実行は、ソースコードの記述に従いプログラムへの入力を具体的な値ではなく記号のまま演算する処理である。
 図12の記号実行の処理概要では、記号実行結果として、条件「x<y」の時に「z=Y」が得られ、条件「x≧y」の時に「z=X」が得られることを示している。
 記号実行部402は、変更前ソースコード(記号実行対象)208と変更後ソースコード(記号実行対象)209のそれぞれに含まれる全てのコードブロックについて記号実行を行う。
 ただし、記号実行部402は、記号実行対象生成部401で抽出された外部操作コードブロック(第1の外部操作コードブロック及び第2の外部操作コードブロック)の記号実行では、外部の要素に対する操作を識別するための識別値(例えば、メソッド呼び出しの引数)を記録部404に記録し、外部操作コードブロックで指定されている外部の要素への操作(例えば、メソッドの呼び出し)の記号実行は行わない。
 図13は、変更前ソースコード(記号実行対象)208及び変更後ソースコード(記号実行対象)209に対する記号実行部402の処理例を示す。
 変更前ソースコード(記号実行対象)208内の符号2080で示すコードブロックは、第1の外部操作コードブロックに相当する。
 このため、記録部404では、条件「file=load(”msg.txt”)」の記号実行の結果として、外部メソッドの呼び出し引数である「msg=file.read()」が記録される。
 変更後ソースコード(記号実行対象)209内の符号2090で示すコードブロックは、第2の外部操作コードブロックに相当する。
 このため、記録部404では、同様に、条件「file=load(”msg.txt”)」の記号実行の結果として、外部メソッドの呼び出し引数である「msg=file.read()」が記録される。
 記録部404には、変更前ソースコード(記号実行対象)208に対する記号実行の結果が順に記録され、変更後ソースコード(記号実行対象)209に対する記号実行の結果が順に記録される。
 また、記録部404では、変更前ソースコード(記号実行対象)208の戻り値(図2の「return y」及び「return z+1」に相当)も記録される。
 同様に、記録部404では、変更後ソースコード(記号実行対象)209の戻り値(図2の「return y」及び「return z+1」に相当)も記録される。
 記号実行部402は、記録部404に記録された各ソースコードの記号実行の結果を記号実行結果(変更前)210と記号実行結果(変更後)211としてソースコード等価性評価フロー制御部201に出力する。
 記号実行結果(変更前)210には、第1の外部操作コードにおける識別値(外部メソッドの呼び出し引数)が第1の外部操作コードの出現順に記述され、変更前ソースコード(記号実行対象)208の戻り値が記述される。
 また、記号実行結果(変更後)211には、第2の外部操作コードにおける識別値(外部メソッドの呼び出し引数)が第2の外部操作コードの出現順に記述され、変更後ソースコード(記号実行対象)209の戻り値が記述される。
 図14は、比較部403の動作例を示すフローチャートである。
 まず、比較部403は、記号実行結果(変更前)210と、記号実行結果(変更後)211とを比較する(S0301)。
 より具体的には、比較部403は、記号実行結果(変更前)210に記述されている識別値(外部メソッドの呼び出し引数)の順序と、記号実行結果(変更後)211に記述されている識別値(外部メソッドの呼び出し引数)の順序とを比較する。
 また、比較部403は、記号実行結果(変更前)210に記述されている戻り値と、記号実行結果(変更後)211に記述されている戻り値とを比較する。
 次に、変更前ソースコード101と変更後ソースコード102との等価性を評価する(S0302)。
 より具体的には、比較部403は、記号実行結果(変更前)210に記述されている識別値(外部メソッドの呼び出し引数)の順序と、記号実行結果(変更後)211に記述されている識別値(外部メソッドの呼び出し引数)の順序とが一致し、記号実行結果(変更前)210に記述されている戻り値と、記号実行結果(変更後)211に記述されている戻り値とが一致する場合に、変更前ソースコード101と変更後ソースコード102が等価であると評価する。
 外部メソッドの呼び出し引数の順序及び戻り値の少なくともいずれかが一致しない場合は、比較部403は、変更前ソースコード101と変更後ソースコード102は不等価であると評価する。
 次に、比較部403は、S0301で得られた全てのコードブロックの比較結果と、S0302で得られた等価性の評価結果とが示されるソースコード等価性評価結果一覧501を出力する(S0303)。
***実施の形態の効果***
 以上のように、本実施の形態では、変更前ソースコードと変更後ソースコードとの差分と、変更前ソースコードと変更後ソースコードとの共通部分との重複範囲を、変更前ソースコードと変更後ソースコードのそれぞれで抽出する。
 そして、変更前ソースコードの重複範囲と変更後ソースコードの重複範囲のそれぞれに対して記号実行を行う。
 更に、重複範囲外への呼び出し引数等の識別値を順序付けて記録し、変更前ソースコードでの識別子の記録順序と、変更後ソースコードでの識別子の記録順序とを比較する。
 本実施の形態によれば、以上の手順により、プログラム外の要素に対する操作がリファクタリングにより変更されている場合に、変更前ソースコードにおけるプログラム外の要素に対する操作の順序と、変更後ソースコードにおけるプログラム外の要素に対する操作の順序とが一致するか否かを正確に評価することができる。
 また、本実施の形態では記号実行の結果を評価するため、変更後ソースコードに木構造の変更を伴う変更がなされている場合でも、変更前ソースコードと変更後ソースコードが等価であれば、変更前ソースコードと変更後ソースコードが等価であることを正確に評価することができる。
 また、本実施の形態では、変更前ソースコードの重複範囲と変更後ソースコードの重複範囲とを対応付けた上で等価性を評価し、評価結果を出力する。
 このため、変更前ソースコードと変更後ソースコードとの間で等価でない箇所を容易に特定することができる。
 また、本実施の形態では、記号実行は、変更前ソースコードと変更後ソースコードとの差分と、変更前ソースコードと変更後ソースコードとの共通部分との重複範囲にのみ行われる。
 このため、本実施の形態によれば、計算負荷を抑えることができる。
 また、本実施の形態では、字句解析及び構文解析によりソースコードを正規化することで、ソースコードをプログラム言語に依存しない形式に変換する。
 このため、本実施の形態によれば、変更前ソースコードと変更後ソースコードが異なるプログラム言語で作成されていても、変更前ソースコードと変更後ソースコードとの等価性を評価することができる。
***ハードウェア構成例の説明***
 最後に、ソースコード評価装置1のハードウェア構成例を図15を参照して説明する。
 ソースコード評価装置1はコンピュータである。
 ソースコード評価装置1は、プロセッサ901、補助記憶装置902、メモリ903、通信装置904、入力インタフェース905、ディスプレイインタフェース906といったハードウェアを備える。
 プロセッサ901は、信号線910を介して他のハードウェアと接続され、これら他のハードウェアを制御する。
 入力インタフェース905は、入力装置907に接続されている。
 ディスプレイインタフェース906は、ディスプレイ908に接続されている。
 プロセッサ901は、プロセッシングを行うIC(Integrated Circuit)である。
 プロセッサ901は、例えば、CPU(Central Processing Unit)、DSP(Digital Signal Processor)、GPU(Graphics Processing Unit)である。
 補助記憶装置902は、例えば、ROM(Read Only Memory)、フラッシュメモリ、HDD(Hard Disk Drive)である。
 メモリ903は、例えば、RAM(Random Access Memory)である。
 図1に示す記録部404は、補助記憶装置902又はメモリ903で実現される。
 通信装置904は、データを受信するレシーバー9041及びデータを送信するトランスミッター9042を含む。
 通信装置904は、例えば、通信チップ又はNIC(Network Interface Card)である。
 入力インタフェース905は、入力装置907のケーブル911が接続されるポートである。
 入力インタフェース905は、例えば、USB(Universal Serial Bus)端子である。
 ディスプレイインタフェース906は、ディスプレイ908のケーブル912が接続されるポートである。
 ディスプレイインタフェース906は、例えば、USB端子又はHDMI(登録商標)(High Definition Multimedia Interface)端子である。
 入力装置907は、例えば、マウス、キーボード又はタッチパネルである。
 ディスプレイ908は、例えば、LCD(Liquid Crystal Display)である。
 補助記憶装置902には、図1に示すソースコード等価性評価フロー制御部201、字句・構文解析部301、ソースコード構造差分抽出部302、コードクローン抽出部303、重複コードブロック抽出部304、記号実行対象生成部401、記号実行部402、比較部403(以下、ソースコード等価性評価フロー制御部201、字句・構文解析部301、ソースコード構造差分抽出部302、コードクローン抽出部303、重複コードブロック抽出部304、記号実行対象生成部401、記号実行部402、比較部403をまとめて「部」と表記する)の機能を実現するプログラムが記憶されている。
 このプログラムは、メモリ903にロードされ、プロセッサ901に読み込まれ、プロセッサ901によって実行される。
 更に、補助記憶装置902には、OS(Operating System)も記憶されている。
 そして、OSの少なくとも一部がメモリ903にロードされ、プロセッサ901はOSを実行しながら、「部」の機能を実現するプログラムを実行する。
 図15では、1つのプロセッサ901が図示されているが、ソースコード評価装置1が複数のプロセッサ901を備えていてもよい。
 そして、複数のプロセッサ901が「部」の機能を実現するプログラムを連携して実行してもよい。
 また、「部」の処理の結果を示す情報やデータや信号値や変数値が、メモリ903、補助記憶装置902、又は、プロセッサ901内のレジスタ又はキャッシュメモリに記憶される。
 「部」を「サーキットリー」で提供してもよい。
 また、「部」を「回路」又は「工程」又は「手順」又は「処理」に読み替えてもよい。
 「回路」及び「サーキットリー」は、プロセッサ901だけでなく、ロジックIC又はGA(Gate Array)又はASIC(Application Specific Integrated Circuit)又はFPGA(Field-Programmable Gate Array)といった他の種類の処理回路をも包含する概念である。
 1 ソースコード評価装置、101 変更前ソースコード、102 変更後ソースコード、201 ソースコード等価性評価フロー制御部、202 変更前ソースコード(正規化)、203 変更後ソースコード(正規化)、204 ソースコード構造差分抽出結果、205 コードクローン抽出結果、206 変更前ソースコード(重複範囲)、207 変更後ソースコード(重複範囲)、208 変更前ソースコード(記号実行対象)、209 変更後ソースコード(記号実行対象)、210 記号実行結果(変更前)、211 記号実行結果(変更後)、300 対応範囲抽出部、301 字句・構文解析部、302 ソースコード構造差分抽出部、303 コードクローン抽出部、304 重複コードブロック抽出部、401 記号実行対象生成部、402 記号実行部、403 比較部、404 記録部、501 ソースコード等価性評価結果一覧。

Claims (6)

  1.  複数のコードブロックに分割される第1のソースコードが変更されて得られた複数のコードブロックに分割される第2のソースコードから、前記第1のソースコードのいずれかのコードブロックと同一のコードブロックであって前記第1のソースコードからの変更部分に該当するコードブロックを第2の対応範囲として抽出し、前記第1のソースコードから、前記第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出する対応範囲抽出部と、
     前記第1の対応範囲と前記第2の対応範囲とに記号実行を行う記号実行部と、
     前記第1の対応範囲の記号実行で前記第1の対応範囲外の要素に対する操作が出現する度に、前記第1の対応範囲外の要素に対する操作を識別するための識別値を記録し、前記第2の対応範囲の記号実行で前記第2の対応範囲外の要素に対する操作が出現する度に、前記第2の対応範囲外の要素に対する操作を識別するための識別値を記録する記録部と、
     前記記録部による前記第1の対応範囲の記号実行での識別値の記録順序と、前記記録部による前記第2の対応範囲の記号実行での識別値の記録順序とを比較する比較部とを有するソースコード評価装置。
  2.  前記記録部は、
     前記第1の対応範囲の記号実行での戻り値と、前記第2の対応範囲の記号実行での戻り値とを記録し、
     前記比較部は、
     前記記録部により記録された、前記第1の対応範囲の記号実行での戻り値と、前記第2の対応範囲の記号実行での戻り値とを比較する請求項1に記載のソースコード評価装置。
  3.  前記比較部は、
     前記第1の対応範囲の記号実行での識別値の記録順序と前記第2の対応範囲の記号実行での識別値の記録順序との比較結果と、前記第1の対応範囲の記号実行での戻り値と前記第2の対応範囲の記号実行での戻り値との比較結果とを出力する請求項2に記載のソースコード評価装置。
  4.  前記対応範囲抽出部は、
     前記第1のソースコード及び前記第2のソースコードの字句解析及び構文解析を行い、
     字句解析及び構文解析が行われた後の前記第2のソースコードから前記第2の対応範囲を抽出し、字句解析及び構文解析が行われた後の前記第1のソースコードから前記第1の対応範囲を抽出する請求項1に記載のソースコード評価装置。
  5.  コンピュータが、
     複数のコードブロックに分割される第1のソースコードが変更されて得られた複数のコードブロックに分割される第2のソースコードから、前記第1のソースコードのいずれかのコードブロックと同一のコードブロックであって前記第1のソースコードからの変更部分に該当するコードブロックを第2の対応範囲として抽出し、前記第1のソースコードから、前記第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出し、
     前記第1の対応範囲と前記第2の対応範囲とに記号実行を行い、
     前記第1の対応範囲の記号実行で前記第1の対応範囲外の要素に対する操作が出現する度に、前記第1の対応範囲外の要素に対する操作を識別するための識別値を記録し、前記第2の対応範囲の記号実行で前記第2の対応範囲外の要素に対する操作が出現する度に、前記第2の対応範囲外の要素に対する操作を識別するための識別値を記録し、
     前記第1の対応範囲の記号実行での識別値の記録順序と、前記第2の対応範囲の記号実行での識別値の記録順序とを比較するソースコード評価方法。
  6.  複数のコードブロックに分割される第1のソースコードが変更されて得られた複数のコードブロックに分割される第2のソースコードから、前記第1のソースコードのいずれかのコードブロックと同一のコードブロックであって前記第1のソースコードからの変更部分に該当するコードブロックを第2の対応範囲として抽出し、前記第1のソースコードから、前記第2の対応範囲と同一のコードブロックを第1の対応範囲として抽出する対応範囲抽出処理と、
     前記第1の対応範囲と前記第2の対応範囲とに記号実行を行う記号実行処理と、
     前記第1の対応範囲の記号実行で前記第1の対応範囲外の要素に対する操作が出現する度に、前記第1の対応範囲外の要素に対する操作を識別するための識別値を記録し、前記第2の対応範囲の記号実行で前記第2の対応範囲外の要素に対する操作が出現する度に、前記第2の対応範囲外の要素に対する操作を識別するための識別値を記録する記録処理と、
     前記記録処理による前記第1の対応範囲の記号実行での識別値の記録順序と、前記記録処理による前記第2の対応範囲の記号実行での識別値の記録順序とを比較する比較処理とをコンピュータに実行させるソースコード評価プログラム。
PCT/JP2015/065354 2015-05-28 2015-05-28 ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム WO2016189721A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2015/065354 WO2016189721A1 (ja) 2015-05-28 2015-05-28 ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2015/065354 WO2016189721A1 (ja) 2015-05-28 2015-05-28 ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム

Publications (1)

Publication Number Publication Date
WO2016189721A1 true WO2016189721A1 (ja) 2016-12-01

Family

ID=57392638

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2015/065354 WO2016189721A1 (ja) 2015-05-28 2015-05-28 ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム

Country Status (1)

Country Link
WO (1) WO2016189721A1 (ja)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020038521A (ja) * 2018-09-05 2020-03-12 株式会社日立製作所 ソースコード生成支援装置およびソースコード生成支援方法
WO2022034919A1 (ja) * 2020-08-13 2022-02-17 株式会社Sider 情報処理装置、情報処理方法、プログラム及び情報処理システム

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013196350A (ja) * 2012-03-19 2013-09-30 Fujitsu Ltd 情報処理装置、情報処理方法、および情報処理プログラム
JP2013232166A (ja) * 2012-05-02 2013-11-14 Hitachi Ltd 計算機システム、情報処理方法、および、情報処理プログラム

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013196350A (ja) * 2012-03-19 2013-09-30 Fujitsu Ltd 情報処理装置、情報処理方法、および情報処理プログラム
JP2013232166A (ja) * 2012-05-02 2013-11-14 Hitachi Ltd 計算機システム、情報処理方法、および、情報処理プログラム

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020038521A (ja) * 2018-09-05 2020-03-12 株式会社日立製作所 ソースコード生成支援装置およびソースコード生成支援方法
WO2022034919A1 (ja) * 2020-08-13 2022-02-17 株式会社Sider 情報処理装置、情報処理方法、プログラム及び情報処理システム

Similar Documents

Publication Publication Date Title
US11740876B2 (en) Method and system for arbitrary-granularity execution clone detection
US8850581B2 (en) Identification of malware detection signature candidate code
WO2021017735A1 (zh) 一种智能合约的形式化验证方法、电子装置及存储介质
Rahimian et al. Bincomp: A stratified approach to compiler provenance attribution
WO2019075390A1 (en) BOX BLACK MATCHING MOTOR
US10613844B2 (en) Using comments of a program to provide optimizations
US20200380125A1 (en) Method for Detecting Libraries in Program Binaries
US20170147562A1 (en) Visually differentiating strings for testing
JP2017010476A (ja) 類似判定装置、類似判定方法及び類似判定プログラム
US10360004B2 (en) Using dynamic information to refine control flow graphs
WO2013191458A1 (en) License verification method and apparatus, and computer readable storage medium storing program therefor
US9189204B2 (en) Static analysis of computer software applications having a model-view-controller architecture
CN111736840A (zh) 小程序应用的编译方法、运行方法、存储介质及电子设备
JP5176478B2 (ja) データフロー解析装置、データフロー解析方法およびデータフロー解析プログラム
US10685298B2 (en) Mobile application compatibility testing
US9563635B2 (en) Automated recognition of patterns in a log file having unknown grammar
WO2016189721A1 (ja) ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム
EP3570173B1 (en) Equivalence verification apparatus and equivalence verification program
CN104123275B (zh) 翻译验证
JP6107455B2 (ja) テストスケジュール決定装置、プログラム
EP4031960A1 (en) Locally implemented terminal latency mitigation
JP6674048B2 (ja) 判定装置、判定方法及び判定プログラム
CN113032003B (zh) 开发文件导出方法、装置、电子设备及计算机存储介质
CN110709814A (zh) 程序代码生成装置和程序代码生成程序
JP6818568B2 (ja) 通信装置、通信仕様差分抽出方法及び通信仕様差分抽出プログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15893355

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15893355

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP