JP7450565B2 - Compilation method, development support device and control system - Google Patents

Compilation method, development support device and control system Download PDF

Info

Publication number
JP7450565B2
JP7450565B2 JP2021014739A JP2021014739A JP7450565B2 JP 7450565 B2 JP7450565 B2 JP 7450565B2 JP 2021014739 A JP2021014739 A JP 2021014739A JP 2021014739 A JP2021014739 A JP 2021014739A JP 7450565 B2 JP7450565 B2 JP 7450565B2
Authority
JP
Japan
Prior art keywords
source code
directed graph
nodes
modified
edges
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
JP2021014739A
Other languages
Japanese (ja)
Other versions
JP2022118310A (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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2021014739A priority Critical patent/JP7450565B2/en
Publication of JP2022118310A publication Critical patent/JP2022118310A/en
Application granted granted Critical
Publication of JP7450565B2 publication Critical patent/JP7450565B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)
  • Programmable Controllers (AREA)

Description

本願は、コンパイル方法、開発支援装置および制御システムに関するものである。 The present application relates to a compilation method, a development support device, and a control system.

計装制御システムにおいて、計装機器の制御装置は原則連続稼働する。そのため、制御装置に使用されているソフトウエアのソースコードの論理式等(ロジック)の修正(変更または更新)が必要な場合に限り、開発支援装置などの保守ツールを用いて、変更されたソースコードのコンパイルを行い、制御装置への転送処理が行われる。 In an instrumentation control system, the control device of the instrumentation equipment operates continuously in principle. Therefore, only when it is necessary to modify (change or update) the logical formulas, etc. (logic) of the source code of the software used in the control device, maintenance tools such as development support equipment can be used to update the modified source code. The code is compiled and transferred to the control device.

このようなプログラムのコンパイル中は客先作業が停止するので、必要に応じて最小限の変更を高速に行うことが求められる。このため、作業の大部分は、局部的な修正で対応可能であるため、修正箇所を含む一部だけをコンパイルし、必要最低限の機械語オブジェクトを生成してプログラムを更新する方法が知られている(例えば、特許文献1参照)。 Since the customer's work stops while compiling such a program, it is necessary to quickly make minimal changes as necessary. For this reason, most of the work can be handled by local modifications, so there is no known method to update the program by compiling only the part that includes the modified parts and generating the minimum necessary machine language objects. (For example, see Patent Document 1).

特開2016-151973号公報JP 2016-151973 Publication

特許文献1のコンパイル方法は、テキスト形式の中間言語を用い、コンパイラ成果物としての機械語を出力することで、入力言語または中間言語の修正のあった箇所のみをコンパイル対象とすることができる。しかし、場合分けの中身を入れ替えるような修正をした場合、ロジックの差分としては少量であるにもかかわらず、入力言語のテキストとしては大きな差分が生じることがある。計装制御ではこのような差分の修正は頻繁に行われるため、コンパイルを行うために計装制御を中止するための時間が増加し、客先作業に支障が生じるなどの問題があった。 The compiling method disclosed in Patent Document 1 uses a text-format intermediate language and outputs machine language as a compiler product, thereby making it possible to compile only the portions where the input language or intermediate language has been modified. However, if a modification is made to replace the contents of the case classification, a large difference may occur in the text of the input language, although the difference in logic is small. Since such differences are frequently corrected in instrumentation control, it increases the amount of time it takes to stop instrumentation control in order to perform compilation, which poses problems such as hindrance to customer work.

本願は、上述のような問題を解決するためになされたもので、ソースコードの修正によるコンパイルの時間を短縮することができるコンパイル方法、開発支援装置および制御システムを提供することを目的とする。 The present application was made to solve the above-mentioned problems, and aims to provide a compilation method, a development support device, and a control system that can shorten compilation time by modifying source code.

本願に開示されるコンパイル方法は、
ソースコードの入力言語から、ノードとエッジからなる複数のグループに分類された有向グラフを中間言語として生成し、ソースコードを修正するとき、修正前のソースコードの有向グラフと修正後のソースコードの有向グラフを、ノードおよびエッジごとに比較し、修正されたノードおよびエッジのいずれかを含むグループをコンパイルするコンパイル方法。
The compilation method disclosed in this application is
A digraph classified into multiple groups consisting of nodes and edges is generated as an intermediate language from the source code input language, and when modifying the source code, the digraph of the source code before modification and the digraph of the source code after modification are generated. , a compilation method that compares node-by-node and edge-by-edge and compiles groups containing any of the modified nodes and edges.

本願に開示されるコンパイル方法によれば、有向グラフの内、修正されたノードおよびエッジのいずれかを含むグループをコンパイルするので、コンパイルの時間を短縮することができる。 According to the compilation method disclosed in this application, a group that includes either a modified node or an edge in a directed graph is compiled, so that the compilation time can be shortened.

