JP2007299082A - Source code generation device, source code generation method, and source code generation program - Google Patents
Source code generation device, source code generation method, and source code generation program Download PDFInfo
- Publication number
- JP2007299082A JP2007299082A JP2006124687A JP2006124687A JP2007299082A JP 2007299082 A JP2007299082 A JP 2007299082A JP 2006124687 A JP2006124687 A JP 2006124687A JP 2006124687 A JP2006124687 A JP 2006124687A JP 2007299082 A JP2007299082 A JP 2007299082A
- Authority
- JP
- Japan
- Prior art keywords
- determination
- state transition
- source code
- state
- code generation
- 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.)
- Granted
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
Description
本発明はプログラムのソースコードを生成するソースコード生成装置、ソースコード生成方法およびソースコード生成プログラムに関し、特に状態遷移図からプログラムのソースコードを生成するソースコード生成装置、ソースコード生成方法およびソースコード生成プログラムに関する。 The present invention relates to a source code generation device, a source code generation method, and a source code generation program for generating a program source code, and more particularly to a source code generation device, a source code generation method, and a source code for generating a program source code from a state transition diagram. It relates to the generation program.
現在、コンピュータで実行されるソフトウェアが大規模化、複雑化するに伴い、ソフトウェアの設計を効率的に行うために多種多様な図が使用されている。例えば、実行する処理の結果に応じてプログラムの状態が変化していくソフトウェアを設計する場合、状態遷移図が使用される。状態遷移図は、状態を表すノードと、状態間の遷移を表す矢印線とから構成される。また、それぞれの状態遷移に対して、その遷移が生起する条件を示す遷移条件が付加されることがある。状態遷移図は、標準化されたモデル記述言語であるUML(Unified Modeling Language)においても状態機械(State Machine)として採用されており、広く一般に使用されている。状態遷移図を記述することで、開発者はプログラムの振る舞いを容易に把握することができる。 Currently, as software executed on a computer becomes larger and more complicated, a wide variety of diagrams are used to efficiently design software. For example, when designing software in which the state of a program changes according to the result of processing to be executed, a state transition diagram is used. The state transition diagram includes nodes representing states and arrow lines representing transitions between states. In addition, a transition condition indicating a condition in which the transition occurs may be added to each state transition. The state transition diagram is also adopted as a state machine in UML (Unified Modeling Language), which is a standardized model description language, and is widely used. By describing the state transition diagram, developers can easily understand the behavior of the program.
一方、ソフトウェアをコンピュータで実行させるためには、最終的にプログラムのソースコードを記述しなければならない。そのため、開発者は状態遷移図を記述して設計を行った後、それに基づいて改めてソースコードを記述する必要がある。状態遷移図の記述とソースコードの記述という二重の作業は、開発者にとって大きな負担となる。 On the other hand, in order for software to be executed on a computer, the source code of the program must be finally written. Therefore, the developer needs to describe the state transition diagram and design it, and then write the source code again based on the design. The double task of describing the state transition diagram and describing the source code is a heavy burden on the developer.
そこで、開発者の作業負担を軽減すべく、遷移条件が付加された状態遷移図から、状態遷移図で表される振る舞いを実現するプログラムのソースコードを自動的に生成する技術が知られている(例えば、特許文献1参照)。この方法では、現在の状態を示す値を格納する変数と、状態遷移図に記述された遷移条件が満たされたときに変数の値を更新する関数とを備えるソースコードが生成される。これにより、プログラムの実行中に状態が変化するソフトウェアの開発の負担が大きく軽減される。
しかし、特許文献1記載の技術では遷移条件の記述方法が固定されており、生成されるソースコードの構造も遷移条件の記述内容に関わらず一定であるという問題がある。遷移条件を記述する際には、条件の複雑さなどの性質に応じて記述形式を変えたいという要求がある。例えば、簡単な遷移条件は論理式を用いることで簡潔に記述できる一方、複雑な遷移条件は条件判定を行う計算の手順を記述する方が理解容易な記述になる。また、遷移条件の記述とソースコードとの対応関係が固定的であると、記述形式によっては著しく処理効率が悪い構造のソースコードが生成されることがある。例えば、遷移条件の記述が1つの論理式のみから成る簡単な記述であっても、複雑な構造をもつ冗長なソースコードが生成されることがある。
However, the technique described in
本発明はこのような点に鑑みてなされたものであり、状態遷移図の遷移条件の記述形式を複数の記述形式の中から選択でき、選択された記述形式に適した構造をもつソースコードを状態遷移図から自動的に生成するソースコード生成装置、ソースコード生成方法およびソースコード生成プログラムを提供することを目的とする。 The present invention has been made in view of the above points, and the description format of the transition condition of the state transition diagram can be selected from a plurality of description formats, and source code having a structure suitable for the selected description format is obtained. It is an object to provide a source code generation device, a source code generation method, and a source code generation program that are automatically generated from a state transition diagram.
本発明では上記問題を解決するために、状態遷移図からプログラムのソースコードを生成するソースコード生成装置において、プログラムの状態と前記状態間の状態遷移の関係とを記述した状態遷移図を記憶する状態遷移図記憶手段と、前記状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示する入力画面表示手段と、前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得する遷移条件情報取得手段と、前記入力画面で選択可能な前記記述形式それぞれに対応付けて、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力するソースコード生成手段と、を有することを特徴とするソースコード生成装置が提供される。 In the present invention, in order to solve the above problem, in a source code generation device that generates a source code of a program from a state transition diagram, a state transition diagram that describes the state of the program and the state transition relationship between the states is stored. For each of the state transitions of the state transition diagram storage unit and the state transition diagram stored in the state transition diagram storage unit, a plurality of preset description formats of transition conditions indicating conditions under which the state transition occurs are set. An input screen display means for displaying an input screen comprising a selection area to be selected from the description format list and a description area for describing the transition condition according to the selected description format; and display by the input screen display means The transition condition information including the selected description format information and the transition condition description is received. A transition condition information acquisition means to be obtained, and a determination code generation function for generating a determination code for performing a condition determination from the transition condition described according to the description format in association with each description format selectable on the input screen. When the transition condition information acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, the transition condition information is obtained for each state transition. The determination code generation function corresponding to the description format shown is called to generate the determination code, and a processing code describing processing other than the condition determination is generated from the state transition diagram, and the generated processing code and Source code generation means for synthesizing all the determination codes and outputting the source code of the program Source code generating device is provided, wherein.
このようなソースコード生成装置によれば、入力画面表示手段により、状態遷移図の状態遷移それぞれについて、遷移条件の記述形式を選択する選択領域と遷移条件を記述する記述領域とを備える入力画面が表示される。次に、遷移条件情報取得手段により、入力画面で選択された記述形式の情報と入力された遷移条件の記述とを備える遷移条件情報が取得される。そして、ソースコード生成手段により、それぞれの遷移条件の記述形式に応じて適切な構造をもつ判定コードが生成されると共に、状態遷移図から条件判定以外の処理を記述した処理コードが生成され、処理コードと判定コードとが合成されてプログラムのソースコードが生成される。 According to such a source code generation device, an input screen including a selection area for selecting a transition condition description format and a description area for describing a transition condition for each state transition of the state transition diagram is displayed by the input screen display means. Is displayed. Next, the transition condition information acquisition means acquires transition condition information including information in the description format selected on the input screen and the description of the input transition condition. Then, the source code generation means generates a determination code having an appropriate structure according to the description format of each transition condition, and also generates a processing code describing processing other than the condition determination from the state transition diagram. The code and the determination code are combined to generate a program source code.
また、上記問題を解決するために、プログラムの状態と前記状態間の状態遷移の関係とを記述した状態遷移図からプログラムのソースコードを生成するソースコード生成方法において、入力画面表示手段が、状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示し、遷移条件情報取得手段が、前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得し、ソースコード生成手段が、前記入力画面で選択可能な前記記述形式それぞれと対応付けて、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力する、ことを特徴とするソースコード生成方法が提供される。 In order to solve the above problem, in the source code generation method for generating the source code of the program from the state transition diagram describing the state of the program and the state transition relationship between the states, the input screen display means includes a state Selection for selecting a description format of a transition condition indicating a condition in which the state transition occurs for each of the state transitions stored in the transition diagram storage means from a list of a plurality of preset description formats An input screen including an area and a description area for describing the transition condition according to the selected description format is displayed, and a transition condition information acquisition unit performs an operation input on the input screen displayed by the input screen display unit To obtain transition condition information including information on the selected description format and a description of the transition condition, and generate source code Has a determination code generation function for generating a determination code for performing a condition determination from the transition condition described according to the description format in association with each of the description formats selectable on the input screen. When the condition information acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, the description format indicated by the transition condition information for each state transition The corresponding determination code generation function is called to generate the determination code, a processing code describing processing other than the condition determination is generated from the state transition diagram, and the generated processing code and all the determination codes A source code generation method is provided that outputs the source code of a program by synthesizing.
このようなソースコード生成方法によれば、状態遷移図の状態遷移それぞれについて、遷移条件の記述形式を選択する選択領域と遷移条件を記述する記述領域とを備える入力画面が表示される。次に、入力画面で選択された記述形式の情報と入力された遷移条件の記述とを備える遷移条件情報が取得される。そして、それぞれの遷移条件の記述形式に応じて適切な構造をもつ判定コードが生成されると共に、状態遷移図から条件判定以外の処理を記述した処理コードが生成され、処理コードと判定コードとが合成されてプログラムのソースコードが生成される。 According to such a source code generation method, an input screen including a selection area for selecting a transition condition description format and a description area for describing a transition condition is displayed for each state transition in the state transition diagram. Next, transition condition information including the description format information selected on the input screen and the input transition condition description is acquired. Then, a determination code having an appropriate structure is generated according to the description format of each transition condition, and a processing code describing processing other than the condition determination is generated from the state transition diagram, and the processing code and the determination code are The source code of the program is generated by synthesis.
また、上記問題を解決するために、状態遷移図からプログラムのソースコードを生成するソースコード生成プログラムにおいて、コンピュータを、プログラムの状態と前記状態間の状態遷移の関係とを記述した状態遷移図を記憶する状態遷移図記憶手段、前記状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示する入力画面表示手段、前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得する遷移条件情報取得手段、前記入力画面で選択可能な前記記述形式それぞれに対応して、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力するソースコード生成手段、として機能させることを特徴とするソースコード生成プログラムが提供される。 In order to solve the above problem, in the source code generation program for generating the source code of the program from the state transition diagram, the computer describes a state transition diagram describing the state of the program and the state transition relationship between the states. A state transition diagram storage means for storing, a plurality of preset description formats of transition conditions indicating conditions under which the state transition occurs for each of the state transitions of the state transition diagram stored in the state transition diagram storage means Input screen display means for displaying an input screen comprising a selection area to be selected from the list of description formats and a description area for describing the transition condition according to the selected description format, and displayed on the input screen display means The operation input to the input screen is received, and the selected description format information and the transition condition description are provided. Transition condition information acquisition means for acquiring transition condition information, a determination code for generating a determination code for performing a condition determination from the transition condition described according to the description format corresponding to each description format selectable on the input screen Having the generation function, and when the transition condition information acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, for each state transition The determination code generation function corresponding to the description format indicated by the transition condition information is called to generate the determination code, and a processing code describing processing other than the condition determination is generated from the state transition diagram and generated. Source code generating means for synthesizing the processing code and all the determination codes and outputting a source code of the program; Source code generator for causing the function is provided.
このようなソースコード生成プログラムを実行するコンピュータによれば、入力画面表示手段により、状態遷移図の状態遷移それぞれについて、遷移条件の記述形式を選択する選択領域と遷移条件を記述する記述領域とを備える入力画面が表示される。次に、遷移条件情報取得手段により、入力画面で選択された記述形式の情報と入力された遷移条件の記述とを備える遷移条件情報が取得される。そして、ソースコード生成手段により、それぞれの遷移条件の記述形式に応じて適切な構造をもつ判定コードが生成されると共に、状態遷移図から条件判定以外の処理を記述した処理コードが生成され、処理コードと判定コードとが合成されてプログラムのソースコードが生成される。 According to the computer that executes such a source code generation program, the input screen display means, for each state transition of the state transition diagram, selects a selection area for selecting a transition condition description format and a description area for describing the transition condition. An input screen is provided. Next, the transition condition information acquisition means acquires transition condition information including information in the description format selected on the input screen and the description of the input transition condition. Then, the source code generation means generates a determination code having an appropriate structure according to the description format of each transition condition, and also generates a processing code describing processing other than the condition determination from the state transition diagram. The code and the determination code are combined to generate a program source code.
本発明では、入力画面において一覧から遷移条件の記述形式を選択できるようにし、選択された記述形式に対応した判定コード生成機能を用いて条件判定を行うコードを生成することとした。これにより、開発者は遷移条件の複雑さなどの性質に応じて適切な記述形式を選択できると共に、選択された記述形式に適した構造をもつソースコードを生成できる。したがって、いずれの記述形式が選択されても冗長なソースコードが生成されることがなくなり、生成されるプログラムの処理効率が向上する。 In the present invention, the description format of the transition condition can be selected from the list on the input screen, and the code for performing the condition determination is generated using the determination code generation function corresponding to the selected description format. As a result, the developer can select an appropriate description format according to the nature of the transition condition and the like, and can generate source code having a structure suitable for the selected description format. Therefore, no redundant source code is generated regardless of which description format is selected, and the processing efficiency of the generated program is improved.
以下、本発明の実施の形態を図面を参照して詳細に説明する。まず、本発明の概要について説明し、その後、実施の形態の具体的な内容を説明する。
図1は、実施の形態に適用される発明の概念図である。図1に示されるソースコード生成装置は、状態遷移図とそれぞれの状態遷移についての遷移条件の詳細な記述とから、ソースコードを自動的に生成するものである。ソースコード生成装置10は、状態遷移図記憶手段11、入力画面表示手段12、遷移条件情報取得手段13およびソースコード生成手段14を有する。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. First, an outline of the present invention will be described, and then specific contents of the embodiment will be described.
FIG. 1 is a conceptual diagram of the invention applied to the embodiment. The source code generation device shown in FIG. 1 automatically generates source code from a state transition diagram and a detailed description of transition conditions for each state transition. The source
状態遷移図記憶手段11は、プログラムの状態2a,2bと、状態2a,2b間の状態遷移2cの関係とを記述した状態遷移図2を記憶する。開発者は、予め状態遷移図2を記述し、状態遷移図記憶手段11に格納しておく。ただし、状態遷移図2には、それぞれの遷移条件の詳細は記述しない。
The state transition diagram storage means 11 stores a state transition diagram 2 describing the
入力画面表示手段12は、状態遷移図記憶手段11に記憶された状態遷移図2の状態遷移それぞれについて、遷移条件の詳細を記述するための入力画面を入出力装置3に表示する。表示される入力画面は、予め設定された複数の記述形式の一覧から遷移条件の記述形式を選択するための選択領域と、選択された記述形式に従って遷移条件を記述するための記述領域とを備える。
The input
遷移条件情報取得手段13は、入出力装置3に表示された入力画面に対する操作入力を受け付け、選択された記述形式の情報と入力された遷移条件の記述とを備える遷移条件情報4を取得する。
The transition condition
ソースコード生成手段14は、入力画面で選択可能な記述形式ごとに、その記述形式で記述された遷移条件から条件判定を行う判定コードを生成する判定コード生成機能14a,14b,14c,・・・を有している。ここで、遷移条件情報取得手段13が状態遷移図記憶手段11に記憶された状態遷移図2のすべての状態遷移について遷移条件情報を取得すると、ソースコード生成手段14はソースコードの生成処理を開始する。
The source
まず、ソースコード生成手段14は、状態遷移ごとに遷移条件情報4で示される記述形式に対応する判定コード生成機能を呼び出して判定コードを生成する。例えば、記述形式が論理式であるとき、判定コード生成機能14aが呼び出される。次に、ソースコード生成手段14は、状態遷移図2から条件判定以外の処理を記述した処理コードを生成する。そして、ソースコード生成手段14は、生成した処理コードとすべての判定コードとを合成してプログラムのソースコード5を出力する。出力されるソースコード5は、状態遷移図2の振る舞いを実現する具体的な処理手順を記述したものである。
First, the source
このようなソースコード生成装置10によれば、入力画面表示手段12により、状態遷移図2の状態遷移それぞれについて、記述形式の選択領域と遷移条件の記述領域とを備える入力画面が入出力装置3に表示される。次に、遷移条件情報取得手段13により、入力画面に対する操作入力を受け付け、選択された記述形式の情報と入力された遷移条件の記述とを備える遷移条件情報4が取得される。そして、ソースコード生成手段14により、それぞれの遷移条件の記述形式に応じて適切な構造をもつ判定コードが生成されると共に、状態遷移図2から条件判定以外の処理を記述した処理コードが生成され、処理コードと判定コードとが合成されてプログラムのソースコード5が生成される。
According to such a source
これにより、開発者は、それぞれの遷移条件の性質に応じて適切な記述形式を選択して遷移条件を記述できると共に、選択された記述形式に適した構造をもつソースコードを生成できる。したがって、いずれの記述形式が選択されても冗長なソースコードが生成されることがなくなり、生成されるプログラムの処理効率が向上する。また、開発者が適切な記述形式を選択することで、遷移条件の記述や理解が容易となり、開発者の入力ミスを防止できる。その結果、生成されるプログラムの品質も向上する。 As a result, the developer can select a suitable description format according to the nature of each transition condition and describe the transition condition, and can generate source code having a structure suitable for the selected description format. Therefore, no redundant source code is generated regardless of which description format is selected, and the processing efficiency of the generated program is improved. In addition, by selecting an appropriate description format, the developer can easily describe and understand the transition condition, and can prevent an input error of the developer. As a result, the quality of the generated program is also improved.
以下、本発明の実施の形態を、図面を参照して詳細に説明する。本実施の形態は、1つのソースコード生成装置100で構成される。開発者は、ソースコード生成装置100を用いて状態遷移図を記述し、記述した状態遷移図からソースコードを生成することができる。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. This embodiment is composed of one source
図2は、ソースコード生成装置のハードウェア構成を示す図である。ソースコード生成装置100は、CPU(Central Processing Unit)101によって装置全体が制御されている。CPU101には、バス107を介してRAM(Random Access Memory)102、ハードディスクドライブ(HDD:Hard Disk Drive)103、グラフィック処理装置104および入力インタフェース105が接続されている。
FIG. 2 is a diagram illustrating a hardware configuration of the source code generation device. The entire source
RAM102には、CPU101に実行させるOS(Operating System)プログラムやアプリケーションプログラムの少なくとも一部が一時的に格納される。また、RAM102には、CPU101による処理に必要な各種データが格納される。HDD103には、OSプログラムやアプリケーションプログラムが格納される。
The
グラフィック処理装置104には、モニタ20が接続されている。グラフィック処理装置104は、CPU101からの命令に従って、画像をモニタ20の画面に表示させる。入力インタフェース105には、キーボード31とマウス32とが接続されている。入力インタフェース105は、キーボード31やマウス32から送られてくる信号を、バス107を介してCPU101に送信する。
A monitor 20 is connected to the
以上のようなハードウェア構成によって、本実施の形態の処理機能を実現することができる。
次に、ソースコード生成装置100のモジュール構成について説明する。
With the hardware configuration as described above, the processing functions of the present embodiment can be realized.
Next, the module configuration of the source
図3は、ソースコード生成装置の機能を示すブロック図である。ソースコード生成装置100は、状態遷移図記憶部110、ソースファイル記憶部120、状態遷移図作成部130、遷移条件記述部140、状態遷移図確認部150およびソースコード生成部160を有する。状態遷移図作成部130、遷移条件記述部140および状態遷移図確認部150は、キーボード31およびマウス32を通じて開発者からの入力を受け付けることができる。また、状態遷移図作成部130、遷移条件記述部140、状態遷移図確認部150およびソースコード生成部160は、モニタ20の画面に処理結果を表示することができる。
FIG. 3 is a block diagram illustrating functions of the source code generation device. The source
状態遷移図記憶部110は、状態遷移図が記述されたファイルを格納する。状態遷移図には、プログラムの状態と状態間の遷移関係とが記述される。また、状態遷移図記憶部110は、状態遷移図のそれぞれの状態遷移と対応付けられた遷移条件情報を格納する。遷移条件情報は、遷移条件の記述形式を示す情報と、その記述形式に従って記述された遷移条件の詳細とを含んでいる。
The state transition
ソースファイル記憶部120は、生成されたソースコードが記述されたファイルを格納する。
状態遷移図作成部130は、開発者からの入力に基づいて状態遷移図を作成する。ここで、状態遷移図作成部130は、開発者による状態遷移図の作図を視覚的に支援する機能をもつ。例えば、モニタ20の画面端に表示されたボタンを押すことで、描画領域に状態を表す楕円が配置されるようにする。そして、状態遷移図作成部130は、作成した状態遷移図をファイルに保存し状態遷移図記憶部110に格納する。
The source file storage unit 120 stores a file in which the generated source code is described.
The state transition
遷移条件記述部140は、開発者からの入力によって、状態遷移図作成部130で作成されモニタ20に表示されている状態遷移図の中から1つの状態遷移が選択されると、遷移条件の記述形式を選択するための選択画面を表示する。
When one state transition is selected from the state transition diagrams created by the state transition
本実施の形態では、選択可能な記述形式として、論理式、判定関数、論理回路の3つの記述形式を用意する。論理式は、変数に具体的な値を代入することで真(True)または偽(False)の判定が可能な式である。判定関数は、真または偽を戻り値として返す関数であり、真偽を判定する過程で行われる計算手順を記述したコードを含む。論理回路は、入力値に基づいて真または偽の値を出力する回路である。論理回路は、同等の意味をもつ論理式に変換することが可能である。 In this embodiment, three description formats of a logical expression, a determination function, and a logic circuit are prepared as selectable description formats. A logical expression is an expression that can be determined to be true or false by assigning a specific value to a variable. The determination function is a function that returns true or false as a return value, and includes a code that describes a calculation procedure performed in the process of determining true or false. The logic circuit is a circuit that outputs a true or false value based on an input value. A logic circuit can be converted into a logical expression having an equivalent meaning.
ここで、モニタ20に表示された選択画面で1つの記述形式が選択されると、遷移条件記述部140は、選択された記述形式に従って遷移条件を記述するための入力画面を表示する。表示された入力画面で遷移条件の記述が入力されると、遷移条件記述部140は、選択された記述形式の情報と入力された遷移条件の記述とを含む遷移条件情報を、選択された状態遷移と対応付けて状態遷移図記憶部110に格納する。
Here, when one description format is selected on the selection screen displayed on the monitor 20, the transition
状態遷移図確認部150は、ソースコードを生成する指示が入力されると、状態遷移図記憶部110を参照して、ソースコードの生成に必要な状態遷移図が作成されているか確認する。また、状態遷移図確認部150は、状態遷移図のすべての状態遷移に対して遷移条件情報が作成されているか確認する。そして、記述に不備がある場合、状態遷移図確認部150は、その旨をモニタ20に表示する。不備がない場合、状態遷移図確認部150は、状態遷移図記憶部110に格納された状態遷移図とすべての遷移条件情報とをソースコード生成部160へ渡す。
When an instruction to generate source code is input, the state transition
ソースコード生成部160は、論理式変換部161、判定関数変換部162および論理回路変換部163を有する。論理式変換部161は、論理式の形式で記述された遷移条件から条件判定を行う判定コードを生成する。判定関数変換部162は、判定関数の形式で記述された遷移条件から判定コードを生成する。論理回路変換部163は、論理回路の形式で記述された遷移条件から判定コードを生成する。
The source
ソースコード生成部160は、状態遷移図と遷移条件情報とを受け取ると、それぞれの状態遷移について、遷移条件の記述形式に対応する生成機能を呼び出して判定コードを生成する。具体的には、記述形式が論理式である場合、ソースコード生成部160は論理式変換部161を呼び出す。記述形式が判定関数である場合、ソースコード生成部160は判定関数変換部162を呼び出す。記述形式が論理回路である場合、ソースコード生成部160は論理回路変換部163を呼び出す。
Upon receiving the state transition diagram and the transition condition information, the source
また、ソースコード生成部160は、状態遷移図から条件判定以外の処理を記述した処理コードを生成する。そして、ソースコード生成部160は、生成した処理コードに生成した判定コードを埋め込みソースコードを生成する。その後、ソースコード生成部160は、生成したソースコードをファイルに保存してソースファイル記憶部120に格納すると共に、生成が完了した旨をモニタ20に表示する。
In addition, the source
図4は、ソースコードの生成に使用される状態遷移図の例である。状態遷移図ファイル111は、状態遷移図記憶部110に格納されている。状態遷移図ファイル111には、状態111a,111b,111cおよび状態遷移111d,111e,111f,111g,111hが記述されている。
FIG. 4 is an example of a state transition diagram used for generating source code. The state transition diagram file 111 is stored in the state transition
状態を表す楕円内には、その状態の状態名が記述される。例えば、状態111aの状態名は“STATE1”である。
状態遷移を表す矢印線には、それぞれラベルが付加される。ラベルは、イベント名、条件名、アクション名の3つの要素で構成される。イベント名は、プログラムの実行時に発生する可能性があるイベントの名前である。条件名は、状態遷移の遷移条件を識別するための名前であり、“[”と“]”の間に記述される。アクション名は、プログラムによって実行される処理を識別するための名前であり、“/”の右側に記述される。
In the ellipse representing the state, the state name of the state is described. For example, the state name of the
A label is added to each arrow line representing a state transition. The label is composed of three elements: event name, condition name, and action name. The event name is the name of an event that may occur when the program is executed. The condition name is a name for identifying the transition condition of the state transition, and is described between “[” and “]”. The action name is a name for identifying a process executed by the program, and is described on the right side of “/”.
上記のラベルは以下の意味をもつ。現在の状態が矢印元の状態であるときに、イベント名で示されるイベントが発生し、かつ、条件名で示される遷移条件が満たされていると、プログラムの状態が矢印先の状態に遷移する。このとき、状態が遷移する直前に、アクション名で示される処理が実行される。 The above labels have the following meanings: When the current state is the state of the arrow source and the event indicated by the event name occurs and the transition condition indicated by the condition name is satisfied, the program state transitions to the arrow destination state . At this time, immediately before the state transitions, the process indicated by the action name is executed.
例えば、状態遷移111dは、現在の状態が状態111aであるときに“event1−1”で示されるイベントが発生し、“cond1−1”で示される遷移条件が満たされていると、“act1−1”で示される処理が実行された上で、状態が状態111bに遷移することを意味する。なお、遷移条件および実行される処理の詳細は状態遷移図に直接記述せず、付加的情報として別手段で記述する。
For example, in the
上記の状態遷移図は、開発者からの入力に基づいて状態遷移図作成部130で作成される。このような状態遷移図によって、プログラムの振る舞いを表現することができる。
次に、遷移条件記述部140がモニタ20に表示する選択画面および入力画面について説明する。
The state transition diagram is created by the state transition
Next, the selection screen and the input screen that the transition
図5は、遷移条件の記述形式の選択画面例を示す図である。選択画面21は、入力領域21a,21b、選択領域21cおよびボタン21dを有する。
入力領域21aは、状態遷移図に記述された条件名のうちの1つを入力するための入力領域である。条件名は、状態遷移図の中の状態遷移と遷移条件情報とを対応付けるために用いられる。入力領域21bは、シンボルを入力するための入力領域である。シンボルは、ソースコード中で遷移条件の条件判定を行うコードを識別するために用いられる。
FIG. 5 is a diagram illustrating a selection screen example of a transition condition description format. The selection screen 21 has
The
選択領域21cは、遷移条件の記述形式を1つ選択するための選択領域である。具体的には、論理式、判定関数、論理回路の中から1つを選択する。ボタン21dは、入力内容を確定するためのボタンである。ボタン21dが押されると、選択領域21cで選択された記述形式に対応する入力画面が次に表示される。
The
例えば、図4に示した状態遷移図の状態遷移111dに対して、条件名を“cond1−1”、シンボルを“Hantei1−1”と入力し、記述形式を“論理式”と選択する。
For example, for the
図6は、論理式形式による遷移条件の入力画面例を示す図である。入力画面22は、選択画面21の選択領域21cで“論理式”が選択された場合に表示される。入力画面22は、入力領域22aおよびボタン22bを有する。
FIG. 6 is a diagram showing an example of a transition condition input screen in a logical expression format. The input screen 22 is displayed when “logical expression” is selected in the
入力領域22aは、論理式を入力するための入力領域である。論理式は、ソースコード中で使用される変数、数値などの定数、“&&”(論理積)や“||”(論理和)などの論理演算子、“+”(加算)や“*”(積)などの算術演算子、“>”などの比較演算子を用いて記述される。これら演算子は、C言語などの一般的なプログラミング言語で使用可能な演算子である。例えば、変数“count”の値が“10”以上であるという条件を示す論理式は、“count>=10”と記述できる。
The
ボタン22bは、入力内容を確定するためのボタンである。ボタン22bが押されると、遷移条件記述部140は、入力領域22aに入力された論理式、選択画面21の入力領域21bに入力されたシンボルおよび記述形式が“論理式”であることを示す情報で構成される遷移条件情報を、選択画面21の入力領域21aに入力された条件名と対応付けて、状態遷移図記憶部110に格納する。
The
図7は、判定関数形式による遷移条件の入力画面例を示す図である。入力画面23は、選択画面21の選択領域21cで“判定関数”が選択された場合に表示される。入力画面23は、入力領域23aおよびボタン23bを有する。
FIG. 7 is a diagram illustrating an example of a transition condition input screen in the determination function format. The input screen 23 is displayed when “determination function” is selected in the
入力領域23aは、判定関数を入力するための入力領域である。判定関数は、出力するソースコードの記述に使用されるプログラミング言語の文法に従って記述する。本実施の形態では、プログラミング言語としてC言語を用いている。入力領域23aには、条件判定の過程で行われる計算の手順を示すコードを記述できる。ただし、最終的に戻り値として真または偽の値を返すように記述する必要がある。なお、入力領域23aには、判定関数の処理内容のコードを記述すればよく、関数名などの宣言文を記述する必要はない。必要な宣言文はソースコード生成装置100が自動的に付加する。
The
ボタン23bは、入力内容を確定するためのボタンである。ボタン23bが押されると、遷移条件記述部140は、入力領域23aに入力された判定関数、選択画面21の入力領域21bに入力されたシンボルおよび記述形式が“判定関数”であることを示す情報で構成される遷移条件情報を、選択画面21の入力領域21aに入力された条件名と対応付けて、状態遷移図記憶部110に格納する。
The
図8は、論理回路形式による遷移条件の入力画面例を示す図である。入力画面24は、選択画面21の選択領域21cで“論理回路”が選択された場合に表示される。入力画面24は、要素ボタン24a,24b,24c,24d,24e,24f,24g、描画領域24hおよびボタン24iを有する。
FIG. 8 is a diagram showing an example of a transition condition input screen in the logic circuit format. The input screen 24 is displayed when “logic circuit” is selected in the
要素ボタン24a,24b,24c,24d,24e,24f,24gは、開発者による論理回路の作図を視覚的に支援するためのボタンである。要素ボタン24a,24b,24c,24d,24e,24f,24gのいずれかのボタンが押されると、そのボタンに対応する回路要素が描画領域24hに配置される。
The
要素ボタン24aは、入力要素を示すボタンである。入力要素は論理回路の入力変数を表す。それぞれの入力要素には変数名が設定される。要素ボタン24bは、定数要素を示すボタンである。定数要素は定数を表す。それぞれの定数要素には数値などの具体的な値が設定される。
The
要素ボタン24cは、比較要素を示すボタンである。比較要素は、“+”の側に入力される値と“−”の側に入力される値とを比較し、“+”の側の値の方が大きい場合は“1”(真)を出力し、それ以外の場合は“0”(偽)を出力する。要素ボタン24dは、加減算要素を示すボタンである。加減算要素は、入力される値をすべて合計した値を出力する。ただし、“−”が付された側から入力される値は、符号を反転させて合計する。
The
要素ボタン24eは、論理積要素を示すボタンである。論理積要素は、入力される値がすべて“0”以外(真)の場合は“1”(真)を出力し、それ以外の場合は“0”(偽)を出力する。要素ボタン24fは、論理和要素を示すボタンである。論理和要素は、入力される値がすべて“0”(偽)の場合には“0”(偽)を出力し、それ以外の場合には“1”(真)を出力する。要素ボタン24gは、出力要素を示すボタンである。出力要素は論理回路の出力を表す。出力要素は論理回路で1つだけ記述できる。
The
描画領域24hは、論理回路を描画するための描画領域である。開発者は、要素ボタン24a,24b,24c,24d,24e,24f,24gを用いて回路要素を描画領域24hに配置し、配置した回路要素を線で接続して入出力関係を定義する。
The
ボタン24iは、入力内容を確定するためのボタンである。ボタン24iが押されると、遷移条件記述部140は、描画領域24hに入力された論理回路、選択画面21の入力領域21bに入力されたシンボルおよび記述形式が“論理回路”であることを示す情報で構成される遷移条件情報を、選択画面21の入力領域21aに入力された条件名と対応付けて、状態遷移図記憶部110に格納する。
The
このように、開発者は、選択画面21および入力画面22,23,24を用いて、遷移条件の詳細を入力することができる。なお、本実施の形態では選択画面21および入力画面22,23,24をそれぞれ別個の画面としたが、これらを1つの画面としてもよい。 Thus, the developer can input details of the transition condition using the selection screen 21 and the input screens 22, 23, and 24. In this embodiment, the selection screen 21 and the input screens 22, 23, and 24 are separate screens, but these may be a single screen.
次に、以上のような装置の構成および入力データの構造のもとで実行されるソースコード生成処理の詳細を説明する。
図9は、ソースコード生成処理の手順を示すフローチャートである。以下、図9に示す処理をステップ番号に沿って説明する。
Next, the details of the source code generation process executed under the above-described apparatus configuration and input data structure will be described.
FIG. 9 is a flowchart illustrating a procedure of source code generation processing. In the following, the process illustrated in FIG. 9 will be described in order of step number.
[ステップS11]ソースコード生成部160は、状態遷移図確認部150から状態遷移図とそれぞれの状態遷移に対応する遷移条件情報とを受け取ると、状態遷移図に記述されたそれぞれの状態遷移について、以下のステップS12からステップS20までの処理を繰り返す。
[Step S11] When the source
[ステップS12]ソースコード生成部160は、ステップS11で選択した状態遷移に付加された条件名と対応付けられている遷移条件情報から、記述形式の情報を抽出する。そして、ソースコード生成部160は、遷移条件の記述形式が論理回路であるか否か判断する。論理回路である場合には、処理がステップS13に進められる。論理回路でない場合には、処理がステップS16に進められる。
[Step S12] The source
[ステップS13]ソースコード生成部160は、ステップS11で選択した状態遷移に対応する遷移条件情報を論理回路変換部163へ渡す。論理回路変換部163は、受け取った遷移条件情報から遷移条件である論理回路を抽出し、抽出した論理回路を同等の意味をもつ論理式に変換する。論理回路から論理式への変換方法は、後で詳細に説明する。
[Step S13] The source
[ステップS14]論理回路変換部163は、ステップS13で変換した論理式を含む判定関数のコードを生成する。具体的には、論理回路変換部163は、ステップS13で受け取った遷移条件情報に含まれるシンボルを判定関数の関数名とし、ステップS13で変換した論理式の評価結果が真の場合には“true”を、偽の場合には“false”を戻り値として返す判定関数のコードを生成する。
[Step S14] The logic
[ステップS15]論理回路変換部163は、ステップS14で生成した判定関数を呼び出す関数呼び出し文を作成し、作成した関数呼び出し文を埋め込んだ条件分岐のコードを生成する。
[Step S15] The logic
[ステップS16]ソースコード生成部160は、ステップS12で抽出した記述形式の情報に基づいて、遷移条件の記述形式が判定関数であるか否か判断する。判定関数である場合には、処理がステップS17に進められる。判定関数でない場合には、処理がステップS19に進められる。
[Step S16] The source
[ステップS17]ソースコード生成部160は、ステップS11で選択した状態遷移に対応する遷移条件情報を判定関数変換部162へ渡す。判定関数変換部162は、受け取った遷移条件情報から遷移条件である判定関数を抽出し、遷移条件情報に含まれるシンボルを関数名とする判定関数のコードを生成する。
[Step S17] The source
[ステップS18]判定関数変換部162は、ステップS17で生成した判定関数を呼び出す関数呼び出し文を作成し、作成した関数呼び出し文を埋め込んだ条件分岐のコードを生成する。
[Step S18] The decision
[ステップS19]ソースコード生成部160は、ステップS12で抽出した記述形式の情報に基づいて、遷移条件の記述形式が論理式であるか否か判断する。論理式である場合には、処理がステップS20に進められる。論理式でない場合には、記述形式の選択が不適切であるため、ステップS11で選択した状態遷移についての処理を終了する。
[Step S19] The source
[ステップS20]ソースコード生成部160は、ステップS11で選択した状態遷移に対応する遷移条件情報を論理式変換部161へ渡す。論理式変換部161は、受け取った遷移条件情報から遷移条件である論理式を抽出し、抽出した論理式が埋め込まれた条件分岐のコードを生成する。
[Step S20] The source
[ステップS21]ソースコード生成部160は、状態遷移図確認部150から受け取った状態遷移図に基づいて、条件判定以外の処理を記述した処理コードを生成する。状態遷移図からの処理コードの生成は、特許文献1に記載の生成方法などを用いて実現できる。これにより、現在の状態を記憶する変数の宣言、イベントの検出、状態の遷移、状態遷移時の処理の実行などを実現するコードが生成される。ただし、遷移条件を評価して条件分岐を行う箇所には、条件名のみを埋め込んでおく。
[Step S <b> 21] The source
[ステップS22]ソースコード生成部160は、ステップS21で生成された処理コードに埋め込まれた条件名を検出し、検出した箇所の文字列を、ステップS15,S18,S20で生成された対応する条件分岐のコードにそれぞれ置き換える。さらに、ソースコード生成部160は、ステップS14,S17で生成された判定関数のコードを処理コードに追加して、ソースコードを出力する。
[Step S22] The source
ここで、ステップS13で行われる論理回路から論理式への変換は、以下の方法で実現できる。まず、ソースコード生成部160は、論理回路のそれぞれの回路要素に対して識別記号を割り当てる。次に、ソースコード生成部160は、回路要素ごとに、識別記号、変数名および定数値を用いて、入力値から出力値を計算する式を作成する。ここで、比較要素では比較演算子“>”、加減算要素では算術演算子“+”または“−”、論理積要素では論理演算子“&&”、論理和要素では論理演算子“||”を演算子としてそれぞれ用いる。例えば、識別記号が“A7”の比較要素において、“+”側の入力に変数名が“c”の変数要素が接続され、“−”側の入力に識別記号が“A8”の加減算要素が接続されているとき、“A7=c>A8”という計算式が作成される。
Here, the conversion from the logic circuit to the logic expression performed in step S13 can be realized by the following method. First, the source
そして、ソースコード生成部160は、出力要素に対応する計算式から順に式を展開していく。例えば、“A7=c>A8”と“A8=a−b”の2つの計算式があるとき、前者に後者を代入すると“A7=c>a−b”という計算式が得られる。このようにして計算式を順に展開すると、左辺に出力要素の識別記号のみをもち、右辺に識別記号を含まない式をもつ計算式が作成される。ここで、右辺の式が論理回路と同様の意味をもつ論理式となる。
Then, the source
このようにして、ソースコード生成部160は、状態遷移図と遷移条件情報とから、それぞれの遷移条件の記述形式に応じた構造をもつソースコードを自動的に生成する。
次に、以上のような処理によって生成されるソースコードについて説明する。本実施の形態で生成されるソースコードは、C言語で記述されたものである。
In this way, the source
Next, source code generated by the above processing will be described. The source code generated in this embodiment is written in C language.
図10は、生成されるソースコード例を示す図である。ソースファイル121は、ソースファイル記憶部120に格納されている。ソースファイル121に記述されたソースコードは、図4に示した状態遷移図に基づいて生成されたものである。なお、状態遷移111dの遷移条件の記述形式は論理式、状態遷移111eの遷移条件の記述形式は判定関数、状態遷移111fの遷移条件の記述形式は論理回路であるとする。
FIG. 10 is a diagram illustrating an example of generated source code. The source file 121 is stored in the source file storage unit 120. The source code described in the source file 121 is generated based on the state transition diagram shown in FIG. The description format of the transition condition of the
条件分岐文121aは、プログラムの実行中に発生するイベントを検出するコードである。状態遷移図に記述されたイベント“event1−1”、“event1−2”、“event2−1”、“event2−2”、“event3”のいずれかが発生すると、以後の処理が開始される。
The
条件分岐文121bは、プログラムの現在の状態に応じて以後の処理の内容を変えるためのコードである。現在の状態が、状態遷移図に記述された状態“STATE1”、“STATE2”、“STATE3”のいずれであるか判断される。
The
条件分岐文121cは、状態遷移111dの遷移条件が満たされているか否か判断するコードである。ここで、状態遷移111dの遷移条件の記述形式が論理式であるので、条件分岐文の中に論理式が埋め込まれたコードが生成される。遷移条件が満たされているときは、“act1−1”の処理が実行された後、状態が“STATE2”に遷移する。
The
条件分岐文121dは、状態遷移111eの遷移条件が満たされているか否か判断するコードである。ここで、状態遷移111eの遷移条件の記述形式が判定関数であるので、条件分岐文の中に関数呼び出し文が埋め込まれたコードが生成される。遷移条件が満たされているときは、“act1−2”の処理が実行された後、状態が“STATE3”に遷移する。
The
条件分岐文121eは、状態遷移111fの遷移条件が満たされているか否か判断するコードである。ここで、状態遷移111fの遷移条件の記述形式が論理回路であるので、条件分岐文の中に関数呼び出し文が埋め込まれたコードが生成される。遷移条件が満たされているときは、“act2−1”の処理が実行された後、状態が“STATE1”に遷移する。
The
関数121fは、条件分岐文121dの中で呼び出される判定関数である。関数121fの処理内容のコードは、入力画面23に入力されたコードと同一である。関数121gは、条件分岐文121eの中で呼び出される判定関数である。関数121gの処理内容のコードは、入力画面24に入力された論理回路と同等の意味をもつ論理式に基づいて真偽を判定するコードである。
The
なお、ソースファイル121では、状態遷移の直前に実行される処理を記述すべき箇所にアクション名のみが記述されているが、予め別手段で処理内容を示すコードを入力しておくことで、そのコードがアクション名の位置に埋め込まれるようにすることができる。また、生成後に開発者がソースコードを編集するようにしてもよい。 Note that in the source file 121, only the action name is described at the location where the processing to be executed immediately before the state transition is to be described, but by inputting a code indicating the processing content by another means in advance, Code can be embedded in the action name position. Further, the developer may edit the source code after generation.
このようなソースコード生成装置を用いることで、開発者は記述する遷移条件の性質に応じて、適切な記述形式を選択することができる。例えば、簡単な遷移条件の場合には、論理式による記述が適切である。遷移条件を判定する過程で複数ステップの計算が必要な場合には、判定関数による記述が適切である。複雑な比較演算や論理演算が必要な遷移条件の場合には、論理回路による記述が適切である。適切な記述形式を選択できることで、開発者の入力ミスが減り、生成されるプログラムの品質が向上する。 By using such a source code generation device, the developer can select an appropriate description format according to the nature of the transition condition to be described. For example, in the case of a simple transition condition, a description using a logical expression is appropriate. In the process of determining the transition condition, when a calculation of a plurality of steps is necessary, the description by the determination function is appropriate. In the case of transition conditions that require complicated comparison operations or logical operations, description using a logic circuit is appropriate. By selecting an appropriate description format, input errors of the developer are reduced, and the quality of the generated program is improved.
また、選択された記述形式に適した構造をもつソースコードが自動的に生成される。例えば、論理式の場合、関数呼び出しを行わずに条件分岐文の中で直接条件判定を行うようにすることで、プログラムの処理効率が向上する。したがって、高い処理効率が求められるソフトウェアを開発する場合にも、ソースコード生成装置を使用することができ、開発効率が大幅に向上する。 In addition, source code having a structure suitable for the selected description format is automatically generated. For example, in the case of a logical expression, the processing efficiency of a program is improved by performing a conditional determination directly in a conditional branch statement without calling a function. Therefore, even when developing software that requires high processing efficiency, the source code generation device can be used, and development efficiency is greatly improved.
なお、上記説明において図5に遷移条件の記述形式の選択画面例を示したが、この選択画面例と異なる構成の選択画面も考えられる。
図11は、遷移条件の記述形式の選択画面の他の例を示す図である。選択画面25は、入力領域25a,25b、選択領域25cおよびボタン25dを有する。入力領域25a,25bおよびボタン25dの機能は、選択画面21における入力領域21a,21bおよびボタン21dの機能とそれぞれ同一である。選択領域25cは、遷移条件の記述形式を1つ選択するための選択領域である。選択画面21の選択領域21cはラジオボタン形式を用いているが、選択領域25cはプルダウン形式を用いている。プルダウン形式にすることで、より小さい画面領域で選択領域を構成することができる。
In the above description, FIG. 5 shows a selection screen example of the transition condition description format, but a selection screen having a configuration different from this selection screen example is also conceivable.
FIG. 11 is a diagram showing another example of the transition condition description format selection screen. The selection screen 25 has
また、本実施の形態ではC言語で記述されたソースコードを生成したが、本実施の形態に係るソースコード生成装置は、さまざまなプログラミング言語への応用が可能である。生成されるソースコードの記述は汎用的な内容であり、さまざまな分野のソフトウェア開発に適用することができる。さらに、本実施の形態では、遷移条件の記述形式を3つの記述形式の中から選択できるようにしたが、これ以外の記述形式を選択できるように拡張することも容易である。 Further, although the source code described in the C language is generated in the present embodiment, the source code generation device according to the present embodiment can be applied to various programming languages. The description of the generated source code has general contents and can be applied to software development in various fields. Furthermore, in the present embodiment, the transition condition description format can be selected from three description formats. However, it is easy to expand so that other description formats can be selected.
以上、本発明のソースコード生成装置、ソースコード生成方法およびソースコード生成プログラムを、図示の実施の形態に基づいて説明したが、本発明はこれに限定されるものではなく、各部の構成は、同様の機能を有する任意の構成のものに置換することができる。また、本発明に、他の任意の構成物や工程が付加されていてもよい。 As described above, the source code generation device, the source code generation method, and the source code generation program of the present invention have been described based on the illustrated embodiment, but the present invention is not limited to this, and the configuration of each unit is as follows. Any structure having a similar function can be substituted. Moreover, other arbitrary structures and processes may be added to the present invention.
また、本発明は、前述した実施の形態のうちの、任意の2以上の構成(特徴)を組み合わせたものであってもよい。
なお、上記の処理機能は、コンピュータによって実現することができる。その場合、ソースコード生成装置100が有すべき機能の処理内容を記述したプログラムが提供される。そのプログラムをコンピュータで実行することにより、上記処理機能がコンピュータ上で実現される。処理内容を記述したプログラムは、コンピュータで読み取り可能な記録媒体に記録しておくことができる。コンピュータで読み取り可能な記録媒体としては、例えば、磁気記録装置、光ディスク、光磁気記録媒体、半導体メモリなどが挙げられる。磁気記録装置としては、例えば、ハードディスク装置(HDD)、フレキシブルディスク(FD)、磁気テープなどが挙げられる。光ディスクとしては、例えば、DVD(Digital Versatile Disc)、DVD−RAM、CD−ROM(Compact Disc Read Only Memory)、CD−R(Recordable)/RW(ReWritable)などが挙げられる。光磁気記録媒体としては、例えば、MO(Magneto-Optical disk)などが挙げられる。
In addition, the present invention may be a combination of any two or more configurations (features) of the above-described embodiments.
The above processing functions can be realized by a computer. In that case, a program describing the processing content of the function that the source
プログラムを流通させる場合には、例えば、そのプログラムが記録されたDVD、CD−ROMなどの可搬型記録媒体が販売される。また、プログラムをサーバコンピュータの記憶装置に格納しておき、ネットワークを介して、サーバコンピュータから他のコンピュータにそのプログラムを転送することもできる。 When distributing the program, for example, portable recording media such as a DVD and a CD-ROM on which the program is recorded are sold. It is also possible to store the program in a storage device of a server computer and transfer the program from the server computer to another computer via a network.
ソースコード生成プログラムを実行するコンピュータは、例えば、可搬型記録媒体に記録されたプログラムもしくはサーバコンピュータから転送されたプログラムを、自己の記憶装置に格納する。そして、コンピュータは、自己の記憶装置からプログラムを読み取り、プログラムに従った処理を実行する。なお、コンピュータは、可搬型記録媒体から直接プログラムを読み取り、そのプログラムに従った処理を実行することもできる。また、コンピュータは、サーバコンピュータからプログラムが転送されるごとに、逐次、受け取ったプログラムに従った処理を実行することもできる。 A computer that executes a source code generation program stores, for example, a program recorded on a portable recording medium or a program transferred from a server computer in its own storage device. Then, the computer reads the program from its own storage device and executes processing according to the program. The computer can also read the program directly from the portable recording medium and execute processing according to the program. Further, each time the program is transferred from the server computer, the computer can sequentially execute processing according to the received program.
2 状態遷移図
2a,2b 状態
2c 状態遷移
3 入出力装置
4 遷移条件情報
5 ソースコード
10 ソースコード生成装置
11 状態遷移図記憶手段
12 入力画面表示手段
13 遷移条件情報取得手段
14 ソースコード生成手段
14a,14b,14c 判定コード生成機能
2 state transition diagram 2a,
Claims (6)
プログラムの状態と前記状態間の状態遷移の関係とを記述した状態遷移図を記憶する状態遷移図記憶手段と、
前記状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示する入力画面表示手段と、
前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得する遷移条件情報取得手段と、
前記入力画面で選択可能な前記記述形式それぞれに対応付けて、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力するソースコード生成手段と、
を有することを特徴とするソースコード生成装置。 In a source code generation device that generates a source code of a program from a state transition diagram,
State transition diagram storage means for storing a state transition diagram describing the state of the program and the state transition relationship between the states;
For each of the state transitions of the state transition diagram stored in the state transition diagram storage means, select a transition condition description format indicating a condition under which the state transition occurs from a list of a plurality of preset description formats. An input screen display means for displaying an input screen comprising a selection area to be described, and a description area for describing the transition condition according to the selected description format;
Transition condition information acquisition means for receiving an operation input for the input screen displayed by the input screen display means and acquiring transition condition information including the selected description format information and the description of the transition condition;
A determination code generating function for generating a determination code for performing a condition determination from the transition condition described according to the description format in association with each description format selectable on the input screen; When the acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, the state corresponds to the description format indicated by the transition condition information for each state transition Call the determination code generation function to generate the determination code, generate a processing code describing processing other than the condition determination from the state transition diagram, and synthesize the generated processing code and all the determination codes Source code generation means for outputting the source code of the program,
A source code generation device comprising:
前記ソースコード生成手段が有する、前記論理式の形式に対応する前記判定コード生成機能は、入力として与えられた前記論理式が埋め込まれた条件分岐文のコードを、前記判定コードとして生成する、
ことを特徴とする請求項1記載のソースコード生成装置。 The selection area of the input screen has, as one of the description formats that can be selected, a logical expression format that can be determined as true or false.
The determination code generation function corresponding to the format of the logical expression that the source code generation means has generates a code of a conditional branch statement in which the logical expression given as an input is embedded as the determination code.
The source code generation device according to claim 1.
前記ソースコード生成手段が有する、前記判定関数の形式に対応する前記判定コード生成機能は、入力として与えられた前記判定関数と、前記判定関数を呼び出す関数呼び出し文が埋め込まれた条件分岐文とを備えるコードを、前記判定コードとして生成する、
ことを特徴とする請求項1記載のソースコード生成装置。 The selection area of the input screen has, as one of the selectable description formats, a determination function format that returns a true / false determination result as a return value,
The determination code generation function corresponding to the determination function format included in the source code generation means includes the determination function given as an input and a conditional branch statement in which a function call statement for calling the determination function is embedded. A code provided is generated as the determination code;
The source code generation device according to claim 1.
前記ソースコード生成手段が有する、前記論理回路の形式に対応する前記判定コード生成機能は、入力として与えられた前記論理回路を同等の意味をもつ論理式に変換すると共に、変換した前記論理式に基づいて真偽を判定し戻り値として判定結果を返す判定関数と、前記判定関数を呼び出す関数呼び出し文が埋め込まれた条件分岐文とを備えるコードを、前記判定コードとして生成する、
ことを特徴とする請求項1記載のソースコード生成装置。 The selection area of the input screen has, as one of the description formats that can be selected, a logic circuit format capable of authenticity determination.
The determination code generation function corresponding to the format of the logic circuit included in the source code generation unit converts the logic circuit given as input into a logical expression having an equivalent meaning, and converts the logical circuit into the converted logical expression. Generating a code including a determination function that determines true / false based on which a determination function returns a determination result as a return value and a conditional branch statement in which a function call statement that calls the determination function is embedded, as the determination code;
The source code generation device according to claim 1.
入力画面表示手段が、状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示し、
遷移条件情報取得手段が、前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得し、
ソースコード生成手段が、前記入力画面で選択可能な前記記述形式それぞれと対応付けて、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力する、
ことを特徴とするソースコード生成方法。 In a source code generation method for generating a program source code from a state transition diagram describing a state of a program and a relationship of state transitions between the states,
The input screen display means has a plurality of descriptions described in advance in a transition condition description format indicating a condition in which the state transition occurs for each of the state transitions of the state transition diagram stored in the state transition diagram storage means. An input screen comprising a selection area to be selected from a list of formats and a description area for describing the transition condition according to the selected description format;
The transition condition information acquisition means receives an operation input for the input screen displayed by the input screen display means, acquires transition condition information including information on the selected description format and a description of the transition condition,
Source code generation means has a determination code generation function for generating a determination code for performing condition determination from the transition conditions described according to the description format in association with each description format selectable on the input screen. When the transition condition information acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, the transition condition information is indicated by the transition condition information for each state transition. The determination code generation function corresponding to the description format is called to generate the determination code, and a processing code describing processing other than the condition determination is generated from the state transition diagram, and the generated processing code and all of the processing codes are generated. Combining the determination code and outputting the source code of the program;
A source code generation method characterized by the above.
コンピュータを、
プログラムの状態と前記状態間の状態遷移の関係とを記述した状態遷移図を記憶する状態遷移図記憶手段、
前記状態遷移図記憶手段に記憶された前記状態遷移図の前記状態遷移それぞれについて、前記状態遷移が生起する条件を示す遷移条件の記述形式を、予め設定された複数の前記記述形式の一覧から選択させる選択領域と、選択された前記記述形式に従って前記遷移条件を記述するための記述領域とを備える入力画面を表示する入力画面表示手段、
前記入力画面表示手段で表示した前記入力画面に対する操作入力を受け付け、選択された前記記述形式の情報と前記遷移条件の記述とを備える遷移条件情報を取得する遷移条件情報取得手段、
前記入力画面で選択可能な前記記述形式それぞれに対応して、前記記述形式に従って記述された前記遷移条件から条件判定を行う判定コードを生成する判定コード生成機能を有しており、前記遷移条件情報取得手段が前記状態遷移図記憶手段に記憶された前記状態遷移図のすべての前記状態遷移について前記遷移条件情報を取得すると、前記状態遷移ごとに前記遷移条件情報で示される前記記述形式に対応する前記判定コード生成機能を呼び出して前記判定コードを生成すると共に、前記状態遷移図から前記条件判定以外の処理を記述した処理コードを生成し、生成した前記処理コードとすべての前記判定コードとを合成してプログラムのソースコードを出力するソースコード生成手段、
として機能させることを特徴とするソースコード生成プログラム。
In a source code generation program that generates a program source code from a state transition diagram,
Computer
State transition diagram storage means for storing a state transition diagram describing the state of the program and the state transition relationship between the states;
For each of the state transitions of the state transition diagram stored in the state transition diagram storage means, select a transition condition description format indicating a condition under which the state transition occurs from a list of a plurality of preset description formats. An input screen display means for displaying an input screen comprising a selection area to be described and a description area for describing the transition condition according to the selected description format;
Transition condition information acquisition means for receiving an operation input to the input screen displayed by the input screen display means, and acquiring transition condition information including the selected description format information and the transition condition description;
Corresponding to each of the description formats selectable on the input screen, it has a determination code generation function for generating a determination code for performing a condition determination from the transition conditions described according to the description format, and the transition condition information When the acquisition unit acquires the transition condition information for all the state transitions of the state transition diagram stored in the state transition diagram storage unit, the state corresponds to the description format indicated by the transition condition information for each state transition Call the determination code generation function to generate the determination code, generate a processing code describing processing other than the condition determination from the state transition diagram, and synthesize the generated processing code and all the determination codes Source code generation means for outputting the source code of the program,
A source code generation program characterized by functioning as
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006124687A JP4670724B2 (en) | 2006-04-28 | 2006-04-28 | Source code generation apparatus, source code generation method, and source code generation program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006124687A JP4670724B2 (en) | 2006-04-28 | 2006-04-28 | Source code generation apparatus, source code generation method, and source code generation program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2007299082A true JP2007299082A (en) | 2007-11-15 |
JP4670724B2 JP4670724B2 (en) | 2011-04-13 |
Family
ID=38768539
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2006124687A Expired - Fee Related JP4670724B2 (en) | 2006-04-28 | 2006-04-28 | Source code generation apparatus, source code generation method, and source code generation program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4670724B2 (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04352029A (en) * | 1991-05-29 | 1992-12-07 | Hitachi Ltd | Automatic formation device for source program |
JPH07225783A (en) * | 1993-05-06 | 1995-08-22 | Matsushita Electric Ind Co Ltd | Function design support device and method therefor |
JPH08286899A (en) * | 1995-04-18 | 1996-11-01 | Hitachi Ltd | Program composition by using display screen state transition table |
JP2003076543A (en) * | 2001-08-31 | 2003-03-14 | Cats Kk | Device, method for generating program and program for making computer execute the same program |
JP2006012017A (en) * | 2004-06-29 | 2006-01-12 | Denso Corp | Program generation program, program generation device and program generation method for generating program based on correspondence information in which actions are assigned to states, and program, device and method for generating the correspondence information |
-
2006
- 2006-04-28 JP JP2006124687A patent/JP4670724B2/en not_active Expired - Fee Related
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04352029A (en) * | 1991-05-29 | 1992-12-07 | Hitachi Ltd | Automatic formation device for source program |
JPH07225783A (en) * | 1993-05-06 | 1995-08-22 | Matsushita Electric Ind Co Ltd | Function design support device and method therefor |
JPH08286899A (en) * | 1995-04-18 | 1996-11-01 | Hitachi Ltd | Program composition by using display screen state transition table |
JP2003076543A (en) * | 2001-08-31 | 2003-03-14 | Cats Kk | Device, method for generating program and program for making computer execute the same program |
JP2006012017A (en) * | 2004-06-29 | 2006-01-12 | Denso Corp | Program generation program, program generation device and program generation method for generating program based on correspondence information in which actions are assigned to states, and program, device and method for generating the correspondence information |
Also Published As
Publication number | Publication date |
---|---|
JP4670724B2 (en) | 2011-04-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4280759B2 (en) | Information processing apparatus and user interface control method | |
US20110126171A1 (en) | Dynamic native editor code view facade | |
US10884711B2 (en) | Code management system and code management method using a visual programming tool | |
JP2006301989A (en) | Method, apparatus and program for automatically generating program in computer language from block diagram | |
JP4702194B2 (en) | Program development support apparatus, program development support method, and program development support program | |
WO2007116490A1 (en) | Source code generation program, source code generation method, and source code generation device | |
JP2004070810A (en) | Visual programming system, visual programming method, program for visual programming, and storage medium containing the program | |
JP2009129327A (en) | Program development support device, method, and program | |
JP4670724B2 (en) | Source code generation apparatus, source code generation method, and source code generation program | |
JP2007011507A (en) | Display method of program tree and program generation system | |
JP4848772B2 (en) | Program generating apparatus and program generating program | |
JP2007287025A (en) | Method and apparatus for creating screen transition program | |
JP2005031737A (en) | System, method, and program for generating source code, and software development support tool | |
JP5399601B2 (en) | Implementation code development system and implementation code development program | |
JP2006293436A (en) | Program code generation device and generation method | |
US20130093645A1 (en) | Computer-readable recording medium, apparatus, and method for creating setting information | |
JP2008107982A (en) | Development support program, development support method, and development support device | |
JP2001273125A (en) | Method and system for automatically generating source program, and program recording medium therefor | |
JP3940922B2 (en) | Software code generation device, software code generation method, recording medium, and program | |
US7683902B1 (en) | Method to visualize performance data of a multi-layered state diagram | |
JP4590907B2 (en) | Software development support device and software development support program | |
JP2002287964A (en) | Screen input/output specification designing system, method and program | |
KR100836218B1 (en) | The method and apparatus for automation to manage features of product line system | |
JP5629355B1 (en) | Source program generation device and source program generation program | |
JPH10105387A (en) | Sdl/program code mutual conversion system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20090313 |
|
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: 20101221 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20110103 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140128 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140128 Year of fee payment: 3 |
|
S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140128 Year of fee payment: 3 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
LAPS | Cancellation because of no payment of annual fees |