JP2017062746A - Document generation device, generation method for document, and program - Google Patents
Document generation device, generation method for document, and program Download PDFInfo
- Publication number
- JP2017062746A JP2017062746A JP2015188841A JP2015188841A JP2017062746A JP 2017062746 A JP2017062746 A JP 2017062746A JP 2015188841 A JP2015188841 A JP 2015188841A JP 2015188841 A JP2015188841 A JP 2015188841A JP 2017062746 A JP2017062746 A JP 2017062746A
- Authority
- JP
- Japan
- Prior art keywords
- source
- program
- information
- comment
- original source
- 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.)
- Pending
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
Description
本発明は、アセンブラのプログラムから他言語のプログラムへのマイグレーションに関する有用なドキュメントを生成するドキュメント生成装置等に関するものである。 The present invention relates to a document generation apparatus that generates a useful document related to migration from an assembler program to another language program.
従来技術において、レガシーシステムのログを元に稼動JCLおよびファイルを抽出して、その抽出された稼動JCLおよびファイルを使用しているCOBOLファイル定義から整理されたデータモデルを作成し、その作成されたデータモデルとMDAツールを繋いだので、新しいオープン系システムを再構築することが可能であるレガシーシステム再構築システムがあった(例えば、特許文献1参照)。 In the prior art, the operating JCL and file are extracted based on the log of the legacy system, and a data model organized from the COBOL file definition that uses the extracted operating JCL and file is created. Since the data model and the MDA tool are connected, there is a legacy system reconstruction system that can reconstruct a new open system (see, for example, Patent Document 1).
しかしながら、従来技術においては、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、他言語のプログラムとコメントとを対応付けて出力できなかった。また、従来技術においては、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、アセンブラのプログラムと他言語のプログラムとコメントとを対応付けて出力できなかった。なお、他言語のプログラムとは、アセンブラ以外の言語のプログラムであり、例えば、C言語等の高級言語のプログラムである。 However, in the prior art, when performing migration for converting an assembler program into a program in another language, the program in another language and a comment cannot be output in association with each other. In the prior art, when migration is performed to convert an assembler program into another language program, the assembler program, the other language program, and the comment cannot be output in association with each other. The other language program is a program in a language other than the assembler, for example, a high-level language program such as C language.
本第一の発明のドキュメント生成装置は、アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、アセンブラのプログラムを他言語のプログラムに変換するための情報である1以上の変換情報を格納し得る変換情報格納部と、1以上の変換情報のいずれかの変換情報に対応付けて、コメントの元になるコメント元情報を格納し得るコメント元情報格納部と、原ソース格納部に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する変換部と、変換部が用いた変換情報に対応するコメント元情報を用いてコメントを取得するコメント取得部と、変換部が取得した1以上の各目的ソース部品と、各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する出力部とを具備するドキュメント生成装置である。 The document generation apparatus according to the first aspect of the present invention is an assembler program written in an assembler language, and converts an original source storage unit that can store an original source, which is a migration target program, into a program in another language. A conversion information storage unit that can store one or more pieces of conversion information that is information to be used, and a comment that can store comment source information that is a source of a comment in association with any one piece of conversion information of the one or more pieces of conversion information The source information storage unit and one or more source source parts that are part of the source source stored in the source source storage unit are converted into other languages using conversion information corresponding to each source source part. A conversion unit that obtains a target source component that is a program in another language for each one or more conversion targets, and a conversion used by the conversion unit. Corresponds to the comment acquisition unit that acquires comments using the comment source information corresponding to the information, one or more target source components acquired by the conversion unit, and the conversion information used when each target source component is acquired The document generation device includes an output unit that outputs a comment obtained by using the comment source information in association with each other.
かかる構成により、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、他言語のプログラムと適切なコメントとを対応付けて出力できる。 With this configuration, when performing migration for converting an assembler program into a program in another language, the program in another language and an appropriate comment can be output in association with each other.
また、本第二の発明のドキュメント生成装置は、第一の発明に対して、出力部は、1以上の各目的ソース部品と、各目的ソース部品に対応するコメントと、各目的ソース部品の元になった原ソースを構成する原ソース部品とを対応付けて出力するドキュメント生成装置である。 Further, in the document generating apparatus according to the second aspect of the present invention, in contrast to the first aspect, the output unit includes one or more target source parts, a comment corresponding to each target source part, and a source of each target source part. This is a document generation device that outputs the original source components constituting the original source in association with each other.
かかる構成により、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、アセンブラプログラムと他言語のプログラムとコメントとを対応付けて出力できる。 With this configuration, when performing migration for converting an assembler program into a program in another language, the assembler program, the program in another language, and a comment can be output in association with each other.
また、本第三の発明のドキュメント生成装置は、第一または第二の発明に対して、原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である1以上の箇所特定条件を格納し得る箇所特定条件格納部をさらに具備し、変換部は、原ソース格納部に格納されている原ソースに対して、1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する原ソース部品に対して、合致する箇所特定条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する可読性向上処理手段を具備し、コメント元情報格納部は、変換情報に対応付いているコメント元情報に代えて、または変換情報に対応付いているコメント元情報に加えて、1以上の箇所特定条件のいずれかの箇所特定条件に対応付いたコメント元情報を格納し得、コメント取得部は、可読性向上処理手段が用いた箇所特定条件に対応するコメント元情報を用いてコメントを取得し、出力部は、変換部が取得した1以上の各目的ソース部品と、各目的ソース部品が取得される際に利用された変換情報または箇所特定条件に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力するドキュメント生成装置である。 The document generation device of the third aspect of the invention is a condition for specifying a portion for performing processing for improving the readability of the program for the original source with respect to the first or second aspect of the invention. And further comprising a location specifying condition storage unit capable of storing one or more location specifying conditions, and the conversion unit applies each of the one or more location specifying conditions to the original source stored in the original source storage unit, The target source corresponding to the original source part by performing the readability improvement process, which is a process corresponding to the matching part specifying condition and improving the readability of the program, for the original source part corresponding to the matching part specifying condition The comment source information storage unit includes a readability improvement processing unit for acquiring a component, and the comment source information storage unit replaces the comment source information corresponding to the conversion information or the comment source corresponding to the conversion information. In addition to the information, the comment source information associated with any one of the one or more location specifying conditions can be stored, and the comment acquisition unit can provide the comment source corresponding to the location specifying condition used by the readability improvement processing means A comment is acquired using information, and the output unit outputs one or more target source parts acquired by the conversion unit and comments corresponding to the conversion information or location specifying conditions used when each target source part is acquired. This is a document generation device that outputs a comment obtained using original information in association with the comment.
かかる構成により、保守性を考慮した、可読性の高い目的言語のプログラムを生成できる。 With this configuration, it is possible to generate a target language program with high readability in consideration of maintainability.
また、本第四の発明のドキュメント生成装置は、第三の発明に対して、箇所特定条件は、プログラムのパターンに関する情報であるソースパターン情報であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する原ソース部品に対して、合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得するドキュメント生成装置である。 Further, in the document generation device according to the fourth aspect of the present invention, in contrast to the third aspect of the invention, the location specifying condition is source pattern information that is information related to a program pattern, and the readability improvement processing means is stored in the original source storage unit One or more pieces of source pattern information are applied to stored source sources, and processing corresponding to matching source pattern information is performed on source source parts corresponding to matching source pattern information. This is a document generation device that performs readability improvement processing, which is processing for improving readability, and acquires a target source component corresponding to an original source component.
かかる構成により、予め決められたパターンに合致するアセンブラのプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 With this configuration, an assembler program matching a predetermined pattern can be converted into a target language program with high readability in consideration of maintainability.
また、本第五の発明のドキュメント生成装置は、第四の発明に対して、ソースパターン情報は、ダミーセクションを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、ダミーセクションを含む原ソース部品を決定し、原ソース部品を用いて、構造体を定義する目的ソース部品を取得するドキュメント生成装置である。 Further, in the document generating apparatus according to the fifth aspect of the invention, in contrast to the fourth aspect of the invention, the source pattern information includes information indicating a dummy section, and the readability improving processing means is stored in the original source storage unit. A document generation apparatus that applies one or more pieces of source pattern information to a source, determines an original source part including a dummy section, and obtains a target source part that defines a structure using the original source part. .
かかる構成により、アセンブラのプログラムの中のダミーセクションのプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 With this configuration, the dummy section program in the assembler program can be converted into a target language program with high readability in consideration of maintainability.
また、本第六の発明のドキュメント生成装置は、第四の発明に対して、ソースパターン情報は、オフセットを持つ戻りであることを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む原ソース部品を決定し、原ソース部品を用いて、原ソース部品に含まれるオフセットを条件に用いた分岐を示す目的ソース部品を取得するドキュメント生成装置である。 The document generation apparatus according to the sixth aspect of the present invention is the same as the fourth aspect of the invention in that the source pattern information includes information indicating that the return has an offset, and the readability improvement processing means is Apply one or more pieces of source pattern information to the stored source source, determine the source source part including the return with offset, and use the source source part as a condition for the offset included in the source source part This is a document generation apparatus that acquires a target source component indicating a branch used in the above.
かかる構成により、アセンブラのプログラムの中のオフセットを持つ戻り処理のプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 With this configuration, it is possible to convert a return processing program having an offset in the assembler program into a target language program having high readability in consideration of maintainability.
また、本第七の発明のドキュメント生成装置は、第四の発明に対して、ソースパターン情報は、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令を有する原ソース部品を特定するためのパターンの情報であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上の命令を有する原ソース部品を決定し、原ソース部品を用いて、一命令の他言語のプログラムである目的ソース部品を取得するドキュメント生成装置である。 Further, the document generation apparatus according to the seventh aspect of the invention, in contrast to the fourth aspect, specifies an original source part having two or more instructions of an assembler that can convert source pattern information into a program of another language of one instruction. Readability improving processing means applies one or more pieces of source pattern information to the original source stored in the original source storage unit and has two or more instructions. The document generation apparatus obtains a target source component which is a program of another language of one instruction using the original source component.
かかる構成により、予め決められたパターンに合致する、アセンブラのプログラムの中の2以上の命令からなるプログラムを、保守性を考慮した、可読性の高い目的言語の一命令のプログラムに変換できる。 With such a configuration, a program composed of two or more instructions in an assembler program that matches a predetermined pattern can be converted into a program of one instruction in a target language with high readability in consideration of maintainability.
また、本第八の発明のドキュメント生成装置は、第四の発明に対して、ソースパターン情報は、退避コードまたは復帰コードを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの原ソース部品を決定し、原ソース部品に対応するプログラムを、原ソースから削除するドキュメント生成装置である。 Further, in the document generating apparatus of the eighth invention, in contrast to the fourth invention, the source pattern information includes information indicating a save code or a return code, and the readability improving processing means is stored in the original source storage unit. A document generation apparatus that applies one or more pieces of source pattern information to an original source, determines an original source part of a save code or a return code, and deletes a program corresponding to the original source part from the original source is there.
かかる構成により、アセンブラのプログラムの中の退避コードまたは復帰コードを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 With this configuration, the saved code or the return code in the assembler program can be converted into a target language program with high maintainability in consideration of maintainability.
また、本第九の発明のドキュメント生成装置は、第四の発明に対して、ソースパターン情報は、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更するドキュメント生成装置である。 In the document generation device according to the ninth aspect of the invention, in contrast to the fourth aspect of the invention, the source pattern information is information indicating that a part of two or more loops formed by two or more jump instructions overlap. The readability improving processing means applies one or more pieces of source pattern information to the original source stored in the original source storage unit, determines a portion where two or more loops overlap, This is a document generation device that changes a program corresponding to a location to a program that indicates a loop that does not have a jump instruction by giving priority to one loop that satisfies a predetermined condition.
かかる構成により、アセンブラのプログラムの中の2以上のループの一部が重なっている箇所を、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 With such a configuration, a portion where two or more loops overlap in the assembler program can be converted into a target language program with high readability in consideration of maintainability.
また、本第十の発明のドキュメント生成装置は、第三の発明に対して、箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行うドキュメント生成装置である。 Further, in the document generation apparatus of the tenth invention, in contrast to the third invention, the location specifying condition is a range condition that is a condition for specifying a range of locations that satisfy a predetermined condition in the original source. The readability improvement processing means applies one or more range conditions to the original source stored in the original source storage unit, and matches the range condition for the location corresponding to the matching range condition. Is a document generation apparatus that performs readability improvement processing that is processing for improving readability of a program.
かかる構成により、アセンブラのプログラムの中の予め決められた条件を満たす箇所の範囲を特定し、保守性を考慮して、当該範囲に対応する可読性の高い目的言語のプログラムに変換できる。 With this configuration, it is possible to identify a range of locations that satisfy a predetermined condition in the assembler program, and to convert the program into a target language program having high readability corresponding to the range in consideration of maintainability.
また、本第十一の発明のドキュメント生成装置は、第十の発明に対して、範囲条件は、実行され得ないプログラムの範囲を判定するための条件であり、可読性向上処理手段は、原ソースを静的解析し、合致する範囲条件に対応する箇所のプログラムを特定し、プログラムを削除するドキュメント生成装置である。 In the document generation device of the eleventh aspect of the invention, the range condition is a condition for determining the range of programs that cannot be executed, and the readability improvement processing means is the original source. Is a document generation device that statically analyzes the program, identifies the program corresponding to the matching range condition, and deletes the program.
かかる構成により、静的解析し、到達できない箇所のアセンブラプログラムを削除することにより、可読性の高い目的言語のプログラムを得ることができる。 With this configuration, it is possible to obtain a highly readable target language program by performing static analysis and deleting an assembler program at a location that cannot be reached.
また、本第十二の発明のドキュメント生成装置は、第十の発明に対して、範囲条件は、変数を特定するための条件であり、可読性向上処理手段は、原ソースまたは目的ソースから変数を取得し、変数の生存区間を取得し、変数を、生存区間におけるローカル変数として定義する可読性向上処理を行うドキュメント生成装置である。 Further, in the document generation device of the twelfth aspect of the invention, the range condition is a condition for specifying a variable with respect to the tenth aspect of the invention, and the readability improvement processing means reads the variable from the original source or the target source. This is a document generation apparatus that performs readability improvement processing that acquires a life span of a variable and defines the variable as a local variable in the life span.
かかる構成により、アセンブラプログラム内の変数の生存区間を特定し、当該変数を当該生存区間におけるローカル変数とすることにより、可読性の高い目的言語のプログラムを得ることができる。 With this configuration, it is possible to obtain a program in a target language with high readability by specifying the life span of a variable in the assembler program and using the variable as a local variable in the life span.
また、本第十三の発明のドキュメント生成装置は、第一から第十二いずれか1つの発明に対して、原ソースは、アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであり、原ソースから、アセンブラプログラムを取得するアセンブラプログラム取得部をさらに具備し、変換部は、アセンブラプログラム取得部が取得したアセンブラプログラムを目的ソースに変換するドキュメント生成装置である。 Further, in the document generation device of the thirteenth invention, in contrast to any one of the first to twelfth inventions, the original source has an assembler program and another language program which is a program in a language other than the assembler. It is a program, and further includes an assembler program acquisition unit that acquires an assembler program from an original source, and the conversion unit is a document generation device that converts the assembler program acquired by the assembler program acquisition unit into a target source.
かかる構成により、アセンブラ以外の言語のプログラムである他言語プログラムと連結して動作するアセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い目的言語のプログラムを生成できる。 With this configuration, when migrating an assembler program that operates in conjunction with another language program that is a program in a language other than the assembler, it is possible to generate a target language program with high readability in consideration of maintainability.
本発明によるドキュメント生成装置によれば、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、他言語のプログラムとコメントとを対応付けて出力できる。 According to the document generation device of the present invention, when performing migration for converting an assembler program into a program of another language, the program of another language and a comment can be output in association with each other.
以下、ドキュメント生成装置等の実施形態について図面を参照して説明する。なお、実施の形態において同じ符号を付した構成要素は同様の動作を行うので、再度の説明を省略する場合がある。 Hereinafter, embodiments of a document generation device and the like will be described with reference to the drawings. In addition, since the component which attached | subjected the same code | symbol in embodiment performs the same operation | movement, description may be abbreviate | omitted again.
(実施の形態1)
本実施の形態において、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、変換した他言語のプログラムと対応するコメントを対応付けて出力するドキュメント生成装置について説明する。なお、かかるドキュメント生成装置により、他言語のプログラムの保守が容易になる。なお、他言語のプログラムとは、アセンブラ以外の言語のプログラムのことである。
(Embodiment 1)
In the present embodiment, a description will be given of a document generation apparatus that outputs a comment corresponding to a converted program in another language when performing migration for converting the assembler program into a program in another language. Such a document generation device facilitates maintenance of programs in other languages. The other language program is a program in a language other than the assembler.
また、本実施の形態において、さらに、アセンブラプログラムをも対応付けて出力するドキュメント生成装置について説明する。 Further, in the present embodiment, a document generation apparatus that outputs an assembler program in association with each other will also be described.
また、本実施の形態において、アセンブラのプログラム集合の中から、予め決められたソースパターンに合致するソース列に対して、可読性向上のための処理を施し、蓄積するドキュメント生成装置について説明する。予め決められたソースパターンとは、例えば、ダミーセクションの箇所を特定するパターン、オフセットを持つ戻りの箇所を特定するパターン、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターン、退避コードまたは復帰コードの箇所を特定するためのパターン、2以上のループの一部が重なっている箇所を特定するためのパターン等である。 Also, in the present embodiment, a document generation apparatus that performs processing for improving readability on a source string that matches a predetermined source pattern from an assembler program set and stores the document sequence will be described. The predetermined source pattern is, for example, a pattern for specifying a dummy section location, a pattern for specifying a return location having an offset, or a location of two or more instructions of an assembler that can be converted into another language program of one instruction. A pattern for specifying the location of the save code or the return code, a pattern for specifying a location where a part of two or more loops overlap, and the like.
また、本実施の形態において、アセンブラのプログラム集合の中の、予め決められた条件を満たす箇所の範囲を特定し、当該箇所に対応する処理を行うドキュメント生成装置について説明する。なお、当該箇所に対応する処理とは、例えば、削除処理、ローカル変数の定義を生成する処理等である。 Also, in the present embodiment, a document generation apparatus that specifies a range of locations that satisfy a predetermined condition in an assembler program set and performs processing corresponding to the locations will be described. The process corresponding to the location is, for example, a deletion process, a process for generating a local variable definition, or the like.
図1は、本実施の形態におけるドキュメント生成装置1のブロック図である。
FIG. 1 is a block diagram of a
ドキュメント生成装置1は、格納部11、処理部12、および出力部13を備える。
The
格納部11は、原ソース格納部111、箇所特定条件格納部112、変換情報格納部113、およびコメント元情報格納部114を備える。
The storage unit 11 includes an original
処理部12は、アセンブラプログラム取得部121、変換部122、コメント取得部123、および出力情報構成部124を備える。
The
変換部122は、可読性向上処理手段1221を備える。
The
格納部11は、各種の情報を格納し得る。各種の情報とは、後述する原ソース、箇所特定条件、変換情報、コメント元情報などである。 The storage unit 11 can store various types of information. The various types of information include an original source, a part specifying condition, conversion information, comment source information, and the like, which will be described later.
原ソース格納部111は、マイグレーション対象のプログラムである原ソースを格納し得る。原ソースは、通常、アセンブラ言語で記述されたアセンブラプログラムを含む。また、原ソースとは、アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであっても良い。なお、他言語プログラムは、ここでは、例えば、高級言語のプログラムである。高級言語は、COBOL、C言語、C++、JAVA(登録商標)等、問わない。また、他言語プログラムは、例えば、アセンブラプログラムを呼び出して利用しているプログラムである。また、アセンブラプログラムにおけるアセンブラの種類は問わない。アセンブラは、ここでは、アセンブリ言語と言っても良い。アセンブラは、例えば、IBM System/370で使用されているアセンブラである。
The original
また、原ソース格納部111が格納している原ソースは、アセンブラ言語で記述されたアセンブラプログラムを変換した中間言語のプログラム(中間表現と言っても良い)でも良い。中間言語のプログラムは、例えば、アセンブラプログラムの一の命令が行う複数の処理を2以上の処理に分解し、得られた2以上の命令群である。なお、中間言語のプログラムの一の命令は、アセンブラプログラムの一の命令に対応づいているものがあっても良い。また、アセンブラプログラムを中間言語のプログラムに変換する処理は、後述する変換部122が行っても良いし、他の装置で行われても良い。
Further, the original source stored in the original
箇所特定条件格納部112は、1以上の箇所特定条件を格納し得る。箇所特定条件とは、原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である。箇所特定条件は、例えば、アセンブラプログラムのパターンに関する情報であるソースパターン情報である。箇所特定条件は、例えば、原ソース内において、予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件である。箇所特定条件格納部112は、箇所特定条件に対応付けて、アセンブラプログラムを他言語に変換する情報を保持していても良い。アセンブラプログラムを他言語に変換する情報は、例えば、他言語のプログラムのパターンに関する他言語パターン情報である。また、アセンブラプログラムを他言語に変換する情報は、例えば、アセンブラプログラムを他言語に変換するプログラムにより構成されている。なお、ソースパターン情報とは、例えば、ダミーセクションを示す情報、オフセットを持つ戻りであることを示す情報、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令を有する原ソース部品を特定するためのパターンの情報、退避コードまたは復帰コードを示す情報、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報等であっても良い。なお、箇所特定条件は、アセンブラプログラムを他言語に変換する際に使用されるので、変換情報の一種である、と考えても良い。かかる場合、箇所特定条件格納部112は、変換情報格納部113の中に含まれる。
The location specifying condition storage unit 112 can store one or more location specifying conditions. The part specifying condition is a condition for specifying a part for performing processing for improving the readability of the program with respect to the original source. The location specifying condition is, for example, source pattern information that is information related to the pattern of the assembler program. The location specifying condition is, for example, a range condition that is a condition for specifying a range of locations that satisfy a predetermined condition in the original source. The location specifying condition storage unit 112 may hold information for converting the assembler program into another language in association with the location specifying condition. The information for converting the assembler program into another language is, for example, other language pattern information related to the program pattern of the other language. The information for converting the assembler program into another language is constituted by, for example, a program for converting the assembler program into another language. The source pattern information includes, for example, information indicating a dummy section, information indicating a return having an offset, and an original source component having two or more instructions of an assembler that can be converted into a program of one language in another language. It may be pattern information for specifying, information indicating a save code or a return code, information indicating that two or more loops formed by two or more jump instructions are overlapped, or the like. Note that the location specifying condition is used when the assembler program is converted into another language, and thus may be considered as a kind of conversion information. In such a case, the location specifying condition storage unit 112 is included in the conversion
変換情報格納部113は、1以上の変換情報を格納し得る。変換情報とは、アセンブラのプログラムを高級言語等の他言語のプログラムに変換するための情報である。変換情報は、通常、可読性を向上するとは限らないプログラム変換のための情報である。変換情報は、例えば、アセンブラプログラムのパターンを示すアセンブラパターン情報と、他言語プログラムのパターンを示す他言語パターン情報とを有する。変換情報は、例えば、アセンブラプログラムのパターンを示すアセンブラパターン情報と、アセンブラプログラムを他言語に変換するプログラムである。
The conversion
変換情報は、アセンブラのプログラムを他のアセンブラのプログラムに変換するための情報でも良い。かかる場合、他のアセンブラのプログラムは、通常、他言語のプログラムへの変換を容易にするプログラムである。 The conversion information may be information for converting an assembler program into another assembler program. In such a case, the other assembler program is usually a program that facilitates conversion to a program in another language.
また、変換情報は、他言語のプログラムを他の他言語のプログラムに変換するための情報でも良い。かかる場合、他の他言語のプログラムは、通常、元の他言語のプログラムより可読性が向上したプログラムである。 The conversion information may be information for converting a program in another language into a program in another language. In such a case, the other language program is usually a program whose readability is improved compared to the original other language program.
また、変換情報は、中間言語のプログラムをアセンブラのプログラムに変換するための情報でも良い。 The conversion information may be information for converting an intermediate language program into an assembler program.
また、変換情報は、中間言語のプログラムを他の中間言語のプログラムに変換するための情報でも良い。かかる場合、他の中間言語のプログラムは、通常、他言語のプログラムへの変換を容易にするプログラムである。 The conversion information may be information for converting an intermediate language program into another intermediate language program. In such a case, the other intermediate language program is usually a program that facilitates conversion to another language program.
変換情報は、例えば、「DSECT以外のUSING命令は削除することを示す情報」「DSECT以外のDROP命令は削除することを示す情報」「アセンブラ"M $変数1,$変数2"はC言語"$変数1=$変数1*$変数2"に変換することを示す情報」「アセンブラ"A $変数1,$変数2"はC言語"$変数1=$変数1+$変数2"に変換することを示す情報」などである。なお、「$変数1」等は、任意の変数を示す文字列である。 The conversion information includes, for example, “information indicating that a USING instruction other than DECT is deleted” “information indicating that a DROP instruction other than DECT is deleted” “assembler“ M $ variable 1, $ variable 2 ”is C language” $ Variable 1 = information indicating conversion to $ variable 1 * $ variable 2 "" assembler "A $ variable 1, $ variable 2" is converted to C language "$ variable 1 = $ variable 1 + $ variable 2" "Information indicating that". “$ Variable 1” or the like is a character string indicating an arbitrary variable.
コメント元情報格納部114は、変換情報格納部113のいずれかの変換情報に対応付けて、1以上のコメント元情報を格納し得る。また、コメント元情報格納部114は、箇所特定条件格納部112のいずれかの箇所特定条件に対応付けて、1以上のコメント元情報を格納し得る。
The comment source
コメント元情報格納部114は、変換情報に対応付いているコメント元情報に代えて、または変換情報に対応付いているコメント元情報に加えて、1以上の箇所特定条件のいずれかの箇所特定条件に対応付いたコメント元情報を格納し得る。
The comment source
なお、コメント元情報は、コメントの元になる情報である。コメント元情報は、例えば、文字列である。コメント元情報は、例えば、アセンブラプログラム内の情報が代入される変数を含んだ文字列パターンでも良い。また、コメント元情報は、例えば、他言語プログラム内の情報が代入される変数を含んだ文字列パターンでも良い。 The comment source information is information that is a source of the comment. The comment source information is, for example, a character string. The comment source information may be, for example, a character string pattern including a variable into which information in the assembler program is substituted. The comment source information may be, for example, a character string pattern including a variable to which information in another language program is substituted.
また、コメント元情報が対応付いていない変換情報が存在しても良いし、コメント元情報が対応付いていない箇所特定条件が存在しても良い。 Also, there may be conversion information that does not correspond to comment source information, or there may exist a location specifying condition that does not correspond to comment source information.
処理部12は、各種の処理を行う。各種の処理とは、例えば、アセンブラプログラム取得部121、変換部122、可読性向上処理手段1221、コメント取得部123、出力情報構成部124が行う処理である。
The
アセンブラプログラム取得部121は、原ソースから、アセンブラプログラムを取得する。原ソースがアセンブラプログラムと他言語プログラムとを有するプログラムである場合、アセンブラプログラム取得部121は、原ソースからアセンブラプログラムを抽出する。なお、例えば、アセンブラプログラム取得部121は、アセンブラプログラムの開始を示す文字列と終了を示す文字列とを用いて、開始を示す文字列と終了を示す文字列との間のプログラム(文字列)を、原ソースから取得する。また、例えば、アセンブラプログラム取得部121は、アセンブラプログラムであることを示す拡張子(例えば、「asm」)を有するファイルを原ソース格納部111から取得する。また、例えば、アセンブラプログラム取得部121は、アセンブラプログラムの命令または命令パターンに合致するプログラム(文字列)を、原ソースから取得する。なお、かかる場合、アセンブラプログラムのすべての命令または命令パターンは、格納部11に格納されている、とする。
The assembler
変換部122は、原ソース格納部111に格納されている原ソース(ここでは、アセンブラプログラム)を、他言語のプログラムであり、目的言語のプログラムである目的ソースに変換する。なお、目的言語のプログラムは、C言語などの他言語のプログラムである。原ソースを目的ソースに変換する処理は、原ソースを無くす処理とは限らず、原ソースと目的ソースの両方が存在する状況にする処理であることは好適である。原ソースを目的ソースに変換する処理は、原ソースから目的ソースを取得する処理である。
The
変換部122は、アセンブラプログラム取得部121が取得したアセンブラプログラムを目的ソースに変換しても良い。かかる場合、変換部122は、アセンブラプログラム以外のプログラム(例えば、Java、COBOL等のプログラム)を、目的ソースに変換しても良い。アセンブラプログラム以外のプログラムとは、アセンブラプログラム取得部121が原ソース格納部111から取得しなかったプログラムであり、原ソース格納部111に格納されているプログラムである。なお、アセンブラプログラム以外のプログラムを、目的ソースに変換するプログラムは公知技術であるので、詳細な説明は省略する。
The
変換部122は、1以上の変換情報を用いて、アセンブラプログラムを目的ソースに変換しても良い。また、変換部122は、1以上の箇所特定条件を用いて、アセンブラプログラムを目的ソースに変換する。つまり、変換部122は、例えば、箇所特定条件に合致する変換対象のプログラムの箇所に対して、当該箇所特定条件に対応する変換情報を用いて、当該変換対象のプログラムの箇所を変換して、変換後のプログラムを取得する。
The
変換対象のプログラムは、通常、アセンブラプログラムであるが、中間言語のプログラム、目的ソースのプログラムでも良い。また、変換後のプログラムは、通常、目的ソースのプログラムであるが、アセンブラプログラム、中間言語のプログラムでも良い。 The program to be converted is usually an assembler program, but may be an intermediate language program or a target source program. The converted program is usually a target source program, but may be an assembler program or an intermediate language program.
変換部122は、原ソース格納部111に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する。なお、目的ソース部品とは、目的ソースを構成する一部のプログラムである。
The
変換部122は、アセンブラプログラム取得部121が取得したアセンブラプログラムを構成する一部のプログラムである1以上の各原ソース部品を、各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する。
The
可読性向上処理手段1221は、プログラムの可読性を向上させる処理である可読性向上処理を行う。可読性向上処理は、例えば、アセンブラのダミーセクションの定義をC言語等の他言語の構造体の定義に書き換える処理である。また、可読性向上処理は、例えば、アセンブラのオフセットを持つ戻り処理を、適切な他言語のプログラムに書き換える処理である。また、可読性向上処理は、例えば、2以上の命令群のアセンブラプログラムを、1命令の他言語のプログラムに書き換える処理である。なお、1命令の他言語のプログラムとは、例えば、C言語において、「;」が一つで足りる命令である。また、可読性向上処理は、例えば、アセンブラプログラム中の退避コードまたは復帰コードを削除する処理である。また、可読性向上処理は、例えば、アセンブラプログラム中の複数のループ処理を、適切な他言語のプログラムに書き換える処理である。また、可読性向上処理は、例えば、到達できないアセンブラプログラムの箇所を削除する処理である。また、可読性向上処理は、例えば、アセンブラプログラムの変数の生存区間を検査し、他言語のローカル変数とする処理である。
The readability
また、可読性向上処理は、例えば、2以上の命令群のアセンブラプログラムを、2以上の命令の目的ソースのプログラムに書き換える処理である。つまり、一の命令のアセンブラプログラムは2以上の命令群を有する中間言語のプログラムに変換され得る。また、2以上の命令群の中間言語のプログラムは、一または2以上の命令の目的ソースのプログラムに変換され得る。そして、かかる場合、2以上の命令群のアセンブラプログラムを、2以上の命令の目的ソースのプログラムに書き換えられ得る。さらに具体的には、2以上の命令群(ac1,ac2)のアセンブラプログラムが存在する場合、アセンブラプログラムの第一の命令(ac1)が中間言語のプログラム(mc1,mc2)に変換され、アセンブラプログラムの第二の命令(ac2)が中間言語のプログラム(mc3,mc4)に変換された、とする。そして、中間言語のプログラムの第一の命令(mc1)は、目的ソースのプログラムの命令(ts1)に変換され、中間言語のプログラムの第二、第三の命令(mc2,mc3)は、目的ソースのプログラムの命令(ts2)に変換され、中間言語のプログラムの第四の命令(mc4)は、目的ソースのプログラムの命令(ts3)に変換された、とする。かかる場合、2つの命令を有するアセンブラプログラム(ac1,ac2)が、3つの命令(ts1,ts2,ts3)を有する目的ソースのプログラムに変換される。 The readability improving process is a process of rewriting an assembler program of two or more instruction groups into a program of a target source of two or more instructions, for example. That is, an assembler program of one instruction can be converted into an intermediate language program having two or more instruction groups. Further, an intermediate language program of two or more instruction groups can be converted into a target source program of one or more instructions. In such a case, an assembler program of two or more instruction groups can be rewritten into a program of a target source of two or more instructions. More specifically, if there is an assembler program of two or more instruction groups (ac1, ac2), the first instruction (ac1) of the assembler program is converted into an intermediate language program (mc1, mc2), and the assembler program Is converted to an intermediate language program (mc3, mc4). The first instruction (mc1) of the intermediate language program is converted to the instruction (ts1) of the target source program, and the second and third instructions (mc2, mc3) of the intermediate language program are converted to the target source. It is assumed that the fourth instruction (mc4) of the intermediate language program is converted to the instruction (ts3) of the target source program. In such a case, the assembler program (ac1, ac2) having two instructions is converted into a target source program having three instructions (ts1, ts2, ts3).
さらに具体的には、可読性向上処理は、原ソース格納部111に格納されている原ソースが有するアセンブラプログラムに対して、1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する箇所に対して、合致する箇所特定条件に対応する処理である。
More specifically, the readability improving process applies one or more location specifying conditions to the assembler program included in the original source stored in the original
第一の可読性向上処理は、箇所特定条件がプログラムのパターンに関する情報であるソースパターン情報である場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースが有するアセンブラプログラムに対して、1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する箇所に対して、合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う。合致するソースパターン情報に対応する処理は、通常、プログラムで実現される。
The first readability improving process is a case where the location specifying condition is source pattern information which is information related to a program pattern. In such a case, the readability
第二の可読性向上処理は、箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件である場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースが有するアセンブラプログラムに対して、1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う。なお、合致する範囲条件に対応する処理は、通常、プログラムで実現される。
The second readability improving process is a case where the location specifying condition is a range condition that is a condition for specifying a range of locations that satisfy a predetermined condition in the original source. In such a case, the readability
また、範囲条件は、例えば、着目した一の変数が使用されている生存区間を特定する条件である。生存区間は、着目した一の変数が出現するプログラムの範囲である、と言える。また、範囲条件は、例えば、アセンブラプログラムを静的解析した結果、実行され得ないプログラムの範囲を特定する条件である。 In addition, the range condition is a condition for specifying, for example, a life span in which one focused variable is used. It can be said that the life span is a range of a program in which one focused variable appears. The range condition is a condition for specifying a range of programs that cannot be executed as a result of static analysis of the assembler program, for example.
また、範囲条件は、例えば、実行され得ないプログラムの範囲を判定するための条件、変数を特定するための条件等である。 The range condition is, for example, a condition for determining a range of a program that cannot be executed, a condition for specifying a variable, or the like.
(A)以下、第一の可読性向上処理の具体例を説明する。第一の可読性向上処理の例は、以下の(A−1)から(A−5)の5つである。 (A) Hereinafter, a specific example of the first readability improving process will be described. Examples of the first readability improvement process are the following five (A-1) to (A-5).
(A−1)ソースパターン情報が、ダミーセクションを示す情報を含む場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、ダミーセクションを含む原ソース部品を決定し、当該原ソース部品を用いて、構造体を定義する他言語のプログラムを取得する。
(A-1) This is a case where the source pattern information includes information indicating a dummy section. In such a case, the readability
(A−2)ソースパターン情報が、オフセットを持つ戻りであることを示す情報を含む場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む原ソース部品を決定し、当該原ソース部品を用いて、プログラムに含まれるオフセットを条件に用いた分岐を示す他言語のプログラムを取得する。
(A-2) This is a case where the source pattern information includes information indicating that the return has an offset. In such a case, the readability
(A−3)ソースパターン情報が、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり含む場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上の命令の原ソース部品を決定し、当該原ソース部品を用いて、一命令の他言語のプログラムを取得する。
(A-3) This is a case where the source pattern information is pattern information for specifying the location of two or more instructions of the assembler that can be converted into a program of another language of one instruction. In such a case, the readability
(A−4)ソースパターン情報が、退避コードまたは復帰コードを示す情報を含む場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの原ソース部品を決定し、当該原ソース部品に対応するプログラムを、原ソースまたは目的ソースから削除する。可読性向上処理手段1221は、退避コードまたは復帰コードが対象とするレジスタまたは変数が、退避コードまたは復帰コードが出現する関数内で使用されていないか否かを判断し、使用されていない場合に、退避コードまたは復帰コードを削除することは好適である。
(A-4) This is a case where the source pattern information includes information indicating a save code or a return code. In such a case, the readability
(A−5)ソースパターン情報が、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含む場合である。かかる場合、可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示す他言語のプログラムに変更する。
(A-5) This is a case where the source pattern information includes information indicating that two or more loops formed by two or more jump instructions overlap each other. In such a case, the readability
ここで、予め決められた条件とは、例えば、以下の(1)(2)の2つである。
(1)ボトムが起点から最も遠いループであること。
Here, the predetermined conditions are, for example, the following two (1) and (2).
(1) The bottom is the loop farthest from the starting point.
この条件の場合、ループが複数あれば、 可読性向上処理手段1221は、ボトムが起点から遠いループを優先し、当該優先されたループの箇所を、他言語のループのプログラムに書き換え、当該優先されたループの箇所からジャンプ命令を無くす。これは、複雑な構造がある場合に、なるべくループへの飛び込みを避けることにより、プログラムの可読性を良くする趣旨である。なお、この場合、ループからの飛び出しは容認する。
In the case of this condition, if there are a plurality of loops, the readability
また、ここで、起点とは、複数のループを含むプログラム群の最初の命令(行と言っても良い)または基本ブロックである。また、ボトムとは、複数のループを含むプログラム群の最後の命令(行と言っても良い)または基本ブロックである。さらに、他言語のループのプログラムとは、例えば、C言語の場合、「while」や「for」を用いたプログラムである。
(2)ボトムが同じループが複数ある場合、ループのトップが起点から最も近いループであること。
Here, the starting point is the first instruction (also referred to as a line) or a basic block of a program group including a plurality of loops. The bottom is the last instruction (also referred to as a line) or basic block of a program group including a plurality of loops. Furthermore, the loop program in another language is, for example, a program using “while” or “for” in the case of C language.
(2) When there are a plurality of loops having the same bottom, the top of the loop is the loop closest to the starting point.
この条件の場合、ボトムが同じループが複数あれば、可読性向上処理手段1221は、トップが起点から最も近いループを優先し、当該優先されたループの箇所を、他言語のループのプログラムに書き換え、当該優先されたループの箇所からジャンプ命令を無くす。
In the case of this condition, if there are a plurality of loops having the same bottom, the readability
本条件に対応するマイグレーション処理を行うことにより、可読性が向上するだけではなく、外側のループから処理することになり、全体の計算量が少なくなる、という効果がある。 By performing the migration processing corresponding to this condition, not only the readability is improved, but also the processing is performed from the outer loop, and the entire calculation amount is reduced.
(B)以下、第二の可読性向上処理の具体例を説明する。第二の可読性向上処理の例は、以下の(B−1)から(B−2)の2つである。 (B) Hereinafter, a specific example of the second readability improving process will be described. Examples of the second readability improvement process are the following two (B-1) to (B-2).
(B−1)範囲条件が、実行され得ないプログラムの範囲を判定するための条件である場合である。かかる場合、可読性向上処理手段1221は、原ソースを静的解析し、合致する範囲条件に対応する箇所のプログラムを特定し、プログラムを削除する。
(B-1) This is a case where the range condition is a condition for determining the range of a program that cannot be executed. In such a case, the readability
(B−2)範囲条件が、変数を特定するための条件である場合である。かかる場合、可読性向上処理手段1221は、原ソースまたは目的ソースから変数を取得し、変数の生存区間を取得し、変数を、生存区間におけるローカル変数として定義する可読性向上処理を行う。
(B-2) This is a case where the range condition is a condition for specifying a variable. In such a case, the readability
なお、可読性向上処理手段1221は、例えば、原ソースまたは目的ソースに出現する一の変数に対して、出現する1以上の基本ブロックを特定する。そして、可読性向上処理手段1221は、特定した1以上の基本ブロックを一の関数として、定義する。そして、可読性向上処理手段1221は、当該一の関数の命令の前に、当該一の変数を定義する。
Note that the readability
例えば、変換する他言語がC言語の場合、可読性向上処理手段1221は、例えば、「function_name(){ 1以上の変数定義; 1以上の基本ブロックを変換した他言語の命令列;}」を取得する。なお、「function_name」は関数名であり、可読性向上処理手段1221が、予め決められた規則に基づいて生成した関数名であることは好適である。また、「1以上の変数定義」は、例えば、「char 変数名;」「int 変数名;」などであり、可読性向上処理手段1221は、C言語の文法に従って、変数の型、変数名を取得し、記載する。なお、変数名は、予め決められたルールに基づいて、決定されることは好適である。
For example, when the other language to be converted is C language, the readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する原ソース部品に対して、合致する箇所特定条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する。
The readability
可読性向上処理手段1221は、例えば、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する原ソース部品に対して、合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する。
For example, the readability
可読性向上処理手段1221は、例えば、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、ダミーセクションを含む原ソース部品を決定し、原ソース部品を用いて、構造体を定義する目的ソース部品を取得する。
For example, the readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む原ソース部品を決定し、原ソース部品を用いて、原ソース部品に含まれるオフセットを条件に用いた分岐を示す目的ソース部品を取得する。
The readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上の命令を有する原ソース部品を決定し、原ソース部品を用いて、一命令の他言語のプログラムである目的ソース部品を取得する。
The readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの原ソース部品を決定し、原ソース部品に対応するプログラムを、原ソースまたは目的ソースから削除する。
The readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更する。
The readability
可読性向上処理手段1221は、原ソース格納部111に格納されている原ソースに対して、1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う。
The readability
可読性向上処理手段1221は、原ソースを静的解析し、合致する範囲条件に対応する箇所のプログラムを特定し、プログラムを削除する。
The readability
可読性向上処理手段1221は、原ソースまたは目的ソースから変数を取得し、変数の生存区間を取得し、変数を、生存区間におけるローカル変数として定義する可読性向上処理を行う。
The readability
コメント取得部123は、変換部122が用いた変換情報に対応するコメント元情報を用いてコメントを取得する。
The
コメント取得部123は、可読性向上処理手段1221が用いた箇所特定条件に対応するコメント元情報を用いてコメントを取得する。
The
なお、コメント元情報がコメントである場合、コメント取得部123は、変換情報または箇所特定条件に対応するコメント元情報を、コメントとして取得する。なお、コメントは、通常、対応する他言語のプログラムを説明する情報である。また、コメントは、例えば、原ソース部品から目的ソース部品を得る変換処理を説明する情報である。
When the comment source information is a comment, the
また、コメント元情報がアセンブラプログラム内の情報が代入される変数を含んだ文字列パターンである場合、コメント取得部123は、変換情報または箇所特定条件に対応するコメント元情報の1以上の各変数に対応する文字列をアセンブラプログラム(原ソース部品)から取得し、当該取得した1以上の各文字列を対応する変数に代入し、変数のない文字列であるコメントを取得する。
In addition, when the comment source information is a character string pattern including a variable to which information in the assembler program is substituted, the
出力情報構成部124は、出力する情報である出力情報を構成する。出力情報は、目的ソース部品と、コメント取得部123が取得したコメントとを有する。なお、このコメントは、目的ソース部品に対応するコメントである。また、出力情報は、原ソース部品と目的ソース部品とコメント取得部123が取得したコメントとを有する。なお、このコメントは、原ソース部品と目的ソース部品に対応するコメントである。出力情報は、原ソース部品と目的ソース部品とコメントのうちの2種類以上の情報を有する。
The output
出力部13は、出力情報構成部124が構成した出力情報を出力する。
The
出力部13は、変換部122が取得した1以上の各目的ソース部品と、各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力しても良い。
The
出力部13は、1以上の各目的ソース部品と、各目的ソース部品に対応するコメントと、各目的ソース部品の元になった原ソースを構成する原ソース部品とを対応付けて出力しても良い。
The
出力部13は、変換部122が取得した1以上の各目的ソース部品と、各目的ソース部品が取得される際に利用された変換情報または箇所特定条件に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力しても良い。
The
出力部13は、変換部122が取得した1以上の各目的ソース部品と、各目的ソース部品が取得される際に利用された変換情報または箇所特定条件に対応するコメント元情報を用いて取得されたコメントと、各目的ソース部品の元になった原ソースを構成する原ソース部品とを対応付けて出力しても良い。
The
出力部13は、変換部122が変換して、取得した目的ソースを出力しても良い。また、出力部13は、変換できないアセンブラプログラムが存在する場合、変換できないアセンブラプログラムが存在する旨のエラーを出力しても良い。
The
ここで、出力とは、ディスプレイへの表示、プロジェクターを用いた投影、プリンタでの印字、外部の装置への送信、記録媒体への蓄積、他の処理装置や他のプログラムなどへの処理結果の引渡しなどを含む概念である。 Here, output refers to display on a display, projection using a projector, printing on a printer, transmission to an external device, storage in a recording medium, processing result to another processing device or other program, etc. It is a concept that includes delivery.
格納部11、原ソース格納部111、箇所特定条件格納部112、変換情報格納部113、およびコメント元情報格納部114は、不揮発性の記録媒体が好適であるが、揮発性の記録媒体でも実現可能である。
The storage unit 11, the original
格納部11等に情報が記憶される過程は問わない。例えば、記録媒体を介して情報が格納部11等で記憶されるようになってもよく、通信回線等を介して送信された情報が格納部11等で記憶されるようになってもよく、あるいは、入力デバイスを介して入力された情報が格納部11等で記憶されるようになってもよい。 The process in which information is stored in the storage unit 11 or the like is not limited. For example, information may be stored in the storage unit 11 or the like via a recording medium, information transmitted via a communication line or the like may be stored in the storage unit 11 or the like, Alternatively, information input via the input device may be stored in the storage unit 11 or the like.
処理部12、アセンブラプログラム取得部121、変換部122、可読性向上処理手段1221、コメント取得部123、出力情報構成部124、および出力部13は、通常、MPUやメモリ等から実現され得る。処理部12等の処理手順は、通常、ソフトウェアで実現され、当該ソフトウェアはROM等の記録媒体に記録されている。但し、ハードウェア(専用回路)で実現しても良い。
The
出力部13は、例えば、出力デバイスのドライバーソフトまたは、出力デバイスのドライバーソフトと出力デバイス等で実現され得る、と考えても良い。
The
次に、ドキュメント生成装置1の動作について、図2のフローチャートを用いて説明する。
Next, the operation of the
(ステップS201)アセンブラプログラム取得部121は、原ソース格納部111に格納されている原ソースから、アセンブラプログラムを取得する。
(Step S201) The assembler
(ステップS202)変換部122は、ステップS201で取得されたアセンブラプログラムに対して、静的解析処理を行う。静的解析処理について、図3のフローチャートを用いて説明する。
(Step S202) The
(ステップS203)変換部122は、カウンタiに1を代入する。
(Step S203) The
(ステップS204)変換部122は、i番目の基本ブロックが存在するか否かを判断する。i番目の基本ブロックが存在する場合はステップS205に行き、i番目の基本ブロックが存在しない場合は処理を終了する。
(Step S204) The
(ステップS205)可読性向上処理手段1221は、カウンタjに1を代入する。
(Step S205) The readability
(ステップS206)可読性向上処理手段1221は、j番目の箇所特定条件が箇所特定条件格納部112に存在するか否かを判断する。j番目の箇所特定条件が存在する場合はステップS207に行き、存在しない場合はステップS213に行く。
(Step S <b> 206) The readability
(ステップS207)可読性向上処理手段1221は、箇所特定条件格納部112からj番目の箇所特定条件を取得する。
(Step S207) The readability
(ステップS208)可読性向上処理手段1221は、i番目の基本ブロックがj番目の箇所特定条件に合致するか否かを判断する。合致する場合はステップS209に行き、合致しない場合はステップS212に行く。なお、i番目の基本ブロックの一部のアセンブラプログラムがj番目の箇所特定条件に合致する場合も、i番目の基本ブロックがj番目の箇所特定条件に合致するとする。また、i番目の基本ブロックのアセンブラプログラムが変換された中間表現(中間コードと言っても良い)の全部または一部が、j番目の箇所特定条件に合致する場合も、i番目の基本ブロックがj番目の箇所特定条件に合致するとする。
(Step S208) The readability
(ステップS209)可読性向上処理手段1221は、j番目の箇所特定条件に合致する箇所を対象として、j番目の箇所特定条件に対応する処理を行い、当該合致する箇所に対応する他言語のプログラムを取得する。
(Step S209) The readability
(ステップS210)出力情報構成部124等は、出力情報構成処理を行う。出力情報構成処理について、図4のフローチャートを用いて説明する。
(Step S210) The output
(ステップS211)出力部13は、ステップS210で構成された出力情報を出力する。
(Step S211) The
(ステップS212)可読性向上処理手段1221は、i番目の基本ブロックのすべてが、他言語のプログラムに変換されたか否かを判断する。i番目の基本ブロックのすべてが変換された場合はステップS213に行き、i番目の基本ブロックにおいて未変換の箇所を含む場合はステップS214に行く。
(Step S212) The readability
(ステップS213)変換部122は、カウンタiを1、インクリメントする。ステップS204に戻る。
(Step S213) The
(ステップS214)可読性向上処理手段1221は、カウンタjを1、インクリメントする。ステップS206に戻る。
(Step S214) The readability
(ステップS215)変換部122は、カウンタkに1を代入する。
(Step S215) The
(ステップS216)変換部122は、変換情報格納部113にk番目の変換情報が存在するか否を判断する。k番目の変換情報が存在する場合はステップS217に行き、k番目の変換情報が存在しない場合はステップS223に行く。
(Step S216) The
(ステップS217)変換部122は、i番目の基本ブロックがk番目の変換情報に対応するか否かを判断する。i番目の基本ブロックがk番目の変換情報に対応する場合はステップS218に行き、対応しない場合はステップS222に行く。なお、i番目の基本ブロックがk番目の変換情報に対応することは、i番目の基本ブロックの中に、変換情報が有するアセンブラパターン情報に合致するアセンブラプログラムを少なくとも一部に含むことである。
(Step S217) The
(ステップS218)変換部122は、k番目の変換情報を用いて、k番目の変換情報に対応するアセンブラプログラムを、他言語のプログラムに変換する。変換部122は、例えば、k番目の変換情報に対応するアセンブラプログラムを、k番目の変換情報が有する他言語パターン情報を用いて、他言語のプログラムを取得する。
(Step S218) The
(ステップS219)出力情報構成部124等は、出力情報構成処理を行う。出力情報構成処理について、図4のフローチャートを用いて説明する。
(Step S219) The output
(ステップS220)出力部13は、ステップS219で構成された出力情報を出力する。
(Step S220) The
(ステップS221)変換部122は、i番目の基本ブロックに含まれるすべてのアセンブラプログラムの変換が完了したか否かを判断する。i番目の基本ブロックの変換が完了した場合はステップS213に行き、変換が完了していない場合はステップS222に行く。
(Step S221) The
(ステップS222)変換部122は、カウンタkを1、インクリメントする。ステップS216に戻る。
(Step S222) The
(ステップS223)出力部13は、i番目の基本ブロックの中に変換できないプログラムが存在する旨のエラーを出力する。ステップS213に行く。
(Step S223) The
なお、図2のフローチャートにおいて、原ソースがアセンブラ言語以外の他言語のプログラムを含む場合、当該他言語のプログラムも、マイグレーションのために変換することは好適である。かかる変換処理は、例えば、特許第4354514号、特許第4698943号、特許第5124660号、特許第5253115号等に記載の公知技術等を用いて、行うことができる。 In the flowchart of FIG. 2, when the source source includes a program in another language other than the assembler language, it is preferable to convert the program in the other language for migration. Such conversion processing can be performed using, for example, known techniques described in Japanese Patent No. 4354514, Japanese Patent No. 4698943, Japanese Patent No. 5124660, Japanese Patent No. 5253115, and the like.
次に、ステップS202の静的解析処理の一例について、図3のフローチャートを用いて説明する。なお、静的解析処理は、ここでは、基本ブロックの範囲を確定する処理と、基本ブロック間のリンクを生成する処理と、実行され得ないプログラムの箇所を特定するための処理である。 Next, an example of the static analysis process in step S202 will be described using the flowchart of FIG. Here, the static analysis process is a process for determining a range of basic blocks, a process for generating a link between basic blocks, and a process for specifying a location of a program that cannot be executed.
(ステップS301)変換部122は、カウンタiに1、カウンタjに1を代入する。
(Step S301) The
(ステップS302)変換部122は、ステップS201で取得されたアセンブラプログラムの中の命令であり、次に実行され得るi番目の命令が存在するか否かを判断する。i番目の命令が存在する場合はステップS303に行き、i番目の命令が存在しない場合はステップS311に行く。
(Step S302) The
(ステップS303)変換部122は、i番目の命令は分岐命令であるか否かを判断する。分岐命令である場合はステップS307に行き、分岐命令でない場合はステップS304に行く。
(Step S303) The
(ステップS304)変換部122は、i番目の命令に対して、他の命令から分岐されてくる可能性があるか否か(ジャンプの先として指定されている命令が存在するか否か)を判断する。他の命令から分岐されてくる可能性がある場合はステップS307に行き、他の命令から分岐されてくる可能性がない場合はステップS305に行く。
(Step S304) The
(ステップS305)変換部122は、i番目をバッファに配置する。なお、バッファは、基本ブロックを作り出すためのワーク用の記憶領域である。
(Step S305) The
(ステップS306)変換部122は、カウンタiを1、インクリメントする。ステップS302に戻る。
(Step S306) The
(ステップS307)変換部122は、バッファ内の1以上の命令群をj番目の基本ブロックとする処理を行う。かかる処理は、例えば、基本ブロックを構成する1以上の命令に対して、「j」を付加したり、「j」をリンク付けたり、基本ブロックを構成する1以上の命令を他と区別してバッファに格納したりすること等である。なお、バッファ内に命令を有しない場合は、何らの処理も行わず、ステップS305に戻る。
(Step S307) The
(ステップS308)変換部122は、j番目の基本ブロックからのリンク先が存在する場合、当該リンク先の基本ブロックの識別子を、j番目の基本ブロックに付加する。かかる処理は、基本ブロック間の制御フローが判断され得る情報を構成する処理であれば、何でも良い。
(Step S308) When there is a link destination from the jth basic block, the
(ステップS309)変換部122は、バッファ内の命令群を削除する。
(Step S309) The
(ステップS310)変換部122は、カウンタjを1、インクリメントする。ステップS305に戻る。
(Step S310) The
(ステップS311)変換部122は、未処理の命令(箇所)に未処理を示すフラグを付す。なお、未処理の命令は、実行され得ない命令である。また、未処理の命令は存在しない可能性もあり、かかる場合、本ステップは実行されない。上位処理にリターンする。なお、 なお、図3のフローチャートにおいて、可読性向上処理手段1221は、未処理を示すフラグを付した箇所のアセンブラプログラムを削除することは好適である。
(Step S311) The
また、図3のフローチャートにおいて示した静的解析処理は一例であり、異なるアルゴリズムにより、基本ブロックの範囲を確定する処理と、基本ブロック間のリンクを生成する処理と、実行され得ないプログラムの箇所を特定するための処理を行っても良い。 Also, the static analysis process shown in the flowchart of FIG. 3 is an example. The process of determining the basic block range, the process of generating a link between the basic blocks, and the location of the program that cannot be executed by different algorithms. You may perform the process for specifying.
次に、ステップS210、ステップS219の出力情報構成処理について、図4のフローチャートを用いて説明する。 Next, the output information configuration processing in step S210 and step S219 will be described using the flowchart in FIG.
(ステップS401)出力情報構成部124は、カレントの原ソース部品を取得する。なお、カレントの原ソース部品とは、現在、処理対象の原ソース部品である。
(Step S401) The output
(ステップS402)出力情報構成部124は、カレントの目的ソース部品を取得する。なお、カレントの目的ソース部品とは、現在、処理対象の目的ソース部品である。
(Step S <b> 402) The output
(ステップS403)コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件または変換情報に対応するコメント元情報をコメント元情報格納部114から取得する。
(Step S403) The
(ステップS404)コメント取得部123は、カウンタiに1を代入する。
(Step S404) The
(ステップS405)コメント取得部123は、ステップS403で取得したコメント元情報の中に、i番目の変数が存在するか否かを判断する。i番目の変数が存在する場合はステップS406に行き、i番目の変数が存在しない場合はステップS409に行く。
(Step S405) The
(ステップS406)コメント取得部123は、i番目の変数に対応する文字列を原ソース部品、または目的ソース部品から取得する。
(Step S406) The
(ステップS407)コメント取得部123は、ステップS406で取得した文字列を、ステップS403で取得したコメント元情報の中に代入する。
(Step S407) The
(ステップS408)コメント取得部123は、カウンタiを1、インクリメントする。ステップS405に戻る。
(Step S408) The
(ステップS409)コメント取得部123は、コメントを取得する。なお、コメントは、ステップS403で取得したコメント元情報、またはコメント元情報の中のすべての変数に文字列が代入された文字列である。
(Step S409) The
(ステップS410)出力情報構成部124は、ステップS401で取得した原ソース部品、ステップS402で取得した目的ソース部品、ステップS409で取得されたコメントを有する出力情報を構成する。上位処理にリターンする。
(Step S410) The output
なお、図4のフローチャートのステップS410において、出力情報構成部124は、原ソース部品、目的ソース部品、コメントのうち、2種類の情報を有する出力情報を構成しても良い。
In step S410 of the flowchart of FIG. 4, the output
以下、本実施の形態におけるドキュメント生成装置1の具体的な動作について説明する。今、マイグレーション対象のアセンブラプログラムは、IBMアセンブラである。また、目的言語のプログラムはC言語のプログラムである。
Hereinafter, a specific operation of the
かかる状況において、以下に、6つの具体例を用いて、ドキュメント生成装置1を説明する。具体例1から具体例4は、アセンブラプログラムからC言語のプログラムを生成する場合の処理の例である。具体例5から具体例6は、出力情報を構成し、出力する例である。
In this situation, the
(具体例1)
具体例1は、第一の可読性向上処理および第二の可読性向上処理の具体例である。具体例1は、ソースパターン情報が、ダミーセクションを示す情報を含む場合であり、かつ退避コードと復帰コードを示す情報を含む場合である。また、具体例1において、範囲条件が、実行され得ないプログラムの範囲を判定するための条件である場合も述べる。つまり、具体例1は、上記の(A−1)、(A−4)、(B−1)に該当する。
(Specific example 1)
Specific example 1 is a specific example of the first readability improving process and the second readability improving process. Specific Example 1 is a case where the source pattern information includes information indicating a dummy section and includes information indicating a save code and a return code. In the first specific example, a case where the range condition is a condition for determining the range of a program that cannot be executed will be described. That is, the specific example 1 corresponds to the above (A-1), (A-4), and (B-1).
今、原ソース格納部111は、図5に示す原ソースを格納している、とする。原ソースは、アセンブラ言語のプログラムの一部である。
Assume that the original
また、箇所特定条件格納部112は、図6に示す箇所特定条件管理表を格納している、とする。箇所特定条件管理表は、「ID」「箇所特定条件」「変換情報」を有する1以上のレコードを格納している。「ID」はレコードを識別する情報である。「箇所特定条件」は、可読性向上処理を行う変換対象の箇所を特定する情報である。「箇所特定条件」は「開始条件」「終了条件」を有しても良い。「開始条件」は「箇所特定条件」に合致する箇所の開始の箇所を特定する条件である。「終了条件」は「箇所特定条件」に合致する箇所の終了の箇所を特定する条件である。つまり、「開始条件」に合致する箇所と「終了条件」に合致する箇所との間の範囲が「箇所特定条件」により特定される範囲である。また、「箇所特定条件」は一つの条件のみでも良い。また、「変換情報」は、「アセンブラ」「他言語」を有し得る。「アセンブラ」「他言語」は、「箇所特定条件」により特定された範囲において、「アセンブラ」に合致する命令や定義に対して、「他言語」に対応する他言語を生成することを意味する。また、「変換情報」は、変化のための処理を記述する情報等でも良い。 Further, it is assumed that the location specifying condition storage unit 112 stores the location specifying condition management table shown in FIG. The location specifying condition management table stores one or more records having “ID”, “location specifying condition”, and “conversion information”. “ID” is information for identifying a record. The “location specifying condition” is information for specifying a conversion target location for performing the readability improving process. The “location specifying condition” may include a “start condition” and an “end condition”. The “start condition” is a condition for specifying the start location of the location that matches the “location specifying condition”. The “end condition” is a condition for specifying the end location of the location that matches the “location specifying condition”. That is, the range between the location that matches the “start condition” and the location that matches the “end condition” is the range specified by the “location specifying condition”. Further, the “location specifying condition” may be only one condition. The “conversion information” may include “assembler” and “other language”. “Assembler” and “other language” mean to generate another language corresponding to “other language” for an instruction or definition that matches “assembler” within the range specified by “location specifying condition”. . The “conversion information” may be information describing processing for change.
図6において、「ID=1」の開始条件「$1_'DSECT'」の「$1」はすべての文字列が合致する。つまり、例えば、アセンブラプログラム「PKTDSECT DSECT」は開始条件「$1_'DSECT'」に合致する。また、「ID=1」の終了条件「'CSECT' or 'DCECT' or 'COM' or 'DXD' or 'END' or プログラムの終末」は文字列「CSECT」または文字列「DSECT」または文字列「COM」または文字列「END」に合致する、またはプログラムの終端である場合に真となる。さらに、アセンブラ「$2 'DS' 'PL'[1-99]」の[1-99]は、1から99のいずれかの数字であり、「$2 'DS' 'PL'[1-99]」は、例えば、「PKT00 DS PL8」が合致する。そして、他言語「'char' $2'['[1-99]'];'」は、例えば、「char PKT00[8];」を生成することを示す。 また、図6の「ID=2」の箇所特定条件「'STM' 数字','数字','$1」は、例えば、「STM 13,12,REGSAVEA」が合致することを示す。つまり、「$1」は任意の文字列に合致する。
In FIG. 6, “$ 1” of the start condition “$ 1_'DSECT '” of “ID = 1” matches all character strings. That is, for example, the assembler program “PKTDSECT DSECT” matches the start condition “$ 1_'DSECT '”. The end condition of “ID = 1” “CSECT” or “DCECT” or “COM” or “DXD” or “END” or the end of the program is the character string “CSECT” or the character string “DSECT” or the character string. True if it matches "COM" or the string "END" or is at the end of the program. Furthermore, [1-99] of the assembler “$ 2 'DS' 'PL' [1-99]” is any number from 1 to 99, and “$ 2 'DS' 'PL' [1-99” ] "Matches, for example," PKT00 DS PL8 ". The other language “'char' $ 2 ′ ['[1-99]']; '” indicates that “char PKT00 [8];” is generated, for example. Further, the location identification condition “'STM” number', 'number', '$ 1' of “ID = 2” in FIG. 6 indicates that, for example, “
そして、図6の「ID=2」の変換情報は、「'STM' $レジスタ番号1',' $レジスタ番号2','$1」に合致する命令について、変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号1で特定されるレジスタから$レジスタ番号2で特定されるレジスタのうち、当該合致する命令より前に値が定義されていない(使用されていない)レジスタが存在する場合、当該使用されていないレジスタの退避を行う他言語の命令は生成されないことを示す。当該レジスタは使用されていないからである。なお、上記を言い換えれば、「ID=2」の変換情報は、「'STM' $レジスタ番号1',' $レジスタ番号2','$1」に合致する命令について、変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号1で特定されるレジスタから$レジスタ番号2で特定されるレジスタのうち、当該命令より前に値が定義されている(使用されている)レジスタのみに対して、退避を行う他言語の命令を生成することを示す。
Then, the conversion information of “ID = 2” in FIG. 6 indicates that the variable $ 1 is used to save the register for an instruction that matches “'STM” $ register
また、図6の「ID=3」の変換情報は、「'LM' $レジスタ番号3',' $レジスタ番号4','$1」内の変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号3で特定されるレジスタから$レジスタ番号4で特定されるレジスタのうち、当該命令より後に値が参照されていない(使用されていない)レジスタが存在する場合、当該使用されていないレジスタの復帰を行う他言語の命令は生成されないことを示す。当該レジスタは使用されていないからである。なお、上記を言い換えれば、「ID=3」の変換情報は、「'LM' $レジスタ番号3',' $レジスタ番号4','$1」内の変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号3で特定されるレジスタから$レジスタ番号4で特定されるレジスタのうち、当該命令より後に値が参照されている(使用されている)レジスタのみに対して、復帰を行う他言語の命令を生成することを示す。
Also, the conversion information of “ID = 3” in FIG. 6 indicates that the variable $ 1 in “'LM” $ register
以上に基づいて、ドキュメント生成装置1は、処理を開始した、とする。すると、アセンブラプログラム取得部121は、原ソース格納部111に格納されている原ソースから、図5に示すアセンブラプログラムを取得する。
Based on the above, it is assumed that the
次に、変換部122は、取得されたアセンブラプログラムに対して、静的解析処理を行う。そして、変換部122は、アセンブラプログラムを基本ブロックに分割する。そして、可読性向上処理手段1221は、未処理の命令(箇所)のアセンブラプログラムを削除する。
Next, the
次に、変換部122は、基本ブロック毎に、C言語に変換する。つまり、可読性向上処理手段1221は、図6の「ID=1」の箇所特定条件を図5のアセンブラプログラムに適用し、当該箇所特定条件に合致するダミーセクションの領域を検知する。そして、「ID=1」の変換情報の各「アセンブラ」に合致する命令や定義を、対応する「他言語」の情報を用いて、C言語に変換する。そして、可読性向上処理手段1221は、アセンブラのダミーセクションの定義を、C言語の構造体の定義に変換する。つまり、可読性向上処理手段1221は、図5の501の箇所のアセンブラプログラムを、図6の「ID=1」のレコードの情報を用いて、図7の701のC言語のプログラムを生成する。
Next, the
次に、変換部122は、図6の「ID=2」の箇所特定条件を図5のアセンブラプログラムに適用し、退避コードの領域を検知する。そして、「ID=2」の変換情報に合致するように、退避コードの箇所を削除する。なお、ここで、変数「REGSAVEA」は、退避コードが出現する関数内では使用されていないとする。つまり、可読性向上処理手段1221は、図5の502の箇所のアセンブラプログラムを、図6の「ID=2」のレコードの情報を用いて、図7の702のC言語のプログラム「BB1: ;」を生成する。なお、「BB1:」はラベルである。また、変換部122は、「すべての基本ブロックの先頭にラベルを生成する」という予め決められたルールに従って、「BB1:」を生成する。なお、予め決められたルールは、例えば、変換部122が保持している。
Next, the
次に、変換部122は、図6の「ID=3」の箇所特定条件を図5のアセンブラプログラムに適用し、復帰コードの領域を検知する。そして、「ID=3」の変換情報に合致するように、復帰コードの箇所を削除する。なお、ここで、変数「REGSAVEA」は、復帰コードが出現する関数内では使用されていないとする。つまり、可読性向上処理手段1221は、図5の503の箇所のアセンブラプログラムを、図6の「ID=3」のレコードの情報を用いて、図7の703のC言語のプログラム「BB2: ;」を生成する。なお、「BB2:」はラベルである。また、変換部122は、予め決められたルールに従って、「BB2:」を生成する。なお、予め決められたルールは、例えば、変換部122が保持している。
Next, the
また、次に、ソースパターン情報が、退避コードを示す情報を含む場合の別の例を説明する。 Next, another example in which the source pattern information includes information indicating a save code will be described.
今、原ソース格納部111の原ソースが有するアセンブラプログラムの一命令は、「STM 5,8,SAVE」であったとする。この一命令は、レジスタ5からレジスタ8の内容を退避する命令である。
Assume that one instruction of the assembler program included in the original source in the original
そして、可読性向上処理手段1221は、この一命令が図5の「ID=2」の箇所特定情報「'STM' $レジスタ番号1',' $レジスタ番号2','$1」に合致する、と判断する。そして、可読性向上処理手段1221は、この一命令を、例えば、レジスタ5(r5)レジスタ6(r6)、レジスタ7(r7)、レジスタ8(r8)の内容を退避する中間表現に変換する。この中間表現は、例えば、以下である。
store(r5,SAVE);
tmp1=SAVE+4;
store(r6,tmp1);
tmp2=SAVE+8;
store(r7,tmp2);
tmp3=SAVE+12;
store(r8,tmp3);
Then, the readability improvement processing means 1221 matches this one instruction with the location identification information “'STM' $ register number 1 ',' $ register number 2 ',' $ 1" of "ID = 2" in FIG. Judge. Then, the readability
store (r5, SAVE);
tmp1 = SAVE + 4;
store (r6, tmp1);
tmp2 = SAVE + 8;
store (r7, tmp2);
tmp3 = SAVE + 12;
store (r8, tmp3);
この中間表現は、変数「SAVE」が示すアドレスを先頭として、4バイトずつずらしなから、r5からr8の各レジスタの値を退避する命令群である。 This intermediate expression is an instruction group that saves the values of the registers r5 to r8 without shifting by 4 bytes starting from the address indicated by the variable “SAVE”.
次に、可読性向上処理手段1221は、レジスタ5からレジスタ8のうち、例えば、レジスタ5のみが、当該命令「STM 5,8,SAVE」の前に使用されている、と判断した、とする。
Next, it is assumed that the readability
次に、可読性向上処理手段1221は、上記の中間表現のうち、レジスタ5(r5)の値のみを退避する目的ソースを生成する。つまり、可読性向上処理手段1221は、上記の中間表現から、レジスタ6からレジスタ8の値の退避に対応する命令群「tmp1=SAVE+4; store(r6,tmp1); tmp2=SAVE+8; store(r7,tmp2); tmp3=SAVE+12; store(r8,tmp3);」を削除する。そして、可読性向上処理手段1221は、中間表現「store(r5,SAVE);」を得る。
Next, the readability
次に、可読性向上処理手段1221は、中間表現「store(r5,SAVE);」を目的ソース「*(unit32_t *)SAVE = r5;」に変換する。そして、可読性向上処理手段1221は、最終的に、C言語のプログラムの命令「*(unit32_t *)SAVE = r5;」を得る。(具体例2)
具体例2も、第一の可読性向上処理の具体例である。具体例2は、ソースパターン情報が、オフセットを持つ戻りであることを示す情報を含む場合である。つまり、具体例2は、上記の(A−2)に該当する。
Next, the readability
Specific example 2 is also a specific example of the first readability improving process. Specific example 2 is a case where the source pattern information includes information indicating that the return has an offset. That is, the specific example 2 corresponds to the above (A-2).
今、原ソース格納部111の原ソースが有するアセンブラプログラムは、図8に示すアセンブラプログラムである、とする。図8の801の命令は、サブルーチンPROC1の呼び出し命令である。801は、戻り番地(次の命令802)をレジスタ(14で識別されるレジスタ)に保存し、805のPROC1にジャンプするという命令である。また、802は、自分の番地(*)に8バイト足したところ(804の命令)にジャンプすることを示す。さらに、806は、サブルーチンからの戻り命令である。806は、レジスタ14+4(オフセット)の番地(命令803の箇所)にジャンプする命令である。
Assume that the assembler program included in the original source in the original
また、格納部11には、図9に示す変換情報管理表が格納されている。変換情報管理表は、「ID」「箇所特定条件」「適用条件」「変換情報」を有するレコードを1以上有する。「ID」は、レコードを識別する情報である。「適用条件」とは、「変換情報」が適用される条件であり、箇所特定条件に追加される条件である。「適用条件」は、箇所特定条件にさらに付加される条件である、と言える。また、「ID=2」の適用条件「$4のサブルーチンの最終部分が「ID=1」の箇所特定条件の場合」とは、変数$4で特定されるサブルーチンの最終部分が「B $1(,$2)」に合致する場合である。また、「ID=2」の変換情報のうち、$ラベルを含む文字列は、任意のラベルが該当し得る。$ラベルに対して、可読性向上処理手段1221は、$ラベルを含む異なる文字列に対して、ユニークなラベルを生成する。なお、2つの$ラベルXは同じラベルに置き換えられる。
The storage unit 11 stores a conversion information management table shown in FIG. The conversion information management table has one or more records having “ID”, “location specifying condition”, “application condition”, and “conversion information”. “ID” is information for identifying a record. “Applied condition” is a condition to which “conversion information” is applied, and is a condition added to the location specifying condition. It can be said that the “applicable condition” is a condition further added to the location specifying condition. Also, the application condition “ID = 2” “when the final part of the subroutine of $ 4 is the location specifying condition of“ ID = 1 ”” means that the final part of the subroutine specified by the variable $ 4 is “B $ 1”. (, $ 2) ". In addition, in the conversion information of “ID = 2”, a character string including a $ label can correspond to an arbitrary label. For the $ label, the readability
そして、可読性向上処理手段1221は、図8のアセンブラプログラムの中の命令801から命令804が、図9の「ID=2」の箇所特定条件に合致する、と判断する。
Then, the readability
また、可読性向上処理手段1221は、図8のアセンブラプログラムの中の命令805以降のサブルーチンが、図9の「ID=2」の適用条件に合致する、と判断する。
Further, the readability
そして、可読性向上処理手段1221は、図8のアセンブラプログラムの中の命令801から命令806に、図9の「ID=2」の変換情報を適用し、図10の命令1001から命令1006を得る。
Then, the readability
また、可読性向上処理手段1221は、図8のアセンブラプログラムの中の命令806が、図9の「ID=1」の箇所特定条件に合致する、と判断する。
Further, the readability
そして、可読性向上処理手段1221は、図8のアセンブラプログラムの中の命令806に、図9の「ID=1」の変換情報を適用し、図10の命令1007、命令1008を得る。
Then, the readability
(具体例3)
具体例3も、第一の可読性向上処理の具体例である。具体例3は、ソースパターン情報が、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり含む場合である。つまり、具体例3は、上記の(A−3)に該当する。
(Specific example 3)
Specific example 3 is also a specific example of the first readability improving process. Specific example 3 is a case in which the source pattern information is pattern information for specifying the location of two or more instructions of the assembler that can be converted into a program of another language of one instruction. That is, the specific example 3 corresponds to the above (A-3).
今、箇所特定条件格納部112は、図11に示す箇所特定条件管理表を保持している。図11の箇所特定条件管理表は「ID」「ソースパターン情報」「他言語パターン情報」を有するレコードを1以上格納している。「ID」はレコードを識別する情報である。「ソースパターン情報」はアセンブラの2以上の命令の箇所を特定するためのパターンの情報である。「他言語パターン情報」は、変換する他言語(ここではC言語)のパターンを示す情報である。 Now, the location specifying condition storage unit 112 holds the location specifying condition management table shown in FIG. The location specifying condition management table in FIG. 11 stores one or more records having “ID”, “source pattern information”, and “other language pattern information”. “ID” is information for identifying a record. “Source pattern information” is pattern information for specifying the location of two or more instructions of the assembler. “Other language pattern information” is information indicating a pattern of another language to be converted (here, C language).
図11の「ID=1」のソースパターン情報の「$1」は任意の文字列であり、「$変数」は任意の変数またはレジスタを示す情報である。また、「ID=1」の他言語パターン情報のlength($1)は、文字列$1の長さを示す。 “$ 1” in the source pattern information of “ID = 1” in FIG. 11 is an arbitrary character string, and “$ variable” is information indicating an arbitrary variable or register. The length ($ 1) of the other language pattern information of “ID = 1” indicates the length of the character string $ 1.
また、図11の「ID=2」のソースパターン情報の「$2」は任意の文字であり、「$変数」は任意の変数またはレジスタを示す情報である。 Further, “$ 2” in the source pattern information of “ID = 2” in FIG. 11 is an arbitrary character, and “$ variable” is information indicating an arbitrary variable or register.
また、図11の「ID=3」「ID=4」のソースパターン情報の各「$変数」は、変数の後の数字が異なれば、異なる変数である、とする。 Further, each “$ variable” of the source pattern information of “ID = 3” and “ID = 4” in FIG. 11 is a different variable if the number after the variable is different.
また、原ソース格納部111には、図12に示すアセンブラプログラムが格納されている。とする。
The original
かかる場合、可読性向上処理手段1221は、図12の1201の箇所が 図11の「ID=1」のソースパターン情報に合致すると判断し、「ID=1」の他言語パターン情報に従って、1201を図13の1301のC言語に変換する。
In such a case, the readability
また、可読性向上処理手段1221は、図12の1202の箇所が 図11の「ID=2」のソースパターン情報に合致すると判断し、「ID=2」の他言語パターン情報に従って、1202を図13の1302のC言語に変換する。
Further, the readability
また、可読性向上処理手段1221は、図12の1203の箇所が 図11の「ID=3」のソースパターン情報に合致すると判断し、「ID=3」の他言語パターン情報に従って、1203を図13の1303のC言語に変換する。
Further, the readability
また、可読性向上処理手段1221は、図12の1204の箇所が 図10の「ID=4」のソースパターン情報に合致すると判断し、「ID=4」の他言語パターン情報に従って、1204を図13の1304のC言語に変換する。
Further, the readability
以上の処理の結果、可読性向上処理手段1221は、図12のアセンブラプログラムから、図13のC言語のプログラムを得る。
As a result of the above processing, the readability
なお、可読性向上処理手段1221は、アセンブラプログラムを中間表現に変換し、中間表現からC言語のプログラムを構成しても良い。例えば、可読性向上処理手段1221は、図12の1201のアセンブラ(図14の1401)を、図14の1402の中間表現1に変換する。そして、1402をtree構造にした図が、1403である。そして、可読性向上処理手段1221は、1403のtree構造を、中間表現2の1404のtree構造に変換する。なお、格納部11には、tree構造間の変換のための情報が格納されている、とする。また、1404のtree構造は、1405の中間表現2に対応する。そして、次に、可読性向上処理手段1221は、1405の中間表現2を1406のC言語のプログラムに変換する。なお、tree構造間の変換を行わずに、中間表現1402をC言語に変換した場合、1407のC言語のプログラムとなる。
The readability
同様に、可読性向上処理手段1221は、図12の1202のアセンブラ(1501)を、図15の1502の中間表現1に変換する。そして、1502をtree構造にした図が、1503である。そして、可読性向上処理手段1221は、1503のtree構造を、中間表現2の1504のtree構造に変換する。なお、1504のtree構造は、1505の中間表現2に対応する。そして、次に、可読性向上処理手段1221は、1505の中間表現2を1506のC言語のプログラムに変換する。なお、1502をC言語に変換した場合、1505となる。
Similarly, the readability
(具体例4)
具体例4も、第一の可読性向上処理の具体例である。具体例4は、ソースパターン情報が、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含む場合である。つまり、具体例4は、上記の(A−5)に該当する。
(Specific example 4)
Specific example 4 is also a specific example of the first readability improving process. Specific example 4 is a case where the source pattern information includes information indicating that two or more loops formed by two or more jump instructions overlap each other. That is, the specific example 4 corresponds to the above (A-5).
また、2以上のジャンプ命令が構成する2以上のループの一部が重なっている箇所が、アセンブラプログラムに存在する場合、変換部122は、(1)「ボトムが起点から最も遠いループを優先する」、(2)「ボトムが同じループが複数ある場合、トップが起点から最も近いループを優先する」の方針により、一のループを優先し、当該一のループをジャンプ命令ではなく、他言語のループのプログラムに変更する。 In addition, when a part where two or more loops formed by two or more jump instructions overlap each other exists in the assembler program, the conversion unit 122 (1) gives priority to the loop whose bottom is farthest from the starting point. ”, (2)“ If there are multiple loops with the same bottom, the top gives priority to the loop closest to the starting point ”gives priority to one loop, and this one loop is not a jump instruction, Change to a loop program.
今、変換部122は、アセンブラプログラムを静的解析し、当該アセンブラプログラムが複数(ここでは、4つ)の基本ブロック間のリンク関係を有する、と判断した、とする。そして、変換部122は、図16(a)に示す、b1、b2、b3、b4の4つの基本ブロック間のリンクを示す情報を得た、とする。なお、基本ブロック間のリンク関係とは、基本ブロック間の処理の流れを示しており、一の基本ブロックから出て行く2以上のリンク(矢印)が存在する場合は分岐があることを示す。また、図16の1601、1602はループを構成するリンクである。そして、図16(a)では、(1)「ボトムが起点から最も遠いループを優先する」の条件に従い、1602のループが優先される。つまり、可読性向上処理手段1221は、1602のループを、C言語の、例えば、「while」文に書き換え、goto文を無くす。なお、基本ブロックb3からb1へのリンク1601を構成するgoto命令は、残ることとなる。
Now, it is assumed that the
さらに具体的には、変換対象のアセンブラプログラムが、図17のプログラムであった、とする。図17において、L0、L1はラベルである。「BE L0」「BE L1」は、ジャンプ命令である。そして、命令1〜命令8は任意の命令である。
More specifically, it is assumed that the assembler program to be converted is the program of FIG. In FIG. 17, L0 and L1 are labels. “BE L0” and “BE L1” are jump instructions.
そして、変換部122は、図17のアセンブラプログラムを静的解析し、当該アセンブラプログラムからb1〜b4の4つの基本ブロックを取得した、とする。
Then, it is assumed that the
そして、変換部122は、2以上のループの一部が重なっている図17の場合に、(1)「ボトムが起点から最も遠いループを優先する」に基づいて、b4のブロックをボトムとするループ(図16の1602のループ)を優先させた場合、変換部122は、図18(a)のプログラムを取得する。そして、b3のブロックをボトムとするループを構成するgoto文1801はそのまま残る。ただし、図18(a)の1801は、ループから飛び出すgoto文であり、可読性の低下度合いは低い。
Then, in the case of FIG. 17 in which a part of two or more loops overlap, the
一方、仮に、変換部122は、2以上のループの一部が重なっている図17の場合に、b3のブロックをボトムとするループ(図16の1601のループ)を優先させた場合、変換部122は、図18(b)のプログラムを取得する。そして、b4のブロックをボトムとするループを構成するgoto文1802はそのまま残る。そして、図18(b)の1802は、ループへ飛び込むgoto文であり、可読性は著しく低下し、望ましくない。
On the other hand, if the
また、変換部122は、上記とは別のアセンブラプログラムを静的解析し、当該アセンブラプログラムが複数(ここでは、4つ)の基本ブロック間のリンク関係を有する、と判断した、とする。そして、変換部122は、図19(a)に示す、t1、t2、t3、t4の4つの基本ブロック間のリンクを示す情報を得た、とする。また、図19の1901、1902はループを構成するリンクである。そして、図19(a)では、(2)「ボトムが同じループが複数ある場合、トップが起点から最も近いループを優先する」の条件に従い、1901のループが優先される。つまり、可読性向上処理手段1221は、1901のループを、C言語の、例えば、「for」文に書き換え、goto文を無くす。なお、基本ブロックt4からt2へのリンク1902を構成するgoto命令は、残ることとなる。
Further, it is assumed that the
さらに具体的には、変換対象のアセンブラプログラムが、図20のプログラムであった、とする。図20において、L0、L1はラベルである。「BE L1」「B L0」は、ジャンプ命令である。そして、命令1〜命令8は任意の命令である。
More specifically, it is assumed that the assembler program to be converted is the program of FIG. In FIG. 20, L0 and L1 are labels. “BE L1” and “B L0” are jump instructions.
そして、変換部122は、図20のアセンブラプログラムを静的解析し、当該アセンブラプログラムからt1〜t4の4つの基本ブロックを取得した、とする。
Then, it is assumed that the
そして、変換部122は、2以上のループの一部が重なっている図20の場合に、(2)「ボトムが同じループが複数ある場合、トップが起点から最も近いループを優先する」に基づいて、t1のブロックをトップとするループ(図19の1901のループ)を優先させた場合、変換部122は、図21(a)のプログラムを取得する。そして、2101内の他のgoto文はそのまま残る。ただし、図21(a)のgoto文の行き先がループ内に存在するので、可読性はあまり低下しない。
Then, in the case of FIG. 20 where two or more loops overlap each other, the
一方、仮に、変換部122は、2以上のループの一部が重なっている図20の場合に、t2のブロックをトップとするループ(図19の1902のループ)を優先させた場合、変換部122は、図21(b)のプログラムを取得する。そして、2102内の他のgoto文はそのまま残る。そして、図21(b)のgoto文の行き先は、プログラムの任意の箇所になり得るので、プログラム全体の中から、goto文の行き先を探す必要があり、可読性は著しく減少する。
On the other hand, if the
なお、変換部122がすべてのgoto文を他言語のループに変換する場合、図22に示すように、トップにt1 とt2 のどちらを選んでも最終的な変換結果は同じになる。ただし、トップにt1 を選んだ方が、計算量が少なくなる。
When the
(具体例5)
今、コメント元情報格納部114は、図23に示すコメント元情報格管理表を格納している、とする。コメント元情報格管理表は、「ID」「コメント元情報」を有する1以上のレコードを格納している。「ID」はレコードを識別する情報である。「コメント元情報」は、文字列または、変数を有する文字列である。また、変数は、変換元のアセンブラプログラムに含まれる文字列が格納され得る変数、または変換後の他言語に含まれる文字列が格納され得る変数である。
(Specific example 5)
Now, it is assumed that the comment source
また、原ソース格納部111は、図5のアセンブラプログラムを格納している、とする。また、箇所特定条件格納部112は、図6に示す箇所特定条件管理表を格納している、とする。
Further, it is assumed that the original
そして、かかる状況において、ドキュメント生成装置1は、処理を開始した、とする。すると、具体例1で説明したように、変換部122は、アセンブラプログラム501を用いて、C言語のプログラム701を取得する。
In such a situation, it is assumed that the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム501を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラム701を取得する。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件に対応するコメント元情報「'DSECT用構造体('$1'DSECT_1)'」をコメント元情報管理表から取得する。なお、かかるコメント元情報は、図23の「ID=図6「ID=1」」のコメント元情報である。
Next, the
次に、コメント取得部123は、取得したコメント元情報が有する変数「$1」に対応する文字列'PKTDSECT'を原ソース部品または目的ソース部品から取得する。
Next, the
次に、コメント取得部123は、取得した文字列'PKTDSECT'を、取得したコメント元情報の中に代入し、コメント'DSECT用構造体(PKTDSECT)'を得る。
Next, the
次に、出力情報構成部124は、原ソース部品、目的ソース部品、およびコメントを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図24の2401である。なお、図24の2401の出力情報は、「アセンブラ」「C言語」「コメント」の情報を有する。
Next, the
次に、具体例1で説明したように、変換部122は、アセンブラプログラム502を削除する。
Next, as described in the first specific example, the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム502を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラムを取得しない。変換時に、アセンブラプログラム502は削除され、C言語は生成されないからである。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件に対応するコメント元情報'退避コードと判定し削除'をコメント元情報管理表から取得する。なお、かかるコメント元情報は、図23の「ID=図6「ID=2」」のコメント元情報である。なお、かかるコメント元情報は、変数を有しないので、コメント元情報はコメント情報である。
Next, the
次に、出力情報構成部124は、原ソース部品、空の目的ソース部品、およびコメントを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図24の2402である。
Next, the
次に、具体例1で説明したように、変換部122は、アセンブラプログラム503を削除する。
Next, as described in the first specific example, the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム503を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラムを取得しない。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件に対応するコメント元情報'復帰コードと判定し削除'をコメント元情報管理表から取得する。なお、かかるコメント元情報は、図23の「ID=図6「ID=3」」のコメント元情報である。なお、かかるコメント元情報は、変数を有しないので、コメント元情報はコメント情報である。
Next, the
次に、出力情報構成部124は、原ソース部品、空の目的ソース部品、およびコメントを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図24の2403である。
Next, the
以上により、図24の出力情報が出力された。なお、出力部13は、通常、図24の出力情報を格納部11に蓄積する。
Thus, the output information of FIG. 24 is output. Note that the
(具体例6)
今、コメント元情報格納部114は、図23に示すコメント元情報格管理表を格納している、とする。また、原ソース格納部111は、図12のアセンブラプログラムを格納している、とする。また、箇所特定条件格納部112は、図11に示す箇所特定条件管理表を格納している、とする。
(Specific example 6)
Now, it is assumed that the comment source
そして、かかる状況において、ドキュメント生成装置1は、処理を開始した、とする。すると、具体例3で説明したように、変換部122は、アセンブラプログラム1201を用いて、C言語のプログラム1301(図13参照)を取得する。
In such a situation, it is assumed that the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム1101を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラム1201を取得する。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件に対応するコメント元情報をコメント元情報管理表から取得する。なお、かかるコメント元情報は、図23の「ID=10「ID=1」」のコメント元情報である。
Next, the
次に、コメント取得部123は、取得したコメント元情報が有する変数「ソースパターン情報.すべての第1文字列」に対応する文字列「CLC」「BE」を原ソース部品から取得する。そして、コメント取得部123は、取得した文字列「CLC」「BE」を、コメント元情報の変数「ソースパターン情報.すべての第1文字列」に代入する。
Next, the
また、コメント取得部123は、取得したコメント元情報が有する変数「他言語パターン情報.1行目の第1文字列」に対応する文字列「if」を目的ソース部品から取得する。そして、コメント取得部123は、取得した文字列「if」を、コメント元情報の変数「他言語パターン情報.1行目の第1文字列」に代入する。
Further, the
そして、コメント取得部123は、コメント「2以上のアセンブラ命令(CLC,BE)を1つのC言語命令(if)に変換」を得る。なお、ここでは、例えば、コメント取得部123は、複数の取得した文字列「CLC」「BE」を「,」で区切る、とする。
Then, the
次に、出力情報構成部124は、原ソース部品、目的ソース部品、およびコメントを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図25の2501である。なお、図25において、出力情報ごとに、ラインで区切られている。一方、図24では、出力情報ごとに、ラインで区切られていなかった。つまり、出力情報をライン等で区切るか否かは問わない。
Next, the
次に、変換部122は、アセンブラプログラム1202を用いて、C言語のプログラム1302を取得する。
Next, the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム1202を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラム1302を取得する。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件または変換情報に対応するコメント元情報をコメント元情報管理表から取得できなかった、とする。つまり、コメント取得部123は、コメントを取得しない。
Next, it is assumed that the
次に、出力情報構成部124は、原ソース部品、目的ソース部品のみを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図25の2502である。
Next, the
次に、変換部122は、アセンブラプログラム1203を用いて、C言語のプログラム1303を取得する。
Next, the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム1203を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラム1303を取得する。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件に対応するコメント元情報をコメント元情報管理表から取得する。なお、かかるコメント元情報は、図23の「図面11「ID=3」」のコメント元情報である。また、取得されたコメント元情報は変数を有さない。つまり、このコメント元情報は、コメント情報である。
Next, the
次に、出力情報構成部124は、原ソース部品、目的ソース部品、およびコメントを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図25の2503である。
Next, the
次に、変換部122は、アセンブラプログラム1204を用いて、C言語のプログラム1304を取得する。
Next, the
次に、出力情報構成部124は、カレントの原ソース部品であるアセンブラプログラム1204を取得する。
Next, the output
次に、出力情報構成部124は、カレントの目的ソース部品であるC言語のプログラム1304を取得する。
Next, the output
次に、コメント取得部123は、目的ソース部品が取得される際に使用された箇所特定条件または変換情報に対応するコメント元情報をコメント元情報管理表から取得できなかった、とする。つまり、コメント取得部123は、コメントを取得しない。
Next, it is assumed that the
次に、出力情報構成部124は、原ソース部品、目的ソース部品のみを有する出力情報を構成する。
Next, the output
次に、出力部13は、構成された出力情報を出力する。かかる出力例は、図25の2504である。
Next, the
なお、本実施の形態の具体例5、6によれば、ドキュメント生成装置1は、アセンブラ、他言語、およびコメントの3種類の情報を対応付けて出力した。しかし、ドキュメント生成装置1は、アセンブラ、他言語、およびコメントの3種類の情報のうち、2種類以上の情報を対応付けて出力すれば良い。また、本実施の形態において、アセンブラ、他言語を出力する場合に、行番号はあってもなくても良い。
According to specific examples 5 and 6 of the present embodiment, the
以上、本実施の形態によれば、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、他言語のプログラムとコメントとを対応付けて出力できる。 As described above, according to the present embodiment, when migration is performed to convert an assembler program into a program in another language, the program in another language and a comment can be output in association with each other.
また、本実施の形態によれば、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、アセンブラプログラムと他言語のプログラムとコメントとを対応付けて出力できる。 Further, according to the present embodiment, when migration is performed to convert an assembler program into another language program, the assembler program, the other language program, and the comment can be output in association with each other.
また、本実施の形態によれば、保守性を考慮した、可読性の高い目的言語のプログラムを生成できる。 Further, according to the present embodiment, it is possible to generate a target language program with high readability in consideration of maintainability.
また、本実施の形態によれば、予め決められたパターンに合致するアセンブラのプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 Further, according to the present embodiment, an assembler program matching a predetermined pattern can be converted into a target language program with high readability in consideration of maintainability.
また、本実施の形態によれば、アセンブラのプログラムの中のダミーセクションのプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 Also, according to the present embodiment, the dummy section program in the assembler program can be converted into a target language program with high readability in consideration of maintainability.
また、本実施の形態によれば、アセンブラのプログラムの中のオフセットを持つ戻り処理のプログラムを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 Furthermore, according to the present embodiment, a return processing program having an offset in the assembler program can be converted into a target language program having high readability in consideration of maintainability.
また、本実施の形態によれば、予め決められたパターンに合致する、アセンブラのプログラムの中の2以上の命令からなるプログラムを、保守性を考慮した、可読性の高い目的言語の一命令のプログラムに変換できる。 In addition, according to the present embodiment, a program consisting of two or more instructions in an assembler program that matches a predetermined pattern, and a one-instruction program of a target language with high readability in consideration of maintainability Can be converted to
また、本実施の形態によれば、アセンブラのプログラムの中の退避コードまたは復帰コードを、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 Further, according to the present embodiment, the save code or the return code in the assembler program can be converted into a target language program with high maintainability in consideration of maintainability.
また、本実施の形態によれば、アセンブラのプログラムの中の2以上のループの一部が重なっている箇所を、保守性を考慮した、可読性の高い目的言語のプログラムに変換できる。 Further, according to the present embodiment, a portion where two or more loops in the assembler program overlap each other can be converted into a target language program with high maintainability in consideration of maintainability.
また、本実施の形態によれば、アセンブラのプログラムの中の予め決められた条件を満たす箇所の範囲を特定し、保守性を考慮して、当該範囲に対応する可読性の高い目的言語のプログラムに変換できる。 In addition, according to the present embodiment, a range of locations that satisfy a predetermined condition in an assembler program is identified, and in consideration of maintainability, a program in a target language with high readability corresponding to the range is provided. Can be converted.
また、本実施の形態によれば、静的解析し、到達できない箇所のアセンブラプログラムを削除することにより、可読性の高い目的言語のプログラムを得ることができる。 Further, according to the present embodiment, it is possible to obtain a target language program with high readability by performing static analysis and deleting an assembler program at a location that cannot be reached.
また、本実施の形態によれば、アセンブラプログラム内の変数の生存区間を特定し、当該変数を当該生存区間におけるローカル変数とすることにより、可読性の高い目的言語のプログラムを得ることができる。 Further, according to the present embodiment, a target language program with high readability can be obtained by specifying a life span of a variable in the assembler program and using the variable as a local variable in the life span.
さらに、本実施の形態によれば、アセンブラ以外の言語のプログラムである他言語プログラムと連結して動作するアセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い目的言語のプログラムを生成できる。 Furthermore, according to the present embodiment, when migrating an assembler program that operates in conjunction with another language program that is a language program other than the assembler, the program in the target language with high readability is considered in consideration of maintainability. Can be generated.
なお、本実施の形態における処理は、ソフトウェアで実現しても良い。そして、このソフトウェアをソフトウェアダウンロード等により配布しても良い。また、このソフトウェアをCD−ROMなどの記録媒体に記録して流布しても良い。なお、このことは、本明細書における他の実施の形態においても該当する。なお、本実施の形態におけるドキュメント生成装置1を実現するソフトウェアは、以下のようなプログラムである。つまり、このプログラムにおいて、コンピュータがアクセス可能な記録媒体は、アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、アセンブラのプログラムを他言語のプログラムに変換するための情報である1以上の変換情報を格納し得る変換情報格納部と、前記1以上の変換情報のいずれかの変換情報に対応付けて、コメントの元になるコメント元情報を格納し得るコメント元情報格納部とを具備し、コンピュータを、前記原ソース格納部に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、前記各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する変換部と、前記変換部が用いた変換情報に対応するコメント元情報を用いてコメントを取得するコメント取得部と、前記変換部が取得した1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する出力部として機能させるためのプログラムである。
Note that the processing in the present embodiment may be realized by software. Then, this software may be distributed by software download or the like. Further, this software may be recorded and distributed on a recording medium such as a CD-ROM. This also applies to other embodiments in this specification. Note that the software that implements the
また、上記プログラムにおいて、前記出力部は、前記1以上の各目的ソース部品と、当該各目的ソース部品に対応するコメントと、当該各目的ソース部品の元になった原ソースを構成する原ソース部品とを対応付けて出力するものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the output unit includes the one or more target source parts, a comment corresponding to the target source part, and a source source part constituting the source source from which the target source part is based. Is a program that causes a computer to function.
また、上記プログラムにおいて、前記記録媒体は、原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である1以上の箇所特定条件を格納し得る箇所特定条件格納部をさらに具備し、前記コメント元情報格納部は、前記変換情報に対応付いているコメント元情報に代えて、または前記変換情報に対応付いているコメント元情報に加えて、前記1以上の箇所特定条件のいずれかの箇所特定条件に対応付いたコメント元情報を格納し得、前記変換部は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する原ソース部品に対して、前記合致する箇所特定条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する可読性向上処理手段を具備し、前記コメント取得部は、前記可読性向上処理手段が用いた箇所特定条件に対応するコメント元情報を用いてコメントを取得し、前記出力部は、前記変換部が取得した1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報または箇所特定条件に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力するものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the recording medium may store one or more location specifying conditions that are conditions for specifying a location for performing processing for improving the readability of the program with respect to the original source. The comment source information storage unit further includes the one or more comment source information instead of the comment source information associated with the conversion information or in addition to the comment source information associated with the conversion information. Comment source information associated with any one of the location specifying conditions can be stored, and the conversion unit specifies each of the one or more locations with respect to the original source stored in the original source storage unit. It is a process corresponding to the matching part specifying condition for the original source part corresponding to the matching part specifying condition by applying the condition, and a process for improving the readability of the program. Readability improvement processing means for acquiring a target source part corresponding to the original source part, and the comment acquisition unit is comment source information corresponding to the location specifying condition used by the readability improvement processing means The output unit corresponds to one or more target source parts acquired by the conversion unit and conversion information or location specifying conditions used when the target source parts are acquired. It is preferable that the program causes a computer to function as an output that is associated with a comment acquired using comment source information.
また、上記プログラムにおいて、前記箇所特定条件は、プログラムのパターンに関する情報であるソースパターン情報であり、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する原ソース部品に対して、前記合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得するものとして、コンピュータを機能させるプログラムであることは好適である。 Further, in the program, the location specifying condition is source pattern information that is information relating to a pattern of the program, and the readability improvement processing unit performs the above-described processing on the original source stored in the original source storage unit. Applying each of the above source pattern information to the source source part corresponding to the matching source pattern information, the processing corresponding to the matching source pattern information, and the readability improving process that is a process for improving the readability of the program It is preferable that the program is a program that causes a computer to function as the target source part corresponding to the original source part.
また、上記プログラムにおいて、前記ソースパターン情報は、ダミーセクションを示す情報を含み、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、ダミーセクションを含む箇所を決定し、当該箇所に対応するプログラムを、構造体を定義するプログラムに変更するものとして、コンピュータを機能させるプログラムであることは好適である。 Further, in the above program, the source pattern information includes information indicating a dummy section, and the readability improvement processing unit performs the one or more source patterns on the original source stored in the original source storage unit. It is preferable that the program is a program that causes a computer to function as a program that applies information, determines a location including a dummy section, and changes a program corresponding to the location to a program that defines a structure.
また、上記プログラムにおいて、前記ソースパターン情報は、オフセットを持つ戻りであることを示す情報を含み、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む箇所を決定し、当該箇所に対応するプログラムを、当該プログラムに含まれるオフセットを条件に用いた分岐を示すプログラムに変更するものとして、コンピュータを機能させるプログラムであることは好適である。 Further, in the above program, the source pattern information includes information indicating that the return has an offset, and the readability improvement processing unit performs the above-described processing on the original source stored in the original source storage unit with respect to the source Applying each of the above source pattern information, determining a location including a return having an offset, and changing the program corresponding to the location to a program indicating a branch using the offset included in the program as a condition, It is preferable that the program functions a computer.
また、上記プログラムにおいて、前記ソースパターン情報は、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、前記2以上の命令の箇所を決定し、当該箇所に対応するプログラムを、一命令の他言語のプログラムに変換するものとして、コンピュータを機能させるプログラムであることは好適である。 Further, in the above program, the source pattern information is pattern information for specifying a location of two or more instructions of an assembler that can be converted into a program of another language of one instruction. The one or more pieces of source pattern information are applied to the original source stored in the original source storage unit, the location of the two or more instructions is determined, and the program corresponding to the location is replaced with one instruction. It is preferable that the program is a program that allows a computer to function as a program to be converted into a language program.
また、上記プログラムにおいて、前記ソースパターン情報は、退避コードまたは復帰コードを示す情報を含み、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの箇所を決定し、当該箇所に対応するプログラムを、前記原ソースから削除するものとして、コンピュータを機能させるプログラムであることは好適である。 Further, in the above program, the source pattern information includes information indicating a save code or a return code, and the readability improvement processing unit performs the one or more of the original source stored in the original source storage unit with respect to the original source. It is preferable that each source pattern information is applied, the location of the save code or the return code is determined, and the program corresponding to the location is deleted from the original source so that the computer functions.
また、上記プログラムにおいて、前記ソースパターン情報は、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含み、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、当該箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更するものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the source pattern information includes information indicating that two or more loops formed by two or more jump instructions overlap each other, and the readability improvement processing means includes the original source storage unit. The one or more source pattern information is applied to the original source stored in the file, the part where two or more loops overlap is determined, and the program corresponding to the part is determined in advance. It is preferable that a program that causes a computer to function as a program that gives priority to one loop that satisfies the conditions and changes to a program that indicates a loop that does not have a jump instruction.
また、上記プログラムにおいて、前記箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件であり、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、前記合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行うものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the location specifying condition is a range condition that is a condition for specifying a range of locations that satisfy a predetermined condition in the original source, and the readability improvement processing means stores the source source storage. A process corresponding to the matching range condition for a portion corresponding to the matching range condition by applying each of the one or more range conditions to the original source stored in the section, and the readability of the program It is preferable that the program is a program that causes a computer to function as a process for improving readability, which is a process for improving the image quality.
また、上記プログラムにおいて、前記範囲条件は、実行され得ないプログラムの範囲を判定するための条件であり、前記可読性向上処理手段は、前記原ソースを静的解析し、前記合致する範囲条件に対応する箇所のプログラムを特定し、当該プログラムを削除するものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the range condition is a condition for determining a range of the program that cannot be executed, and the readability improvement processing unit statically analyzes the original source and corresponds to the matching range condition. It is preferable that the program that causes the computer to function as the program that identifies the program to be deleted and deletes the program.
また、上記プログラムにおいて、前記範囲条件は、変数を特定するための条件であり、前記可読性向上処理手段は、前記原ソースまたは目的ソースから変数を取得し、当該変数の生存区間を取得し、当該変数を、当該生存区間におけるローカル変数として定義する可読性向上処理を行うものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the range condition is a condition for specifying a variable, and the readability improvement processing unit acquires a variable from the original source or the target source, acquires a life span of the variable, It is preferable that the program causes a computer to function as a program for improving readability in which a variable is defined as a local variable in the life span.
また、上記プログラムにおいて、前記原ソースは、アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであり、コンピュータを、前記原ソースから、アセンブラプログラムを取得するアセンブラプログラム取得部としてさらに機能させ、前記変換部は、前記アセンブラプログラム取得部が取得したアセンブラプログラムを目的ソースに変換するものとして、コンピュータを機能させるプログラムであることは好適である。 In the above program, the original source is a program having an assembler program and another language program that is a program in a language other than the assembler, and the computer is used as an assembler program acquisition unit that acquires the assembler program from the original source. Further, it is preferable that the conversion unit is a program that causes a computer to function as a program that converts the assembler program acquired by the assembler program acquisition unit into a target source.
また、図26は、本明細書で述べたプログラムを実行して、上述した種々の実施の形態のドキュメント生成装置1等を実現するコンピュータの外観を示す。上述の実施の形態は、コンピュータハードウェア及びその上で実行されるコンピュータプログラムで実現され得る。図26は、このコンピュータシステム300の概観図であり、図27は、システム300のブロック図である。
FIG. 26 shows the external appearance of a computer that executes the program described in this specification to realize the
図26において、コンピュータシステム300は、CD−ROMドライブ3012を含むコンピュータ301と、キーボード302と、マウス303と、モニタ304とを含む。
In FIG. 26, the
図27において、コンピュータ301は、CD−ROMドライブ3012に加えて、MPU3013と、MPU3013、CD−ROMドライブ3012に接続されたバス3014と、ブートアッププログラム等のプログラムを記憶するためのROM3015と、MPU3013に接続され、アプリケーションプログラムの命令を一時的に記憶するとともに一時記憶空間を提供するためのRAM3016と、アプリケーションプログラム、システムプログラム、及びデータを記憶するためのハードディスク3017とを含む。ここでは、図示しないが、コンピュータ301は、さらに、LANへの接続を提供するネットワークカードを含んでも良い。
27, in addition to the CD-
コンピュータシステム300に、上述した実施の形態のドキュメント生成装置1等の機能を実行させるプログラムは、CD−ROM3101に記憶されて、CD−ROMドライブ3012に挿入され、さらにハードディスク3017に転送されても良い。これに代えて、プログラムは、図示しないネットワークを介してコンピュータ301に送信され、ハードディスク3017に記憶されても良い。プログラムは実行の際にRAM3016にロードされる。プログラムは、CD−ROM3101またはネットワークから直接、ロードされても良い。
A program that causes the
プログラムは、コンピュータ301に、上述した実施の形態のドキュメント生成装置1等の機能を実行させるオペレーティングシステム(OS)、またはサードパーティープログラム等は、必ずしも含まなくても良い。プログラムは、制御された態様で適切な機能(モジュール)を呼び出し、所望の結果が得られるようにする命令の部分のみを含んでいれば良い。コンピュータシステム300がどのように動作するかは周知であり、詳細な説明は省略する。
The program does not necessarily include an operating system (OS), a third party program, or the like that causes the
また、上記プログラムを実行するコンピュータは、単数であってもよく、複数であってもよい。すなわち、集中処理を行ってもよく、あるいは分散処理を行ってもよい。 Further, the computer that executes the program may be singular or plural. That is, centralized processing may be performed, or distributed processing may be performed.
また、上記各実施の形態において、一の装置に存在する2以上の通信手段は、物理的に一の媒体で実現されても良いことは言うまでもない。 Further, in each of the above embodiments, it goes without saying that two or more communication units existing in one apparatus may be physically realized by one medium.
また、上記各実施の形態において、各処理は、単一の装置によって集中処理されることによって実現されてもよく、あるいは、複数の装置によって分散処理されることによって実現されてもよい。 In each of the above embodiments, each process may be realized by centralized processing by a single device, or may be realized by distributed processing by a plurality of devices.
本発明は、以上の実施の形態に限定されることなく、種々の変更が可能であり、それらも本発明の範囲内に包含されるものであることは言うまでもない。 The present invention is not limited to the above-described embodiments, and various modifications are possible, and it goes without saying that these are also included in the scope of the present invention.
以上のように、本発明にかかるドキュメント生成装置は、アセンブラのプログラムを他言語のプログラムに変換するマイグレーションを行う場合に、他言語のプログラムとコメントとを対応付けて出力できるという効果を有し、マイグレーション装置等として有用である。 As described above, the document generation apparatus according to the present invention has an effect that, when performing migration for converting an assembler program into a program in another language, the program in another language and a comment can be output in association with each other. It is useful as a migration device.
1 ドキュメント生成装置
11 格納部
12 処理部
13 出力部
111 原ソース格納部
112 箇所特定条件格納部
113 変換情報格納部
114 コメント元情報格納部
121 アセンブラプログラム取得部
122 変換部
123 コメント取得部
124 出力情報構成部
1221 可読性向上処理手段
DESCRIPTION OF
Claims (15)
アセンブラのプログラムを他言語のプログラムに変換するための情報である1以上の変換情報を格納し得る変換情報格納部と、
前記1以上の変換情報のいずれかの変換情報に対応付けて、コメントの元になるコメント元情報を格納し得るコメント元情報格納部と、
前記原ソース格納部に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、前記各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する変換部と、
前記変換部が用いた変換情報に対応するコメント元情報を用いてコメントを取得するコメント取得部と、
前記変換部が取得した1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する出力部とを具備するドキュメント生成装置。 An assembler program written in an assembler language, an original source storage unit capable of storing an original source that is a program to be migrated, and
A conversion information storage unit that can store one or more conversion information that is information for converting an assembler program into a program in another language;
A comment source information storage unit that can store comment source information that is a source of a comment in association with any one of the one or more pieces of conversion information;
One or more original source parts, which are a part of programs constituting the original source stored in the original source storage unit, are converted into a program in another language using conversion information corresponding to each original source part. A conversion unit that acquires a target source component that is a program in another language for each of one or more conversion targets;
A comment acquisition unit that acquires a comment using comment source information corresponding to the conversion information used by the conversion unit;
One or more target source parts acquired by the conversion unit and a comment acquired using the comment source information corresponding to the conversion information used when the target source parts are acquired are output in association with each other A document generation device.
前記1以上の各目的ソース部品と、当該各目的ソース部品に対応するコメントと、当該各目的ソース部品の元になった原ソースを構成する原ソース部品とを対応付けて出力する請求項1記載のドキュメント生成装置。 The output unit is
2. The one or more target source parts, a comment corresponding to each target source part, and an original source part constituting the original source that is the source of each target source part are output in association with each other. Document generation device.
前記変換部は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する原ソース部品に対して、前記合致する箇所特定条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する可読性向上処理手段を具備し、
前記コメント元情報格納部は、
前記変換情報に対応付いてるコメント元情報に代えて、または前記変換情報に対応付いてるコメント元情報に加えて、前記1以上の箇所特定条件のいずれかの箇所特定条件に対応付いたコメント元情報を格納し得、
前記コメント取得部は、
前記可読性向上処理手段が用いた箇所特定条件に対応するコメント元情報を用いてコメントを取得し、
前記出力部は、
前記変換部が取得した1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報または箇所特定条件に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する請求項1または請求項2記載のドキュメント生成装置。 A location specifying condition storage unit that can store one or more location specifying conditions that are conditions for specifying a location for performing processing for improving the readability of the program with respect to the original source,
The converter is
The one or more part specifying conditions are applied to the original source stored in the original source storage unit, and the matching part specifying condition is applied to the original source part corresponding to the matching part specifying condition. A process for improving readability, which is a corresponding process, and a process for improving the readability of the program, and obtains a target source part corresponding to the original source part;
The comment source information storage unit
Instead of the comment source information associated with the conversion information, or in addition to the comment source information associated with the conversion information, the comment source information associated with any one of the one or more location identification conditions Can store
The comment acquisition unit
Obtaining a comment using comment source information corresponding to the location specifying condition used by the readability improvement processing means;
The output unit is
One or more target source components acquired by the conversion unit, and conversion information used when each target source component is acquired or a comment acquired using comment source information corresponding to the location specifying condition 3. The document generation apparatus according to claim 1, wherein the document generation apparatus outputs the data in association with each other.
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する原ソース部品に対して、前記合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行い、原ソース部品に対応する目的ソース部品を取得する請求項3記載のドキュメント生成装置。 The location specifying condition is source pattern information which is information related to a program pattern,
The readability improvement processing means includes:
The one or more pieces of source pattern information are applied to the original source stored in the original source storage unit, and the matching source pattern information is applied to the source source part corresponding to the matching source pattern information. The document generation apparatus according to claim 3, wherein the target source part corresponding to the original source part is acquired by performing a readability improving process that is a corresponding process and improving the readability of the program.
ダミーセクションを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、ダミーセクションを含む原ソース部品を決定し、当該原ソース部品を用いて、構造体を定義する目的ソース部品を取得する請求項4記載のドキュメント生成装置。 The source pattern information is
Including information indicating the dummy section,
The readability improvement processing means includes:
The one or more pieces of source pattern information are applied to the original source stored in the original source storage unit, an original source part including a dummy section is determined, and a structure is formed using the original source part. The document generation apparatus according to claim 4, wherein a target source part to be defined is acquired.
オフセットを持つ戻りであることを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む原ソース部品を決定し、当該原ソース部品を用いて、当該原ソース部品に含まれるオフセットを条件に用いた分岐を示す目的ソース部品を取得する請求項4記載のドキュメント生成装置。 The source pattern information is
Contains information indicating that the return has an offset,
The readability improvement processing means includes:
Applying each of the one or more source pattern information to an original source stored in the original source storage unit, determining an original source part including a return having an offset, and using the original source part, 5. The document generation apparatus according to claim 4, wherein a target source part indicating a branch using an offset included in the original source part as a condition is acquired.
一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令を有する原ソース部品を特定するためのパターンの情報であり、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、前記2以上の命令を有する原ソース部品を決定し、当該原ソース部品を用いて、一命令の他言語のプログラムである目的ソース部品を取得する請求項4記載のドキュメント生成装置。 The source pattern information is
Pattern information for specifying an original source part having two or more instructions of an assembler that can be converted into a program of another language of one instruction;
The readability improvement processing means includes:
Applying each of the one or more source pattern information to the original source stored in the original source storage unit, determining an original source part having the two or more instructions, using the original source part, The document generation apparatus according to claim 4, wherein a target source component that is a program in another language of one instruction is acquired.
退避コードまたは復帰コードを示す情報を含み、、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの原ソース部品を決定し、当該原ソース部品に対応するプログラムを、前記原ソースから削除する請求項4記載のドキュメント生成装置。 The source pattern information is
Including information indicating the evacuation code or return code,
The readability improvement processing means includes:
A program corresponding to the original source part is determined by applying the one or more pieces of source pattern information to the original source stored in the original source storage unit, determining an original source part of the save code or return code, and The document generation device according to claim 4, wherein the document generation device is deleted from the original source.
2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、当該箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更する請求項4記載のドキュメント生成装置。 The source pattern information is
Including information indicating that a part of two or more loops formed by two or more jump instructions overlap,
The readability improvement processing means includes:
A program that applies the one or more pieces of source pattern information to the original source stored in the original source storage unit, determines a place where a part of two or more loops overlap, and corresponds to the place The document generation apparatus according to claim 4, wherein the first priority is given to a loop satisfying a predetermined condition and the program is changed to a program indicating a loop having no jump instruction.
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、前記合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う請求項3記載のドキュメント生成装置。 The location specifying condition is a range condition that is a condition for specifying a range of locations that satisfy a predetermined condition in the original source,
The readability improvement processing means includes:
A process corresponding to the matching range condition for a portion corresponding to the matching range condition by applying each of the one or more range conditions to the source source stored in the source source storage unit The document generation apparatus according to claim 3, wherein a readability improving process that is a process for improving the readability of the program is performed.
実行され得ないプログラムの範囲を判定するための条件であり、
前記可読性向上処理手段は、
前記原ソースを静的解析し、前記合致する範囲条件に対応する箇所のプログラムを特定し、当該プログラムを削除する請求項10記載のドキュメント生成装置。 The range condition is
It is a condition for determining the range of programs that cannot be executed,
The readability improvement processing means includes:
The document generation apparatus according to claim 10, wherein the original source is statically analyzed, a program corresponding to the matching range condition is specified, and the program is deleted.
変数を特定するための条件であり、
前記可読性向上処理手段は、
前記原ソースまたは目的ソースから変数を取得し、当該変数の生存区間を取得し、当該変数を、当該生存区間におけるローカル変数として定義する可読性向上処理を行う請求項10記載のドキュメント生成装置。 The range condition is
It is a condition to specify the variable,
The readability improvement processing means includes:
The document generation apparatus according to claim 10, wherein a variable is acquired from the original source or the target source, a life span of the variable is obtained, and readability improvement processing is performed to define the variable as a local variable in the life span.
アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであり、
前記原ソースから、アセンブラプログラムを取得するアセンブラプログラム取得部をさらに具備し、
前記変換部は、
前記アセンブラプログラム取得部が取得したアセンブラプログラムを目的ソースに変換する請求項1から請求項12いずれか一項に記載のドキュメント生成装置。 The original source is
A program having an assembler program and another language program which is a program in a language other than the assembler,
An assembler program acquisition unit for acquiring an assembler program from the original source;
The converter is
The document generation apparatus according to any one of claims 1 to 12, wherein the assembler program acquired by the assembler program acquisition unit is converted into a target source.
アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、
アセンブラのプログラムを他言語のプログラムに変換するための情報である1以上の変換情報を格納し得る変換情報格納部と、
前記1以上の変換情報のいずれかの変換情報に対応付けて、コメントの元になるコメント元情報を格納し得るコメント元情報格納部とを具備し、
変換部、コメント取得部、出力部により実現されるドキュメントの生産方法であって、
前記変換部が、前記原ソース格納部に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、前記各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する変換ステップと、
前記コメント取得部が、前記変換ステップで用いられた変換情報に対応するコメント元情報を用いてコメントを取得するコメント取得ステップと、
前記出力部が、前記変換ステップで取得された1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する出力ステップとを具備するキュメントの生産方法。 The recording medium is
An assembler program written in an assembler language, an original source storage unit capable of storing an original source that is a program to be migrated, and
A conversion information storage unit that can store one or more conversion information that is information for converting an assembler program into a program in another language;
A comment source information storage unit that can store comment source information that is a source of a comment in association with any one of the one or more pieces of conversion information;
A document production method realized by a conversion unit, a comment acquisition unit, and an output unit,
The conversion unit uses one or more original source parts, which are a part of programs constituting the original source stored in the original source storage part, by using conversion information corresponding to each original source part. A conversion step of converting into a language program and obtaining a target source component that is a program in another language for each of one or more conversion objects;
The comment acquisition unit acquires a comment using comment source information corresponding to the conversion information used in the conversion step;
Comments acquired by the output unit using one or more target source components acquired in the conversion step and comment source information corresponding to the conversion information used when the target source components are acquired A document production method comprising: an output step for outputting the information in association with each other.
アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、
アセンブラのプログラムを他言語のプログラムに変換するための情報である1以上の変換情報を格納し得る変換情報格納部と、
前記1以上の変換情報のいずれかの変換情報に対応付けて、コメントの元になるコメント元情報を格納し得るコメント元情報格納部とを具備し、
コンピュータを、
前記原ソース格納部に格納されている原ソースを構成する一部のプログラムである1以上の各原ソース部品を、前記各原ソース部品に対応する変換情報を用いて、他言語のプログラムに変換し、1以上の各変換対象ごとに、他言語のプログラムである目的ソース部品を取得する変換部と、
前記変換部が用いた変換情報に対応するコメント元情報を用いてコメントを取得するコメント取得部と、
前記変換部が取得した1以上の各目的ソース部品と、当該各目的ソース部品が取得される際に利用された変換情報に対応するコメント元情報を用いて取得されたコメントとを対応付けて出力する出力部として機能させるためのプログラム。 Computer-accessible recording media
An assembler program written in an assembler language, an original source storage unit capable of storing an original source that is a program to be migrated, and
A conversion information storage unit that can store one or more conversion information that is information for converting an assembler program into a program in another language;
A comment source information storage unit that can store comment source information that is a source of a comment in association with any one of the one or more pieces of conversion information;
Computer
One or more original source parts, which are a part of programs constituting the original source stored in the original source storage unit, are converted into a program in another language using conversion information corresponding to each original source part. A conversion unit that acquires a target source component that is a program in another language for each of one or more conversion targets;
A comment acquisition unit that acquires a comment using comment source information corresponding to the conversion information used by the conversion unit;
One or more target source parts acquired by the conversion unit and a comment acquired using the comment source information corresponding to the conversion information used when the target source parts are acquired are output in association with each other A program for functioning as an output unit.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2015188841A JP2017062746A (en) | 2015-09-25 | 2015-09-25 | Document generation device, generation method for document, and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2015188841A JP2017062746A (en) | 2015-09-25 | 2015-09-25 | Document generation device, generation method for document, and program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2017062746A true JP2017062746A (en) | 2017-03-30 |
Family
ID=58428873
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2015188841A Pending JP2017062746A (en) | 2015-09-25 | 2015-09-25 | Document generation device, generation method for document, and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2017062746A (en) |
-
2015
- 2015-09-25 JP JP2015188841A patent/JP2017062746A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8086618B2 (en) | Configuration rule translation mapper | |
US9405518B2 (en) | Leveraging legacy applications for use with modern applications | |
US20200285454A1 (en) | System and method for source code translation using stream expressions | |
US20130152061A1 (en) | Full fidelity parse tree for programming language processing | |
US20150278231A1 (en) | System and method for customizing archive of a device driver generator tool for a user | |
US20090055421A1 (en) | Migration and transformation of data structures | |
US11029924B2 (en) | Program optimization by converting code portions to directly reference internal data representations | |
US20210389977A1 (en) | System migration support apparatus, system migration support method and program | |
US20110209135A1 (en) | Program Change Management Apparatus, Computer Readable Record Medium Storing Program Change Management Program, And Program Change Management Method | |
Klinbua et al. | Translating tosca into docker-compose yaml file using antlr | |
JP2009169864A (en) | Compile method and compile program | |
JP2017062746A (en) | Document generation device, generation method for document, and program | |
JP2017054277A (en) | Migration device, creation method of program and program | |
Kirchhof et al. | Variant and product line co-evolution | |
US10127034B1 (en) | System, method, and computer program for delayed evaluation of condition based trees | |
JP2014228990A (en) | Control program creation apparatus and control program creation method | |
JP2017126176A (en) | Migration apparatus, production method of target source, and program | |
JP5932707B2 (en) | Computer, program, and data generation method | |
JP4405571B1 (en) | program | |
US9792197B2 (en) | Apparatus and program | |
CN109086043A (en) | A kind of method and apparatus for quickly generating WEB project based on configuration | |
JP2015035174A (en) | Control program division device, control program division method, and recording medium therefor | |
US11789727B2 (en) | Conversion apparatus, conversion method and program | |
WO2015030016A1 (en) | System for processing unstructured data, method for processing unstructured data, and recording medium | |
JP2006126886A (en) | Learning device for knowledge for shortening sentence, sentence shortening device, machine translating device and computer program for shortening sentence |