実施の形態1に係る制御システムの構成図である。1 is a configuration diagram of a control system according to Embodiment 1. FIG. 実施の形態1に係る開発支援装置のハードウエア構成図である。1 is a hardware configuration diagram of a development support device according to Embodiment 1. FIG. 実施の形態1に係るコンパイラ機能部の処理を説明する図である。FIG. 3 is a diagram illustrating processing of a compiler functional unit according to the first embodiment. 実施の形態1に係るソースコードと中間言語の例を説明する図である。FIG. 3 is a diagram illustrating an example of source code and intermediate language according to the first embodiment. 実施の形態1に係る実施例1を説明する図である。1 is a diagram illustrating Example 1 according to Embodiment 1. FIG. 実施の形態1に係る実施例2を説明する図である。FIG. 7 is a diagram illustrating Example 2 according to Embodiment 1. 実施の形態1に係る実施例3を説明する図である。FIG. 7 is a diagram illustrating Example 3 according to Embodiment 1. 実施の形態1に係る実施例4を説明する図である。FIG. 4 is a diagram illustrating Example 4 according to Embodiment 1. 実施の形態1に係る実施例5を説明する図である。FIG. 7 is a diagram illustrating Example 5 according to Embodiment 1. 実施の形態2に係る動作ロジックの転送を説明する図である。FIG. 7 is a diagram illustrating transfer of operation logic according to the second embodiment. 実施の形態3に係るソースコードのロジック等価性を説明する図である。FIG. 7 is a diagram illustrating logic equivalence of source codes according to Embodiment 3; 実施の形態3に係るロジック等価性に基づいたソースコードの変換を説明する図である。FIG. 7 is a diagram illustrating source code conversion based on logic equivalence according to Embodiment 3; 実施の形態4に係るロジック等価性に基づいた静的解析を説明する図である。FIG. 7 is a diagram illustrating static analysis based on logic equivalence according to Embodiment 4;

以下、本願に係るコンパイル方法の好適な実施の形態について、図面を参照して説明する。なお、同一内容および相当部については同一符号を配し、その詳しい説明は省略する。以降の実施形態も同様に、同一符号を付した構成について重複した説明は省略する。 Hereinafter, preferred embodiments of the compiling method according to the present application will be described with reference to the drawings. Note that the same content and corresponding parts are designated by the same reference numerals, and detailed explanation thereof will be omitted. Similarly, in the embodiments that follow, redundant explanations will be omitted for the components denoted by the same reference numerals.

実施の形態1.
<制御システムの構成>
図1は、本実施の形態に係る制御システムの構成図である。本システムは、開発支援装置10、計装機器を制御する制御装置30などを有する。開発支援装置10は、制御装置30用の制御プログラムのソースコード21をユーザに作成させるインターフェース機能部11を有する。制御装置30は、例えばPLC(プログラマブルコントローラ)、DCS(Distributed Control System:分散制御システム)などであってもよい。
Embodiment 1.
<Control system configuration>
FIG. 1 is a configuration diagram of a control system according to this embodiment. This system includes a development support device 10, a control device 30 that controls instrumentation equipment, and the like. The development support device 10 includes an interface function section 11 that allows a user to create a source code 21 of a control program for the control device 30. The control device 30 may be, for example, a PLC (programmable controller), a DCS (distributed control system), or the like.

また、ユーザが作成したソースコード21を、制御装置30上で動作する機械語24に変換するコンパイラ機能部13(フロントエンドコンパイラ13a、バックエンドコンパイラ13b)を有する。これは、一旦、中間言語22に変換した後に機械語24に変換するものである。 It also includes a compiler function unit 13 (front-end compiler 13a, back-end compiler 13b) that converts the source code 21 created by the user into machine language 24 that runs on the control device 30. This is done by first converting into intermediate language 22 and then into machine language 24.

フロントエンドコンパイラ13aが、ソースコード21を解析して中間言語22に変換する。続いて、バックエンドコンパイラ13bが、この中間言語22を制御装置30で動作する機械語24に変換する。 The front-end compiler 13a analyzes the source code 21 and converts it into an intermediate language 22. Subsequently, the back-end compiler 13b converts this intermediate language 22 into a machine language 24 that operates on the control device 30.

開発支援装置10は、通信機能部12を有する。通信機能部12により、無線あるいは通信線などを介して制御装置30の通信機能部31と通信を行うことができる。例えば、コンパイル処理により生成された機械語24等を、通信機能部12によって制御装置30にダウンロードする。ダウンロードされた機械語24は、プログラム実行管理機能部32に記憶されて処理され、制御装置30は機械語24に応じた動作を行う。さらに、ディスプレイなどの画面15、キーボードおよびマウスなどの入力装置16を備えている。 The development support device 10 has a communication function section 12 . The communication function section 12 can communicate with the communication function section 31 of the control device 30 wirelessly or via a communication line. For example, the machine language 24 and the like generated by the compiling process are downloaded to the control device 30 by the communication function unit 12. The downloaded machine language 24 is stored and processed in the program execution management function unit 32, and the control device 30 performs operations according to the machine language 24. Furthermore, it is provided with a screen 15 such as a display, and an input device 16 such as a keyboard and a mouse.

開発支援装置10および制御装置30は、例えば、パソコンなどの汎用のコンピュータ上で実現されるものであってもよく、図2にハードウエア構成を示す。プロセッサ100と記憶装置200から構成され、図示していないが、記憶装置はランダムアクセスメモリ等の揮発性記憶装置と、フラッシュメモリ等の不揮発性の補助記憶装置とを具備する。また、フラッシュメモリの代わりにハードディスクの補助記憶装置を具備してもよい。プロセッサ100は、記憶装置200から入力されたアプリケーションプログラムを実行することにより、コンパイルを行う。この場合、補助記憶装置から揮発性記憶装置を介してプロセッサ100にプログラムが入力される。また、プロセッサ100は、演算結果等のデータを記憶装置200の揮発性記憶装置に出力してもよいし、揮発性記憶装置を介して補助記憶装置にデータを保存してもよい。 The development support device 10 and the control device 30 may be realized, for example, on a general-purpose computer such as a personal computer, and the hardware configuration is shown in FIG. 2. It is composed of a processor 100 and a storage device 200, and although not shown, the storage device includes a volatile storage device such as a random access memory, and a nonvolatile auxiliary storage device such as a flash memory. Further, an auxiliary storage device such as a hard disk may be provided instead of the flash memory. The processor 100 compiles the application program input from the storage device 200 by executing it. In this case, the program is input from the auxiliary storage device to the processor 100 via the volatile storage device. Furthermore, the processor 100 may output data such as calculation results to a volatile storage device of the storage device 200, or may store data in an auxiliary storage device via the volatile storage device.

