JP6953962B2 - Analysis method, analysis device and analysis program - Google Patents

Analysis method, analysis device and analysis program Download PDF

Info

Publication number
JP6953962B2
JP6953962B2 JP2017187242A JP2017187242A JP6953962B2 JP 6953962 B2 JP6953962 B2 JP 6953962B2 JP 2017187242 A JP2017187242 A JP 2017187242A JP 2017187242 A JP2017187242 A JP 2017187242A JP 6953962 B2 JP6953962 B2 JP 6953962B2
Authority
JP
Japan
Prior art keywords
node
directed graph
unit
function
flow
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
JP2017187242A
Other languages
Japanese (ja)
Other versions
JP2019061587A (en
Inventor
晃治 山本
晃治 山本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2017187242A priority Critical patent/JP6953962B2/en
Publication of JP2019061587A publication Critical patent/JP2019061587A/en
Application granted granted Critical
Publication of JP6953962B2 publication Critical patent/JP6953962B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Description

本発明は、解析方法、解析装置及び解析プログラムに関する。 The present invention relates to an analysis method, an analysis device and an analysis program.

ソースコードを解析して、変数や関数引数の設定元や取りうる値の候補を列挙する技術が知られている。例えば、ソースコードにエラーがある場合やソースコード作成規約に適合していない箇所がある場合に、修正箇所が広範囲におよぶ場合であっても、ソースコードをソースコード作成規約に従って変換するソースコード変換装置が知られている。当該装置は、ソースコードの全てについて、事前に構造及び呼出関係の解析を行い、ソースコードの解析結果に基づいて変換対象となる箇所の抽出を行う。そして、当該装置は、抽出された変換対象箇所に対応するソースコードの書き換え対象箇所を特定し、該当箇所のソースコードの書き換えを行う。 A technique is known that analyzes the source code and lists the setting sources of variables and function arguments and possible value candidates. For example, if there is an error in the source code or if there is a part that does not conform to the source code creation rules, even if there are a wide range of corrections, the source code is converted according to the source code creation rules. The device is known. The device analyzes the structure and calling relationship of all the source code in advance, and extracts the part to be converted based on the analysis result of the source code. Then, the device identifies the rewriting target portion of the source code corresponding to the extracted conversion target portion, and rewrites the source code of the corresponding portion.

また、ユーザの判定作業を排除し、プログラムの検証を効率化することのできるプログラム検証装置も知られている。当該装置は、プログラムを抽象構文木に変換し、プログラム抽象構文木とする。当該装置は、内部仕様を抽象構文木に変換し、仕様抽象構文木とする。当該装置は、プログラム抽象構文木と仕様抽象構文木とを比較し、検証対象プログラムが内部仕様を満足するかを検証する。当該装置は、検証対象プログラムが内部仕様を満足することができなかった場合は、検証結果をプログラムの誤り位置として示す検証結果報告書を出力する。 Further, a program verification device capable of eliminating the user's determination work and improving the efficiency of program verification is also known. The device converts the program into an abstract syntax tree and makes it a program abstract syntax tree. The device converts the internal specifications into an abstract syntax tree and makes it a specification abstract syntax tree. The device compares the program abstract syntax tree with the specification abstract syntax tree and verifies whether the program to be verified satisfies the internal specifications. If the verification target program cannot satisfy the internal specifications, the device outputs a verification result report showing the verification result as an error position of the program.

さらに、人手で実施されたリファクタリングに対する等価性検証を、記号実行により行うときに、計算量を爆発させずに、迅速に行えるようにする検証装置も知られている。当該装置は、ソースコードの等価性を検証する際に、ソースコードを解析した構造グラフを用いた構造比較による検証と記号実行による検証の二種類の検証を行う。当該装置は、構造グラフによる構造比較によって構造が一致すると判定できる場合は、記号実行を行わない。また、当該装置は、構造比較による検証の前には、リファクタリング前後の各々のソースコードを、リファクタリングパターンごとに定められた正規化情報に基づき、構造グラフを正規化し、リファクタリングが正当なときには、構造が一致するように調整する。さらに、当該装置は、リファクタリング前後の各々の構造グラフを抽象化したものを記号実行して検証することにより、記号実行を行う箇所を限定する。 Further, there is also known a verification device that enables quick equivalence verification for refactoring performed manually without exploding the amount of calculation when performing symbol execution. When verifying the equivalence of the source code, the device performs two types of verification: verification by structural comparison using a structural graph in which the source code is analyzed, and verification by symbol execution. The apparatus does not execute the symbol when it can be determined that the structures match by the structure comparison using the structure graph. In addition, before verification by structural comparison, the device normalizes the structural graph of each source code before and after refactoring based on the normalization information determined for each refactoring pattern, and when the refactoring is valid, the structure. Adjust so that they match. Further, the apparatus limits the places where the symbols are executed by executing and verifying the abstraction of each structural graph before and after the refactoring.

特開2014−134962号公報Japanese Unexamined Patent Publication No. 2014-134962 特開2011−215998号公報Japanese Unexamined Patent Publication No. 2011-215998 国際公開第2015/029154号International Publication No. 2015/029154

しかし、上記技術においては、ソースコードの変数や関数引数の設定元や取りうる値の候補を、誤列挙又は列挙漏れなく列挙することが難しい。例えば、ソースコードをコンパイルする等して実行可能な状態として、動的に解析する場合、誤列挙は生じないが、実際に実行した内容しか結果が戻らないため、列挙漏れが生じる場合がある。また、ソースコードを構文解析して静的に解析する場合において、同一クラスの別オブジェクトを同一オブジェクトとして扱い、また関数内の実行順序を無視すると、列挙漏れは生じないが、誤列挙が生じる場合がある。 However, in the above technique, it is difficult to enumerate the source code variables and function argument setting sources and possible value candidates without erroneous enumeration or omission of enumeration. For example, when the source code is compiled and dynamically analyzed as an executable state, erroneous enumeration does not occur, but the result is returned only for the actually executed contents, so enumeration omission may occur. Also, when parsing the source code statically, if another object of the same class is treated as the same object and the execution order in the function is ignored, enumeration omission does not occur, but erroneous enumeration occurs. There is.

一つの側面では、動的型付き言語のソースコードを解析する際の誤列挙及び列挙漏れを抑制できる解析方法、解析装置及び解析プログラムを提供することを目的とする。 In one aspect, it is an object of the present invention to provide an analysis method, an analysis device, and an analysis program capable of suppressing erroneous enumeration and omission of enumeration when analyzing the source code of a dynamically typed language.

一つの態様において、解析方法は、コンピュータが、プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成する。解析方法は、コンピュータが、データの流れと処理の流れとを用いて、動的型の参照解決と名前解決を実行する。解析方法は、コンピュータが、有向グラフをプログラムの関数単位で縮約する。さらに、解析方法は、コンピュータが、縮約済みの有向グラフのうち、解析指示を受けた関数に関する呼出元及び呼出先のプログラムの有向グラフを結合し、結合された新たな有向グラフを用いてデータの処理の流れを探索する。 In one embodiment, the analysis method causes a computer to generate a directed graph that represents the flow of data and the flow of processing within a function of a program. In the analysis method, a computer performs dynamic type reference resolution and name resolution using a data flow and a processing flow. In the analysis method, the computer contracts the directed graph for each function of the program. Further, in the analysis method, the computer combines the directed graphs of the caller and called programs related to the function that received the analysis instruction from the reduced directed graphs , and processes the data using the combined new directed graphs. Explore the flow.

一つの態様によれば、動的型付き言語のソースコードを解析する際の誤列挙及び列挙漏れを抑制できる。 According to one aspect, it is possible to suppress erroneous enumeration and omission of enumeration when analyzing the source code of the dynamically typed language.

図1は、動的型付き言語と静的型付き言語との値の差異の一例を示す図である。FIG. 1 is a diagram showing an example of a value difference between a dynamically typed language and a statically typed language. 図2は、構文木の一例を示す図である。FIG. 2 is a diagram showing an example of a syntax tree. 図3は、有向グラフの一例を示す図である。FIG. 3 is a diagram showing an example of a directed graph. 図4は、実施例1における解析装置の一例を示す図である。FIG. 4 is a diagram showing an example of the analysis device according to the first embodiment. 図5は、実施例1におけるクラステーブルの一例を示す図である。FIG. 5 is a diagram showing an example of the class table in the first embodiment. 図6は、実施例1におけるノード関係テーブルの一例を示す図である。FIG. 6 is a diagram showing an example of the node relation table in the first embodiment. 図7は、実施例1におけるノードテーブルの一例を示す図である。FIG. 7 is a diagram showing an example of the node table in the first embodiment. 図8は、実施例1におけるエッジテーブルの一例を示す図である。FIG. 8 is a diagram showing an example of the edge table in the first embodiment. 図9は、実施例1における書換規則の一例を示す図である。FIG. 9 is a diagram showing an example of the rewriting rule in the first embodiment. 図10は、グラフ要素の一例を示す図である。FIG. 10 is a diagram showing an example of graph elements. 図11は、実施例1におけるソースコード変換結果の一例を示す図である。FIG. 11 is a diagram showing an example of the source code conversion result in the first embodiment. 図12は、実施例1におけるソースコード変換結果の別の一例を示す図である。FIG. 12 is a diagram showing another example of the source code conversion result in the first embodiment. 図13は、ソースコード1の解決処理の一例を示す図である。FIG. 13 is a diagram showing an example of the resolution process of the source code 1. 図14は、ソースコード1の縮約処理の一例を示す図である。FIG. 14 is a diagram showing an example of the reduction process of the source code 1. 図15Aは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15A is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図15Bは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15B is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図15Cは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15C is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図15Dは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15D is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図15Eは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15E is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図15Fは、ソースコード3の解決処理及び縮約処理の一例を示す図である。FIG. 15F is a diagram showing an example of the resolution process and the contraction process of the source code 3. 図16Aは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16A is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Bは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16B is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Cは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16C is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Dは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16D is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Eは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16E is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Fは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16F is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図16Gは、ソースコード3の列挙処理及び結合処理の一例を示す図である。FIG. 16G is a diagram showing an example of the enumeration process and the combination process of the source code 3. 図17は、実施例1における解析処理の一例を示すフローチャートである。FIG. 17 is a flowchart showing an example of the analysis process in the first embodiment. 図18は、実施例1における変換処理の一例を示すフローチャートである。FIG. 18 is a flowchart showing an example of the conversion process in the first embodiment. 図19は、実施例1における解決処理の一例を示すフローチャートである。FIG. 19 is a flowchart showing an example of the solution process in the first embodiment. 図20は、実施例1における縮約処理の一例を示すフローチャートである。FIG. 20 is a flowchart showing an example of the reduction process in the first embodiment. 図21は、実施例1における列挙処理の一例を示すフローチャートである。FIG. 21 is a flowchart showing an example of the enumeration process in the first embodiment. 図22は、実施例1における結合処理の一例を示すフローチャートである。FIG. 22 is a flowchart showing an example of the joining process in the first embodiment. 図23は、実施例2におけるソースコード変換結果の一例を示す図である。FIG. 23 is a diagram showing an example of the source code conversion result in the second embodiment. 図24は、実施例2におけるソースコード変換結果の別の一例を示す図である。FIG. 24 is a diagram showing another example of the source code conversion result in the second embodiment. 図25Aは、ソースコード5の列挙処理及び統合処理の一例を示す図である。FIG. 25A is a diagram showing an example of the enumeration process and the integrated process of the source code 5. 図25Bは、ソースコード5の列挙処理及び統合処理の一例を示す図である。FIG. 25B is a diagram showing an example of the enumeration process and the integration process of the source code 5. 図26は、解析プログラムを実行するコンピュータの一例を示す図である。FIG. 26 is a diagram showing an example of a computer that executes an analysis program.

以下に、本願の開示する解析方法、解析装置及び解析プログラムの実施例を図面に基づいて詳細に説明する。なお、この実施例によりこの発明が限定されるものではない。また、以下に示す各実施例は、矛盾を起こさない範囲で適宜組み合わせても良い。 Hereinafter, examples of the analysis method, analysis device, and analysis program disclosed in the present application will be described in detail with reference to the drawings. The present invention is not limited to this embodiment. In addition, the examples shown below may be appropriately combined as long as they do not cause a contradiction.

本実施例における、後に説明する解析装置100は、動的型付き言語のソースコードを解析対象とする。図1は、動的型付き言語と静的型付き言語との値の差異の一例を示す図である。図1に示す動的型付き言語のソースコード9100及び静的型付き言語のソースコード9200は、いずれも2つのクラス「C」及び「D」を含む。また、2つのクラス「C」及び「D」は、それぞれ同じ名前の関数「f」を含む。 In the present embodiment, the analysis device 100 described later targets the source code of the dynamically typed language as the analysis target. FIG. 1 is a diagram showing an example of a value difference between a dynamically typed language and a statically typed language. The source code 9100 of the dynamically typed language and the source code 9200 of the statically typed language shown in FIG. 1 both include two classes "C" and "D". Also, the two classes "C" and "D" each include a function "f" with the same name.

図1に示すように、静的型付き言語のソースコード9200においては、オブジェクトを生成する際に、オブジェクトの「型」がソースコード中に明記される。例えば、静的型付き言語のソースコード9200においては、オブジェクト「o」の変数及び引数の型は、クラス「C」で定義され、オブジェクト「o2」の変数及び引数の型は、クラス「D」で定義されることが明確に特定できる。この場合において、関数「send」のパラメータ値の候補は「3」のみとなる。また、ソースコード9201に示すように、同じ名前のオブジェクト「o」を生成する場合も、それぞれの変数及び引数の型は、ソースコードにおいて明確に定義される。 As shown in FIG. 1, in the source code 9200 of a statically typed language, when an object is created, the "type" of the object is specified in the source code. For example, in the source code 9200 of a statically typed language, the type of the variable and the argument of the object "o" is defined by the class "C", and the type of the variable and the argument of the object "o2" is the class "D". Can be clearly identified as defined in. In this case, only "3" is a candidate for the parameter value of the function "send". Further, as shown in the source code 9201, when the object "o" having the same name is generated, the types of the respective variables and arguments are clearly defined in the source code.

一方、動的型付き言語のソースコード9100においては、オブジェクトを生成する際に、オブジェクトの「型」がソースコード中に明記されない。例えば、静的型付き言語のソースコード9200においては、オブジェクト「o」の変数及び引数の型が、クラス「C」で定義されるか、クラス「D」で定義されるかが明確に特定されていない。この場合において、関数「send」のパラメータ値は、実行文の順序に応じて、「3」だけでなく「8」も候補となる場合がある。 On the other hand, in the source code 9100 of the dynamically typed language, when the object is created, the "type" of the object is not specified in the source code. For example, in the source code 9200 of a statically typed language, it is clearly specified whether the variable and argument types of the object "o" are defined in the class "C" or the class "D". Not. In this case, the parameter value of the function "send" may be a candidate not only "3" but also "8" depending on the order of the execution statements.

このように、動的型付き言語においては、実行文の順序に応じてパラメータ値の候補が異なる場合がある。この場合、同一クラスの別オブジェクトを、同じオブジェクトとして扱い、実行順序を無視してプログラムを静的に解析する(いわゆる「曖昧な静的解析」をする)と、候補値の誤列挙が生じる場合がある。一方、動的型付き言語のソースコードをコンパイルするなどして実行可能な状態において値の候補を列挙する場合、候補値の誤列挙は生じないが、候補値の列挙漏れが生じる場合がある。 As described above, in the dynamically typed language, the parameter value candidates may differ depending on the order of the executable statements. In this case, if another object of the same class is treated as the same object and the program is statically analyzed (so-called "ambiguous static analysis") ignoring the execution order, an erroneous enumeration of candidate values will occur. There is. On the other hand, when enumerating value candidates in an executable state by compiling the source code of a dynamically typed language, erroneous enumeration of candidate values does not occur, but enumeration of candidate values may be omitted.

本実施例における解析装置100は、プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成し、データの流れと処理の流れとを用いて、動的型の参照解決と名前解決を実行する。また、解析装置100は、有向グラフをプログラムの関数単位で縮約し、縮約した結果のうち、解析指示を受けた関数に関する解決結果を合わせた後に、データの処理の流れを探索する。 The analysis device 100 in this embodiment generates a directed graph representing the data flow and the processing flow in the function of the program, and uses the data flow and the processing flow to perform dynamic type reference resolution and name. Perform the resolution. Further, the analysis device 100 reduces the directed graph for each function of the program, and among the reduced results, after matching the solution results related to the function that received the analysis instruction, searches the data processing flow.

解析装置100によるソースコードの処理について、図2乃至図3を用いて説明する。図2は、構文木の一例を示す図である。図2に示すように、解析装置100は、符号1000で示す動的型付き言語で記述されたソースコード1から、例えば後に説明するような処理により、アセンブラでの命令列の粒度で、構文木1010を生成する。 The processing of the source code by the analysis device 100 will be described with reference to FIGS. 2 to 3. FIG. 2 is a diagram showing an example of a syntax tree. As shown in FIG. 2, the analyzer 100 starts with the source code 1 described in the dynamically typed language indicated by reference numeral 1000, and performs a processing as described later, for example, in a syntax tree with the particle size of the instruction sequence in the assembler. Generate 1010.

また、解析装置100は、生成された構文木1010から、さらに図3に示すような有向グラフ1100を生成する。図3は、有向グラフの一例を示す図である。図3において、有向グラフ1100は、処理に対応する第1ノード1111及び1114と、データの参照に対応する第2ノード1112及び1115と、データの設定に対応する第3ノード1116とを含む。 Further, the analysis device 100 further generates a directed graph 1100 as shown in FIG. 3 from the generated syntax tree 1010. FIG. 3 is a diagram showing an example of a directed graph. In FIG. 3, the directed graph 1100 includes first nodes 1111 and 1114 corresponding to processing, second nodes 1112 and 1115 corresponding to data reference, and third node 1116 corresponding to data setting.

本実施例における有向グラフ1100は、例えば図3に示すように、第1ノード乃至第3ノードとエッジとを有する3部グラフである。図3においては、第2ノードを円形状で示すとともに、円形内に「1」などの正の値を示す。また、図3においては、第3ノードを円形状で示すとともに、円形内に「−1」などの負の値を示す。なお、図3に示すように、以下において、第1ノード1114から第2ノード1115へのエッジ1117、及び第3ノード1116から第1ノード1114へのエッジ1118の表記を省略する場合がある。 The directed graph 1100 in this embodiment is, for example, as shown in FIG. 3, a three-part graph having first to third nodes and an edge. In FIG. 3, the second node is shown in a circular shape, and a positive value such as “1” is shown in the circle. Further, in FIG. 3, the third node is shown in a circular shape, and a negative value such as “-1” is shown in the circle. As shown in FIG. 3, in the following, the notation of the edge 1117 from the first node 1114 to the second node 1115 and the edge 1118 from the third node 1116 to the first node 1114 may be omitted.

図3に示す第2ノード及び第3ノードは、関数内のデータの流れ(記憶領域の参照更新、処理の入出力値)と処理の流れとを示す。第2ノード及び第3ノードにおいて、絶対値が「1」であるノードは環境を示し、絶対値が「2」以上であるノードはパラメータを示す。 The second node and the third node shown in FIG. 3 show the flow of data in the function (reference update of storage area, input / output value of processing) and the flow of processing. In the second node and the third node, a node having an absolute value of "1" indicates an environment, and a node having an absolute value of "2" or more indicates a parameter.

また、解析装置100は、図3に示すような有向グラフに対して、データの流れと処理の流れとの両方を用いて、参照解決と名前解決を行う。解析装置100は、解決結果を関数単位で縮約して保持する。さらに、解析装置100は、縮約した結果のうち、解析指示を受けた関数に関する解決結果を合わせた後に、データの処理の流れを探索する。 Further, the analysis device 100 performs reference resolution and name resolution on the directed graph as shown in FIG. 3 by using both the data flow and the processing flow. The analysis device 100 contracts and holds the solution result in function units. Further, the analysis device 100 searches the data processing flow after combining the resolution results related to the function that received the analysis instruction among the reduced results.

このように、本実施例における解析装置100は、関数内のデータの流れと処理の流れとを有向グラフで示して参照解決と名前解決を実行し、解析対象の関数のデータの流れ及び処理の流れをたどるので、動的型付言語解析時の列挙漏れや誤列挙を抑制できる。 As described above, the analysis device 100 in the present embodiment shows the data flow and the processing flow in the function as a directed graph, executes reference resolution and name resolution, and executes the reference resolution and the name resolution, and the data flow and the processing flow of the function to be analyzed. Therefore, it is possible to suppress omission of enumeration and erroneous enumeration at the time of dynamically typed language analysis.

[機能ブロック]
次に、本実施例における解析装置100について、図4を用いて説明する。図4は、実施例1における解析装置の一例を示す図である。図4に示すように、本実施例における解析装置100は、通信部110と、記憶部120と、制御部130とを有する。
[Functional block]
Next, the analysis device 100 in this embodiment will be described with reference to FIG. FIG. 4 is a diagram showing an example of the analysis device according to the first embodiment. As shown in FIG. 4, the analysis device 100 in this embodiment includes a communication unit 110, a storage unit 120, and a control unit 130.

通信部110は、有線又は無線を問わず、図示しない外部のサーバや、図示しない解析装置100の利用者や管理者の端末など、その他のコンピュータ等との通信を制御する。通信部110は、例えばNIC(Network Interface Card)等の通信インタフェース等である。 The communication unit 110 controls communication with other computers such as an external server (not shown), a terminal of a user or an administrator of the analysis device 100 (not shown), regardless of whether it is wired or wireless. The communication unit 110 is, for example, a communication interface such as a NIC (Network Interface Card).

記憶部120は、例えば制御部130が実行するプログラムなどの各種データなどを記憶する。また、記憶部120は、ソースコードDB121、クラス定義DB122、元フローDB123、解決済みフローDB124、書換規則DB125、縮約済みフローDB126及び値候補DB127を有する。記憶部120は、RAM(Random Access Memory)、ROM(Read Only Memory)、フラッシュメモリなどの半導体メモリ素子や、HDD(Hard Disk Drive)などの記憶装置に対応する。なお、以下の説明では、データベースを「DB」と表記する場合がある。 The storage unit 120 stores various data such as a program executed by the control unit 130, for example. Further, the storage unit 120 has a source code DB 121, a class definition DB 122, an original flow DB 123, a resolved flow DB 124, a rewriting rule DB 125, a contracted flow DB 126, and a value candidate DB 127. The storage unit 120 corresponds to semiconductor memory elements such as RAM (Random Access Memory), ROM (Read Only Memory), and flash memory, and storage devices such as HDD (Hard Disk Drive). In the following description, the database may be referred to as "DB".

ソースコードDB121は、解析対象とするプログラムのソースコードを記憶する。なお、ソースコードDB121に記憶される情報は、例えば後に説明する取得部131により入力される。 The source code DB 121 stores the source code of the program to be analyzed. The information stored in the source code DB 121 is input by, for example, the acquisition unit 131 described later.

クラス定義DB122は、ソースコードから有向グラフを生成する際に用いられる各クラスの定義に関する情報を記憶する。クラス定義DB122は、クラスの定義に関する情報として、例えば図5に示すようなクラステーブル122−1と、図6に示すようなノード関係テーブル122−2とを記憶する。なお、クラス定義DB122に記憶される情報は、例えば図示しない解析装置100の管理者により予め入力される。 The class definition DB 122 stores information regarding the definition of each class used when generating a directed graph from the source code. The class definition DB 122 stores, for example, a class table 122-1 as shown in FIG. 5 and a node relation table 122-2 as shown in FIG. 6 as information regarding the definition of the class. The information stored in the class definition DB 122 is input in advance by, for example, the administrator of the analysis device 100 (not shown).

図5は、実施例1におけるクラステーブルの一例を示す図である。図5に示すように、クラステーブル122−1は、各ノードの名前と、当該名前のノードが示す内容とを対応付けて記憶する。例えば、クラス「λI&」は、当該ノードが「クラスメンバ関数の処理内容を定義する」クラスのノードであることを示す。 FIG. 5 is a diagram showing an example of the class table in the first embodiment. As shown in FIG. 5, the class table 122-1 stores the name of each node in association with the content indicated by the node having the name. For example, the class "λI &" indicates that the node is a node of the class that "defines the processing content of the class member function".

図6は、実施例1におけるノード関係テーブルの一例を示す図である。図6に示すように、ノード関係テーブル122−2は、クラステーブルに列挙された各クラスのノードに対応する第2ノード及び第3ノードの属性を示す。図6に示すように、第2ノード及び第3ノードの属性は、絶対値「1」で示される「環境」、絶対値「2」以降で示される「パラメータ」に加えて、「メモリ領域」を示す「plc」、「名前空間」を示す「def」などをさらに含む。また、クラス「λI&」の第2ノード及びクラス「R&」の第3ノードに示されるように、絶対値が最も大きい属性は、「継続」を示す場合がある。 FIG. 6 is a diagram showing an example of the node relation table in the first embodiment. As shown in FIG. 6, the node relation table 122-2 shows the attributes of the second node and the third node corresponding to the nodes of each class listed in the class table. As shown in FIG. 6, the attributes of the second node and the third node are the "environment" indicated by the absolute value "1", the "parameter" indicated by the absolute value "2" and thereafter, and the "memory area". Further includes "plc" indicating "namespace", "def" indicating "namespace", and the like. Further, as shown in the second node of the class "λI &" and the third node of the class "R &", the attribute having the largest absolute value may indicate "continuation".

図4に戻って、元フローDB123は、後に説明する変換部132により、ソースコードから生成される有向グラフに関する情報を記憶する。元フローDB123は、例えば図7に示すような有向グラフを構成するノードに関する情報を記憶するノードテーブル123−1と、図8に示すような有向グラフを構成するエッジに関する情報を記憶するエッジテーブル123−2とを有する。なお、元フローDB123に記憶される情報は、例えば変換部132により入力される。 Returning to FIG. 4, the original flow DB 123 stores information about the directed graph generated from the source code by the conversion unit 132 described later. The original flow DB 123 has, for example, a node table 123-1 that stores information about nodes that make up a directed graph as shown in FIG. 7, and an edge table 123-2 that stores information about edges that make up a directed graph as shown in FIG. And have. The information stored in the original flow DB 123 is input by, for example, the conversion unit 132.

図7は、実施例1におけるノードテーブルの一例を示す図である。図7に示すように、ノードテーブル123−1は、例えば、「格納位置」と、「ノード種類」と、「クラス」と、「属性」とを、「ID」に対応付けて記憶する。 FIG. 7 is a diagram showing an example of the node table in the first embodiment. As shown in FIG. 7, the node table 123-1 stores, for example, a "storage position", a "node type", a "class", and an "attribute" in association with an "ID".

図7において、「ID」は、ノードを一意に識別する識別子(Identifier)を示す。「格納位置」は、当該ノードに対応するソースコードが格納された位置を示す。「ノード種類」は、当該ノードが、図3に示す第1ノード乃至第3ノードのいずれに該当するかを示す。 In FIG. 7, “ID” indicates an identifier that uniquely identifies a node. The "storage position" indicates the position where the source code corresponding to the node is stored. The "node type" indicates which of the first node to the third node shown in FIG. 3 corresponds to the node.

図7において、「クラス」は、当該ノードがどのクラスに該当するかを示す。なお、クラスは、「ノード種類」が「1」であるノードについてのみ記憶される。「属性」は、当該ノードの属性を示す。例えば「ノード種類」が「1」であるノードの「属性」は、「‘http://’」などの文字列や、「self」などの関数名を記憶する。また、例えば「ノード種類」が「2」又は「3」であるノードの「属性」は、「1」や「−1」など、「環境」や「パラメータ」などの属性を記憶する。なお、後に説明するように、「ノード種類」が「2」又は「3」であるノードの「属性」は、メモリ領域を示す「plc」や、名前空間を示す「def」などの属性も含む。 In FIG. 7, “class” indicates which class the node corresponds to. The class is stored only for the node whose "node type" is "1". "Attribute" indicates the attribute of the node. For example, the "attribute" of a node whose "node type" is "1" stores a character string such as "'http: //'" or a function name such as "self". Further, for example, the "attribute" of the node whose "node type" is "2" or "3" stores attributes such as "environment" and "parameter" such as "1" and "-1". As will be described later, the "attribute" of the node whose "node type" is "2" or "3" includes attributes such as "plc" indicating a memory area and "def" indicating a namespace. ..

例えば、図7に示すように、IDが「11」のノードは、第1ノードn1であり、クラスが「IV」であり、属性が「‘http://’」である。また、IDが「11」のノードに対応するソースコードは、「/src/rev.1/」に格納されている。 For example, as shown in FIG. 7, the node having the ID "11" is the first node n1, the class is "IV", and the attribute is "'http: //'". The source code corresponding to the node whose ID is "11" is stored in "/src/rev.1/".

図8は、実施例1におけるエッジテーブルの一例を示す図である。図8に示すように、エッジテーブルは、「起点ID」と「終点ID」とを対応付けて記憶する。図8において、「起点ID」は、当該エッジの起点となるノードのIDを示し、「終点ID」は、当該エッジの終点となるIDを示す。 FIG. 8 is a diagram showing an example of the edge table in the first embodiment. As shown in FIG. 8, the edge table stores the “start point ID” and the “end point ID” in association with each other. In FIG. 8, the “start point ID” indicates the ID of the node that is the start point of the edge, and the “end point ID” indicates the ID that is the end point of the edge.

図4に戻って、解決済みフローDB124は、後に説明する解決部133により、参照解決及び名前解決を行う解決処理が行われた結果である有向グラフに関する情報を記憶する。解決済みフローDB124は、例えば図7に示すノードテーブル123−1及び図8に示すエッジテーブル123−2と同様に、有向グラフを構成するノード及びエッジに関する情報を記憶する。なお、解決済みフローDB124に記憶される情報は、例えば後に解決部133により入力される。 Returning to FIG. 4, the resolved flow DB 124 stores information regarding the directed graph which is the result of the resolution process for performing reference resolution and name resolution by the resolution unit 133 which will be described later. The resolved flow DB 124 stores information about the nodes and edges constituting the directed graph, as in the node table 123-1 shown in FIG. 7 and the edge table 123-2 shown in FIG. 8, for example. The information stored in the resolved flow DB 124 is input later, for example, by the resolution unit 133.

書換規則DB125は、有向グラフに対する、後に説明する解決処理、縮約処理及び結合処理に適用される書換規則に関する情報を記憶する。なお、書換規則DB125に記憶される情報は、例えば図示しない解析装置100の管理者により予め入力される。 The rewriting rule DB 125 stores information about the rewriting rule applied to the resolution process, the contraction process, and the join process, which will be described later, for the directed graph. The information stored in the rewriting rule DB 125 is input in advance by, for example, the administrator of the analysis device 100 (not shown).

図9は、実施例1における書換規則の一例を示す図である。図9に示すように、書換規則は、「内容」と、「種別」と、「優先度」とを「タイトル」に対応付けて記憶する。図9において、「タイトル」は、書換種別を一意に識別する情報である。「内容」は、当該タイトルの書換規則が適用される有向グラフの対象及び条件、並びに書換処理の内容を示す。 FIG. 9 is a diagram showing an example of the rewriting rule in the first embodiment. As shown in FIG. 9, the rewriting rule stores the "content", the "type", and the "priority" in association with the "title". In FIG. 9, the "title" is information that uniquely identifies the rewriting type. "Content" indicates the target and conditions of the directed graph to which the rewriting rule of the title is applied, and the content of the rewriting process.

図9において、「種別」は、当該書換規則を行う処理の種別を示す。なお、本実施例において、種別「S」は解決処理に適用される書換規則を示し、種別「D」は縮約処理に適用される書換規則を示し、種別「M」は統合処理に適用される書換規則を示す。また、「優先度」は、当該書換規則が適用される順序を示す。本実施例においては、書換規則は、優先度が高い、すなわち優先度の値が小さいものから順に適用される。 In FIG. 9, “type” indicates the type of processing for which the rewriting rule is applied. In this embodiment, the type "S" indicates the rewriting rule applied to the resolution process, the type "D" indicates the rewriting rule applied to the contraction process, and the type "M" is applied to the integrated process. Rewrite rules are shown. In addition, "priority" indicates the order in which the rewriting rule is applied. In this embodiment, the rewriting rules are applied in order from the one with the highest priority, that is, the one with the lowest priority value.

図4に戻って、縮約済みフローDB126は、後に説明する縮約部134による縮約処理が行われた結果である有向グラフに関する情報を記憶する。縮約済みフローDB126は、例えば図7に示すノードテーブル123−1及び図8に示すエッジテーブル123−2と同様に、有向グラフを構成するノード及びエッジに関する情報を記憶する。なお、縮約済みフローDB126に記憶される情報は、例えば縮約部134により入力される。 Returning to FIG. 4, the contracted flow DB 126 stores information about the directed graph which is the result of the contraction processing performed by the contraction unit 134, which will be described later. The contracted flow DB 126 stores information about the nodes and edges constituting the directed graph, as in the node table 123-1 shown in FIG. 7 and the edge table 123-2 shown in FIG. 8, for example. The information stored in the contracted flow DB 126 is input by, for example, the contracted unit 134.

値候補DB127は、後に説明する列挙処理の結果である値に関する情報を記憶する。値候補DB127は、対象となる関数において、引数又は変数の設定値の候補となる値を記憶する。なお、値候補DB127に記憶される情報は、例えば後に説明する列挙部135により入力される。 The value candidate DB 127 stores information about a value that is the result of the enumeration process described later. The value candidate DB 127 stores a value that is a candidate for a setting value of an argument or a variable in the target function. The information stored in the value candidate DB 127 is input by, for example, the enumeration unit 135 described later.

図4に戻って、制御部130は、解析装置100の全体的な処理を司る処理部である。制御部130は、例えば、CPU(Central Processing Unit)やMPU(Micro Processing Unit)等によって、内部の記憶装置に記憶されているプログラムがRAMを作業領域として実行されることにより実現される。また、制御部130は、例えば、ASIC(Application Specific Integrated Circuit)やFPGA(Field Programmable Gate Array)等の集積回路により実現されるようにしてもよい。 Returning to FIG. 4, the control unit 130 is a processing unit that controls the overall processing of the analysis device 100. The control unit 130 is realized by, for example, a CPU (Central Processing Unit), an MPU (Micro Processing Unit), or the like executing a program stored in an internal storage device using a RAM as a work area. Further, the control unit 130 may be realized by, for example, an integrated circuit such as an ASIC (Application Specific Integrated Circuit) or an FPGA (Field Programmable Gate Array).

制御部130は、取得部131、変換部132、解決部133、縮約部134、列挙部135及び出力部136を有する。なお、取得部131、変換部132、解決部133、縮約部134、列挙部135及び出力部136は、プロセッサが有する電子回路の一例やプロセッサが実行するプロセスの一例である。 The control unit 130 includes an acquisition unit 131, a conversion unit 132, a resolution unit 133, a contraction unit 134, an enumeration unit 135, and an output unit 136. The acquisition unit 131, the conversion unit 132, the resolution unit 133, the contraction unit 134, the enumeration unit 135, and the output unit 136 are examples of electronic circuits included in the processor and examples of processes executed by the processor.

取得部131は、ソースコード及び解析対象の関数に関する情報を取得する。取得部131は、例えば通信部110を通じて、図示しない外部のサーバや利用者の端末から、ソースコードを取得し、ソースコードDB121に記憶する。 The acquisition unit 131 acquires information about the source code and the function to be analyzed. The acquisition unit 131 acquires the source code from an external server or a user's terminal (not shown) through the communication unit 110, for example, and stores the source code in the source code DB 121.

また、取得部131は、通信部110を通じて、例えば利用者の端末から解析対象の関数に関する指示を受け付ける。取得部131は、変換部132に対して、解析対象の関数に関する有向グラフの生成指示を出力するとともに、列挙部135に解析対象の関数を特定する情報を出力する。 Further, the acquisition unit 131 receives an instruction regarding the function to be analyzed from, for example, the user's terminal through the communication unit 110. The acquisition unit 131 outputs a directed graph generation instruction regarding the function to be analyzed to the conversion unit 132, and outputs information for specifying the function to be analyzed to the enumeration unit 135.

次に、変換部132は、ソースコードを、図3に示すような有向グラフに変換する。なお、変換部132は、生成部の一例である。 Next, the conversion unit 132 converts the source code into a directed graph as shown in FIG. The conversion unit 132 is an example of a generation unit.

変換部132は、取得部131から有向グラフの生成指示の出力を受けると、ソースコードDB121から解析対象の関数を含むソースコードを抽出し、例えば図10に示すようなグラフ要素を特定して、図2に示すような構文木を生成する。 When the conversion unit 132 receives the output of the directed graph generation instruction from the acquisition unit 131, the conversion unit 132 extracts the source code including the function to be analyzed from the source code DB 121, identifies the graph element as shown in FIG. Generate a syntax tree as shown in 2.

図10は、グラフ要素の一例を示す図である。変換部132は、図10に示すような節点に対応する要素をソースコード中から特定し、図2に示すような構文木を生成する。さらに、変換部132は、生成された構文木を、図3に示すような有向グラフの形に変換し、元フローDB123に記憶する。 FIG. 10 is a diagram showing an example of graph elements. The conversion unit 132 identifies the elements corresponding to the nodes as shown in FIG. 10 from the source code, and generates a syntax tree as shown in FIG. Further, the conversion unit 132 converts the generated syntax tree into a directed graph as shown in FIG. 3 and stores it in the original flow DB 123.

変換部132が生成する有向グラフは、例えばソースコードをアセンブラの粒度で分解したものである。すなわち、生成された有向グラフは、参照先のレジスタやメモリアドレスが特定できる形で、データの流れ及び処理の流れを示したものである。 The directed graph generated by the conversion unit 132 is, for example, a source code decomposed at the particle size of the assembler. That is, the generated directed graph shows the data flow and the processing flow in a form in which the referenced register and memory address can be specified.

変換部132により生成される有向グラフについて、図11及び図12を用いて説明する。図11は、実施例1におけるソースコード変換結果の一例を示す図である。符号2000に示す変換元となるソースコード2は、図2に示すソースコード1と同名のクラスであるが、関数「__init__」2001に加えて、別の関数「newSpace」2002をさらに定義している。 The directed graph generated by the conversion unit 132 will be described with reference to FIGS. 11 and 12. FIG. 11 is a diagram showing an example of the source code conversion result in the first embodiment. The source code 2 that is the conversion source shown in reference numeral 2000 is a class having the same name as the source code 1 shown in FIG. 2, but in addition to the function “____init__” 2001, another function “newSpace” 2002 is further defined. ..

この場合において、変換部132は、関数「__init__」2001に対応するノード「λI&」2101に加えて、別の関数「newSpace」2002に対応するノード「λI&」2102をさらに含む有向グラフ2100を生成する。 In this case, the conversion unit 132 generates a directed graph 2100 including the node "λI &" 2101 corresponding to the function "____init__" 2001 and the node "λI &" 2102 corresponding to another function "newSpace" 2002.

図12は、実施例1におけるソースコード変換結果の別の一例を示す図である。符号3000に示すソースコード3は、クラス「Proxy」のオブジェクト「p」を生成する命令3001を含む。 FIG. 12 is a diagram showing another example of the source code conversion result in the first embodiment. The source code 3 shown by reference numeral 3000 includes an instruction 3001 that creates an object “p” of the class “Proxy”.

この場合において、変換部132は、値の参照先「RI」としてクラス「Proxy」を示すノード3101を含む有向グラフ3100を生成する。なお、ノード3101の参照先を特定する処理については、後に説明する。 In this case, the conversion unit 132 generates a directed graph 3100 including a node 3101 indicating the class “Proxy” as the reference destination “RI” of the value. The process of specifying the reference destination of the node 3101 will be described later.

次に、解決部133は、有向グラフに対して参照解決及び名前解決を行う解決処理を実行する。解決部133は、元フローDB123から有向グラフに関する情報を読み出し、書換規則DB125に記憶された種別「S」の書換規則を有向グラフに適用する。解決部133は、種別「S」の書換規則を適用した有向グラフに関する情報を、解決済みフローDB124に記憶する。 Next, the resolution unit 133 executes a resolution process that performs reference resolution and name resolution for the directed graph. The solution unit 133 reads the information about the directed graph from the original flow DB 123, and applies the rewriting rule of the type "S" stored in the rewriting rule DB 125 to the directed graph. The resolution unit 133 stores the information regarding the directed graph to which the rewriting rule of the type "S" is applied in the resolved flow DB 124.

本実施例における解決処理について、図13を用いて説明する。図13は、ソースコード1の解決処理の一例を示す図である。図13に示す有向グラフ1200は、図3に示す有向グラフ1100のレイアウトを変更したもので、ノード及びエッジの構成は有向グラフ1100と同様である。なお、以下の有向グラフを示す図面において、次の処理対象となるノード又はエッジを破線で示し、前の処理により変更されたノード又はエッジを太線で示す場合がある。 The solution process in this embodiment will be described with reference to FIG. FIG. 13 is a diagram showing an example of the resolution process of the source code 1. The directed graph 1200 shown in FIG. 13 is a modification of the layout of the directed graph 1100 shown in FIG. 3, and the configurations of the nodes and edges are the same as those of the directed graph 1100. In the drawing showing the following directed graph, the node or edge to be processed next may be indicated by a broken line, and the node or edge changed by the previous processing may be indicated by a thick line.

まず、解決部133は、書換規則DB125を参照し、元フローDB123に記憶される有向グラフ1200に含まれる主ノードλI&「__init__」(コンストラクタのメソッド名)に種別「S」の書換規則を適用する。まず、解決部133は、書換規則DB125に記憶される種別「S」の書換規則のうち、最も優先度が高い、すなわち優先度の値が最も小さい「M_I」を有向グラフ1200に適用するか否かを判定する。 First, the solution unit 133 refers to the rewriting rule DB 125, and applies the rewriting rule of the type "S" to the main node λI & "____ init __" (constructor method name) included in the directed graph 1200 stored in the original flow DB 123. First, whether or not the solution unit 133 applies "M_I", which has the highest priority, that is, the lowest priority value, to the directed graph 1200 among the rewrite rules of the type "S" stored in the rewrite rule DB 125. To judge.

この場合において、有向グラフ1200は対象となるグラフ形状「A&(−2)→(2)P(−plc)→(+plc)Class」を含まないので、解決部133は、書換規則「M_I」を有向グラフ1200に対して適用しない。 In this case, since the directed graph 1200 does not include the target graph shape "A & (-2)-> (2) P (-plc)-> (+ plc) Class", the solution unit 133 sets the rewriting rule "M_I" as the directed graph. Not applicable to 1200.

次に、解決部133は、書換規則DB125に記憶された種別「S」の書換規則のうち、2番目に優先度が高い書換規則「RI_E(1)」を有向グラフ1200に適用するか否かを判定する。この場合において、有向グラフ1200は対象となるグラフ形状「RI(−1)→(1)…(−1)→(1)λI&」に該当するノード「RI」1201を含むので、解決部133は、書換規則「RI_E(1)」を有向グラフ1200に適用する。 Next, the resolution unit 133 determines whether or not to apply the rewriting rule "RI_E (1)" having the second highest priority among the rewriting rules of the type "S" stored in the rewriting rule DB 125 to the directed graph 1200. judge. In this case, since the directed graph 1200 includes the node “RI” 1201 corresponding to the target graph shape “RI (-1) → (1) ... (-1) → (1) λI &”, the solution unit 133 The rewriting rule "RI_E (1)" is applied to the directed graph 1200.

すなわち、解決部133は、有向グラフ1200のノード「RI」1201をノードID1301に変更する。また、解決部133は、ノードλI&からノードID1301の第2ノードへのエッジ1323を追加することにより、有向グラフ1200を有向グラフ1300に変換する。 That is, the solution unit 133 changes the node "RI" 1201 of the directed graph 1200 to the node ID 1301. Further, the solution unit 133 converts the directed graph 1200 into the directed graph 1300 by adding an edge 1323 from the node λI & to the second node of the node ID 1301.

同様に、解決部133は、変換された有向グラフ1300が、さらに別のノード「RI」1311を含むので、解決部133は、書換規則「RI_E(1)」を有向グラフ1300にも適用する。 Similarly, the resolution unit 133 also applies the rewriting rule "RI_E (1)" to the directed graph 1300 because the transformed directed graph 1300 includes yet another node "RI" 1311.

すなわち、解決部133は、有向グラフ1300のノード「RI」1311をノードID1411に変更する。また、解決部133は、ノード「λI&」からノードID1411の第2ノードへのエッジ1433を追加することにより、有向グラフ1300を有向グラフ1400に変換する。 That is, the solution unit 133 changes the node "RI" 1311 of the directed graph 1300 to the node ID 1411. Further, the solution unit 133 converts the directed graph 1300 into the directed graph 1400 by adding an edge 1433 from the node "λI &" to the second node of the node ID 1411.

また、解決部133は、変換された有向グラフ1400は、書換規則「RI_E(1)」の対象となるグラフ形状に該当するノードを含まないと判定する。この場合、解決部133は、書換規則DB125に記憶された、優先度が書換規則「RI_E(1)」以下であるその他の種別「S」の書換規則を、有向グラフ1400に適用するか否かを判定する。 Further, the solution unit 133 determines that the converted directed graph 1400 does not include a node corresponding to the graph shape subject to the rewriting rule “RI_E (1)”. In this case, the resolution unit 133 determines whether or not the rewriting rule of the other type "S" stored in the rewriting rule DB 125 and having a priority of the rewriting rule "RI_E (1)" or lower is applied to the directed graph 1400. judge.

この場合において、有向グラフ1400は、その他の種別「S」の書換規則の対象となるグラフ形状を含んでいないため、解決部133はその他の種別「S」の書換規則を有向グラフ1400に適用しない。そして、解決部133は、全ての種別「S」の書換規則について、有向グラフ1400に適用するか否かを判定した後に、変換された有向グラフ1400を、解決済みフローDB124に記憶する。 In this case, since the directed graph 1400 does not include the graph shape subject to the rewriting rule of the other type "S", the solution unit 133 does not apply the rewriting rule of the other type "S" to the directed graph 1400. Then, the resolution unit 133 determines whether or not to apply the rewriting rules of all the types "S" to the directed graph 1400, and then stores the converted directed graph 1400 in the resolved flow DB 124.

次に、縮約部134は、解決済みの有向グラフを、プログラムの関数単位で縮約する縮約処理を実行する。縮約部134は、解決済みフローDB124から有向グラフに関する情報を読み出し、書換規則DB125に記憶された種別「D」の書換規則を有向グラフに適用する。縮約部134は、種別「D」の書換規則を適用した有向グラフに関する情報を、縮約済みフローDB126に記憶する。 Next, the contraction unit 134 executes a contraction process for contracting the resolved directed graph in function units of the program. The contraction unit 134 reads information about the directed graph from the resolved flow DB 124, and applies the rewriting rule of type "D" stored in the rewriting rule DB 125 to the directed graph. The contraction unit 134 stores information about the directed graph to which the rewriting rule of the type “D” is applied in the contracted flow DB 126.

本実施例における縮約処理について、図14を用いて説明する。図14は、ソースコード1の縮約処理の一例を示す図である。まず、縮約部134は、書換規則DB125を参照し、解決済みフローDB124に記憶される有向グラフ1400に含まれる主ノード「λI&」である「__init__」に、種別「D」の書換規則を適用する。まず、縮約部134は、書換規則DB125に記憶される種別「D」の書換規則のうち、最も優先度が高い、すなわち優先度の値が最も小さい「ID_E」を有向グラフ1400に適用するか否かを判定する。この場合において、有向グラフ1400は対象となるグラフ形状「ID」を含むので、縮約部134は、書換規則「ID_E」を有向グラフ1400に適用する。 The contraction process in this embodiment will be described with reference to FIG. FIG. 14 is a diagram showing an example of the reduction process of the source code 1. First, the contraction unit 134 refers to the rewriting rule DB 125, and applies the rewriting rule of the type “D” to the main node “λI &” “__init__” included in the directed graph 1400 stored in the resolved flow DB 124. .. First, whether or not the contraction unit 134 applies "ID_E", which has the highest priority, that is, the lowest priority value, to the directed graph 1400 among the rewriting rules of the type "D" stored in the rewriting rule DB 125. Is determined. In this case, since the directed graph 1400 includes the target graph shape “ID”, the contraction unit 134 applies the rewriting rule “ID_E” to the directed graph 1400.

すなわち、縮約部134は、有向グラフ1400のノード「ID」1401を削除するとともに、図13に示すノード「ID」1401に隣接するエッジ1412、1413、1422及び1423を削除する。また、縮約部134は、削除された各エッジの接続先を相互に接続するエッジ1513及び1523を追加する。これにより、縮約部134は、有向グラフ1400を有向グラフ1500に変換する。 That is, the contraction unit 134 deletes the node "ID" 1401 of the directed graph 1400 and deletes the edges 1412, 1413, 1422, and 1423 adjacent to the node "ID" 1401 shown in FIG. In addition, the contraction unit 134 adds edges 1513 and 1523 that connect the connection destinations of the deleted edges to each other. As a result, the contraction unit 134 converts the directed graph 1400 into the directed graph 1500.

同様に、縮約部134は、有向グラフ1500にも、さらに書換規則「ID_E」を適用することにより、ノード「ID」1511、並びにエッジ1512、1513、1532及び1533を削除するとともに、エッジ1613及び1633を追加する。これにより、縮約部134は、有向グラフ1500を有向グラフ1600に変換する。 Similarly, the contraction unit 134 deletes the node "ID" 1511 and the edges 1512, 1513, 1532 and 1533 by further applying the rewriting rule "ID_E" to the directed graph 1500, and also deletes the edges 1613 and 1633. To add. As a result, the contraction unit 134 converts the directed graph 1500 into the directed graph 1600.

また、縮約部134は、書換規則DB125に記憶された、優先度が書換規則「ID_E」以下であるその他の種別「D」の書換規則を、有向グラフ1600に適用するか否かを判定する。この場合において、有向グラフ1600は、その他の種別「D」の書換規則の対象となるグラフ形状を含んでいないため、縮約部134はその他の種別「D」の書換規則を有向グラフ1400に適用しない。そして、縮約部134は、全ての種別「D」の書換規則について、有向グラフ1600に適用するか否かを判定した後に、変換された有向グラフ1600を、縮約済みフローDB126に記憶する。 Further, the contraction unit 134 determines whether or not the rewriting rule of the other type “D” whose priority is equal to or lower than the rewriting rule “ID_E” stored in the rewriting rule DB 125 is applied to the directed graph 1600. In this case, since the directed graph 1600 does not include the graph shape subject to the rewriting rule of the other type "D", the contraction unit 134 does not apply the rewriting rule of the other type "D" to the directed graph 1400. Then, the contraction unit 134 determines whether or not to apply the rewriting rules of all the types "D" to the directed graph 1600, and then stores the converted directed graph 1600 in the contracted flow DB 126.

本実施例による解決部133及び縮約部134による処理の別の一例について、図15A乃至図15Fを用いて説明する。図15A乃至図15Fは、ソースコード3の解決処理及び縮約処理の一例を示す図である。まず、解決部133は、図12に示すソースコード3から生成された有向グラフ3100に対し、種別「S」の書換規則を適用する。この場合において、解決部133は、書換規則「RI_E(1)」を、対象となるグラフ形状に該当するノード「RI」3101に適用する。 Another example of the processing by the solution unit 133 and the contraction unit 134 according to this embodiment will be described with reference to FIGS. 15A to 15F. 15A to 15F are diagrams showing an example of the resolution process and the contraction process of the source code 3. First, the solution unit 133 applies a rewriting rule of type "S" to the directed graph 3100 generated from the source code 3 shown in FIG. In this case, the solution unit 133 applies the rewriting rule "RI_E (1)" to the node "RI" 3101 corresponding to the target graph shape.

また、縮約部134は、解決部133により書換規則「RI_E(1)」が適用された有向グラフ3100に対し、さらに種別「D」の書換規則を適用する。この場合において、縮約部134は、書換規則「ID_E」を有向グラフ3100に適用することにより、解決及び縮約された有向グラフ3200を生成する。 Further, the contraction unit 134 further applies the rewriting rule of the type "D" to the directed graph 3100 to which the rewriting rule "RI_E (1)" is applied by the resolving unit 133. In this case, the contraction unit 134 generates the resolved and contracted directed graph 3200 by applying the rewriting rule "ID_E" to the directed graph 3100.

図15Aに示すように、有向グラフ3200は、有向グラフ3100に含まれるノード「RI」3101及び当該ノードの第2ノード及び第3ノードに接続するエッジ3112、3113及び3132が削除されている。また、有向グラフ3200は、ノード「RI」3211の第2ノードに接続するエッジ3212と、ノード「λI&」の第2ノード3109に接続するエッジ3233とが追加されている。 As shown in FIG. 15A, in the directed graph 3200, the node "RI" 3101 included in the directed graph 3100 and the edges 3112, 3113, and 3132 connected to the second node and the third node of the node are deleted. Further, in the directed graph 3200, an edge 3212 connected to the second node of the node "RI" 3211 and an edge 3233 connected to the second node 3109 of the node "λI &" are added.

本実施例におけるソースコード3は、図12に示すように、クラス「Proxy」のオブジェクト「p」を生成する命令3001を含む。そこで、本実施例における列挙部135は、ソースコード3の参照解決及び名前解決に際し、クラス「Proxy」を呼び出すノードを追加する。 As shown in FIG. 12, the source code 3 in this embodiment includes an instruction 3001 that creates an object “p” of the class “Proxy”. Therefore, the enumeration unit 135 in this embodiment adds a node that calls the class "Proxy" when resolving the reference and the name of the source code 3.

図15Bに移って、解決部133は、有向グラフ3200に対し、さらに書換規則「RI_E(2)」を適用する。これにより、解決部133は、有向グラフ3200からクラス「Proxy」に関するノード「RI」3211を削除する。また、解決部133は、主ノード「Class」3321、ノード「P」3311及び両ノードを接続するエッジ3313を追加することにより、有向グラフ3300を生成する。 Moving on to FIG. 15B, the solution unit 133 further applies the rewriting rule "RI_E (2)" to the directed graph 3200. As a result, the solution unit 133 deletes the node "RI" 3211 related to the class "Proxy" from the directed graph 3200. In addition, the solution unit 133 generates a directed graph 3300 by adding a main node "Class" 3321, a node "P" 3311, and an edge 3313 connecting both nodes.

また、解決部133は、有向グラフ3300に対し、さらに書換規則「M_I」を適用する。これにより、解決部133は、有向グラフ3200にノード「M」3431、ノード「RM」3441を追加することにより、有向グラフ3400を生成する。 Further, the solution unit 133 further applies the rewriting rule "M_I" to the directed graph 3300. As a result, the solution unit 133 generates the directed graph 3400 by adding the node "M" 3431 and the node "RM" 3441 to the directed graph 3200.

図15Cに移って、解決部133は、有向グラフ3400に対し、さらに書換規則「DI_I」を適用する。これにより、解決部133は、有向グラフ3400からノード「WI」3451を削除するとともに、ノード「DI」3561、ノード「WI」3551及び両ノードを接続するエッジを追加することにより、有向グラフ3500を生成する。 Moving on to FIG. 15C, the solution unit 133 further applies the rewriting rule "DI_I" to the directed graph 3400. As a result, the solution unit 133 generates the directed graph 3500 by deleting the node "WI" 3451 from the directed graph 3400 and adding the node "DI" 3651, the node "WI" 3551, and the edge connecting both nodes. ..

また、解決部133は、有向グラフ3500に対し、さらに書換規則「DI_E」を適用する。これにより、解決部133は、有向グラフ3500のノード「DI」3561及びノード「WI」3551を削除するとともに、ノード「S」3661及びノード「U」3651を追加することにより、有向グラフ3600を生成する。 Further, the solution unit 133 further applies the rewriting rule "DI_E" to the directed graph 3500. As a result, the solution unit 133 generates the directed graph 3600 by deleting the node "DI" 3651 and the node "WI" 3551 of the directed graph 3500 and adding the node "S" 3661 and the node "U" 3651.

図15Dに移って、解決部133は、有向グラフ3600に対し、さらに書換規則「RI_I(4)」及び「P.E_E」を適用する。これにより、解決部133は、有向グラフ3400からノード「RI」3671を削除するとともに、ノード「P」3771及びこれに接続するエッジを追加する。また、解決部133は、ノード「S」3661及びノード「P」3771を、第2ノード「+plc」及び第3ノード「−plc」を介して接続する。さらに、解決部133は、ノード「M」3781とノード「RM」3789とを接続するエッジ3783を追加することにより、有向グラフ3700を生成する。 Moving on to FIG. 15D, the solution unit 133 further applies the rewriting rules “RI_I (4)” and “PE_E” to the directed graph 3600. As a result, the solution unit 133 deletes the node "RI" 3671 from the directed graph 3400 and adds the node "P" 3771 and the edge connected to the node "P" 3771. Further, the resolution unit 133 connects the node "S" 3661 and the node "P" 3771 via the second node "+ plc" and the third node "-plc". Further, the solution unit 133 generates a directed graph 3700 by adding an edge 3783 connecting the node "M" 3781 and the node "RM" 3789.

また、解決部133は、有向グラフ3700に対し、さらに書換規則「M_E(3)」を適用する。これにより、解決部133は、有向グラフ3700に、主ノード「Class」3821から第2ノード「+def」及び第3ノード「−def」を介して接続されたノード「S」3891を追加する。また、解決部133は、有向グラフ3700のノード「M」3781をノード「P」3881に置き換えて、有向グラフ3800を生成する。なお、ノード「S」3891とノード「M」3781とは、第2ノード「1」及び第3ノード「−1」に加えて、第2ノード「+plc」及び第3ノード「−plc」を介しても接続される。 Further, the solution unit 133 further applies the rewriting rule "M_E (3)" to the directed graph 3700. As a result, the solution unit 133 adds the node "S" 3891 connected from the main node "Class" 3821 via the second node "+ def" and the third node "-def" to the directed graph 3700. Further, the solution unit 133 replaces the node "M" 3781 of the directed graph 3700 with the node "P" 3881 to generate the directed graph 3800. The node "S" 3891 and the node "M" 3781 are connected to the node "S" 3891 via the second node "+ plc" and the third node "-plc" in addition to the second node "1" and the third node "-1". Even connected.

図15Eに移って、解決部133は、有向グラフ3800に対し、さらに書換規則「CL_I(4)」を適用する。これにより、解決部133は、「__init__」メソッドに対応するノード「λI&」3901を呼び出すノード「CL」3911を有向グラフ3800に追加する。また、解決部133は、ノード「CL」3911に接続するエッジを修正して、有向グラフ3900を生成する。これにより、解決部133は、関数「Client.getResource」による、関数「Proxy.__init__」に対する呼出関係を有向グラフ3900に記録する。 Moving on to FIG. 15E, the solution unit 133 further applies the rewriting rule "CL_I (4)" to the directed graph 3800. As a result, the solution unit 133 adds the node "CL" 3911 that calls the node "λI &" 3901 corresponding to the "____ init__" method to the directed graph 3800. Further, the solution unit 133 modifies the edge connected to the node “CL” 3911 to generate the directed graph 3900. As a result, the solution unit 133 records the call relationship to the function "Proxy.____init__" by the function "Client.getResource" in the directed graph 3900.

同様に、解決部133は、有向グラフ3900に対し、さらに書換規則「CL_I(4)」を適用して、「newSpace」メソッドに対応するノード「λI&」3A01を呼び出すノード「CL」3A11を有向グラフ3800に追加する。また、解決部133は、ノード「CL」3A11に接続するエッジを修正して、有向グラフ3A00を生成する。これにより、解決部133は、関数「Client.getResource」による、関数「Proxy.newSpace」に対する呼出関係を有向グラフ3A00に記録する。 Similarly, the solution unit 133 further applies the rewriting rule "CL_I (4)" to the directed graph 3900 to change the node "CL" 3A11 that calls the node "λI &" 3A01 corresponding to the "newSpace" method to the directed graph 3800. to add. Further, the solution unit 133 modifies the edge connected to the node "CL" 3A11 to generate the directed graph 3A00. As a result, the solution unit 133 records the call relationship to the function "Proxy.newSpace" by the function "Client.getResource" in the directed graph 3A00.

図15Fに移って、縮約部134は、有向グラフ3A00に対し、種別「D」の書換規則「unref_E,S_U_E」を適用する。これにより、縮約部134は、有向グラフ3A00から、ノード「RM」3A21及び3A22、ノード「P」3A31及び3A32、ノード「U」3A41及びノード「S」3A51を削除して、有向グラフ3B00を生成する。なお、有向グラフ6000は、有向グラフ3B00のレイアウトを変更したもので、ノード及びエッジの構成は有向グラフ3B00と同様である。 Moving to FIG. 15F, the contraction unit 134 applies the rewriting rule “unref_E, S_U_E” of the type “D” to the directed graph 3A00. As a result, the contraction unit 134 deletes the nodes "RM" 3A21 and 3A22, the nodes "P" 3A31 and 3A32, the node "U" 3A41 and the node "S" 3A51 from the directed graph 3A00, and generates the directed graph 3B00. .. Note that the directed graph 6000 is a modification of the layout of the directed graph 3B00, and the configuration of the nodes and edges is the same as that of the directed graph 3B00.

図4に戻って、列挙部135は、縮約済みの有向グラフを用いて、対象となる関数の引数又は変数の設定値の候補となる値を列挙する。列挙部135は、取得部131から解析対象の関数を特定する情報の出力を受けると、特定された関数の値の候補値を列挙する。なお、列挙部135は、探索部の一例である。 Returning to FIG. 4, the enumeration unit 135 enumerates the values that are candidates for the setting values of the arguments or variables of the target function by using the reduced directed graph. When the enumeration unit 135 receives the output of the information for specifying the function to be analyzed from the acquisition unit 131, the enumeration unit 135 enumerates the candidate values of the values of the specified function. The enumeration unit 135 is an example of a search unit.

列挙部135は、特定された関数に対して、呼出先のプログラムがあるか否かを判定する。列挙部135は、呼出先のプログラムがあると判定した場合、呼出先のプログラムの有向グラフを、呼出元のプログラムの有向グラフと結合する。 The enumeration unit 135 determines whether or not there is a program to be called for the specified function. When the enumeration unit 135 determines that there is a called program, the enumeration unit 135 combines the directed graph of the called program with the directed graph of the calling program.

列挙部135は、関数の呼出元の有向グラフを列挙して、書換規則DB125を参照し、種別「M」の書換規則を呼出先の有向グラフと呼出元の有向グラフとに適用する。具体的には、列挙部135は、列挙対象とする引数又は変数を含む関数の呼出元を列挙し、各呼出元関数に対応する有向グラフの関数呼出部分を、呼出先の有向グラフと結合する。 The enumeration unit 135 enumerates the directed graph of the caller of the function, refers to the rewriting rule DB 125, and applies the rewriting rule of the type "M" to the directed graph of the callee and the directed graph of the caller. Specifically, the enumeration unit 135 enumerates the callers of the functions including the arguments or variables to be enumerated, and combines the function call portion of the directed graph corresponding to each caller function with the directed graph of the callee.

例えば、列挙部135は、呼出先の有向グラフを、サブグラフとして呼出元の有向グラフに追加する。なお、サブグラフとして追加される呼出先の有向グラフは、例えば主ノードを「λI& $2」のように変更する。そして、列挙部135は、呼出元のグラフにおける、ノード「A&」に対して種別「M」の書換規則を適用する。また、列挙部135は、呼出元の有向グラフと呼出先の有向グラフとが結合されたグラフに対して、さらに種別「M」の書換規則を適用する。 For example, the enumeration unit 135 adds the directed graph of the callee to the directed graph of the caller as a subgraph. In the directed graph of the callee added as a subgraph, the main node is changed to "λI & $ 2", for example. Then, the enumeration unit 135 applies the rewriting rule of the type "M" to the node "A &" in the graph of the caller. Further, the enumeration unit 135 further applies a rewriting rule of type "M" to the graph in which the directed graph of the caller and the directed graph of the callee are combined.

また、列挙部135は、種別「M」の書換規則を適用した有向グラフに対して、種別「S」の書換規則を適用する解決処理と、種別「D」の書換規則を適用する縮約処理とを繰り返す。 Further, the enumeration unit 135 includes a resolution process for applying the rewrite rule of the type "S" and a contraction process for applying the rewrite rule of the type "D" to the directed graph to which the rewrite rule of the type "M" is applied. repeat.

また、列挙部135は、全ての呼出先の有向グラフを結合した場合、又は呼出先のプログラムが無いと判定した場合、有向グラフの関数に対して値を設定するノードを列挙し、Fノードをデータの流れ及び処理の流れとは逆方向に探索していく。列挙部135は、IVノードに到達するまで探索を繰り返し、IVノードに到達すると、列挙されたノードを文字列に変換する。 Further, the enumeration unit 135 enumerates the nodes for setting the value for the function of the directed graph when the directed graphs of all the called destinations are combined or when it is determined that there is no program of the called destination, and the F node is the data. Search in the opposite direction to the flow and processing flow. The enumeration unit 135 repeats the search until it reaches the IV node, and when it reaches the IV node, it converts the enumerated nodes into a character string.

出力部136は、解析処理の結果を出力する。出力部136は、値候補DB127に記憶された引数又は変数の候補値を抽出し、例えば通信部110を通じて、図示しない利用者の端末に出力する。 The output unit 136 outputs the result of the analysis process. The output unit 136 extracts the candidate values of the arguments or variables stored in the value candidate DB 127, and outputs them to a user's terminal (not shown) through, for example, the communication unit 110.

本実施例における解析装置100による列挙処理及び出力内容について、図16A乃至図16Gを用いて説明する。図16A乃至図16Gは、ソースコード3の列挙処理及び結合処理の一例を示す図である。以下においては、図12に示すソースコード3により生成されるオブジェクト「p」に含まれる「send」関数に渡される引数の候補値を列挙する処理について説明する。 The enumeration process and output contents by the analysis device 100 in this embodiment will be described with reference to FIGS. 16A to 16G. 16A to 16G are diagrams showing an example of the enumeration process and the combination process of the source code 3. In the following, a process of listing the candidate values of the arguments passed to the "send" function included in the object "p" generated by the source code 3 shown in FIG. 12 will be described.

「send」関数は、ソースコード3の「Client」クラスに含まれる「Client.getResource」関数により呼び出される。しかし、「send」関数は、ソースコード3ではなく、ソースコード2の「Proxy」クラスに含まれている。そこで、本実施例における列挙部135は、呼出元であるソースコード3の有向グラフと、呼出先であるソースコード2の有向グラフとの結合処理を行う。 The "send" function is called by the "Client.getResource" function included in the "Client" class of the source code 3. However, the "send" function is included in the "Proxy" class of source code 2 instead of source code 3. Therefore, the enumeration unit 135 in this embodiment performs a combination process of the directed graph of the source code 3 which is the caller and the directed graph of the source code 2 which is the callee.

図16Aに示すように、列挙部135は、図15Fに示すソースコード3の有向グラフ6000に対して、種別「M」の書換規則「AC_E」を適用する。まず、列挙部135は、図9に示す書換規則「AC_E」の処理1.を実行することにより、ノード「λI&」から始まるサブグラフを複製する。本実施例においては、列挙部135は、ソースコード2の「newSpace」関数を定義するノード「λI&」2201から始まるサブグラフ2200を追加する。なお、図16B以下においては、追加されたサブグラフ2200のノード「λI&」2201を、「λI& $2」と表す場合がある。これにより、列挙部135は、有向グラフ6000とサブグラフ2200とを含む有向グラフ6100を生成する。 As shown in FIG. 16A, the enumeration unit 135 applies the rewriting rule “AC_E” of the type “M” to the directed graph 6000 of the source code 3 shown in FIG. 15F. First, the enumeration unit 135 processes the rewriting rule “AC_E” shown in FIG. 9. Duplicates the subgraph starting with the node "λI &" by executing. In this embodiment, the enumeration unit 135 adds a subgraph 2200 starting with the node "λI &" 2201 that defines the "newSpace" function in source code 2. In FIG. 16B and below, the node "λI &" 2201 of the added subgraph 2200 may be represented as "λI & $ 2". As a result, the enumeration unit 135 generates a directed graph 6100 including a directed graph 6000 and a subgraph 2200.

図16Bに移って、列挙部135は、有向グラフ6100に対して、種別「M」の書換規則「AC_E」の処理2.1.を実行する。これにより、列挙部135は、有向グラフ6000のノード「CL」6221からサブグラフ2200のノード「RI」6211へ接続するエッジが追加された有向グラフ6200を生成する。 Moving to FIG. 16B, the enumeration unit 135 processes the rewriting rule “AC_E” of the type “M” for the directed graph 6100 2.1. To execute. As a result, the enumeration unit 135 generates a directed graph 6200 to which an edge connecting the node "CL" 6221 of the directed graph 6000 to the node "RI" 6211 of the subgraph 2200 is added.

また、列挙部135は、有向グラフ6200に対して、書換規則「AC_E」の処理2.2.及び処理2.3.1.を実行する。これにより、ノード「P」6311からノード「RM」6312へ接続するエッジ6313、及びノード「IV」6321からノード「F」6322へ接続するエッジ6323が追加される。さらに、列挙部135は、ノード「R&」6331からノード「R&」6332へ接続するエッジ6333が追加された有向グラフ6300を生成する。なお、ソースコード3には、書換規則「AC_E」の処理2.3.2.及び2.3.3.の対象となるノード又はエッジは含まれない。 Further, the enumeration unit 135 processes the rewriting rule “AC_E” for the directed graph 6200 2.2. And processing 2.3.1. To execute. As a result, an edge 6313 connecting the node "P" 6311 to the node "RM" 6312 and an edge 6323 connecting the node "IV" 6321 to the node "F" 6322 are added. Further, the enumeration unit 135 generates a directed graph 6300 to which an edge 6333 connecting from the node “R &” 6331 to the node “R &” 6332 is added. In addition, in the source code 3, the processing of the rewriting rule "AC_E" 2.3.2. And 2.3.3. Does not include nodes or edges that are subject to.

図16Cに移って、列挙部135は、有向グラフ6300に対して、書換規則「AC_E」の処理3.を実行する。これにより、列挙部135は、図16Bに示すノード「λI&」6341及び接続する各エッジが削除された有向グラフ6400を生成する。 Moving to FIG. 16C, the enumeration unit 135 processes the rewriting rule “AC_E” with respect to the directed graph 6300. To execute. As a result, the enumeration unit 135 generates a directed graph 6400 in which the node “λI &” 6341 shown in FIG. 16B and each connecting edge are deleted.

また、列挙部135は、有向グラフ6400に対して、書換規則「AC_E」の処理4.を実行する。これにより、列挙部135は、図16Bに示すノード「R&」6331及び接続する各エッジが削除された有向グラフ6500を生成する。なお、列挙部135は、有向グラフ6500において、削除されたノード「R&」6331と接続されていたノード「A&」6401からノード「R&」6332へ接続するエッジを追加する。 Further, the enumeration unit 135 processes the rewriting rule “AC_E” with respect to the directed graph 6400. To execute. As a result, the enumeration unit 135 generates a directed graph 6500 in which the node “R &” 6331 shown in FIG. 16B and each connecting edge are deleted. In the directed graph 6500, the enumeration unit 135 adds an edge connecting the node "A &" 6401 connected to the deleted node "R &" 6331 to the node "R &" 6332.

ところで、クラス「Proxy」は、ソースコード2に加えて、ソースコード1にも定義されている。そこで、列挙部135は、呼出元であるソースコード3の有向グラフに、呼出先であるソースコード1の有向グラフをさらに結合する処理を行う。 By the way, the class "Proxy" is defined in the source code 1 in addition to the source code 2. Therefore, the enumeration unit 135 performs a process of further combining the directed graph of the source code 1 which is the callee with the directed graph of the source code 3 which is the caller.

図16Dに移って、列挙部135は、有向グラフ6400に対して、書換規則「AC_E」の処理1.を実行する。これにより、列挙部135は、有向グラフ6500に、ソースコード1の「__init__」関数を定義するノード「λI& $2」1701から始まるサブグラフ1700を追加した有向グラフ7000を生成する。 Moving to FIG. 16D, the enumeration unit 135 processes the rewriting rule “AC_E” with respect to the directed graph 6400. To execute. As a result, the enumeration unit 135 generates a directed graph 7000 by adding a subgraph 1700 starting from the node "λI & $ 2" 1701 that defines the "____ init__" function of the source code 1 to the directed graph 6500.

図16Eに移って、列挙部135は、有向グラフ7000に対して、書換規則「AC_E」の処理2.1.、2.2.、及び2.3.1.を実行する。これにより、列挙部135は、有向グラフ7000に、ノード「CL」7111からノード「IV」7112へ接続するエッジ、及びノード「λI&」7121からノード「F」7122へ接続するエッジを追加する。さらに、列挙部135は、有向グラフ7000に、ノード「R&」7131からノード「IV」7132へ接続するエッジ、及びノード「P」7141からノード「WM」7142へ接続するエッジを追加して、有向グラフ7100を生成する。 Moving to FIG. 16E, the enumeration unit 135 processes the rewriting rule “AC_E” for the directed graph 7000 2.1. 2.2. , And 2.3.1. To execute. As a result, the enumeration unit 135 adds an edge connecting the node "CL" 7111 to the node "IV" 7112 and an edge connecting the node "λI &" 7121 to the node "F" 7122 to the directed graph 7000. Further, the enumeration unit 135 adds an edge connecting the node "R &" 7131 to the node "IV" 7132 and an edge connecting the node "P" 7141 to the node "WM" 7142 to the directed graph 7000, and adds an edge connecting the node "R &" 7131 to the node "WM" 7142. To generate.

図16Fに移って、列挙部135は、有向グラフ7100に対して、書換規則「AC_E」の処理3.を実行する。これにより、列挙部135は、有向グラフ7000から、ノード「λI& $2」7151及びノード「A&」7161を削除して、有向グラフ7200を生成する。 Moving to FIG. 16F, the enumeration unit 135 processes the rewriting rule “AC_E” with respect to the directed graph 7100. To execute. As a result, the enumeration unit 135 deletes the node "λI & $ 2" 7151 and the node "A &" 7161 from the directed graph 7000 to generate the directed graph 7200.

さらに、列挙部135は、有向グラフ7200に対して、書換規則「AC_E」の処理4.、及び種別「D」の書換規則「unref_E」を実行する。これにより、列挙部135は、有向グラフ7200から、ノード「R&」7131、ノード「λI&」7211及び7212、ノード「CL」7211及び7222並びにノード「RM」7231を削除する。また、列挙部135は、削除される各ノードに接続するエッジを整理して、有向グラフ7300を生成する。 Further, the enumeration unit 135 processes the rewriting rule “AC_E” with respect to the directed graph 7200. , And the rewriting rule "unref_E" of type "D" is executed. As a result, the enumeration unit 135 deletes the node “R &” 7131, the nodes “λI &” 7211 and 7212, the nodes “CL” 7211 and 7222, and the node “RM” 7231 from the directed graph 7200. In addition, the enumeration unit 135 organizes the edges connected to each node to be deleted and generates a directed graph 7300.

図16Gに移って、列挙部135は、統合された有向グラフ7300に対して、列挙処理を行う。有向グラフ7300において、「send」関数に関するノード「RI」7311は、ノード「A&」7321により参照される。また、ノード「A&」7321は、ノード「F」7331も参照している。そこで、列挙部135は、「send」関数に関するノード「RI」7311と呼出関係にあるノードを列挙する。 Moving on to FIG. 16G, the enumeration unit 135 performs an enumeration process on the integrated directed graph 7300. In directed graph 7300, node "RI" 7311 with respect to the "send" function is referenced by node "A &" 7321. Node "A &" 7321 also refers to node "F" 7331. Therefore, the enumeration unit 135 enumerates the nodes having a calling relationship with the node "RI" 7311 related to the "send" function.

列挙部135は、ノード「F」7331に呼び出されるノード「F」7341及びノード「IV」7333を列挙する。また、列挙部135は、ノード「F」7341にさらに呼び出されるノード「F」7351及びノード「IV」7343を列挙する。さらに、列挙部135は、ノード「F」7351にさらに呼び出されるノード「λI&」7353及びノード「IV」7352を列挙する。 The enumeration unit 135 enumerates the node "F" 7341 and the node "IV" 7333 called by the node "F" 7331. In addition, the enumeration unit 135 enumerates the node "F" 7351 and the node "IV" 7343 that are further called by the node "F" 7341. Further, the enumeration unit 135 enumerates the node "λI &" 7353 and the node "IV" 7352 which are further called by the node "F" 7351.

そして、列挙部135は、列挙されたノードを用いて、オブジェクト「p」に含まれる「send」関数に渡される引数の候補値を生成する。列挙部135は、ノード「IV」7333に対応する文字列「‘Foo’」7933と、ノード「IV」7343に対応する文字列「/create/space/」7943とを含む候補値を生成する。また、列挙部135は、候補値に、ノード「IV」7352に対応する文字列「‘http://’」7952と、ノード「λI&」7353に対応する変数「λI&Client.getResource.3」7953とをさらに含める。 Then, the enumeration unit 135 uses the enumerated nodes to generate candidate values of arguments to be passed to the "send" function included in the object "p". The enumeration unit 135 generates a candidate value including the character string "'Foo'" 7933 corresponding to the node "IV" 7333 and the character string "/ create / space /" 7943 corresponding to the node "IV" 7343. Further, the enumeration unit 135 includes, as candidate values, a character string "'http: //'" 7952 corresponding to the node "IV" 7352 and a variable "λI & Client.getResource.3" 7953 corresponding to the node "λI &" 7353. Include more.

そして、出力部136は、生成された候補値を含む出力画面7999を、例えば通信部110を通じて利用者の端末に出力する。 Then, the output unit 136 outputs the output screen 7999 including the generated candidate value to the user's terminal through, for example, the communication unit 110.

[処理の流れ]
次に、本実施例における処理について、図17乃至図22を用いて説明する。図17は、実施例1における解析処理の一例を示すフローチャートである。図17に示すように、解析装置100の取得部131は、例えば通信部110を通じて解析処理の開始指示を受け付けるまで待機する(S100:No)。
[Processing flow]
Next, the processing in this embodiment will be described with reference to FIGS. 17 to 22. FIG. 17 is a flowchart showing an example of the analysis process in the first embodiment. As shown in FIG. 17, the acquisition unit 131 of the analysis device 100 waits until, for example, the communication unit 110 receives an instruction to start the analysis process (S100: No).

取得部131は、開始指示を受け付けたと判定した場合(S100:Yes)、変換部132に対して、解析対象の関数に関する有向グラフの生成指示を出力するとともに、列挙部135に解析対象の関数を特定する情報を出力する。 When the acquisition unit 131 determines that the start instruction has been accepted (S100: Yes), the acquisition unit 131 outputs a directed graph generation instruction regarding the function to be analyzed to the conversion unit 132, and specifies the function to be analyzed to the enumeration unit 135. Output the information to be done.

変換部132は、有向グラフの生成指示の出力を受けると、変換処理を開始する(S110)。図18は、実施例1における変換処理の一例を示すフローチャートである。図18に示すように、変換部132は、ソースコードDB121から、解析対象の関数を含むソースコードを読み出して、構文木に変換する(S111)。次に、変換部132は、ノードを格納する変数であるfuncdicと、グラフを格納する変数であるgraphとを初期化する(S112)。例えば、変換部132は、funcdic及びgraphを初期化する。 Upon receiving the output of the directed graph generation instruction, the conversion unit 132 starts the conversion process (S110). FIG. 18 is a flowchart showing an example of the conversion process in the first embodiment. As shown in FIG. 18, the conversion unit 132 reads the source code including the function to be analyzed from the source code DB 121 and converts it into a syntax tree (S111). Next, the conversion unit 132 initializes funcdic, which is a variable that stores a node, and graph, which is a variable that stores a graph (S112). For example, the conversion unit 132 initializes the fundic and graph.

次に、変換部132は、生成した構文木の節点を、グラフ要素に変換する(S113)。変換部132は、全ての節点についてグラフ要素に変換するまで処理を繰り返す(S114:No)。変換部132は、全ての節点についてグラフ要素に変換すると(S114:Yes)、変換結果である有向グラフを元フローDB123に記憶し、S120に移行する。 Next, the conversion unit 132 converts the nodes of the generated syntax tree into graph elements (S113). The conversion unit 132 repeats the process until all the nodes are converted into graph elements (S114: No). When the conversion unit 132 converts all the nodes into graph elements (S114: Yes), the conversion unit 132 stores the directed graph as the conversion result in the original flow DB 123 and shifts to S120.

図17に戻って、解決部133は、記憶された有向グラフに対して解決処理を行う(S120)。図19は、実施例1における解決処理の一例を示すフローチャートである。まず、解決部133は、有向グラフに含まれる主ノード「λI&」を列挙し(S121)、各主ノードに対して種別「S」の書換規則を適用する(S122)。解決部133は、全ての主ノード「λI&」に対して処理を繰り返す(S123:No)。解決部133は、全ての主ノード「λI&」に対処した場合(S123:Yes)、変換結果である有向グラフを解決済みフローDB124に記憶し、S130に移行する。 Returning to FIG. 17, the resolution unit 133 performs a resolution process on the stored directed graph (S120). FIG. 19 is a flowchart showing an example of the solution process in the first embodiment. First, the solution unit 133 enumerates the main nodes "λI &" included in the directed graph (S121), and applies the rewriting rule of the type "S" to each main node (S122). The solution unit 133 repeats the process for all the main nodes "λI &" (S123: No). When all the main nodes "λI &" are dealt with (S123: Yes), the solving unit 133 stores the directed graph which is the conversion result in the solved flow DB 124 and shifts to S130.

図17に戻って、縮約部134は、記憶された解決済みの有向グラフに対して縮約処理を行う(S130)。図20は、実施例1における縮約処理の一例を示すフローチャートである。まず、縮約部134は、有向グラフに含まれる主ノード「λI&」を列挙し(S131)、各主ノードに対して種別「D」の書換規則を適用する(S132)。縮約部134は、全ての主ノード「λI&」に対して処理を繰り返す(S133:No)。縮約部134は、全ての主ノード「λI&」に対処した場合(S133:Yes)、変換結果である有向グラフを縮約済みフローDB126に記憶し、S140に移行する。 Returning to FIG. 17, the contraction unit 134 performs a contraction process on the stored resolved directed graph (S130). FIG. 20 is a flowchart showing an example of the reduction process in the first embodiment. First, the contraction unit 134 enumerates the main nodes "λI &" included in the directed graph (S131), and applies a rewriting rule of type "D" to each main node (S132). The contraction unit 134 repeats the process for all the main nodes “λI &” (S133: No). When all the main nodes "λI &" are dealt with (S133: Yes), the contraction unit 134 stores the directed graph as the conversion result in the contracted flow DB 126 and shifts to S140.

図17に戻って、解決部133は、解決処理及び縮約処理によって有向グラフが更新されたか否かを判定する(S140)。解決部133は、有向グラフが更新されたと判定した場合(S140:Yes)、S120に戻って処理を繰り返す。 Returning to FIG. 17, the resolution unit 133 determines whether or not the directed graph has been updated by the resolution process and the contraction process (S140). When the solution unit 133 determines that the directed graph has been updated (S140: Yes), it returns to S120 and repeats the process.

解決部133は、有向グラフが更新されていないと判定した場合(S140:No)、候補値の入力を受け付けるまで待機する(S150:No)。候補値の入力を受け付けた場合(S150:Yes)、列挙部135は、列挙処理を行う(S160)。 When the solution unit 133 determines that the directed graph has not been updated (S140: No), it waits until the input of the candidate value is accepted (S150: No). When the input of the candidate value is accepted (S150: Yes), the enumeration unit 135 performs the enumeration process (S160).

図21は、実施例1における列挙処理の一例を示すフローチャートである。列挙部135は、特定された関数に対して、呼出先のプログラムがあるか否かを判定する(S161)。列挙部135は、呼出先のプログラムがないと判定した場合(S161:No)、S162に移行する。一方、列挙部135は、呼出先のプログラムがあると判定した場合(S161:Yes)、結合処理を行う(S170)。 FIG. 21 is a flowchart showing an example of the enumeration process in the first embodiment. The enumeration unit 135 determines whether or not there is a program to be called for the specified function (S161). When the enumeration unit 135 determines that there is no program to be called (S161: No), the enumeration unit 135 shifts to S162. On the other hand, when the enumeration unit 135 determines that there is a program to be called (S161: Yes), the enumeration unit 135 performs a join process (S170).

図22は、実施例1における結合処理の一例を示すフローチャートである。まず、列挙部135は、列挙対象とする引数又は変数を含む関数の呼出元を列挙する(S171)。次に、列挙部135は、書換規則DB125を参照し、種別「M」の書換規則を呼出先の有向グラフに適用する(S172)。 FIG. 22 is a flowchart showing an example of the joining process in the first embodiment. First, the enumeration unit 135 enumerates the callers of the function including the arguments or variables to be enumerated (S171). Next, the enumeration unit 135 refers to the rewriting rule DB 125 and applies the rewriting rule of the type “M” to the directed graph of the callee (S172).

次に、列挙部135は、結合した有向グラフに含まれる主ノード「λI&」に対して、種別「M」の書換規則を適用する(S173)。列挙部135は、種別「M」の書換規則が適用されたグラフに含まれるノード「λI&」に対して、種別「S」の書換規則を適用する解決処理を行う(S174)。また、列挙部135は、ノード「λI&」に対して、種別「D」の書換規則を適用する解決処理を行う(S175)。 Next, the enumeration unit 135 applies a rewriting rule of type "M" to the main node "λI &" included in the combined directed graph (S173). The enumeration unit 135 performs a resolution process for applying the rewriting rule of the type "S" to the node "λI &" included in the graph to which the rewriting rule of the type "M" is applied (S174). Further, the enumeration unit 135 performs a resolution process for applying the rewriting rule of the type "D" to the node "λI &" (S175).

そして、列挙部135は、解決処理及び縮約処理によって結合した有向グラフが更新されたか否かを判定する(S176)。解決部133は、結合した有向グラフが更新されたと判定した場合(S176:Yes)、S174に戻って処理を繰り返す。 Then, the enumeration unit 135 determines whether or not the directed graph combined by the resolution process and the contraction process has been updated (S176). When it is determined that the combined directed graph has been updated (S176: Yes), the solving unit 133 returns to S174 and repeats the process.

列挙部135は、結合した有向グラフが更新されていないと判定した場合(S176:No)、列挙した全ての呼出元に対して対処するまで、S172に戻って処理を繰り返す(S177:No)。列挙部135は、全ての呼出元に対して対処したと判定した場合(S177:Yes)、S161に戻る。 When the enumeration unit 135 determines that the combined directed graph has not been updated (S176: No), the enumeration unit 135 returns to S172 and repeats the process until all the enumerated callers are dealt with (S177: No). When it is determined that all the callers have been dealt with (S177: Yes), the enumeration unit 135 returns to S161.

図21に戻って、列挙部135は、特定された関数に対して値を設定するノードを列挙する(S162)。次に、列挙部135は、有向グラフに含まれるFノードを、データの流れ及び処理の流れとは逆方向に探索していく(S163)。そして、列挙部135は、IVノードに到達するまで探索を繰り返す(S164:No)。 Returning to FIG. 21, the enumeration unit 135 enumerates the nodes for which the value is set for the specified function (S162). Next, the enumeration unit 135 searches for the F node included in the directed graph in the direction opposite to the data flow and the processing flow (S163). Then, the enumeration unit 135 repeats the search until it reaches the IV node (S164: No).

列挙部135は、IVノードに到達すると(S164:Yes)、列挙されたノードを文字列に変換し(S165)、S190に移行する。 When the enumeration unit 135 reaches the IV node (S164: Yes), the enumeration unit 135 converts the enumerated nodes into a character string (S165), and shifts to S190.

そして、出力部136は、値候補DB127に記憶された引数又は変数の候補値を、通信部110を通じて出力し(S190)、処理を終了する。 Then, the output unit 136 outputs the candidate values of the arguments or variables stored in the value candidate DB 127 through the communication unit 110 (S190), and ends the process.

[効果]
以上説明したように、本実施例における解析方法は、コンピュータが、プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成する。解析方法は、コンピュータが、データの流れと処理の流れとを用いて、動的型の参照解決と名前解決を実行する。解析方法は、コンピュータが、有向グラフをプログラムの関数単位で縮約する。さらに、解析方法は、コンピュータが、縮約した結果のうち、解析指示を受けた関数に関する解決結果を合わせた後に、データの処理の流れを探索する。これにより、動的型付き言語のソースコードを解析する際の誤列挙及び列挙漏れを抑制できる。
[effect]
As described above, in the analysis method in this embodiment, the computer generates a directed graph representing the data flow and the processing flow in the function of the program. In the analysis method, a computer performs dynamic type reference resolution and name resolution using a data flow and a processing flow. In the analysis method, the computer contracts the directed graph for each function of the program. Further, in the analysis method, the computer searches the data processing flow after matching the solution results related to the function for which the analysis instruction has been received among the contracted results. As a result, it is possible to suppress erroneous enumeration and omission of enumeration when analyzing the source code of the dynamically typed language.

また、解析方法は、コンピュータが、処理に対応する第1ノードと、データの参照に対応する第2ノードと、データの設定に対応する第3ノードとの接続関係を示す3部グラフを生成する。また、解析方法は、コンピュータが、第2ノード及び第3ノードとして、環境を渡すノードを含む3部グラフを生成する。これにより、データの流れ及び処理の流れを容易に特定できる。 Further, in the analysis method, the computer generates a three-part graph showing the connection relationship between the first node corresponding to the processing, the second node corresponding to the data reference, and the third node corresponding to the data setting. .. Further, in the analysis method, the computer generates a three-part graph including a node passing the environment as the second node and the third node. Thereby, the data flow and the processing flow can be easily specified.

また、解析方法は、コンピュータが、有向グラフを、解析指示を受けた関数の呼出先となるソースコードから生成された有向グラフの一部又は全部と結合し、結合された新たな有向グラフを用いてデータの処理の流れを探索する。これにより、呼出関係にあるその他のソースコードも含めて、データの流れ及び処理の流れを特定できる。 In the analysis method, the computer combines the directed graph with a part or all of the directed graph generated from the source code that is the call destination of the function that received the analysis instruction, and uses the combined new directed graph to obtain the data. Search the processing flow. Thereby, the data flow and the processing flow can be specified including other source codes having a calling relationship.

また、解析方法は、コンピュータが、探索された、関数に渡される値の候補を出力するので、候補値を容易に知得できる。 Further, in the analysis method, the computer outputs the searched value candidates to be passed to the function, so that the candidate values can be easily known.

また、解析方法は、コンピュータが、関数の呼出し時に参照されるオブジェクトの設定値候補を列挙することにより、関数が所属するクラスを特定する。これにより、誤列挙及び列挙漏れなく、候補値を列挙できる。 Further, in the analysis method, the computer identifies the class to which the function belongs by enumerating the setting value candidates of the object referred to when the function is called. As a result, candidate values can be enumerated without erroneous enumeration and omission of enumeration.

さらに、解析方法は、コンピュータが、有向グラフのうち、設定値候補の列挙対象の変数・引数が現れる関数に関連する部分に探索範囲を限定してデータの流れをたどるので、解析の時間を短縮できる。 Furthermore, the analysis method can shorten the analysis time because the computer traces the data flow by limiting the search range to the part of the directed graph related to the function in which the variable / argument to be listed as the set value candidate appears. ..

さて、これまで本発明の実施例について説明したが、本発明は上述した実施例以外にも、種々の異なる形態にて実施されてよいものである。例えば、実施例1に示す解析装置100は、プログラムに含まれる関数の引数の値を列挙することに加え、実施例1と同様の機能ブロックを用いて、実施例1と同様の処理の流れにより、関数内の変数への設定値を列挙することもできる。そこで、解析装置100が関数内の変数への設定値を列挙する構成について説明する。 By the way, although the examples of the present invention have been described so far, the present invention may be implemented in various different forms other than the above-mentioned examples. For example, the analysis device 100 shown in the first embodiment enumerates the values of the arguments of the functions included in the program, and uses the same functional blocks as those in the first embodiment, and follows the same processing flow as in the first embodiment. , You can also list the settings for variables in the function. Therefore, a configuration in which the analysis device 100 enumerates the set values for the variables in the function will be described.

本実施例において解析対象とするソースコードを、図23及び図24を用いて説明する。図23は、実施例2におけるソースコード変換結果の一例を示す図である。符号4000に示すソースコード4は、引数「self」及び「n」に対して、戻り値「n」を返す関数「Calc.abs」を定義するクラス「Calc」のソースコードである。 The source code to be analyzed in this embodiment will be described with reference to FIGS. 23 and 24. FIG. 23 is a diagram showing an example of the source code conversion result in the second embodiment. The source code 4 shown by reference numeral 4000 is the source code of the class “Calc” that defines the function “Calc.abs” that returns the return value “n” for the arguments “self” and “n”.

図24は、実施例2におけるソースコード変換結果の別の一例を示す図である。符号5000に示すソースコード5は、引数「self」及び「x」に対して、「self.n」を戻り値として返す関数「Calc.get」を定義するクラス「Calc」のソースコードである。本実施例においては、関数「Calc.get」において、変数「n」に設定される値の候補値を列挙する例について説明する。 FIG. 24 is a diagram showing another example of the source code conversion result in the second embodiment. The source code 5 shown by reference numeral 5000 is the source code of the class “Calc” that defines the function “Calc.get” that returns “self.n” as a return value for the arguments “self” and “x”. In this embodiment, an example of enumerating the candidate values of the values set in the variable "n" in the function "Calc.get" will be described.

図24に示すように、関数「Calc.get」は、ソースコード4に含まれる関数「Calc.abs」を呼び出している。そこで、解析装置100は、ソースコード5から有向グラフ5100を生成し、ソースコード4から生成した有向グラフ4100と統合する。 As shown in FIG. 24, the function "Calc.get" calls the function "Calc.abs" included in the source code 4. Therefore, the analysis device 100 generates a directed graph 5100 from the source code 5 and integrates it with the directed graph 4100 generated from the source code 4.

図25A及び図25Bは、ソースコード5の列挙処理及び統合処理の一例を示す図である。図25Aに示すように、解析装置100の列挙部135は、有向グラフ4100と有向グラフ5100とを統合した有向グラフ8100に対して、種別「M」の書換規則「AC_E」を適用することにより、有向グラフ8200を生成する。 25A and 25B are diagrams showing an example of the enumeration process and the integrated process of the source code 5. As shown in FIG. 25A, the enumeration unit 135 of the analysis device 100 applies the rewriting rule “AC_E” of the type “M” to the directed graph 8100, which integrates the directed graph 4100 and the directed graph 5100, to obtain the directed graph 8200. Generate.

次に、列挙部135は、変数「n」に関するノード「WM」8201に対して、変数「n」に関するパラメータを受け渡すノードとして、ノード「ID」8211及びノード「ID」8221を列挙する。 Next, the enumeration unit 135 enumerates the node "ID" 8211 and the node "ID" 8221 as nodes for passing the parameters related to the variable "n" to the node "WM" 8201 related to the variable "n".

図25Bに移って、列挙部135は、ノード「ID」8211に対して変数「n」に関するパラメータを受け渡すノードとして、ノード「λI&」8231を列挙する。また、列挙部135は、ノード「ID」8221に対して変数「n」に関するパラメータを受け渡すノードとして、ノード「F」8222を列挙する。さらに、列挙部135は、ノード「F」8222に対して変数「n」に関するパラメータを受け渡すノードとして、ノード「λI&」8231を列挙する。 Moving on to FIG. 25B, the enumeration unit 135 enumerates the node "λI &" 8231 as a node that passes the parameter related to the variable "n" to the node "ID" 8211. Further, the enumeration unit 135 enumerates the node "F" 8222 as a node that passes the parameter related to the variable "n" to the node "ID" 8221. Further, the enumeration unit 135 enumerates the node "λI &" 8231 as a node that passes the parameter related to the variable "n" to the node "F" 8222.

そして、列挙部135は、列挙されたノードを用いて、変数「n」に設定される値の候補値を生成する。列挙部135は、ノード「ID」8211に対応する値「λI&Calc.get.3」8911を、候補値として列挙する。また、列挙部135は、ノード「ID」8221に対応する値「F − λI&Calc.get.3」8921を、候補値として列挙する。 Then, the enumeration unit 135 generates a candidate value of the value set in the variable "n" by using the enumerated nodes. The enumeration unit 135 enumerates the value “λI & Calc.get.3” 8911 corresponding to the node “ID” 8211 as a candidate value. Further, the enumeration unit 135 enumerates the value "F-λI & Calc. Get.3" 8921 corresponding to the node "ID" 8221 as a candidate value.

そして、出力部136は、列挙された候補値を含む出力画面8999を、例えば通信部110を通じて利用者の端末に出力する。 Then, the output unit 136 outputs an output screen 8999 including the listed candidate values to the user's terminal through, for example, the communication unit 110.

このように、解析装置100は、プログラムに含まれる関数内の変数への設定値を列挙することもできる。 In this way, the analysis device 100 can also list the setting values for the variables in the function included in the program.

[システム]
また、図示した各部の各構成要素は、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各部の分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況等に応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。例えば、解決部133と縮約部134とを統合してもよい。また、図示した各処理は、上記の順番に限定されるものではなく、処理内容を矛盾させない範囲において、同時に実施してもよく、順序を入れ替えて実施してもよい。
[system]
Further, each component of each of the illustrated parts does not necessarily have to be physically configured as shown in the figure. That is, the specific form of distribution / integration of each part is not limited to the one shown in the figure, and all or part of it is functionally or physically distributed / integrated in any unit according to various loads and usage conditions. Can be configured. For example, the solution unit 133 and the contraction unit 134 may be integrated. Further, the illustrated processes are not limited to the above order, and may be performed simultaneously or in a different order as long as the processing contents do not contradict each other.

さらに、各装置で行われる各種処理機能は、CPU(又はMPU、MCU(Micro Controller Unit)等のマイクロ・コンピュータ)上で、その全部または任意の一部を実行するようにしてもよい。また、各種処理機能は、CPU(またはMPU、MCU等のマイクロ・コンピュータ)で解析実行されるプログラム上、またはワイヤードロジックによるハードウェア上で、その全部又は任意の一部を実行するようにしてもよいことは言うまでもない。 Further, the various processing functions performed by each device may execute all or any part thereof on the CPU (or a microcomputer such as an MPU or a MCU (Micro Controller Unit)). Further, various processing functions may be executed in whole or in any part on a program analyzed and executed by a CPU (or a microcomputer such as an MPU or MCU) or on hardware by wired logic. Needless to say, it's good.

ところで、上記の各実施例で説明した各種の処理は、予め用意されたプログラムをコンピュータで実行することで実現できる。そこで、以下では、上記の各実施例と同様の機能を有するプログラムを実行するコンピュータの一例を説明する。図26は、解析プログラムを実行するコンピュータの一例を示す図である。 By the way, various processes described in each of the above embodiments can be realized by executing a program prepared in advance on a computer. Therefore, in the following, an example of a computer that executes a program having the same functions as those in each of the above embodiments will be described. FIG. 26 is a diagram showing an example of a computer that executes an analysis program.

図26に示すように、コンピュータ300は、各種演算処理を実行するCPU370と、データ入力を受け付ける入力装置310と、出力装置320とを有する。また、コンピュータ300は、記憶媒体からプログラム等を読み取る媒体読取装置340と、各種装置との間でデータの授受を行う通信インターフェース(IF)330とを有する。また、コンピュータ300は、各種情報を一時記憶するRAM360と、ハードディスク装置(HDD)350とを有する。また、各装置310〜370は、バス380に接続される。 As shown in FIG. 26, the computer 300 includes a CPU 370 that executes various arithmetic processes, an input device 310 that accepts data input, and an output device 320. Further, the computer 300 has a medium reading device 340 for reading a program or the like from a storage medium, and a communication interface (IF) 330 for exchanging data between various devices. Further, the computer 300 has a RAM 360 for temporarily storing various information and a hard disk device (HDD) 350. Further, each device 310-370 is connected to the bus 380.

HDD350には、図4に示した取得部131、変換部132、解決部133、縮約部134、列挙部135及び出力部136の各処理部と同様の機能を有する解析プログラム351が記憶される。また、HDD350には、ソースコードDB121、クラス定義DB122、元フローDB123、解決済みフローDB124、書換規則DB125、縮約済みフローDB126及び値候補DB127が記憶される。さらに、HDD350には、解析プログラム351を実現するための各種データが記憶される。入力装置310は、例えば、コンピュータ300の管理者から各種情報の入力を受け付ける。出力装置320は、例えば、コンピュータ300の管理者に対して各種画面を表示する。通信IF330は、図示しないネットワークと接続され、各種装置と各種情報をやりとりする。 The HDD 350 stores an analysis program 351 having the same functions as the processing units of the acquisition unit 131, the conversion unit 132, the resolution unit 133, the contraction unit 134, the enumeration unit 135, and the output unit 136 shown in FIG. .. Further, the HDD 350 stores the source code DB 121, the class definition DB 122, the original flow DB 123, the resolved flow DB 124, the rewriting rule DB 125, the contracted flow DB 126, and the value candidate DB 127. Further, the HDD 350 stores various data for realizing the analysis program 351. The input device 310 receives, for example, input of various information from the administrator of the computer 300. The output device 320 displays various screens to the administrator of the computer 300, for example. The communication IF 330 is connected to a network (not shown) and exchanges various information with various devices.

CPU370は、HDD350に記憶された解析プログラム351などの各プログラムを読み出して、RAM360に展開して実行することで、解析プロセス371を行う。また、これらのプログラムは、コンピュータ300を図4に示した取得部131、変換部132、解決部133、縮約部134、列挙部135及び出力部136として機能させることができる。 The CPU 370 performs the analysis process 371 by reading out each program such as the analysis program 351 stored in the HDD 350, expanding the program into the RAM 360, and executing the program. Further, these programs can make the computer 300 function as the acquisition unit 131, the conversion unit 132, the resolution unit 133, the contraction unit 134, the enumeration unit 135, and the output unit 136 shown in FIG.

なお、上記の解析プログラム351は、必ずしもHDD350に記憶されている必要はない。例えば、コンピュータ300が読み取り可能な記憶媒体に記憶されたプログラムを、コンピュータ300が読み出して実行するようにしてもよい。コンピュータ300が読み取り可能な記憶媒体は、例えば、CD−ROMやDVD(Digital Versatile Disk)、USB(Universal Serial Bus)メモリ等の可搬型記録媒体、フラッシュメモリ等の半導体メモリ、ハードディスクドライブ等が対応する。また、公衆回線、インターネット、LAN等に接続された装置にこの解析プログラムを記憶させておき、コンピュータ300がこれらから解析プログラムを読み出して実行するようにしてもよい。 The analysis program 351 does not necessarily have to be stored in the HDD 350. For example, the computer 300 may read and execute a program stored in a storage medium that can be read by the computer 300. The storage medium that can be read by the computer 300 is, for example, a portable recording medium such as a CD-ROM, a DVD (Digital Versatile Disk), or a USB (Universal Serial Bus) memory, a semiconductor memory such as a flash memory, a hard disk drive, or the like. .. Further, the analysis program may be stored in a device connected to a public line, the Internet, a LAN, or the like, and the computer 300 may read the analysis program from these and execute the analysis program.

100 解析装置
110 通信部
120 記憶部
121 ソースコードDB
122 クラス定義DB
123 元フローDB
124 解決済みフローDB
125 書換規則DB
126 縮約済みフローDB
127 値候補DB
130 制御部
131 取得部
132 変換部
133 解決部
134 縮約部
135 列挙部
136 出力部
100 Analytical device 110 Communication unit 120 Storage unit 121 Source code DB
122 Class definition DB
123 original flow DB
124 Solved flow DB
125 Rewriting Rule DB
126 Contracted flow DB
127 Value Candidate DB
130 Control unit 131 Acquisition unit 132 Conversion unit 133 Resolution unit 134 Reduction unit 135 Enumeration unit 136 Output unit

Claims (8)

動的型付き言語のプログラムを静的に解析する解析方法において、
プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成し、
前記データの流れと前記処理の流れとを用いて、動的型の参照解決と名前解決を実行し、
前記有向グラフをプログラムの関数単位で縮約し、
前記縮約済みの有向グラフのうち、解析指示を受けた関数に関する呼出元及び呼出先のプログラムの有向グラフを結合し、結合された新たな有向グラフを用いてデータの処理の流れを探索する
処理をコンピュータが実行する解析方法。
In the analysis method that statically analyzes a program of a dynamically typed language
Generate a directed graph that represents the flow of data and the flow of processing in the function of the program.
Using the data flow and the processing flow, perform dynamic type reference resolution and name resolution.
The directed graph is reduced for each function of the program.
Among the reduced directed graphs , the computer performs the process of combining the directed graphs of the caller and called program related to the function that received the analysis instruction and searching the data processing flow using the combined new directed graph. The analysis method to perform.
前記生成する処理は、前記処理に対応する第1ノードと、前記データの参照に対応する第2ノードと、前記データの設定に対応する第3ノードとの接続関係を示す3部グラフを生成することを特徴とする請求項1に記載の解析方法。 The generated process generates a three-part graph showing the connection relationship between the first node corresponding to the process, the second node corresponding to the reference of the data, and the third node corresponding to the setting of the data. The analysis method according to claim 1, wherein the analysis method is characterized by the above. 前記生成する処理は、前記第2ノード及び前記第3ノードとして、環境を渡すノードを含む前記3部グラフを生成することを特徴とする請求項2に記載の解析方法。 The analysis method according to claim 2, wherein the generated process generates the three-part graph including the node passing the environment as the second node and the third node. 前記探索する処理により探索された、前記関数に渡される値の候補を出力する処理をさらに含むことを特徴とする請求項1乃至のいずれか1つに記載の解析方法。 The analysis method according to any one of claims 1 to 3 , further comprising a process of outputting a candidate of a value passed to the function, which is searched by the search process. 前記探索する処理は、前記関数の呼出し時に参照されるオブジェクトの設定値候補を列挙することにより、前記関数が所属するクラスを特定することを特徴とする請求項1乃至のいずれか1つに記載の解析方法。 The search process corresponds to any one of claims 1 to 4 , characterized in that the class to which the function belongs is specified by enumerating the setting value candidates of the object referred to when the function is called. The described analysis method. 前記探索する処理は、前記有向グラフのうち、前記設定値候補の列挙対象の変数・引数が現れる関数に関連する部分に探索範囲を限定することを特徴とする請求項に記載の解析方法。 The analysis method according to claim 5 , wherein the search process limits the search range to a portion of the directed graph related to a function in which the variable / argument to be enumerated of the set value candidate appears. プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成する生成部と、
前記データの流れと前記処理の流れとを用いて、動的型の参照解決と名前解決を実行する解決部と、
前記有向グラフをプログラムの関数単位で縮約する縮約部と、
前記縮約済みの有向グラフのうち、解析指示を受けた関数に関する呼出元及び呼出先のプログラムの有向グラフを結合し、結合された新たな有向グラフを用いてデータの処理の流れを探索する探索部と
を含む解析装置。
A generator that generates a directed graph that expresses the flow of data and the flow of processing in a program function,
A resolution unit that executes dynamic type reference resolution and name resolution using the data flow and the processing flow.
A contraction part that contracts the directed graph for each function of the program,
Among the reduced directed graphs , a search unit that combines the directed graphs of the caller and called program related to the function that received the analysis instruction and searches the data processing flow using the combined new directed graph. Analytical equipment including.
コンピュータに、
プログラムの関数内のデータの流れと処理の流れとを表現する有向グラフを生成し、
前記データの流れと前記処理の流れとを用いて、動的型の参照解決と名前解決を実行し、
前記有向グラフをプログラムの関数単位で縮約し、
前記縮約済みの有向グラフのうち、解析指示を受けた関数に関する呼出元及び呼出先のプログラムの有向グラフを結合し、結合された新たな有向グラフを用いてデータの処理の流れを探索する
処理を行わせる解析プログラム。
On the computer
Generate a directed graph that represents the flow of data and the flow of processing in the function of the program.
Using the data flow and the processing flow, perform dynamic type reference resolution and name resolution.
The directed graph is reduced for each function of the program.
Among the reduced directed graphs, the directed graphs of the caller and callee programs related to the function that received the analysis instruction are combined, and the combined new directed graph is used to search the data processing flow. Analysis program.
JP2017187242A 2017-09-27 2017-09-27 Analysis method, analysis device and analysis program Active JP6953962B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017187242A JP6953962B2 (en) 2017-09-27 2017-09-27 Analysis method, analysis device and analysis program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017187242A JP6953962B2 (en) 2017-09-27 2017-09-27 Analysis method, analysis device and analysis program

Publications (2)

Publication Number Publication Date
JP2019061587A JP2019061587A (en) 2019-04-18
JP6953962B2 true JP6953962B2 (en) 2021-10-27

Family

ID=66176700

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017187242A Active JP6953962B2 (en) 2017-09-27 2017-09-27 Analysis method, analysis device and analysis program

Country Status (1)

Country Link
JP (1) JP6953962B2 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007084780A2 (en) * 2006-01-20 2007-07-26 Aptana, Inc. Type inference system and method
JP5775829B2 (en) * 2012-01-30 2015-09-09 日立オートモティブシステムズ株式会社 Software structure visualization program and system
JP2014106770A (en) * 2012-11-28 2014-06-09 Fujitsu Frontech Ltd Type check device, type check method and type check program
JP5903038B2 (en) * 2012-12-26 2016-04-13 株式会社日立製作所 Source code equivalence verification apparatus and source code equivalence verification method

Also Published As

Publication number Publication date
JP2019061587A (en) 2019-04-18

Similar Documents

Publication Publication Date Title
US9934270B2 (en) Source code search engine
Chen et al. Case study of feature location using dependence graph
Sui et al. Value-flow-based demand-driven pointer analysis for C and C++
EP3234851B1 (en) A system and method for facilitating static analysis of software applications
US20050182614A1 (en) Systems and methods that facilitate quantum computer simulation
US9043757B2 (en) Identifying differences between source codes of different versions of a software when each source code is organized using incorporated files
JP2006523898A (en) Source code vulnerability detection method and detection system
CN106469049B (en) File scanning method and device
CN112860265A (en) Method and device for detecting operation abnormity of source code database
US10013244B2 (en) Apparatus and method to compile a variadic template function
JP2018169693A (en) Information processing device, information processing method, and information processing program
JP6953962B2 (en) Analysis method, analysis device and analysis program
US20220206934A1 (en) Test apparatus, test method and program
US8689200B1 (en) Method and system for optimizing an executable program by generating special operations for identical program entities
CN116578282A (en) Code generation method, device, electronic equipment and medium
Timo et al. Fault model-driven testing from FSM with symbolic inputs
Cholakov et al. Duplicate code detection algorithm
US20230315862A1 (en) Method and apparatus for identifying dynamically invoked computer code using literal values
JP7513116B2 (en) Call graph creation device, call graph creation method, and program
JP5342508B2 (en) Information processing apparatus, information processing method, and program
Sui et al. Demand-driven pointer analysis with strong updates via value-flow refinement
Takamatsu et al. Automated test generation for object-oriented programs with multiple targets
Sun et al. Model-based testing of web service with EFSM
Battle Analysis separation without visitors
Takamatsu et al. Automated test case generation considering object states in object-oriented programming

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20200611

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20210531

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20210622

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20210811

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20210831

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20210913

R150 Certificate of patent or registration of utility model

Ref document number: 6953962

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150