図3は実施の形態1における開発支援装置10内のコンパイラ機能部13での処理を説明する図である。例えば、図に示すように、ソースコード21をコンパイルする場合(1回目)、フロントエンドコンパイラ13aに入力されたソースコード21から中間言語である有向グラフの動作ロジックを生成する。有向グラフは、後述するように、ロジックで使用されるデータをデータフローと制御フローとで表す。データフローと制御フローは、それぞれノードとエッジから構成される。その後、バックエンドコンパイラ13bで、有向グラフを入力として、機械語24を生成する。 FIG. 3 is a diagram illustrating processing in the compiler function unit 13 in the development support apparatus 10 in the first embodiment. For example, as shown in the figure, when compiling the source code 21 (first time), the operational logic of a directed graph, which is an intermediate language, is generated from the source code 21 input to the front-end compiler 13a. A directed graph represents data used in logic as a data flow and a control flow, as described below. Data flow and control flow are composed of nodes and edges, respectively. Thereafter, the back-end compiler 13b receives the directed graph as input and generates the machine language 24.

次に、ソースコード21の修正があった場合、機械語を書き換える必要があるため、修正があったソースコード21aをコンパイルする(2回目)。入力された修正ソースコード21aから有向グラフの動作ロジックを生成した後、1回目に行ったコンパイルの有向グラフとコンパイル2回目の有向グラフとの差分をフロントエンドコンパイラ13aにより生成する。生成された有向グラフの差分から差分箇所のみの機械語24aを生成し、コンパイル1回目に生成された機械語24を、バックエンドコンパイラ13bにより変更する(機械語24b)。これによりコンパイルの時間は短縮される。 Next, when the source code 21 is modified, the machine language needs to be rewritten, so the modified source code 21a is compiled (second time). After generating the operational logic of the directed graph from the input modified source code 21a, the front-end compiler 13a generates a difference between the directed graph of the first compilation and the digraph of the second compilation. A machine language 24a containing only the difference portion is generated from the difference between the generated directed graphs, and the machine language 24 generated at the first time of compilation is changed by the back-end compiler 13b (machine language 24b). This reduces compilation time.

<実施例1>
図4に具体的なソースコードとソースコードから生成した中間言語の例を示す。ソースコードはST(Structured Text)言語を例に説明するがこれに限るものではない。また、中間言語は簡易化した表現としている。図1に示されたインターフェース機能部11から、図4の版1に示されたソースコードがコンパイラ機能部13に入力され、1回目のコンパイルが行われる。コンパイラ機能部13のフロントエンドコンパイラ13aにより、ソースコードから、ノードとエッジで構成される有向グラフの中間言語を生成する(図4の版1の中間言語を参照)。生成された中間言語22の有向グラフは、図1の差分情報管理部14に記憶される。
<Example 1>
FIG. 4 shows an example of a specific source code and an intermediate language generated from the source code. The source code will be explained using ST (Structured Text) language as an example, but is not limited to this. In addition, the intermediate language is expressed in a simplified manner. The source code shown in version 1 of FIG. 4 is input from the interface function section 11 shown in FIG. 1 to the compiler function section 13, and the first compilation is performed. The front-end compiler 13a of the compiler function unit 13 generates an intermediate language of a directed graph composed of nodes and edges from the source code (see version 1 intermediate language of FIG. 4). The generated directed graph of the intermediate language 22 is stored in the difference information management unit 14 in FIG.

次に、図4中、版2で示された、修正ソースコードがインターフェース機能部11を介してコンパイラ機能部13に入力され、2回目のコンパイルが行われる。版2の修正ソースコードは、版1のソースコードと同様、フロントエンドコンパイラ13aにより、ノードとエッジで構成される有向グラフの中間言語を生成する。(図4の版2の中間言語を参照)。生成された中間言語の有向グラフは、版1の場合同様、差分情報管理部14に記憶される。 Next, the modified source code shown as version 2 in FIG. 4 is input to the compiler function unit 13 via the interface function unit 11, and a second compilation is performed. Similar to the version 1 source code, the version 2 modified source code generates an intermediate language of a directed graph composed of nodes and edges by the front-end compiler 13a. (See version 2 intermediate language in Figure 4). The generated digraph of the intermediate language is stored in the difference information management unit 14 as in the case of version 1.

差分情報管理部14に記憶されている1回目のコンパイルによる版1の中間言語の有向グラフと、2回目のコンパイルが行われた版2の有向グラフの中間言語とをフロントエンドコンパイラ13aで比較し、差分を抽出する。差分の抽出は、それぞれの有向グラフを構成するノードとエッジの同一性を比較することにより行う。 The front-end compiler 13a compares the intermediate language digraph of version 1 obtained by the first compilation, which is stored in the difference information management unit 14, and the intermediate language digraph of version 2 compiled the second time, and calculates the difference. Extract. Differences are extracted by comparing the identities of nodes and edges that constitute each directed graph.

比較した結果、図4中、版1から版2への有向グラフの変更点は、要素のノードBと要素のノードCを加算する「加算演算子」のノードを、「減算演算子」のノードに変更している。従って、有向グラフの中間言語上では、演算子を表す1つのノードのみが差分となる。 As a result of the comparison, the changes in the directed graph from version 1 to version 2 in Figure 4 are that the "addition operator" node that adds element node B and element node C is replaced with the "subtraction operator" node. It is changing. Therefore, in the intermediate language of the directed graph, only one node representing the operator is a difference.

さらに、版2のソースコードを、版3のソースコードに修正する場合、上述と同様の手順により、版3の中間言語の有向グラフを生成する。生成された中間言語の有向グラフは、版1の場合同様、差分情報管理部14に記憶される。版2の中間言語の有向グラフと、版3の有向グラフの中間言語を、それぞれのノードとエッジを比較し、差分を抽出する。 Further, when modifying the version 2 source code to the version 3 source code, a directed graph of the version 3 intermediate language is generated using the same procedure as described above. The generated digraph of the intermediate language is stored in the difference information management unit 14 as in the case of version 1. Compare the nodes and edges of the intermediate language digraph of version 2 and the intermediate language of the digraph of version 3, and extract the difference.

版2の有向グラフから版3の有向グラフへの変更点は、IF文の分岐先が異なるのみであるので、制御エッジの繋ぎ替えのみが差分となる。このように、中間言語である有向グラフで表した動作ロジックの差分は、コーディング変更量に対して比較的小さくなる傾向がある。有向グラフの差分比較は、有向グラフ間の編集距離(ノードおよびエッジの追加/編集/削除の回数)を求めることにより実現する。以降のバックエンドコンパイラ13bのコンパイル処理では中間言語の各ノードを順に処理していくが、この結果を利用すれば、ソースコードの変更点については差異のあった有向グラフのノードまたはエッジのみを処理すれば良く、処理が高速化する。 The only change from the version 2 directed graph to the version 3 directed graph is that the branch destination of the IF statement is different, so the only difference is the reconnection of control edges. In this way, the difference in operational logic expressed in a directed graph, which is an intermediate language, tends to be relatively small compared to the amount of coding change. Difference comparison of directed graphs is achieved by determining the edit distance (number of additions/edits/deletions of nodes and edges) between directed graphs. In the subsequent compilation process of the back-end compiler 13b, each node of the intermediate language is processed in turn, but if this result is used, it is possible to process only the nodes or edges of the directed graph that have differences when it comes to changes in the source code. The better, the faster the processing.

図5(a)は、図4における、版3で示した有向グラフの中間言語である。版2から版3のソースコードの変更について、中間言語にテキスト形式を使用したコンパイル(比較例1)と有向グラフを使用したコンパイル(実施例1)のそれぞれの処理ステップ数の比較を図5(b)に示す。中間言語のコンパイルは、図5(a)に示すように、ノードから次のノードへ接続されるエッジまたは末端までを1グループとした単位で処理される。従って、図6には、8つのグループが示されている。 FIG. 5(a) is an intermediate language of the directed graph shown in version 3 in FIG. Figure 5 (b) shows a comparison of the number of processing steps between compilation using text format as the intermediate language (Comparative Example 1) and compilation using directed graph (Example 1) regarding changes in source code from version 2 to version 3. ). As shown in FIG. 5(a), the intermediate language is compiled in units of groups including edges or terminals connected from a node to the next node. Accordingly, eight groups are shown in FIG.

各グループのコンパイルに掛かる処理時間を処理ステップ数で表す。処理ステップ数をそれぞれ平均10ステップとすると、8つのグループの処理に合計80ステップを要する。比較例1ではテキスト形式で差分比較をするので、図4の版3に示すように、差分として、「D:=B-C;」および「D:=A;」を検出する。ここで、テキストの差分比較に掛かる時間は無視できるものとする。すると、これらの差分に相当するグループは、グループ3~8の6グループあるので、合計60ステップ掛かる。 The processing time required to compile each group is expressed by the number of processing steps. Assuming that the number of processing steps is 10 on average for each, a total of 80 steps are required to process the eight groups. In Comparative Example 1, differences are compared in text format, so as shown in version 3 of FIG. 4, "D:=B−C;" and "D:=A;" are detected as differences. Here, it is assumed that the time required to compare text differences can be ignored. Then, since there are six groups corresponding to these differences, groups 3 to 8, it takes a total of 60 steps.

一方、実施例1の有向グラフの中間言語に対して差分比較を行う。前述したように、差分比較は、ノード、エッジなどすべての要素を対象として行う。1要素の比較に掛かる時間を平均1ステップとすると、図5(b)の場合は19要素あるので、19ステップ掛かる。差分比較の結果、図5(a)中、実線で囲んだグループ2のみをコンパイルすればよいので、処理時間は10ステップで済み、合計29ステップとなる。従って比較例1に比べ、コンパイル時間が48%に短縮されている。 On the other hand, a difference comparison is performed on the intermediate language of the directed graph of the first embodiment. As mentioned above, the difference comparison is performed for all elements such as nodes and edges. Assuming that the time required to compare one element is one step on average, in the case of FIG. 5(b), there are 19 elements, so it takes 19 steps. As a result of the difference comparison, only the group 2 surrounded by the solid line in FIG. 5(a) needs to be compiled, so the processing time is only 10 steps, resulting in a total of 29 steps. Therefore, compared to Comparative Example 1, the compile time is reduced by 48%.

<実施例2>
図6(a)は、代入文の例である。テキスト形式で差分比較をした比較例2では、差分として「B:=C;」を検出する。テキストの差分比較に掛かる時間は無視できるものとする。これらの差分に相当するグループは、グループ1~3の3グループであるので、合計30ステップ掛かる。
<Example 2>
FIG. 6(a) is an example of an assignment statement. In Comparative Example 2 in which the difference is compared in text format, "B:=C;" is detected as the difference. It is assumed that the time required to compare text differences can be ignored. Since there are three groups corresponding to these differences, groups 1 to 3, it takes a total of 30 steps.

一方、有向グラフの中間言語に対して差分比較を行う実施例2において、図6(b)に示すように、各ノードおよび各エッジ、合わせて5要素を差分比較するので、5ステップ掛かる。差分比較の結果、図6(a)中、実線で囲んだグループ1のみをコンパイルすればよいので、処理時間は10ステップで済み、合計15ステップとなる。従って、比較例2に比べ、コンパイル時間は50%に短縮されている。 On the other hand, in the second embodiment in which differential comparison is performed for the intermediate language of a directed graph, as shown in FIG. 6(b), each node and each edge, a total of five elements, are differentially compared, so it takes five steps. As a result of the difference comparison, only the group 1 surrounded by the solid line in FIG. 6(a) needs to be compiled, so the processing time is only 10 steps, resulting in a total of 15 steps. Therefore, compared to Comparative Example 2, the compile time is reduced by 50%.

<実施例3>
図7(a)は、四則演算の例である。テキスト形式で差分比較をした比較例3では、差分として、「D:=(A-B)/C;」を検出する。テキストの差分比較に掛かる時間は無視できるものとする。これらの差分に相当するグループは、グループ1~7の7グループであるので、合計70ステップ掛かる。
<Example 3>
FIG. 7(a) is an example of four arithmetic operations. In Comparative Example 3 in which the difference is compared in text format, "D:=(AB)/C;" is detected as the difference. It is assumed that the time required to compare text differences can be ignored. Since there are seven groups corresponding to these differences, groups 1 to 7, it takes a total of 70 steps.

一方、有向グラフの中間言語に対して差分比較を行う実施例3において、図7(b)に示すように、ノードとエッジを合わせて13要素を差分比較するので、13ステップ掛かる。差分比較の結果、図7(a)中、実線で囲んだグループ3およびグループ5をコンパイルすればよいので、処理時間は20ステップで済み、合計33ステップとなる。従って、比較例3に比べ、コンパイル時間は47%に短縮される。 On the other hand, in the third embodiment in which differential comparison is performed on the intermediate language of a directed graph, as shown in FIG. 7(b), 13 elements including nodes and edges are differentially compared, so it takes 13 steps. As a result of the difference comparison, it is only necessary to compile groups 3 and 5 surrounded by solid lines in FIG. 7(a), so the processing time is only 20 steps, resulting in a total of 33 steps. Therefore, compared to Comparative Example 3, the compile time is reduced to 47%.

<実施例4>
図8(a)は、FOR文の例である。テキスト形式で差分比較をした比較例4では、差分として、「A:=0;」「FOR I:=(4 TO 8 DO)」「A:A+I-3;」「END_FOR;」を検出する。テキストの差分比較に掛かる時間は無視できるものとする。これらの差分に相当するグループは、グループ4~14の11グループであるので、合計110ステップ掛かる。
<Example 4>
FIG. 8(a) is an example of a FOR statement. In Comparative Example 4, in which differences are compared in text format, "A:=0;", "FOR I:=(4 TO 8 DO)", "A:A+I-3;", and "END_FOR;" are detected as differences. It is assumed that the time required to compare text differences can be ignored. Since there are 11 groups corresponding to these differences, groups 4 to 14, it takes a total of 110 steps.

一方、有向グラフの中間言語に対して差分比較を行う実施例4において、図8(b)に示すように、ノードとエッジ合わせて27要素を差分比較するので、27ステップ掛かる。差分比較の結果、図8(a)中、実線で囲んだグループ5、6、10、13、およびグループ14をコンパイルすればよいので、処理時間は50ステップで済み、合計77ステップとなる。従って、比較例4に比べ、コンパイル時間は70%に短縮される。 On the other hand, in the fourth embodiment in which differential comparison is performed on the intermediate language of a directed graph, as shown in FIG. 8(b), since 27 elements including nodes and edges are differentially compared, it takes 27 steps. As a result of the difference comparison, it is sufficient to compile groups 5, 6, 10, 13, and group 14 surrounded by solid lines in FIG. 8(a), so the processing time is only 50 steps, making a total of 77 steps. Therefore, compared to Comparative Example 4, the compile time is reduced by 70%.

<実施例5>
図9(a)は、WHILE文の例である。テキスト形式で差分比較をした比較例5では、差分として、「A:=5;」「WHILE A<10 DO)」「A:A+I;」「END_WHILE」を検出する。テキストの差分比較に掛かる時間は無視できるものとする。これらの差分に相当するグループは、グループ4~12の9グループであるので、合計90ステップ掛かる。
<Example 5>
FIG. 9(a) is an example of a WHILE statement. In Comparative Example 5, in which differences are compared in text format, "A:=5;", "WHILE A<10 DO)", "A:A+I;", and "END_WHILE" are detected as differences. It is assumed that the time required to compare text differences can be ignored. Since there are nine groups corresponding to these differences, groups 4 to 12, it takes a total of 90 steps.

一方、有向グラフの中間言語に対して差分比較を行う実施例5において、図9(b)に示すように、ノードとエッジ合わせて23要素を差分比較するので、23ステップ掛かる。差分比較の結果、図9(a)中、実線で囲んだグループ5、6、およびグループ10をコンパイルすればよいので、処理時間は30ステップで済み、合計53ステップとなる。従って、比較例5に比べ、コンパイル時間は59%に短縮される。 On the other hand, in the fifth embodiment in which differential comparison is performed on the intermediate language of a directed graph, as shown in FIG. 9(b), 23 elements including nodes and edges are differentially compared, so it takes 23 steps. As a result of the difference comparison, it is sufficient to compile groups 5, 6, and 10 surrounded by solid lines in FIG. 9(a), so that the processing time is only 30 steps, resulting in a total of 53 steps. Therefore, compared to Comparative Example 5, the compile time is reduced to 59%.

以上説明したように、テキスト形式での差分比較に比べ本実施の形態による中間言語に有向グラフを使用した動作ロジックの差分比較によるコンパイルは、処理時間を半分程度に短縮できる。 As described above, compared to text-based differential comparison, compiling by differential comparison of operational logic using a directed graph as an intermediate language according to the present embodiment can reduce processing time to about half.

実施の形態2.
実施の形態1で使用した有向グラフによる動作ロジックを、コンパイルだけではなく、図1に示す制御装置30への転送処理にも適用する。この場合、制御装置30内のプログラム実行管理機能部32が動作ロジックを有向グラフの構造で認識出来ることを前提とする。
Embodiment 2.
The operation logic using the directed graph used in the first embodiment is applied not only to compilation but also to the transfer process to the control device 30 shown in FIG. In this case, it is assumed that the program execution management function unit 32 in the control device 30 can recognize the operation logic in the structure of a directed graph.

例えば、図10において、実施の形態1同様、ユーザが作成したソースコード21を、開発支援装置10のフロントエンドコンパイラ13aで、中間言語の有向グラフによる動作ロジックにコンパイルする(1回目)。この動作ロジックを差分情報管理部14に記憶するとともに、制御装置30に転送する。次に、ソースコード21の修正があった場合、制御装置30の機械語を書き換える必要があるため、修正があったソースコード21aをコンパイルする(2回目)、1回目のコンパイルと同様に、入力されたソースコードから有向グラフの動作ロジックをコンパイルした後、差分情報管理部に記憶されている1回目の動作ロジックと比較し、差分をフロントエンドコンパイラ13aにより生成する。生成された動作ロジックの差分箇所のみを通信機能部12、31を介して制御装置30に転送する。転送された修正部分の動作ロジックをプログラム実行管理機能部32で併合し、併合されたプログラムにより、制御装置は動作する。差分比較については、実施の形態1で説明した実施例1~5と同様に行う。 For example, in FIG. 10, as in the first embodiment, the source code 21 created by the user is compiled by the front-end compiler 13a of the development support device 10 into operational logic using a directed graph of an intermediate language (first time). This operation logic is stored in the difference information management section 14 and transferred to the control device 30. Next, when the source code 21 is modified, it is necessary to rewrite the machine language of the control device 30, so the modified source code 21a is compiled (second time). As in the first compilation, the input After compiling the operational logic of the directed graph from the source code, it is compared with the first operational logic stored in the difference information management section, and a difference is generated by the front-end compiler 13a. Only the generated operational logic differences are transferred to the control device 30 via the communication function units 12 and 31. The transferred operation logic of the modified portion is merged by the program execution management function unit 32, and the control device operates according to the merged program. The difference comparison is performed in the same manner as in Examples 1 to 5 described in Embodiment 1.

このように、中間言語に有向グラフで構成した動作ロジックを使用し、ソースコードの修正部分を有向グラフの差分で制御装置に転送することにより、転送時間を短縮することが可能となる。 In this way, by using the operation logic composed of a directed graph in the intermediate language and transferring the modified portion of the source code to the control device using the difference in the directed graph, it is possible to shorten the transfer time.

実施の形態3.
実施の形態1で適用した有向グラフによるロジック差分比較法を、ロジックの等価性確認に適用することもできる。例えば、旧機種の制御装置から新機種の制御装置へソースコードを移植する場合、移植に伴い、変更部分の機械語を書き換える必要があるが、ソースコードの入力言語の文法あるいはデータ構造には変化があるが、ロジックには変化が無い場合がある。このように、機種変更または言語変更の際のロジックの変化の有無の分析をコンパイルを行う際の1つのステップに組み入れてもよい。
Embodiment 3.
The logic difference comparison method using a directed graph applied in the first embodiment can also be applied to logic equivalence confirmation. For example, when porting source code from a control device of an old model to a control device of a new model, it is necessary to rewrite the machine language of the changed part due to the porting, but the grammar or data structure of the input language of the source code will change. However, there may be no change in logic. In this way, analysis of whether there is a change in logic when changing the model or language may be incorporated into one step when performing compilation.

例えば、図11に示すように旧機種のソースコードである、「ADD(IN:=A,IN2:=B,OUT=>C);」と新機種のソースコード「C=A+B」は、実施の形態1で説明した方法で有向グラフを作成し、比較差分を行うと、変更されたノードおよびエッジの要素は無く、ロジックの等価性が確認できる。これにより、機種の変更によるコンパイルを行う必要がないことがわかる。 For example, as shown in Figure 11, the source code for the old model "ADD(IN:=A, IN2:=B, OUT=>C);" and the source code for the new model "C=A+B" are When a directed graph is created using the method described in Embodiment 1 and a comparison and difference is performed, there are no changed node or edge elements, and the equivalence of logic can be confirmed. This shows that there is no need to compile when changing the model.

このように、機種または言語の変更による機械語の変更が必要ないことが、ロジック差分比較法により認められた場合、ロジックの等価性を担保したまま、他言語間、または新旧機種間のソースコードの変換機能に適用することができる。すなわち、コンパイラ機能部13により、図12に示すように、旧機種のソースコードを、有向グラフの中間言語が一致する種類の異なる新機種のソースコードに逆変換することもできる。 In this way, if it is recognized by the logic difference comparison method that there is no need to change the machine language due to a change in model or language, source code between different languages or between old and new models while maintaining logic equivalence. It can be applied to the conversion function of That is, as shown in FIG. 12, the compiler function unit 13 can also reversely convert the source code of an old model into the source code of a new model of a different type in which the intermediate language of the directed graph matches.

以上のように、有向グラフによるロジック差分比較法を用いることで、ロジックの等価性を確認するとともに、有向グラフが一致する別種のソースコードに変換することができる。 As described above, by using the logic difference comparison method using a directed graph, it is possible to confirm the equivalence of logic and to convert to a different type of source code with matching directed graphs.

実施の形態4.
実施の形態3で適用したロジック等価性を応用して、あるロジックを変更したときに、他のロジックへどのように影響するかの確認を、プログラムを実際に実行しない、静的解析に適用する。図13は、IF文の「YES」の場合の処理と「NO」の場合の処理を入れ替えた例である。有向グラフによる中間言語の差分は、IF文の接続先のみである。従って、影響を確認する場合にはIF文の接続先が変わった点を起点とし、静的解析を開始すれば良いので、全体のロジックを確認する必要がなく、解析時間を短縮可能である。
Embodiment 4.
Applying the logic equivalence applied in Embodiment 3 to static analysis without actually running the program to check how changing one logic affects other logic. . FIG. 13 is an example in which the processing in the case of "YES" and the processing in the case of "NO" in the IF statement are swapped. The only difference in the intermediate language based on the directed graph is the connection destination of the IF statement. Therefore, when checking the influence, static analysis can be started from the point where the connection destination of the IF statement has changed, so there is no need to check the entire logic, and the analysis time can be shortened.

本願は、様々な例示的な実施の形態及び実施例が記載されているが、1つ、または複数の実施の形態に記載された様々な特徴、態様、及び機能は特定の実施の形態の適用に限られるのではなく、単独で、または様々な組み合わせで実施の形態に適用可能である。
従って、例示されていない無数の変形例が、本願明細書に開示される技術の範囲内において想定される。例えば、少なくとも1つの構成要素を変形する場合、追加する場合または省略する場合、さらには、少なくとも1つの構成要素を抽出し、他の実施の形態の構成要素と組み合わせる場合が含まれるものとする。
Although this application describes various exemplary embodiments and examples, various features, aspects, and functions described in one or more embodiments may be applicable to a particular embodiment. The present invention is not limited to, and can be applied to the embodiments alone or in various combinations.
Accordingly, countless variations not illustrated are envisioned within the scope of the technology disclosed herein. For example, this includes cases where at least one component is modified, added, or omitted, and cases where at least one component is extracted and combined with components of other embodiments.

10:開発支援装置、11:インターフェース機能部、12:通信機能部、13:コンパイラ機能部、14:差分情報管理部、15:画面、16:入力装置、30:制御装置、31:通信機能部、32:プログラム実行管理機能部、100:プロセッサ、200:記憶装置。 10: Development support device, 11: Interface function unit, 12: Communication function unit, 13: Compiler function unit, 14: Difference information management unit, 15: Screen, 16: Input device, 30: Control device, 31: Communication function unit , 32: program execution management function unit, 100: processor, 200: storage device.

Claims (5)

ソースコードから、ノードとエッジからなる複数のグループに分類された有向グラフを中間言語として生成し、前記ソースコードを修正するとき、修正前のソースコードの有向グラフと修正後のソースコードの有向グラフを、前記ノードおよび前記エッジごとに比較し、修正された前記ノードおよび前記エッジのいずれかを含む前記グループをコンパイルするコンパイル方法。 When a directed graph classified into multiple groups consisting of nodes and edges is generated from a source code as an intermediate language, and the source code is modified, the digraph of the source code before modification and the directed graph of the source code after modification are A compilation method that compares each node and each edge and compiles the group that includes any of the modified nodes and edges. 第1のソースコードから、ノードとエッジからなる複数のグループに分類された第1の有向グラフを生成し、第2のソースコードから、ノードとエッジからなる複数のグループに分類された第2の有向グラフを生成し、前記第1の有向グラフと前記第2の有向グラフとをノードおよびエッジごとに比較し、比較した全てのノードとエッジが一致した場合に、前記第1のソースコードと前記第2のソースコードに等価性があると判断するステップを有するコンパイル方法。 A first directed graph classified into multiple groups consisting of nodes and edges is generated from the first source code, and a second directed graph classified into multiple groups consisting of nodes and edges is generated from the second source code. and compares the first digraph and the second digraph for each node and edge, and if all the compared nodes and edges match, the first source code and the second source code A compilation method that includes the step of determining whether the code is equivalent. ソースコードを入力するためのインターフェース機能部、前記ソースコードを、ノードとエッジからなる複数のグループに分類された有向グラフを生成するコンパイラ機能部、前記有向グラフを記憶する差分情報管理部を備え、前記コンパイラ機能部は、修正されたソースコードが入力された場合、前記修正されたソースコードの修正有向グラフを生成するとともに、前記差分情報管理部に記憶された修正前の有向グラフと前記修正有向グラフとをノードおよびエッジごとに比較することにより、修正されたノードおよびエッジのいずれかを含むグループをコンパイルして機械語を生成することを特徴とする開発支援装置。 The compiler includes an interface function unit for inputting source code, a compiler function unit that generates a directed graph in which the source code is classified into a plurality of groups consisting of nodes and edges, and a difference information management unit that stores the directed graph. When the modified source code is input, the functional unit generates a modified digraph of the modified source code, and connects the unmodified digraph stored in the difference information management unit and the modified digraph to nodes and A development support device that generates machine language by compiling a group including either a corrected node or edge by comparing each edge. 請求項3の開発支援装置と前記開発支援装置と通信で接続される制御装置とを備え、前記開発支援装置でコンパイルされたソースコードの修正部分の機械語を前記制御装置に送信することを特徴とする制御システム。 The development support device according to claim 3, and a control device that is communicatively connected to the development support device, and transmits a machine language of a modified portion of the source code compiled by the development support device to the control device. control system. 請求項3の開発支援装置と前記開発支援装置と通信で接続される制御装置とを備え、前記制御装置は、中間言語としての有向グラフの構造を認識可能なプログラム実行管理機能部を有し、前記開発支援装置から送信される修正されたノードおよびエッジのいずれかを含む有向グラフのグループの情報を前記プログラム実行管理機能部で処理することを特徴とする制御システム。 The development support device according to claim 3 and a control device communicatively connected to the development support device, the control device having a program execution management function unit capable of recognizing the structure of a directed graph as an intermediate language, A control system characterized in that the program execution management function unit processes information about a group of directed graphs including either modified nodes or edges transmitted from a development support device.
JP2021014739A 2021-02-02 2021-02-02 Compilation method, development support device and control system Active JP7450565B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2021014739A JP7450565B2 (en) 2021-02-02 2021-02-02 Compilation method, development support device and control system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2021014739A JP7450565B2 (en) 2021-02-02 2021-02-02 Compilation method, development support device and control system

Publications (2)

Publication Number Publication Date
JP2022118310A JP2022118310A (en) 2022-08-15
JP7450565B2 true JP7450565B2 (en) 2024-03-15

Family

ID=82839975

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2021014739A Active JP7450565B2 (en) 2021-02-02 2021-02-02 Compilation method, development support device and control system

Country Status (1)

Country Link
JP (1) JP7450565B2 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001290656A (en) 2000-04-07 2001-10-19 Hitachi Ltd Differential compiling system
JP2016151973A (en) 2015-02-18 2016-08-22 富士電機株式会社 Management control system, development support device therefor, and management device
CN106462434A (en) 2014-06-25 2017-02-22 微软技术许可有限责任公司 Incremental compilation of whole program code
JP2018151936A (en) 2017-03-14 2018-09-27 オムロン株式会社 Program creation device and program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001290656A (en) 2000-04-07 2001-10-19 Hitachi Ltd Differential compiling system
CN106462434A (en) 2014-06-25 2017-02-22 微软技术许可有限责任公司 Incremental compilation of whole program code
JP2016151973A (en) 2015-02-18 2016-08-22 富士電機株式会社 Management control system, development support device therefor, and management device
JP2018151936A (en) 2017-03-14 2018-09-27 オムロン株式会社 Program creation device and program

Also Published As

Publication number Publication date
JP2022118310A (en) 2022-08-15

Similar Documents

Publication Publication Date Title
CN109254776B (en) Multi-language code compiling method and compiler
CN103077064B (en) A kind of parsing also executive language method and interpreting means
CN110825384A (en) ST language compiling method, system and compiler based on LLVM
JPH0561683A (en) Information processing system and software maintenance system based on object
JP2004295398A (en) Compiler, method for compiling and program developing tool
US11656592B2 (en) Analysis device, analysis method, and recording medium
US10365902B2 (en) Method for compiling a source code
US20190012168A1 (en) Program generating apparatus
Fischer et al. Abstract syntax trees-and their role in model driven software development
JP7450565B2 (en) Compilation method, development support device and control system
JP5405684B1 (en) Source program programming language converter
CN113448851A (en) Automatic test method and system for RUST programming language compiler
CN110472411B (en) Memory overflow processing method, device, equipment and readable storage medium
JP2008165342A (en) Source code creating method, device and program
JP6175306B2 (en) Control program dividing apparatus, control program dividing method and recording medium therefor
Moyen et al. Loop quasi-invariant chunk motion by peeling with statement composition
JP2010204855A (en) Program generation device and block diagram generation device
JP5908374B2 (en) Compiler evaluation apparatus, method, and program
KR101658795B1 (en) User created robot programming tool having intermediate language generator and the intermediate language code based on robot programming method
JP2016151973A (en) Management control system, development support device therefor, and management device
CN109814869B (en) Analysis method and system applied to robot and computer readable storage medium
WO2022190418A1 (en) Development assitance device, development assitance method, and development assitance program
JP2002312167A (en) Program for making computer calculate value of variable, compile program, variable value determining method, and program generating method
JP5181788B2 (en) Source program language conversion apparatus, method and program
KR0169909B1 (en) Method for designing assembly code generator for target processor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20230119

TRDD Decision of grant or rejection written
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20240131

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20240206

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20240305

R151 Written notification of patent or utility model registration

Ref document number: 7450565

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151