JP2017054277A - Migration device, creation method of program and program - Google Patents

Migration device, creation method of program and program Download PDF

Info

Publication number
JP2017054277A
JP2017054277A JP2015177171A JP2015177171A JP2017054277A JP 2017054277 A JP2017054277 A JP 2017054277A JP 2015177171 A JP2015177171 A JP 2015177171A JP 2015177171 A JP2015177171 A JP 2015177171A JP 2017054277 A JP2017054277 A JP 2017054277A
Authority
JP
Japan
Prior art keywords
program
source
readability
original source
location
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
Application number
JP2015177171A
Other languages
Japanese (ja)
Inventor
菜岐佐 石浦
Nagisa Ishiura
菜岐佐 石浦
隆史 小河原
Takashi Ogawara
隆史 小河原
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SYSTEMS CO Ltd
Kwansei Gakuin Educational Foundation
Original Assignee
SYSTEMS CO Ltd
Kwansei Gakuin Educational Foundation
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SYSTEMS CO Ltd, Kwansei Gakuin Educational Foundation filed Critical SYSTEMS CO Ltd
Priority to JP2015177171A priority Critical patent/JP2017054277A/en
Publication of JP2017054277A publication Critical patent/JP2017054277A/en
Pending legal-status Critical Current

Links

Images

Abstract

PROBLEM TO BE SOLVED: To provide a migration device which creates a program of another language from a program of an assembler, and a method.SOLUTION: A migration device comprises: a conversion part which accommodates one or more point-specification conditions being a condition for specifying a point at which processing for improving the readability of a program is performed to an original source being an assembler program of a migration object, and converts the original source to a target source being a program of another language, and a program of a target language; and an output part for outputting the target source. The conversion part employs one or more point-specification conditions to the original source, and performs processing corresponding to the coincident point-specification condition to a point corresponding to the coincident point-specification condition.EFFECT: A program of another language which is high in readability can be created.SELECTED DRAWING: Figure 1

Description

本発明は、アセンブラのプログラムから他言語のプログラムを生成するマイグレーション装置等に関するものである。   The present invention relates to a migration apparatus for generating a program in another language from an assembler 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).

特開2007−334号公報(第1頁、第1図等)JP 2007-334 (first page, FIG. 1 etc.)

しかしながら、従来技術においては、アセンブラのプログラムから他言語のプログラムの全部または一部を生成することはできなかった。   However, in the prior art, it was not possible to generate all or part of a program in another language from an assembler program.

そして、アセンブラとC言語等の他言語とは、仕様、構造が大きく異なり、仮にアセンブラのプログラムをC言語等の他言語のプログラムに変換したとしても、そのプログラムを保守する保守者にとって、読みにくいプログラムとなり、そのプログラムの保守は困難になる。つまり、従来技術においては、アセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い他言語のプログラムを生成できなかった。   The assembler and other languages such as C language are greatly different in specifications and structure, and even if the assembler program is converted into another language program such as C language, it is difficult for a maintainer who maintains the program to read it. The program becomes difficult to maintain. In other words, in the prior art, when an assembler program is migrated, it is not possible to generate a program in another language with high readability in consideration of maintainability.

本第一の発明のマイグレーション装置は、アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である1以上の箇所特定条件を格納し得る箇所特定条件格納部と、原ソース格納部に格納されている原ソースを、他言語のプログラムであり、目的言語のプログラムである目的ソースに変換する変換部と、変換部が変換して、取得した目的ソースを出力する出力部とを具備するマイグレーション装置であって、変換部は、原ソース格納部に格納されている原ソースに対して、1以上の各箇所特定条件を適用し、合致する箇所特定条件に対応する箇所に対して、合致する箇所特定条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う可読性向上処理手段を具備するマイグレーション装置である。   The migration apparatus according to the first aspect of the present invention is an assembler program written in an assembler language, and improves the readability of the program with respect to the original source storage section that can store the original source that is the migration target program. A location specifying condition storage unit that can store one or more location specifying conditions, which are conditions for specifying a location for performing processing to be performed, and an original source stored in the original source storage unit using a program in another language A migration apparatus comprising: a conversion unit that converts a target language that is a target language program; and an output unit that converts the conversion unit and outputs the acquired target source. The conversion unit stores the original source Apply one or more location identification conditions to the source source stored in the section, and A process corresponding to the matching point specifying condition is a migration apparatus comprising readability enhancement processing means for performing readability enhancement is a process for improving the readability of the program.

かかる構成により、アセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い他言語のプログラムを生成できる。   With this configuration, when an assembler program is migrated, it is possible to generate a program in another language with high readability in consideration of maintainability.

また、本第二の発明のマイグレーション装置は、第一の発明に対して、箇所特定条件は、プログラムのパターンに関する情報であるソースパターン情報であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する箇所に対して、合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行うマイグレーション装置である。   Further, in the migration apparatus of the second invention, in contrast to the first 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 the source source being processed, and processing corresponding to the matching source pattern information is applied to the location corresponding to the matching source pattern information, improving the readability of the program This is a migration apparatus that performs readability improvement processing that is processing to be performed.

かかる構成により、予め決められたパターンに合致するアセンブラのプログラムを、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   With this configuration, an assembler program that matches a predetermined pattern can be converted into a program in another language with high readability in consideration of maintainability.

また、本第三の発明のマイグレーション装置は、第二の発明に対して、ソースパターン情報は、ダミーセクションを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、ダミーセクションを含む箇所を決定し、箇所に対応するプログラムを、構造体を定義するプログラムに変更するマイグレーション装置である。   Further, in the migration apparatus of the third invention, in contrast to the second invention, the source pattern information includes information indicating a dummy section, and the readability improvement processing means is an original source stored in the original source storage unit. On the other hand, the migration apparatus applies one or more pieces of source pattern information, determines a location including a dummy section, and changes a program corresponding to the location to a program defining a structure.

かかる構成により、アセンブラのプログラムの中のダミーセクションのプログラムを、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   With this configuration, the dummy section program in the assembler program can be converted into a program in another language with high readability in consideration of maintainability.

また、本第四の発明のマイグレーション装置は、第二の発明に対して、ソースパターン情報は、オフセットを持つ戻りであることを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む箇所を決定し、箇所に対応するプログラムを、プログラムに含まれるオフセットを条件に用いた分岐を示すプログラムに変更するマイグレーション装置である。   Further, in the migration apparatus of the fourth invention, in contrast to the second invention, the source pattern information includes information indicating that the return has an offset, and the readability improvement processing means is stored in the original source storage unit. Apply one or more pieces of source pattern information to the source source, determine the location that contains the return with the offset, and branch the program corresponding to the location using the offset included in the program as a condition It is a migration device that changes to the program shown.

かかる構成により、アセンブラのプログラムの中のオフセットを持つ戻り処理のプログラムを、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   With this configuration, it is possible to convert a return processing program having an offset in the assembler program into a program of another language with high readability in consideration of maintainability.

また、本第五の発明のマイグレーション装置は、第二の発明に対して、ソースパターン情報は、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上の命令の箇所を決定し、箇所に対応するプログラムを、一命令の他言語のプログラムに変換するマイグレーション装置である。   The migration apparatus of the fifth aspect of the invention provides a pattern for specifying two or more instruction parts of an assembler that can be converted into a program of another language of one instruction in the source pattern information in the second invention. The readability improvement processing means applies one or more source pattern information to the original source stored in the original source storage unit, determines the location of two or more instructions, and corresponds to the location. This is a migration apparatus that converts a program to be converted into a program of another language of one instruction.

かかる構成により、予め決められたパターンに合致する、アセンブラのプログラムの中の2以上の命令からなるプログラムを、保守性を考慮した、可読性の高い他言語の一命令のプログラムに変換できる。   With this 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 another language with high readability in consideration of maintainability.

また、本第六の発明のマイグレーション装置は、第二の発明に対して、ソースパターン情報は、退避コードまたは復帰コードを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの箇所を決定し、箇所に対応するプログラムを、原ソースまたは目的ソースから削除するマイグレーション装置である。   Further, in the migration apparatus of the sixth invention, in contrast to the second invention, the source pattern information includes information indicating a save code or a return code, and the readability improvement processing means is stored in the original source storage unit. The migration apparatus applies one or more pieces of source pattern information to the original source, determines the location of the save code or the return code, and deletes the program corresponding to the location from the original source or the target source.

かかる構成により、アセンブラのプログラムの中の退避コードまたは復帰コードを、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   With this configuration, the save code or return code in the assembler program can be converted into a program in another language with high readability in consideration of maintainability.

また、本第七の発明のマイグレーション装置は、第二の発明に対して、ソースパターン情報は、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含み、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更するマイグレーション装置である。   Further, in the migration device of the seventh aspect of the invention, in contrast to the second aspect of the invention, the source pattern information includes information indicating that a part of two or more loops constituted 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, Is a migration device that prioritizes one loop that satisfies a predetermined condition and changes it to a program that indicates a loop that does not have a jump instruction.

かかる構成により、アセンブラのプログラムの中の2以上のループの一部が重なっている箇所を、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   With such a configuration, a portion where two or more loops overlap in the assembler program can be converted into a program of another language having high readability in consideration of maintainability.

また、本第八の発明のマイグレーション装置は、第一の発明に対して、箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件であり、可読性向上処理手段は、原ソース格納部に格納されている原ソースに対して、1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行うマイグレーション装置である。   In the migration apparatus of the eighth aspect of the invention, in contrast to the first aspect, 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. Yes, the readability improvement processing means applies one or more range conditions to the original source stored in the original source storage unit, and sets the matching range condition to the location corresponding to the matching range condition. It is a migration apparatus that performs a readability improvement process that is a corresponding process and a process that improves the 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 another language program having high readability corresponding to the range in consideration of maintainability.

また、本第九の発明のマイグレーション装置は、第八の発明に対して、範囲条件は、実行され得ないプログラムの範囲を判定するための条件であり、可読性向上処理手段は、原ソースを静的解析し、合致する範囲条件に対応する箇所のプログラムを特定し、プログラムを削除するマイグレーション装置である。   In the migration apparatus of the ninth 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 It is a migration device that performs a statistical analysis, identifies a program corresponding to a matching range condition, and deletes the program.

かかる構成により、静的解析し、到達できない箇所のアセンブラプログラムを削除することにより、可読性の高い他言語のプログラムを得ることができる。   With this configuration, it is possible to obtain a program in another language with high readability by performing static analysis and deleting an assembler program at a location that cannot be reached.

また、本第十の発明のマイグレーション装置は、第八の発明に対して、範囲条件は、変数を特定するための条件であり、可読性向上処理手段は、原ソースまたは目的ソースから変数を取得し、変数の生存区間を取得し、変数を、生存区間におけるローカル変数として定義する可読性向上処理を行うマイグレーション装置である。   In the migration apparatus of the tenth invention, the range condition is a condition for specifying a variable, and the readability improvement processing means acquires the variable from the original source or the target source. The migration apparatus performs a readability improvement process of acquiring a life span of a variable and defining the variable as a local variable in the life span.

かかる構成により、アセンブラプログラム内の変数の生存区間を特定し、当該変数を当該生存区間におけるローカル変数とすることにより、可読性の高い他言語のプログラムを得ることができる。   With this configuration, it is possible to obtain a program in another 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つの発明に対して、原ソースは、アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであり、原ソースから、アセンブラプログラムを取得するアセンブラプログラム取得部をさらに具備し、変換部は、アセンブラプログラム取得部が取得したアセンブラプログラムを目的ソースに変換するマイグレーション装置である。   In addition, the migration apparatus of the eleventh aspect of the invention is a program having an assembler program and another language program that is a program in a language other than the assembler, as opposed to any one of the first to tenth inventions. And an assembler program acquisition unit that acquires an assembler program from an original source, and the conversion unit is a migration 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, a program in another language with high maintainability can be generated in consideration of maintainability.

本発明によるマイグレーション装置によれば、アセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い他言語のプログラムを生成できる。   According to the migration apparatus of the present invention, when an assembler program is migrated, it is possible to generate a program in another language with high readability in consideration of maintainability.

実施の形態1におけるマイグレーション装置1のブロック図Block diagram of migration apparatus 1 in the first embodiment 同マイグレーション装置1の動作について説明するフローチャートA flowchart for explaining the operation of the migration apparatus 1 同静的解析処理について説明するフローチャートFlow chart explaining the static analysis process 同原ソースを示す図Diagram showing the same source 同箇所特定条件管理表を示す図Figure showing the same location specific condition management table 同生成されたC言語のプログラムを示す図The figure which shows the program of the same C language which is generated 同アセンブラプログラムを示す図Diagram showing the assembler program 同生成されたC言語のプログラムを示す図The figure which shows the program of the same C language which is generated 同箇所特定条件管理表を示す図Figure showing the same location specific condition management table 同アセンブラプログラムを示す図Diagram showing the assembler program 同生成されたC言語のプログラムを示す図The figure which shows the program of the same C language which is generated 同中間表現を含む変換例を示す図Diagram showing conversion example including the intermediate representation 同中間表現を含む変換例を示す図Diagram showing conversion example including the intermediate representation 同ループの処理を示す図Diagram showing the processing of the same loop 同変換対象のアセンブラプログラムの例を示す図Diagram showing an example of the assembler program to be converted 同C言語のプログラムの例を示す図The figure which shows the example of the program of the same C language 同ループの処理を示す図Diagram showing the processing of the same loop 同変換対象のアセンブラプログラムの例を示す図Diagram showing an example of the assembler program to be converted 同C言語のプログラムの例を示す図The figure which shows the example of the program of the same C language 同C言語のプログラムの例を示す図The figure which shows the example of the program of the same C language 同C言語のプログラムの例を示す図The figure which shows the example of the program of the same C language 同コンピュータシステムの概観図Overview of the computer system 同コンピュータシステムのブロック図Block diagram of the computer system

以下、マイグレーション装置等の実施形態について図面を参照して説明する。なお、実施の形態において同じ符号を付した構成要素は同様の動作を行うので、再度の説明を省略する場合がある。   Hereinafter, embodiments of the migration apparatus 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)

本実施の形態において、アセンブラのプログラム集合の中から、予め決められたソースパターンに合致するソース列に対して、可読性向上のための処理を施し、蓄積するマイグレーション装置について説明する。予め決められたソースパターンとは、例えば、ダミーセクションの箇所を特定するパターン、オフセットを持つ戻りの箇所を特定するパターン、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターン、退避コードまたは復帰コードの箇所を特定するためのパターン、2以上のループの一部が重なっている箇所を特定するためのパターン等である。なお、他言語のプログラムとは、アセンブラ以外の言語のプログラムのことである。   In the present embodiment, a description will be given of a migration apparatus that performs processing for improving readability on a source string that matches a predetermined source pattern from an assembler program set, and accumulates it. 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. The other language program is a program in a language other than the assembler.

また、本実施の形態において、アセンブラのプログラム集合の中の、予め決められた条件を満たす箇所の範囲を特定し、当該箇所に対応する処理を行うマイグレーション装置について説明する。なお、当該箇所に対応する処理とは、例えば、削除処理、ローカル変数の定義を生成する処理等である。   Further, in the present embodiment, a description will be given of a migration apparatus that identifies a range of locations that satisfy a predetermined condition in an assembler program set and performs processing corresponding to the locations. 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 migration apparatus 1 according to this embodiment.

マイグレーション装置1は、格納部11、処理部12、および出力部13を備える。   The migration apparatus 1 includes a storage unit 11, a processing unit 12, and an output unit 13.

格納部11は、原ソース格納部111、箇所特定条件格納部112、および変換情報格納部113を備える。   The storage unit 11 includes an original source storage unit 111, a location specifying condition storage unit 112, and a conversion information storage unit 113.

処理部12は、アセンブラプログラム取得部121、および変換部122を備える。変換部122は、可読性向上処理手段1221を備える。   The processing unit 12 includes an assembler program acquisition unit 121 and a conversion unit 122. The conversion unit 122 includes a readability improvement processing unit 1221.

格納部11は、各種の情報を格納し得る。各種の情報とは、後述する原ソース、箇所特定条件、変換情報などである。   The storage unit 11 can store various types of information. The various types of information include an original source, a location specifying condition, conversion information, and the like which will be described later.

原ソース格納部111は、原ソースを格納し得る。原ソースは、通常、アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである。また、原ソースとは、アセンブラプログラムとアセンブラ以外の言語のプログラムである他言語プログラムとを有するプログラムであっても良い。なお、他言語プログラムは、ここでは、例えば、高級言語のプログラムである。高級言語は、COBOL、C言語、C++、JAVA(登録商標)等、問わない。また、他言語プログラムは、例えば、アセンブラプログラムを呼び出して利用しているプログラムである。また、アセンブラプログラムにおけるアセンブラの種類は問わない。アセンブラは、ここでは、アセンブリ言語と言っても良い。アセンブラは、例えば、IBM System/370で使用されているアセンブラである。   The original source storage unit 111 can store an original source. The original source is usually an assembler program written in an assembler language, and is a program to be migrated. The original source may be a program having an assembler program and another language program that is a program in a language other than the assembler. Here, the other language program is, for example, a high-level language program. The high-level language is not limited, such as COBOL, C language, C ++, JAVA (registered trademark), or the like. The other language program is, for example, a program that is used by calling an assembler program. The type of assembler in the assembler program is not limited. The assembler may be referred to herein as assembly language. The assembler is an assembler used in, for example, IBM System / 370.

また、原ソース格納部111が格納している原ソースは、アセンブラ言語で記述されたアセンブラプログラムを変換した中間言語のプログラム(中間表現と言っても良い)でも良い。中間言語のプログラムは、例えば、アセンブラプログラムの一の命令が行う複数の処理を2以上の処理に分解し、得られた2以上の命令群である。なお、中間言語のプログラムの一の命令は、アセンブラプログラムの一の命令に対応づいているものがあっても良い。また、アセンブラプログラムを中間言語のプログラムに変換する処理は、後述する変換部122が行っても良いし、他の装置で行われても良い。   Further, the original source stored in the original source storage unit 111 may be an intermediate language program (which may be referred to as an intermediate expression) obtained by converting an assembler program described in an assembler language. The intermediate language program is, for example, a group of two or more instructions obtained by decomposing a plurality of processes performed by one instruction of the assembler program into two or more processes. Note that one instruction of the intermediate language program may correspond to one instruction of the assembler program. The process of converting the assembler program into an intermediate language program may be performed by the conversion unit 122 described later, or may be performed by another device.

箇所特定条件格納部112は、1以上の箇所特定条件を格納し得る。箇所特定条件とは、原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である。箇所特定条件は、例えば、アセンブラプログラムのパターンに関する情報であるソースパターン情報である。箇所特定条件は、例えば、原ソース内において、予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件である。箇所特定条件格納部112は、箇所特定条件に対応付けて、アセンブラプログラムを他言語に変換する情報を保持していても良い。アセンブラプログラムを他言語に変換する情報は、例えば、高級言語のプログラムのパターンに関する高級言語パターン情報である。また、アセンブラプログラムを他言語に変換する情報は、例えば、アセンブラプログラムを他言語に変換するプログラムにより構成されている。なお、ソースパターン情報とは、例えば、ダミーセクションを示す情報、オフセットを持つ戻りであることを示す情報、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令を有する原ソース部品を特定するためのパターンの情報、退避コードまたは復帰コードを示す情報、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報等であっても良い。   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, high-level language pattern information related to a high-level language program pattern. 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.

変換情報格納部113は、1以上の変換情報を格納し得る。変換情報とは、アセンブラのプログラムを高級言語等の他言語のプログラムに変換するための情報である。変換情報は、通常、可読性を向上するとは限らないプログラム変換のための情報である。変換情報は、例えば、アセンブラプログラムのパターンを示すアセンブラパターン情報と、他言語プログラムのパターンを示す他言語パターン情報とを有する。変換情報は、例えば、アセンブラプログラムのパターンを示すアセンブラパターン情報と、アセンブラプログラムを他言語に変換するプログラムである。   The conversion information storage unit 113 can store one or more pieces of conversion information. The conversion information is information for converting an assembler program into a program in another language such as a high-level language. The conversion information is information for program conversion that does not always improve readability. The conversion information includes, for example, assembler pattern information indicating an assembler program pattern and other language pattern information indicating a pattern of another language program. The conversion information is, for example, assembler pattern information indicating an assembler program pattern and a program for converting the assembler program into another language.

変換情報は、アセンブラのプログラムを他のアセンブラのプログラムに変換するための情報でも良い。かかる場合、他のアセンブラのプログラムは、通常、他言語のプログラムへの変換を容易にするプログラムである。   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.

処理部12は、各種の処理を行う。各種の処理とは、例えば、アセンブラプログラム取得部121、変換部122、可読性向上処理手段1221が行う処理である。   The processing unit 12 performs various processes. The various processes are processes performed by the assembler program acquisition unit 121, the conversion unit 122, and the readability improvement processing unit 1221, for example.

アセンブラプログラム取得部121は、原ソースから、アセンブラプログラムを取得する。原ソースがアセンブラプログラムと他言語プログラムとを有するプログラムである場合、アセンブラプログラム取得部121は、原ソースからアセンブラプログラムを抽出する。なお、例えば、アセンブラプログラム取得部121は、アセンブラプログラムの開始を示す文字列と終了を示す文字列とを用いて、開始を示す文字列と終了を示す文字列との間のプログラム(文字列)を、原ソースから取得する。また、例えば、アセンブラプログラム取得部121は、アセンブラプログラムであることを示す拡張子(例えば、「asm」)を有するファイルを原ソース格納部111から取得する。また、例えば、アセンブラプログラム取得部121は、アセンブラプログラムの命令または命令パターンに合致するプログラム(文字列)を、原ソースから取得する。なお、かかる場合、アセンブラプログラムのすべての命令または命令パターンは、格納部11に格納されている、とする。   The assembler program acquisition unit 121 acquires an assembler program from the original source. When the original source is a program having an assembler program and another language program, the assembler program acquisition unit 121 extracts the assembler program from the original source. For example, the assembler program acquisition unit 121 uses a character string indicating the start and a character string indicating the end of the assembler program, and a program (character string) between the character string indicating the start and the character string indicating the end. From the original source. For example, the assembler program acquisition unit 121 acquires a file having an extension (for example, “asm”) indicating that it is an assembler program from the original source storage unit 111. Further, for example, the assembler program acquisition unit 121 acquires a program (character string) that matches an instruction or instruction pattern of the assembler program from the original source. In such a case, it is assumed that all instructions or instruction patterns of the assembler program are stored in the storage unit 11.

変換部122は、原ソース格納部111に格納されている原ソース(ここでは、アセンブラプログラム)を、他言語のプログラムであり、目的言語のプログラムである目的ソースに変換する。なお、目的言語のプログラムは、C言語などの他言語のプログラムである。   The conversion unit 122 converts the original source (here, the assembler program) stored in the original source storage unit 111 into a target source that is a program in another language and is a program in the target language. The target language program is a program in another language such as C language.

変換部122は、アセンブラプログラム取得部121が取得したアセンブラプログラムを目的ソースに変換しても良い。かかる場合、変換部122は、アセンブラプログラム以外のプログラム(例えば、Java、COBOL等のプログラム)を、目的ソースに変換しても良い。アセンブラプログラム以外のプログラムとは、アセンブラプログラム取得部121が原ソース格納部111から取得しなかったプログラムであり、原ソース格納部111に格納されているプログラムである。なお、アセンブラプログラム以外のプログラムを、目的ソースに変換するプログラムは公知技術であるので、詳細な説明は省略する。   The conversion unit 122 may convert the assembler program acquired by the assembler program acquisition unit 121 into a target source. In such a case, the conversion unit 122 may convert a program other than the assembler program (for example, a program such as Java or COBOL) into a target source. A program other than the assembler program is a program that is not acquired from the original source storage unit 111 by the assembler program acquisition unit 121 and is a program stored in the original source storage unit 111. Since a program for converting a program other than the assembler program into a target source is a known technique, detailed description thereof is omitted.

変換部122は、1以上の変換情報を用いて、アセンブラプログラムを目的ソースに変換しても良い。また、変換部122は、1以上の箇所特定条件を用いて、アセンブラプログラムを目的ソースに変換する。つまり、変換部122は、例えば、箇所特定条件に合致する変換対象のプログラムの箇所に対して、当該箇所特定条件に対応する変換情報を用いて、当該変換対象のプログラムの箇所を変換して、変換後のプログラムを取得する。   The conversion unit 122 may convert the assembler program into a target source using one or more pieces of conversion information. The conversion unit 122 converts the assembler program into a target source using one or more location specifying conditions. That is, for example, the conversion unit 122 converts the location of the program to be converted using the conversion information corresponding to the location specifying condition for the location of the program to be converted that matches the location specifying condition, Get the converted program.

変換対象のプログラムは、通常、アセンブラプログラムであるが、中間言語のプログラム、目的ソースのプログラムでも良い。また、変換後のプログラムは、通常、目的ソースのプログラムであるが、アセンブラプログラム、中間言語のプログラムでも良い。   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.

可読性向上処理手段1221は、プログラムの可読性を向上させる処理である可読性向上処理を行う。可読性向上処理は、例えば、アセンブラのダミーセクションの定義をC言語等の他言語の構造体の定義に書き換える処理である。また、可読性向上処理は、例えば、アセンブラのオフセットを持つ戻り処理を、適切な他言語のプログラムに書き換える処理である。また、可読性向上処理は、例えば、2以上の命令群のアセンブラプログラムを、1命令の他言語のプログラムに書き換える処理である。なお、1命令の他言語のプログラムとは、例えば、C言語において、「;」が一つで足りる命令である。また、可読性向上処理は、例えば、アセンブラプログラム中の退避コードまたは復帰コードを削除する処理である。また、可読性向上処理は、例えば、アセンブラプログラム中の複数のループ処理を、適切な他言語のプログラムに書き換える処理である。また、可読性向上処理は、例えば、到達できないアセンブラプログラムの箇所を削除する処理である。また、可読性向上処理は、例えば、アセンブラプログラムの変数の生存区間を検査し、他言語のローカル変数とする処理である。   The readability improvement processing unit 1221 performs readability improvement processing that is processing for improving the readability of the program. The readability improving process is, for example, a process of rewriting the definition of the assembler dummy section to the definition of a structure in another language such as C language. The readability improving process is, for example, a process of rewriting a return process having an assembler offset into an appropriate other language program. Further, the readability improving process is a process of rewriting an assembler program of two or more instruction groups into a program of another language of one instruction, for example. The one-language other language program is, for example, an instruction in which one “;” is sufficient in the C language. Further, the readability improving process is a process of deleting a save code or a return code in the assembler program, for example. Further, the readability improving process is a process of rewriting a plurality of loop processes in the assembler program into appropriate other language programs, for example. Further, the readability improving process is a process of deleting a part of the assembler program that cannot be reached, for example. The readability improving process is, for example, a process of checking a life span of a variable in an assembler program and setting it as a local variable in another language.

また、可読性向上処理は、例えば、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 source storage unit 111, and corresponds to the matching location specifying conditions. This is processing corresponding to the location specifying condition that matches the location.

第一の可読性向上処理は、箇所特定条件がプログラムのパターンに関する情報であるソースパターン情報である場合である。かかる場合、可読性向上処理手段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 improvement processing unit 1221 applies one or more pieces of source pattern information to the assembler program included in the original source stored in the original source storage unit 111, and corresponds to the matching source pattern information. On the other hand, the readability improving process is a process corresponding to the matching source pattern information and improving the readability of the program. The processing corresponding to the matching source pattern information is usually realized by a program.

第二の可読性向上処理は、箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件である場合である。かかる場合、可読性向上処理手段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 improvement processing unit 1221 applies one or more range conditions to the assembler program included in the original source stored in the original source storage unit 111, and applies to the portion corresponding to the matching range condition. Thus, the readability improving process, which is a process corresponding to the matching range condition and improving the readability of the program, is performed. The processing corresponding to the matching range condition is usually realized by a program.

また、範囲条件は、例えば、着目した一の変数が使用されている生存区間を特定する条件である。生存区間は、着目した一の変数が出現するプログラムの範囲である、と言える。また、範囲条件は、例えば、アセンブラプログラムを静的解析した結果、実行され得ないプログラムの範囲を特定する条件である。   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.

(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 improvement processing unit 1221 applies one or more pieces of source pattern information to the original source stored in the original source storage unit 111, determines a location including a dummy section, and corresponds to the location. Acquire a program in another language that defines a structure.

(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 improvement processing unit 1221 applies one or more pieces of source pattern information to the original source stored in the original source storage unit 111, determines a location including a return having an offset, and determines the location. The corresponding program is acquired as a program in another language indicating a branch using the offset included in the program as a condition.

(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 improvement processing unit 1221 applies one or more pieces of source pattern information to the original source stored in the original source storage unit 111, determines the location of two or more instructions, and corresponds to the location. To obtain a program of another language with one instruction.

(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 improvement processing unit 1221 applies one or more pieces of source pattern information to the original source stored in the original source storage unit 111, determines the location of the save code or return code, Delete the corresponding program from the source or destination source. The readability improvement processing unit 1221 determines whether the register or variable targeted by the save code or the return code is not used in the function in which the save code or the return code appears. It is preferable to delete the save code or the return code.

(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 improvement processing unit 1221 applies one or more pieces of source pattern information to the original source stored in the original source storage unit 111, and finds a place where a part of two or more loops overlap. The program corresponding to the location is changed to a program in another language indicating a loop that does not have a jump instruction, giving priority to one loop that satisfies a predetermined condition.

ここで、予め決められた条件とは、例えば、以下の(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 improvement processing unit 1221 gives priority to the loop whose bottom is far from the starting point, and rewrites the portion of the priority loop with a program of a loop in another language. Eliminate jump instructions from loop locations. This is to improve the readability of the program by avoiding jumping into the loop as much as possible when there is a complicated structure. In this case, jumping out of the loop is permitted.

また、ここで、起点とは、複数のループを含むプログラム群の最初の命令(行と言っても良い)または基本ブロックである。また、ボトムとは、複数のループを含むプログラム群の最後の命令(行と言っても良い)または基本ブロックである。さらに、他言語のループのプログラムとは、例えば、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 improvement processing unit 1221 gives priority to the loop whose top is closest to the starting point, and rewrites the place of the priority loop to a loop program in another language. The jump instruction is eliminated from the location of the priority loop.

本条件に対応するマイグレーション処理を行うことにより、可読性が向上するだけではなく、外側のループから処理することになり、全体の計算量が少なくなる、という効果がある。   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 improvement processing unit 1221 statically analyzes the original source, identifies a program corresponding to the matching range condition, and deletes the program.

(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 improvement processing unit 1221 acquires a variable from the original source or the target source, acquires a life span of the variable, and performs readability improvement processing that defines the variable as a local variable in the life span.

なお、可読性向上処理手段1221は、例えば、原ソースまたは目的ソースに出現する一の変数に対して、出現する1以上の基本ブロックを特定する。そして、可読性向上処理手段1221は、特定した1以上の基本ブロックを一の関数として定義する。そして、可読性向上処理手段1221は、当該一の関数の命令の前に、当該一の変数を定義する。 例えば、変換する他言語がC言語の場合、可読性向上処理手段1221は、例えば、「function_name(){ 1以上の変数定義; 1以上の基本ブロックを変換した他言語の命令列;}」を取得する。なお、「function_name」は関数名であり、可読性向上処理手段1221が、予め決められた規則に基づいて生成した関数名であることは好適である。また、「1以上の変数定義」は、例えば、「char 変数名;」「int 変数名;」などであり、可読性向上処理手段1221は、C言語の文法に従って、変数の型、変数名を取得し、記載する。なお、変数名は、予め決められたルールに基づいて、決定されることは好適である。   Note that the readability improvement processing unit 1221 identifies one or more basic blocks that appear for one variable that appears in the original source or the target source, for example. Then, the readability improvement processing unit 1221 defines the identified one or more basic blocks as one function. Then, the readability improvement processing unit 1221 defines the one variable before the instruction of the one function. For example, when the other language to be converted is C language, the readability improvement processing unit 1221 obtains, for example, “function_name () {one or more variable definitions; one or more basic block converted instruction sequence;}”, for example. To do. Note that “function_name” is a function name, and it is preferable that the function name generated by the readability improvement processing unit 1221 based on a predetermined rule. The “one or more variable definitions” are, for example, “char variable name;” “int variable name;”, etc., and the readability improvement processing unit 1221 acquires the variable type and variable name according to the C language grammar. And describe. The variable name is preferably determined based on a predetermined rule.

出力部13は、変換部122が変換して、取得した目的ソースを出力する。また、出力部13は、変換できないアセンブラプログラムが存在する場合、変換できないアセンブラプログラムが存在する旨のエラーを出力しても良い。ここで、出力とは、通常、記録媒体への蓄積であるが、ディスプレイへの表示、プロジェクターを用いた投影、プリンタでの印字、音出力、外部の装置への送信、他の処理装置や他のプログラムなどへの処理結果の引渡しなどを含む概念である。   The output unit 13 outputs the target source obtained by conversion by the conversion unit 122. Further, when there is an assembler program that cannot be converted, the output unit 13 may output an error indicating that there is an assembler program that cannot be converted. Here, the output is usually accumulation in a recording medium, but display on a display, projection using a projector, printing with a printer, sound output, transmission to an external device, other processing devices and others This is a concept that includes delivery of processing results to other programs.

格納部11、原ソース格納部111、箇所特定条件格納部112、および変換情報格納部113は、不揮発性の記録媒体が好適であるが、揮発性の記録媒体でも実現可能である。   The storage unit 11, the original source storage unit 111, the location specifying condition storage unit 112, and the conversion information storage unit 113 are preferably non-volatile recording media, but can also be realized by volatile recording media.

格納部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、および出力部13は、通常、MPUやメモリ等から実現され得る。処理部12等の処理手順は、通常、ソフトウェアで実現され、当該ソフトウェアはROM等の記録媒体に記録されている。但し、ハードウェア(専用回路)で実現しても良い。   The processing unit 12, the assembler program acquisition unit 121, the conversion unit 122, the readability improvement processing unit 1221 and the output unit 13 can be usually realized by an MPU, a memory, or the like. The processing procedure of the processing unit 12 or the like is usually realized by software, and the software is recorded on a recording medium such as a ROM. However, it may be realized by hardware (dedicated circuit).

出力部13は、例えば、出力デバイスのドライバーソフトまたは、出力デバイスのドライバーソフトと出力デバイス等で実現され得る、と考えても良い。   The output unit 13 may be considered to be realized by, for example, driver software for an output device or driver software for an output device and an output device.

次に、マイグレーション装置1の動作について、図2のフローチャートを用いて説明する。   Next, the operation of the migration apparatus 1 will be described using the flowchart of FIG.

(ステップS201)アセンブラプログラム取得部121は、原ソース格納部111に格納されている原ソースから、アセンブラプログラムを取得する。   (Step S201) The assembler program acquisition unit 121 acquires an assembler program from the original source stored in the original source storage unit 111.

(ステップS202)変換部122は、ステップS201で取得されたアセンブラプログラムに対して、静的解析処理を行う。静的解析処理について、図3のフローチャートを用いて説明する。   (Step S202) The conversion unit 122 performs a static analysis process on the assembler program acquired in Step S201. The static analysis process will be described with reference to the flowchart of FIG.

(ステップS203)変換部122は、カウンタiに1を代入する。   (Step S203) The conversion unit 122 substitutes 1 for the counter i.

(ステップS204)変換部122は、i番目の基本ブロックが存在するか否かを判断する。i番目の基本ブロックが存在する場合はステップS205に行き、i番目の基本ブロックが存在しない場合は処理を終了する。   (Step S204) The conversion unit 122 determines whether or not the i-th basic block exists. If the i-th basic block exists, the process goes to step S205. If the i-th basic block does not exist, the process ends.

(ステップS205)可読性向上処理手段1221は、カウンタjに1を代入する。   (Step S205) The readability improvement processing unit 1221 substitutes 1 for the counter j.

(ステップS206)可読性向上処理手段1221は、j番目の箇所特定条件が箇所特定条件格納部112に存在するか否かを判断する。j番目の箇所特定条件が存在する場合はステップS207に行き、存在しない場合はステップS213に行く。   (Step S <b> 206) The readability improvement processing unit 1221 determines whether or not the j-th location specifying condition exists in the location specifying condition storage unit 112. If the j-th location specifying condition exists, the process goes to step S207; otherwise, the process goes to step S213.

(ステップS207)可読性向上処理手段1221は、箇所特定条件格納部112からj番目の箇所特定条件を取得する。   (Step S207) The readability improvement processing unit 1221 acquires the j-th location specifying condition from the location specifying condition storage unit 112.

(ステップS208)可読性向上処理手段1221は、i番目の基本ブロックがj番目の箇所特定条件に合致するか否かを判断する。合致する場合はステップS209に行き、合致しない場合はステップS212に行く。なお、i番目の基本ブロックの一部のアセンブラプログラムがj番目の箇所特定条件に合致する場合も、i番目の基本ブロックがj番目の箇所特定条件に合致するとする。また、i番目の基本ブロックのアセンブラプログラムが変換された中間表現(中間コードと言っても良い)の全部または一部が、j番目の箇所特定条件に合致する場合も、i番目の基本ブロックがj番目の箇所特定条件に合致するとする。   (Step S208) The readability improvement processing unit 1221 determines whether or not the i-th basic block matches the j-th location specifying condition. If they match, go to step S209; otherwise, go to step S212. It should be noted that even if some assembler programs of the i-th basic block match the j-th location specifying condition, the i-th basic block also matches the j-th location specifying condition. In addition, even if all or part of the intermediate representation (which may be called intermediate code) converted from the assembler program of the i-th basic block matches the j-th location specifying condition, the i-th basic block is Assume that the jth location specifying condition is met.

(ステップS209)可読性向上処理手段1221は、j番目の箇所特定条件に合致する箇所を対象として、j番目の箇所特定条件に対応する処理を行い、当該合致する箇所に対応する他言語のプログラムを取得する。   (Step S209) The readability improvement processing unit 1221 performs a process corresponding to the jth location specifying condition for a location that matches the jth location specifying condition, and executes a program in another language corresponding to the matched location. get.

(ステップS210)可読性向上処理手段1221は、i番目の基本ブロックのすべてが、他言語のプログラムに変換されたか否かを判断する。i番目の基本ブロックのすべてが変換された場合はステップS211に行き、i番目の基本ブロックにおいて未変換の箇所を含む場合はステップS212に行く。   (Step S210) The readability improvement processing unit 1221 determines whether or not all the i-th basic block has been converted into a program in another language. If all the i-th basic blocks have been converted, the process goes to step S211. If the i-th basic block includes an unconverted part, the process goes to step S212.

(ステップS211)変換部122は、カウンタiを1、インクリメントする。ステップS204に戻る。   (Step S211) The converter 122 increments the counter i by one. The process returns to step S204.

(ステップS212)可読性向上処理手段1221は、カウンタjを1、インクリメントする。ステップS206に戻る。   (Step S212) The readability improvement processing unit 1221 increments the counter j by 1. The process returns to step S206.

(ステップS213)変換部122は、カウンタkに1を代入する。   (Step S213) The conversion unit 122 substitutes 1 for the counter k.

(ステップS214)変換部122は、変換情報格納部113にk番目の変換情報が存在するか否を判断する。k番目の変換情報が存在する場合はステップS215に行き、k番目の変換情報が存在しない場合はステップS219に行く。   (Step S214) The conversion unit 122 determines whether or not the k-th conversion information exists in the conversion information storage unit 113. If the k-th conversion information exists, the process goes to step S215. If the k-th conversion information does not exist, the process goes to step S219.

(ステップS215)変換部122は、i番目の基本ブロックがk番目の変換情報に対応するか否かを判断する。i番目の基本ブロックがk番目の変換情報に対応する場合はステップS216に行き、対応しない場合はステップS218に行く。なお、i番目の基本ブロックがk番目の変換情報に対応することは、i番目の基本ブロックの中に、変換情報が有するアセンブラパターン情報に合致するアセンブラプログラムを少なくとも一部に含むことである。   (Step S215) The conversion unit 122 determines whether or not the i-th basic block corresponds to the k-th conversion information. If the i-th basic block corresponds to the k-th conversion information, the process goes to step S216; otherwise, the process goes to step S218. The fact that the i-th basic block corresponds to the k-th conversion information means that the ith basic block includes at least a part of an assembler program that matches the assembler pattern information included in the conversion information.

(ステップS216)変換部122は、k番目の変換情報を用いて、k番目の変換情報に対応するアセンブラプログラムを、他言語のプログラムに変換する。変換部122は、例えば、k番目の変換情報に対応するアセンブラプログラムを、k番目の変換情報が有する他言語パターン情報を用いて、他言語のプログラムを取得する。   (Step S216) Using the kth conversion information, the conversion unit 122 converts the assembler program corresponding to the kth conversion information into a program in another language. The conversion unit 122 acquires, for example, an assembler program corresponding to the kth conversion information, using another language pattern information included in the kth conversion information, and a program in another language.

(ステップS217)変換部122は、i番目の基本ブロックに含まれるすべてのアセンブラプログラムの変換が完了したか否かを判断する。i番目の基本ブロックの変換が完了した場合はステップS211に行き、変換が完了していない場合はステップS218に行く。   (Step S217) The conversion unit 122 determines whether conversion of all assembler programs included in the i-th basic block has been completed. When the conversion of the i-th basic block is completed, the process goes to step S211, and when the conversion is not completed, the process goes to step S218.

(ステップS218)変換部122は、カウンタkを1、インクリメントする。ステップS214に戻る。   (Step S218) The converter 122 increments the counter k by 1. The process returns to step S214.

(ステップS219)出力部13は、i番目の基本ブロックの中に変換できないプログラムが存在する旨のエラーを出力する。   (Step S219) The output unit 13 outputs an error indicating that there is a program that cannot be converted in the i-th basic block.

なお、図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 conversion unit 122 substitutes 1 for the counter i and 1 for the counter j.

(ステップS302)変換部122は、ステップS201で取得されたアセンブラプログラムの中の命令であり、次に実行され得るi番目の命令が存在するか否かを判断する。i番目の命令が存在する場合はステップS303に行き、i番目の命令が存在しない場合はステップS311に行く。   (Step S302) The conversion unit 122 determines whether there is an i-th instruction that can be executed next, which is an instruction in the assembler program acquired in Step S201. If the i-th instruction exists, the process goes to step S303, and if the i-th instruction does not exist, the process goes to step S311.

(ステップS303)変換部122は、i番目の命令は分岐命令であるか否かを判断する。分岐命令である場合はステップS307に行き、分岐命令でない場合はステップS304に行く。   (Step S303) The conversion unit 122 determines whether or not the i-th instruction is a branch instruction. If it is a branch instruction, the process goes to step S307, and if it is not a branch instruction, the process goes to step S304.

(ステップS304)変換部122は、i番目の命令に対して、他の命令から分岐されてくる可能性があるか否か(ジャンプの先として指定されている命令が存在するか否か)を判断する。他の命令から分岐されてくる可能性がある場合はステップS307に行き、他の命令から分岐されてくる可能性がない場合はステップS305に行く。   (Step S304) The conversion unit 122 determines whether there is a possibility of branching from another instruction with respect to the i-th instruction (whether there is an instruction specified as a jump destination). to decide. If there is a possibility of branching from another instruction, the process goes to step S307, and if there is no possibility of branching from another instruction, the process goes to step S305.

(ステップS305)変換部122は、i番目をバッファに配置する。なお、バッファは、基本ブロックを作り出すためのワーク用の記憶領域である。   (Step S305) The conversion unit 122 places the i-th in the buffer. The buffer is a work storage area for creating a basic block.

(ステップS306)変換部122は、カウンタiを1、インクリメントする。ステップS302に戻る。   (Step S306) The conversion unit 122 increments the counter i by 1. The process returns to step S302.

(ステップS307)変換部122は、バッファ内の1以上の命令群をj番目の基本ブロックとする処理を行う。かかる処理は、例えば、基本ブロックを構成する1以上の命令に対して、「j」を付加したり、「j」をリンク付けたり、基本ブロックを構成する1以上の命令を他と区別してバッファに格納したりすること等である。なお、バッファ内に命令を有しない場合は、何らの処理も行わず、ステップS305に戻る。   (Step S307) The conversion unit 122 performs a process of setting one or more instruction groups in the buffer as the jth basic block. Such processing includes, for example, adding “j” to one or more instructions constituting a basic block, linking “j”, or distinguishing one or more instructions constituting a basic block from others. Or storing it in If there is no instruction in the buffer, no processing is performed and the process returns to step S305.

(ステップS308)変換部122は、j番目の基本ブロックからのリンク先が存在する場合、当該リンク先の基本ブロックの識別子を、j番目の基本ブロックに付加する。かかる処理は、基本ブロック間の制御フローが判断され得る情報を構成する処理であれば、何でも良い。   (Step S308) When there is a link destination from the jth basic block, the conversion unit 122 adds the identifier of the basic block of the link destination to the jth basic block. Such processing may be anything as long as it constitutes information that can determine the control flow between basic blocks.

(ステップS309)変換部122は、バッファ内の命令群を削除する。   (Step S309) The conversion unit 122 deletes the instruction group in the buffer.

(ステップS310)変換部122は、カウンタjを1、インクリメントする。ステップS305に戻る。   (Step S310) The converter 122 increments the counter j by 1. The process returns to step S305.

(ステップS311)変換部122は、未処理の命令(箇所)に未処理を示すフラグを付す。なお、未処理の命令は、実行され得ない命令である。また、未処理の命令は存在しない可能性もあり、かかる場合、本ステップは実行されない。上位処理にリターンする。なお、 なお、図3のフローチャートにおいて、可読性向上処理手段1221は、未処理を示すフラグを付した箇所のアセンブラプログラムを削除することは好適である。   (Step S311) The conversion unit 122 attaches a flag indicating unprocessed to an unprocessed instruction (location). An unprocessed instruction is an instruction that cannot be executed. Further, there is a possibility that an unprocessed instruction does not exist, and in this case, this step is not executed. Return to upper process. In the flowchart of FIG. 3, it is preferable that the readability improvement processing unit 1221 deletes the assembler program at a location with a flag indicating unprocessed.

また、図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.

以下、本実施の形態におけるマイグレーション装置1の具体的な動作について説明する。今、マイグレーション対象のアセンブラプログラムは、IBMアセンブラである。また、目的言語のプログラムはC言語のプログラムである。   Hereinafter, a specific operation of the migration apparatus 1 in the present embodiment will be described. Now, the migration target assembler program is the IBM assembler. The target language program is a C language program.

かかる状況において、以下に、4つの具体例を用いて、マイグレーション装置1を説明する。
(具体例1)
In this situation, the migration apparatus 1 will be described below using four specific examples.
(Specific example 1)

具体例1は、第一の可読性向上処理および第二の可読性向上処理の具体例である。具体例1は、ソースパターン情報が、ダミーセクションを示す情報を含む場合であり、かつ退避コードと復帰コードを示す情報を含む場合である。また、具体例1において、範囲条件が、実行され得ないプログラムの範囲を判定するための条件である場合も述べる。つまり、具体例1は、上記の(A−1)、(A−4)、(B−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は、図4に示す原ソースを格納している、とする。原ソースは、アセンブラ言語のプログラムの一部である。   Assume that the original source storage unit 111 stores the original source shown in FIG. The original source is part of an assembler language program.

また、箇所特定条件格納部112は、図5に示す箇所特定条件管理表を格納している、とする。箇所特定条件管理表は、「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.

図5において、「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];」を生成することを示す。 また、図5の「ID=2」の箇所特定条件「'STM' 数字','数字','$1」は、例えば、「STM 13,12,REGSAVEA」が合致することを示す。つまり、「$1」は任意の文字列に合致する。   In FIG. 5, “$ 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. 5 indicates that, for example, “STM 13,12, REGSAVEA” matches. That is, “$ 1” matches an arbitrary character string.

そして、図5の「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. 5 indicates that the variable $ 1 is used for register saving for an instruction that matches “'STM” $ register number 1 ”,“ $ register number 2 ”,“ $ 1 ”. Among the registers specified by $ register number 1 to the register specified by $ register number 1 that point to the address, there is a register whose value is not defined (not used) before the matching instruction. If present, it indicates that an instruction in another language for saving the unused register is not generated. This is because the register is not used. In other words, the conversion information of “ID = 2” indicates that the variable $ 1 is saved in the register for the instruction matching “STM” $ register number 1 ”,“ $ register number 2 ”,“ $ 1 ”. Of the register specified by $ register number 1 to the register specified by $ register number 2, only the register whose value is defined (used) before the instruction Indicates generation of an instruction in another language for saving.

また、図5の「ID=3」の変換情報は、「'LM' $レジスタ番号3',' $レジスタ番号4','$1」内の変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号3で特定されるレジスタから$レジスタ番号4で特定されるレジスタのうち、当該命令より後に値が参照されていない(使用されていない)レジスタが存在する場合、当該使用されていないレジスタの復帰を行う他言語の命令は生成されないことを示す。当該レジスタは使用されていないからである。なお、上記を言い換えれば、「ID=3」の変換情報は、「'LM' $レジスタ番号3',' $レジスタ番号4','$1」内の変数$1がレジスタ退避用の番地を指しており、かつ$レジスタ番号3で特定されるレジスタから$レジスタ番号4で特定されるレジスタのうち、当該命令より後に値が参照されている(使用されている)レジスタのみに対して、復帰を行う他言語の命令を生成することを示す。   In addition, the conversion information of “ID = 3” in FIG. 5 indicates that the variable $ 1 in “'LM' $ register number 3”, “$ register number 4”, “$ 1” points to the register saving address. And among registers specified by $ register number 3 to $ register number 4, if there is a register whose value is not referenced (not used) after the instruction, it is used. Indicates that no other language instruction that restores a register that has not been generated is generated. This is because the register is not used. In other words, the conversion information of “ID = 3” indicates that the variable $ 1 in “'LM' $ register number 3 ',' $ register number 4 ',' $ 1" indicates the register saving address. Return to only the register that is pointed to and whose value is referenced (used) after the instruction among the registers specified by $ register number 3 to $ register number 4 Indicates that an instruction in another language is performed.

以上に基づいて、マイグレーション装置1は、処理を開始した、とする。すると、アセンブラプログラム取得部121は、原ソース格納部111に格納されている原ソースから、図4に示すアセンブラプログラムを取得する。   Based on the above, it is assumed that the migration apparatus 1 has started processing. Then, the assembler program acquisition unit 121 acquires the assembler program shown in FIG. 4 from the original source stored in the original source storage unit 111.

次に、変換部122は、取得されたアセンブラプログラムに対して、静的解析処理を行う。そして、変換部122は、アセンブラプログラムを基本ブロックに分割する。そして、可読性向上処理手段1221は、未処理の命令(箇所)のアセンブラプログラムを削除する。   Next, the conversion unit 122 performs a static analysis process on the acquired assembler program. Then, the conversion unit 122 divides the assembler program into basic blocks. Then, the readability improvement processing unit 1221 deletes the assembler program of the unprocessed instruction (location).

次に、変換部122は、基本ブロック毎に、C言語に変換する。つまり、可読性向上処理手段1221は、図5の「ID=1」の箇所特定条件を図4のアセンブラプログラムに適用し、当該箇所特定条件に合致するダミーセクションの領域を検知する。そして、「ID=1」の変換情報の各「アセンブラ」に合致する命令や定義を、対応する「他言語」の情報を用いて、C言語に変換する。そして、可読性向上処理手段1221は、アセンブラのダミーセクションの定義を、C言語の構造体の定義に変換する。つまり、可読性向上処理手段1221は、図4の401の箇所のアセンブラプログラムを、図5の「ID=1」のレコードの情報を用いて、図6の601のC言語のプログラムを生成する。   Next, the conversion part 122 converts into C language for every basic block. That is, the readability improvement processing unit 1221 applies the location identification condition of “ID = 1” in FIG. 5 to the assembler program in FIG. 4 and detects a dummy section region that matches the location identification condition. Then, an instruction or definition that matches each “assembler” of the conversion information of “ID = 1” is converted into the C language using the corresponding “other language” information. Then, the readability improvement processing unit 1221 converts the definition of the dummy section of the assembler into the definition of the structure in C language. That is, the readability improvement processing unit 1221 generates the C language program 601 in FIG. 6 by using the assembler program at the position 401 in FIG. 4 and the information of the record of “ID = 1” in FIG.

次に、変換部122は、図5の「ID=2」の箇所特定条件を図4のアセンブラプログラムに適用し、退避コードの領域を検知する。そして、「ID=2」の変換情報に合致するように、退避コードの箇所を削除する。なお、ここで、変数「REGSAVEA」は、退避コードが出現する関数内では使用されていないとする。つまり、可読性向上処理手段1221は、図4の402の箇所のアセンブラプログラムを、図5の「ID=2」のレコードの情報を用いて、図6の602のC言語のプログラム「BB1: ;」を生成する。なお、「BB1:」はラベルである。また、変換部122は、「すべての基本ブロックの先頭にラベルを生成する」という予め決められたルールに従って、「BB1:」を生成する。なお、予め決められたルールは、例えば、変換部122が保持している。   Next, the conversion unit 122 applies the location identification condition of “ID = 2” in FIG. 5 to the assembler program in FIG. 4 to detect a save code area. Then, the portion of the save code is deleted so as to match the conversion information of “ID = 2”. Here, it is assumed that the variable “REGSAVEA” is not used in the function in which the save code appears. That is, the readability improvement processing unit 1221 uses the information in the record of “ID = 2” in FIG. 5 as the assembler program at the location 402 in FIG. 4 and the C language program “BB1:;” in 602 in FIG. Is generated. “BB1:” is a label. Further, the conversion unit 122 generates “BB1:” according to a predetermined rule “generate labels at the beginning of all basic blocks”. For example, the conversion unit 122 holds the predetermined rule.

次に、変換部122は、図5の「ID=3」の箇所特定条件を図4のアセンブラプログラムに適用し、復帰コードの領域を検知する。そして、「ID=3」の変換情報に合致するように、復帰コードの箇所を削除する。なお、ここで、変数「REGSAVEA」は、復帰コードが出現する関数内では使用されていないとする。つまり、可読性向上処理手段1221は、図4の403の箇所のアセンブラプログラムを、図5の「ID=3」のレコードの情報を用いて、図6の603のC言語のプログラム「BB2: ;」を生成する。なお、「BB2:」はラベルである。また、変換部122は、予め決められたルールに従って、「BB2:」を生成する。なお、予め決められたルールは、例えば、変換部122が保持している。   Next, the conversion unit 122 applies the location identification condition of “ID = 3” in FIG. 5 to the assembler program in FIG. 4 to detect the return code area. The part of the return code is deleted so as to match the conversion information of “ID = 3”. Here, it is assumed that the variable “REGSAVEA” is not used in the function in which the return code appears. That is, the readability improvement processing unit 1221 uses the information in the record of “ID = 3” in FIG. 5 for the assembler program at the position 403 in FIG. 4 and the C language program “BB2:;” in 603 in FIG. Is generated. “BB2:” is a label. In addition, the conversion unit 122 generates “BB2:” according to a predetermined rule. For example, the conversion unit 122 holds the predetermined rule.

また、次に、ソースパターン情報が、退避コードを示す情報を含む場合の別の例を説明する。   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 source storage unit 111 is “STM 5, 8, SAVE”. This one instruction is an instruction for saving the contents of the register 8 from the register 5.

そして、可読性向上処理手段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 improvement processing unit 1221 converts this one instruction into, for example, an intermediate representation that saves the contents of the register 5 (r5), register 6 (r6), register 7 (r7), and register 8 (r8). This intermediate representation is, for example:
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 improvement processing unit 1221 determines that, for example, only the register 5 among the registers 5 to 8 is used before the instruction “STM 5, 8, SAVE”.

次に、可読性向上処理手段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 improvement processing unit 1221 generates a target source that saves only the value of the register 5 (r5) in the above intermediate representation. In other words, the readability improvement processing unit 1221 uses the above-described intermediate representation, the instruction group “tmp1 = SAVE + 4; store (r6, tmp1); tmp2 = SAVE + 8; (r7, tmp2); tmp3 = SAVE + 12; store (r8, tmp3); "is deleted. Then, the readability improvement processing unit 1221 obtains an intermediate expression “store (r5, SAVE);”.

次に、可読性向上処理手段1221は、中間表現「store(r5,SAVE);」を目的ソース「*(unit32_t *)SAVE = r5;」に変換する。そして、可読性向上処理手段1221は、最終的に、C言語のプログラムの命令「*(unit32_t *)SAVE = r5;」を得る。
(具体例2)
Next, the readability improvement processing unit 1221 converts the intermediate expression “store (r5, SAVE);” into the target source “* (unit32_t *) SAVE = r5;”. Then, the readability improvement processing unit 1221 finally obtains an instruction “* (unit32_t *) SAVE = r5;” of the C language program.
(Specific example 2)

具体例2も、第一の可読性向上処理の具体例である。具体例2は、ソースパターン情報が、オフセットを持つ戻りであることを示す情報を含む場合である。つまり、具体例2は、上記の(A−2)に該当する。   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の原ソースが有するアセンブラプログラムは、図7に示すアセンブラプログラムである、とする。図7の701の命令は、サブルーチンPROC1の呼び出し命令である。701は、戻り番地(次の命令702)をレジスタ(14で識別されるレジスタ)に保存し、705のPROC1にジャンプするという命令である。また、702は、自分の番地(*)に8バイト足したところ(704の命令)にジャンプすることを示す。さらに、706は、サブルーチンからの戻り命令である。706は、レジスタ14+4(オフセット)の番地(命令703の箇所)にジャンプする命令である。   Assume that the assembler program included in the original source in the original source storage unit 111 is the assembler program shown in FIG. The instruction 701 in FIG. 7 is a call instruction for the subroutine PROC1. Reference numeral 701 is an instruction to save the return address (next instruction 702) in a register (register identified by 14) and jump to PROC1 in 705. Reference numeral 702 indicates a jump to a place where 8 bytes are added to the address (*) (instruction 704). Reference numeral 706 denotes a return instruction from the subroutine. An instruction 706 jumps to the address of register 14 + 4 (offset) (the position of the instruction 703).

また、格納部11には、図8に示す変換情報管理表が格納されている。変換情報管理表は、「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 improvement processing unit 1221 generates a unique label for different character strings including the $ label. Two $ labels X are replaced with the same label.

そして、可読性向上処理手段1221は、図7のアセンブラプログラムの中の命令701から命令704が、図8の「ID=2」の箇所特定条件に合致する、と判断する。   Then, the readability improvement processing unit 1221 determines that the instructions 701 to 704 in the assembler program in FIG. 7 match the location specifying condition of “ID = 2” in FIG.

また、可読性向上処理手段1221は、図7のアセンブラプログラムの中の命令705以降のサブルーチンが、図8の「ID=2」の適用条件に合致する、と判断する。   Further, the readability improvement processing unit 1221 determines that the subroutine after the instruction 705 in the assembler program in FIG. 7 matches the application condition of “ID = 2” in FIG.

そして、可読性向上処理手段1221は、図7のアセンブラプログラムの中の命令701から命令706に、図8の「ID=2」の変換情報を適用し、図9の命令901から命令906を得る。   Then, the readability improvement processing unit 1221 applies the conversion information “ID = 2” in FIG. 8 to the instructions 701 to 706 in the assembler program in FIG. 7 to obtain the instructions 906 from the instructions 901 in FIG.

また、可読性向上処理手段1221は、図7のアセンブラプログラムの中の命令706が、図8の「ID=1」の箇所特定条件に合致する、と判断する。   Further, the readability improvement processing unit 1221 determines that the instruction 706 in the assembler program in FIG. 7 matches the location specifying condition of “ID = 1” in FIG.

そして、可読性向上処理手段1221は、図7のアセンブラプログラムの中の命令706に、図8の「ID=1」の変換情報を適用し、図9の命令907、命令908を得る。   Then, the readability improving processing unit 1221 applies the conversion information “ID = 1” in FIG. 8 to the instruction 706 in the assembler program in FIG. 7 to obtain the instruction 907 and the instruction 908 in FIG.

以上により、可読性向上処理手段1221は、原ソース(図7参照)に対して、1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む箇所(図7の命令706「B 4(,14)」)を決定し、当該箇所に対応するプログラムを、当該プログラムに含まれるオフセットを条件に用いた分岐(図9の904)を示すプログラム(図9参照)に変更できた。
(具体例3)
As described above, the readability improvement processing unit 1221 applies one or more pieces of source pattern information to the original source (see FIG. 7), and includes a place including a return having an offset (the instruction 706 “B 4 (, 14) ”) was determined, and the program corresponding to the location could be changed to a program (see FIG. 9) indicating a branch (904 in FIG. 9) using the offset included in the program as a condition.
(Specific example 3)

具体例3も、第一の可読性向上処理の具体例である。具体例3は、ソースパターン情報が、一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり含む場合である。つまり、具体例3は、上記の(A−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は、図10に示す箇所特定条件管理表を保持している。図10の箇所特定条件管理表は「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 of FIG. 10 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).

図10の「ID=1」のソースパターン情報の「$1」は任意の文字列であり、「$変数」は任意の変数またはレジスタを示す情報である。また、「ID=1」の他言語パターン情報のlength($1)は、文字列$1の長さを示す。   In FIG. 10, “$ 1” in the source pattern information of “ID = 1” 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.

また、図10の「ID=2」のソースパターン情報の「$2」は任意の文字であり、「$変数」は任意の変数またはレジスタを示す情報である。   Further, “$ 2” in the source pattern information of “ID = 2” in FIG. 10 is an arbitrary character, and “$ variable” is information indicating an arbitrary variable or register.

また、図10の「ID=3」「ID=4」のソースパターン情報の各「$変数」は、変数の後の数字が異なれば、異なる変数である、とする。   Further, each “$ variable” of the source pattern information of “ID = 3” and “ID = 4” in FIG. 10 is a different variable if the number after the variable is different.

また、原ソース格納部111には、図11に示すアセンブラプログラムが格納されている。とする。   The original source storage unit 111 stores the assembler program shown in FIG. And

かかる場合、可読性向上処理手段1221は、図11の1101の箇所が 図10の「ID=1」のソースパターン情報に合致すると判断し、「ID=1」の他言語パターン情報に従って、1101を図12の1201のC言語に変換する。   In this case, the readability improvement processing unit 1221 determines that the portion 1101 in FIG. 11 matches the source pattern information of “ID = 1” in FIG. 10, and displays 1101 according to the other language pattern information of “ID = 1”. 12 to 1201 C language.

また、可読性向上処理手段1221は、図11の1102の箇所が 図10の「ID=2」のソースパターン情報に合致すると判断し、「ID=2」の他言語パターン情報に従って、1102を図12の1202のC言語に変換する。   Further, the readability improvement processing unit 1221 determines that the portion 1102 in FIG. 11 matches the source pattern information of “ID = 2” in FIG. 10, and sets 1102 in FIG. 12 according to the other language pattern information of “ID = 2”. To 1202 C language.

また、可読性向上処理手段1221は、図11の1103の箇所が 図10の「ID=3」のソースパターン情報に合致すると判断し、「ID=3」の他言語パターン情報に従って、1103を図12の1203のC言語に変換する。   Further, the readability improvement processing unit 1221 determines that the portion 1103 in FIG. 11 matches the source pattern information of “ID = 3” in FIG. 10, and changes 1103 according to the other language pattern information of “ID = 3”. To 1203 C language.

また、可読性向上処理手段1221は、図11の1104の箇所が 図10の「ID=4」のソースパターン情報に合致すると判断し、「ID=4」の他言語パターン情報に従って、1102を図12の1204のC言語に変換する。   Further, the readability improvement processing unit 1221 determines that the portion 1104 in FIG. 11 matches the source pattern information of “ID = 4” in FIG. 10, and sets 1102 in FIG. 12 according to the other language pattern information of “ID = 4”. To 1204 C language.

以上の処理の結果、可読性向上処理手段1221は、図11のアセンブラプログラムから、図12のC言語のプログラムを得る。   As a result of the above processing, the readability improvement processing unit 1221 obtains the C language program of FIG. 12 from the assembler program of FIG.

なお、可読性向上処理手段1221は、アセンブラプログラムを中間表現に変換し、中間表現からC言語のプログラムを構成しても良い。例えば、可読性向上処理手段1221は、図11の1101のアセンブラ(図13の1301)を、図13の1302の中間表現1に変換する。そして、1302をtree構造にした図が、1303である。そして、可読性向上処理手段1221は、1303のtree構造を、中間表現2の1304のtree構造に変換する。なお、格納部11には、tree構造間の変換のための情報が格納されている、とする。また、1304のtree構造は、1305の中間表現2に対応する。そして、次に、可読性向上処理手段1221は、1305の中間表現2を1306のC言語のプログラムに変換する。なお、tree構造間の変換を行わずに、中間表現1302をC言語に変換した場合、1307のC言語のプログラムとなる。   The readability improvement processing unit 1221 may convert the assembler program into an intermediate representation and configure a C language program from the intermediate representation. For example, the readability improvement processing unit 1221 converts the assembler 1101 in FIG. 11 (1301 in FIG. 13) into the intermediate representation 1 in 1302 in FIG. A diagram 1303 having a tree structure is 1303. Then, the readability improvement processing unit 1221 converts the 1303 tree structure into a 1304 tree structure of the intermediate representation 2. It is assumed that the storage unit 11 stores information for conversion between tree structures. The tree structure 1304 corresponds to the intermediate representation 2 1305. Then, the readability improvement processing unit 1221 converts the intermediate representation 2 of 1305 into a C language program of 1306. When the intermediate representation 1302 is converted into C language without converting between tree structures, a C language program 1307 is obtained.

同様に、可読性向上処理手段1221は、図11の1102のアセンブラ(1401)を、図14の1402の中間表現1に変換する。そして、1402をtree構造にした図が、1403である。そして、可読性向上処理手段1221は、1403のtree構造を、中間表現2の1404のtree構造に変換する。なお、1404のtree構造は、1405の中間表現2に対応する。そして、次に、可読性向上処理手段1221は、1405の中間表現2を1406のC言語のプログラムに変換する。なお、1402をC言語に変換した場合、1407となる。
(具体例4)
Similarly, the readability improvement processing unit 1221 converts the assembler (1401) of 1102 in FIG. 11 into the intermediate representation 1 of 1402 in FIG. A diagram 1404 having a tree structure is 1403. Then, the readability improvement processing unit 1221 converts the tree structure 1403 into a tree structure 1404 of the intermediate representation 2. The tree structure 1404 corresponds to the intermediate representation 2 1405. Then, the readability improvement processing unit 1221 converts the intermediate representation 2 1405 into a C language program 1406. When 1402 is converted into C language, 1407 is obtained.
(Specific example 4)

具体例4も、第一の可読性向上処理の具体例である。具体例4は、ソースパターン情報が、2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含む場合である。つまり、具体例4は、上記の(A−5)に該当する。   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は、図15(a)に示す、b1、b2、b3、b4の4つの基本ブロック間のリンクを示す情報を得た、とする。なお、基本ブロック間のリンク関係とは、基本ブロック間の処理の流れを示しており、一の基本ブロックから出て行く2以上のリンク(矢印)が存在する場合は分岐があることを示す。また、図15の1501、1502はループを構成するリンクである。そして、図15(a)では、(1)「ボトムが起点から最も遠いループを優先する」の条件に従い、1502のループが優先される。つまり、可読性向上処理手段1221は、1502のループを、C言語の、例えば、「while」文に書き換え、goto文を無くす。なお、基本ブロックb3からb1へのリンク1501を構成するgoto命令は、残ることとなる。   Now, it is assumed that the conversion unit 122 statically analyzes the assembler program and determines that the assembler program has a link relationship between a plurality of (here, four) basic blocks. Then, it is assumed that the conversion unit 122 has obtained information indicating links between the four basic blocks b1, b2, b3, and b4 illustrated in FIG. The link relationship between the basic blocks indicates the flow of processing between the basic blocks, and indicates that there is a branch when there are two or more links (arrows) that go out from one basic block. Also, 1501 and 1502 in FIG. 15 are links constituting a loop. In FIG. 15A, the loop 1502 is given priority in accordance with the condition of (1) “priority is given to the loop whose bottom is farthest from the starting point”. That is, the readability improvement processing unit 1221 rewrites the loop 1502 into a C language “for example” sentence, and eliminates the goto sentence. Note that the goto instruction constituting the link 1501 from the basic block b3 to b1 remains.

さらに具体的には、変換対象のアセンブラプログラムが、図16のプログラムであった、とする。図16において、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. 16, L0 and L1 are labels. “BE L0” and “BE L1” are jump instructions. Instructions 1 to 8 are arbitrary instructions.

そして、変換部122は、図16のアセンブラプログラムを静的解析し、当該アセンブラプログラムがb1〜b4の4つの基本ブロックを取得した、とする。   Then, it is assumed that the conversion unit 122 statically analyzes the assembler program in FIG. 16 and the assembler program has acquired four basic blocks b1 to b4.

そして、変換部122は、2以上のループの一部が重なっている図16の場合に、(1)「ボトムが起点から最も遠いループを優先する」に基づいて、b4のブロックをボトムとするループ(図15の1502のループ)を優先させた場合、変換部122は、図17(a)のプログラムを取得する。そして、b3のブロックをボトムとするループを構成するgoto文1601はそのまま残る。ただし、図17(a)の1701は、ループから飛び出すgoto文であり、可読性の低下度合いは低い。   Then, in the case of FIG. 16 where two or more loops overlap each other, the conversion unit 122 sets the block b4 as the bottom based on (1) “priority is given to the loop whose bottom is farthest from the starting point”. When the loop (the loop 1502 in FIG. 15) is prioritized, the conversion unit 122 acquires the program in FIG. Then, the goto statement 1601 constituting the loop with the block b3 as the bottom remains as it is. However, 1701 in FIG. 17A is a goto sentence that jumps out of the loop, and the degree of decrease in readability is low.

一方、仮に、変換部122は、2以上のループの一部が重なっている図16の場合に、b3のブロックをボトムとするループ(図15の1501のループ)を優先させた場合、変換部122は、図17(b)のプログラムを取得する。そして、b4のブロックをボトムとするループを構成するgoto文1702はそのまま残る。そして、図17(b)の1702は、ループへ飛び込むgoto文であり、可読性は著しく低下し、望ましくない。   On the other hand, in the case of FIG. 16 where two or more loops overlap each other, the converting unit 122 gives priority to the loop with the b3 block as the bottom (the loop 1501 in FIG. 15). 122 acquires the program of FIG. Then, the goto statement 1702 constituting the loop with the block b4 as the bottom remains as it is. Reference numeral 1702 in FIG. 17B is a goto statement that jumps into the loop, which is not desirable because it significantly reduces readability.

また、変換部122は、上記とは別のアセンブラプログラムを静的解析し、当該アセンブラプログラムが複数(ここでは、4つ)の基本ブロック間のリンク関係を有する、と判断した、とする。そして、変換部122は、図18(a)に示す、t1、t2、t3、t4の4つの基本ブロック間のリンクを示す情報を得た、とする。また、図18の1801、1802はループを構成するリンクである。そして、図18(a)では、(2)「ボトムが同じループが複数ある場合、トップが起点から最も近いループを優先する」の条件に従い、1801のループが優先される。つまり、可読性向上処理手段1221は、1801のループを、C言語の、例えば、「for」文に書き換え、goto文を無くす。なお、基本ブロックt4からt2へのリンク1802を構成するgoto命令は、残ることとなる。   Further, it is assumed that the conversion unit 122 statically analyzes an assembler program different from the above and determines that the assembler program has a link relationship between a plurality (four in this case) of basic blocks. Then, it is assumed that the conversion unit 122 has obtained information indicating links between the four basic blocks t1, t2, t3, and t4 illustrated in FIG. Also, 1801 and 1802 in FIG. 18 are links constituting a loop. In FIG. 18A, the loop 1801 is prioritized according to the condition of (2) “If there are multiple loops with the same bottom, the top gives priority to the loop closest to the starting point”. That is, the readability improvement processing unit 1221 rewrites the loop 1801 into a C language “for” sentence, for example, and eliminates the goto sentence. Note that the goto instruction constituting the link 1802 from the basic block t4 to t2 remains.

さらに具体的には、変換対象のアセンブラプログラムが、図19のプログラムであった、とする。図19において、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. 19, L0 and L1 are labels. “BE L1” and “B L0” are jump instructions. Instructions 1 to 8 are arbitrary instructions.

そして、変換部122は、図19のアセンブラプログラムを静的解析し、当該アセンブラプログラムがt1〜t4の4つの基本ブロックを取得した、とする。   Then, it is assumed that the conversion unit 122 statically analyzes the assembler program in FIG. 19 and the assembler program has acquired four basic blocks t1 to t4.

そして、変換部122は、2以上のループの一部が重なっている図19の場合に、(2)「ボトムが同じループが複数ある場合、トップが起点から最も近いループを優先する」に基づいて、t1のブロックをトップとするループ(図18の1801のループ)を優先させた場合、変換部122は、図20(a)のプログラムを取得する。そして、2001内の他のgoto文はそのまま残る。ただし、図20(a)のgoto文の行き先がループ内に存在するので、可読性はあまり低下しない。   Then, in the case of FIG. 19 where two or more loops overlap each other, the conversion unit 122 is based on (2) “If there are multiple loops with the same bottom, the top gives priority to the loop closest to the starting point”. Thus, when priority is given to the loop with the t1 block at the top (the loop 1801 in FIG. 18), the conversion unit 122 acquires the program in FIG. And other goto statements in 2001 remain as they are. However, since the destination of the goto statement in FIG. 20A exists in the loop, the readability does not deteriorate much.

一方、仮に、変換部122は、2以上のループの一部が重なっている図18の場合に、t2のブロックをトップとするループ(図18の1802のループ)を優先させた場合、変換部122は、図20(b)のプログラムを取得する。そして、2002内の他のgoto文はそのまま残る。そして、図20(b)のgoto文の行き先は、プログラムの任意の箇所になり得るので、プログラム全体の中から、goto文の行き先を探す必要があり、可読性は著しく減少する。   On the other hand, if the conversion unit 122 gives priority to the loop (the loop 1802 in FIG. 18) with the top of the t2 block in the case of FIG. 122 acquires the program shown in FIG. And other goto statements in 2002 remain as they are. Since the destination of the goto sentence in FIG. 20B can be an arbitrary part of the program, it is necessary to search for the destination of the goto sentence from the entire program, and the readability is significantly reduced.

なお、変換部122がすべてのgoto文を他言語のループに変換する場合、図21に示すように、トップにt1 とt2 のどちらを選んでも最終的な変換結果は同じになる。ただし、トップにt1 を選んだ方が計算量が少なくなる。   When the conversion unit 122 converts all goto sentences into loops in other languages, the final conversion result is the same regardless of which t1 or t2 is selected as the top, as shown in FIG. However, the amount of calculation is smaller when t1 is selected at the top.

以上、本実施の形態によれば、アセンブラのプログラムをマイグレーションする場合に、保守性を考慮した、可読性の高い他言語のプログラムを生成できる。   As described above, according to this embodiment, when an assembler program is migrated, it is possible to generate a program in another language with high readability in consideration of maintainability.

また、本実施の形態によれば、予め決められたパターンに合致するアセンブラのプログラムを、保守性を考慮した、可読性の高い他言語のプログラムに変換できる。   Further, according to the present embodiment, an assembler program that matches a predetermined pattern can be converted into a program in another language that has high maintainability in consideration of maintainability.

さらに、本実施の形態によれば、アセンブラのプログラムの中の予め決められた条件を満たす箇所の範囲を特定し、保守性を考慮して、当該範囲に対応する可読性の高い他言語のプログラムに変換できる。   Furthermore, according to the present embodiment, a range of locations satisfying a predetermined condition in the assembler program is identified, and in consideration of maintainability, a program in another language having high readability corresponding to the range is specified. Can be converted.

なお、本実施の形態における処理は、ソフトウェアで実現しても良い。そして、このソフトウェアをソフトウェアダウンロード等により配布しても良い。また、このソフトウェアをCD−ROMなどの記録媒体に記録して流布しても良い。なお、このことは、本明細書における他の実施の形態においても該当する。なお、本実施の形態におけるマイグレーション装置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 migration apparatus 1 in the present embodiment is the following program. That is, in this program, the computer-accessible recording medium is an assembler program written in an assembler language, and the program is stored in an original source storage unit that can store an original source that is a migration target program and the original source. 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 computer, and a computer is stored in the original source storage unit A source unit that is a program in another language and converts it into a target source that is a target language program, and the converter converts the source source to function as an output unit that outputs the acquired target source The conversion unit is a program for the original source stored in the original source storage unit. The readability improving process, which is a process corresponding to the matching location specifying condition and improving the readability of the program, is applied to the location corresponding to the matching location specifying condition. A program that causes a computer to function as an improvement processing unit.

また、上記プログラムにおいて、前記箇所特定条件は、プログラムのパターンに関する情報であるソースパターン情報であり、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記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, a process corresponding to the matching source pattern information is performed on a location corresponding to the matching source pattern information, and a readability improving process which is a process for improving the readability of the program is performed. As a thing, it is suitable that it is a program which functions a computer.

また、上記プログラムにおいて、前記ソースパターン情報は、ダミーセクションを示す情報を含み、前記可読性向上処理手段は、前記原ソース格納部に格納されている原ソースに対して、前記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 to apply each source pattern information, determine the location of the save code or return code, and delete the program corresponding to the location from the original source or the target source, and to be a program that causes the computer to function. It is.

また、上記プログラムにおいて、前記ソースパターン情報は、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.

また、図22は、本明細書で述べたプログラムを実行して、上述した種々の実施の形態のマイグレーション装置等を実現するコンピュータの外観を示す。上述の実施の形態は、コンピュータハードウェア及びその上で実行されるコンピュータプログラムで実現され得る。図22は、このコンピュータシステム300の概観図であり、図23は、システム300のブロック図である。   FIG. 22 shows the external appearance of a computer that executes the programs described in this specification and realizes the migration apparatus and the like of the various embodiments described above. The above-described embodiments can be realized by computer hardware and a computer program executed thereon. FIG. 22 is an overview diagram of the computer system 300, and FIG. 23 is a block diagram of the system 300.

図22において、コンピュータシステム300は、CD−ROMドライブを含むコンピュータ301と、キーボード302と、マウス303と、モニタ304とを含む。   In FIG. 22, a computer system 300 includes a computer 301 including a CD-ROM drive, a keyboard 302, a mouse 303, and a monitor 304.

図23において、コンピュータ301は、CD−ROMドライブ3012に加えて、MPU3013と、MPU3013、CD−ROMドライブ3012に接続されたバス3014と、ブートアッププログラム等のプログラムを記憶するためのROM3015と、MPU3013に接続され、アプリケーションプログラムの命令を一時的に記憶するとともに一時記憶空間を提供するためのRAM3016と、アプリケーションプログラム、システムプログラム、及びデータを記憶するためのハードディスク3017とを含む。ここでは、図示しないが、コンピュータ301は、さらに、LANへの接続を提供するネットワークカードを含んでも良い。   23, in addition to the CD-ROM drive 3012, the computer 301 includes an MPU 3013, a bus 3014 connected to the MPU 3013 and the CD-ROM drive 3012, a ROM 3015 for storing a program such as a bootup program, and an MPU 3013. And a RAM 3016 for temporarily storing instructions of the application program and providing a temporary storage space, and a hard disk 3017 for storing the application program, the system program, and data. Although not shown here, the computer 301 may further include a network card that provides connection to a LAN.

コンピュータシステム300に、上述した実施の形態のマイグレーション装置1等の機能を実行させるプログラムは、CD−ROM3101に記憶されて、CD−ROMドライブ3012に挿入され、さらにハードディスク3017に転送されても良い。これに代えて、プログラムは、図示しないネットワークを介してコンピュータ301に送信され、ハードディスク3017に記憶されても良い。プログラムは実行の際にRAM3016にロードされる。プログラムは、CD−ROM3101またはネットワークから直接、ロードされても良い。   A program that causes the computer system 300 to execute the functions of the migration apparatus 1 or the like of the above-described embodiment may be stored in the CD-ROM 3101, inserted into the CD-ROM drive 3012, and further transferred to the hard disk 3017. Alternatively, the program may be transmitted to the computer 301 via a network (not shown) and stored in the hard disk 3017. The program is loaded into the RAM 3016 at the time of execution. The program may be loaded directly from the CD-ROM 3101 or the network.

プログラムは、コンピュータ301に、上述した実施の形態のマイグレーション装置1等の機能を実行させるオペレーティングシステム(OS)、またはサードパーティープログラム等は、必ずしも含まなくても良い。プログラムは、制御された態様で適切な機能(モジュール)を呼び出し、所望の結果が得られるようにする命令の部分のみを含んでいれば良い。コンピュータシステム300がどのように動作するかは周知であり、詳細な説明は省略する。   The program does not necessarily include an operating system (OS) or a third-party program that causes the computer 301 to execute the functions of the migration apparatus 1 according to the above-described embodiment. The program only needs to include an instruction portion that calls an appropriate function (module) in a controlled manner and obtains a desired result. How the computer system 300 operates is well known and will not be described in detail.

また、上記プログラムを実行するコンピュータは、単数であってもよく、複数であってもよい。すなわち、集中処理を行ってもよく、あるいは分散処理を行ってもよい。   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.

また、上記各実施の形態において、各処理は、単一の装置によって集中処理されることによって実現されてもよく、あるいは、複数の装置によって分散処理されることによって実現されてもよい。   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 migration apparatus according to the present invention has the effect of being able to generate a program in another language with high readability in consideration of maintainability when migrating an assembler program, and is useful as a migration apparatus or the like. is there.

1 マイグレーション装置
11 格納部
12 処理部
13 出力部
111 原ソース格納部
112 箇所特定条件格納部
113 変換情報格納部
121 アセンブラプログラム取得部
122 変換部
1221 可読性向上処理手段
DESCRIPTION OF SYMBOLS 1 Migration apparatus 11 Storage part 12 Processing part 13 Output part 111 Original source storage part 112 Location specific condition storage part 113 Conversion information storage part 121 Assembler program acquisition part 122 Conversion part 1221 Readability improvement processing means

Claims (13)

アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、
原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である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 location specifying condition storage 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;
A conversion unit that converts the original source stored in the original source storage unit into a target source that is a program in another language and is a target language program;
An output unit for converting the conversion unit and outputting the acquired target source;
The converter is
The one or more location specifying conditions are applied to the original source stored in the original source storage unit, and the location corresponding to the matching location specifying condition is applied to the matching location specifying condition. A migration apparatus comprising readability improvement processing means for performing readability improvement processing, which is processing and processing for improving the readability of a program.
前記箇所特定条件は、プログラムのパターンに関する情報であるソースパターン情報であり、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、合致するソースパターン情報に対応する箇所に対して、前記合致するソースパターン情報に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う請求項1記載のマイグレーション装置。
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 corresponding source pattern information corresponds to the corresponding source pattern information. The migration apparatus according to claim 1, wherein the migration apparatus performs a readability improvement process that is a process for improving the readability of a program.
前記ソースパターン情報は、
ダミーセクションを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、ダミーセクションを含む箇所を決定し、当該箇所に対応するプログラムを、構造体を定義するプログラムに変更する請求項2記載のマイグレーション装置。
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 source source stored in the source source storage unit, a location including a dummy section is determined, and a structure corresponding to the program corresponding to the location is defined. The migration apparatus according to claim 2, wherein the migration apparatus is changed to a program.
前記ソースパターン情報は、
オフセットを持つ戻りであることを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、オフセットを持つ戻りを含む箇所を決定し、当該箇所に対応するプログラムを、当該プログラムに含まれるオフセットを条件に用いた分岐を示すプログラムに変更する請求項2記載のマイグレーション装置。
The source pattern information is
Contains information indicating that the return has an offset,
The readability improvement processing means includes:
The one or more source pattern information is applied to the original source stored in the original source storage unit, a location including a return having an offset is determined, and a program corresponding to the location is assigned to the program. The migration apparatus according to claim 2, wherein the program is changed to a program indicating a branch using an included offset as a condition.
前記ソースパターン情報は、
一命令の他言語のプログラムに変換可能なアセンブラの2以上の命令の箇所を特定するためのパターンの情報であり、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、前記2以上の命令の箇所を決定し、当該箇所に対応するプログラムを、一命令の他言語のプログラムに変換する請求項2記載のマイグレーション装置。
The source pattern information is
It 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.
The readability improvement processing means includes:
The one or more source pattern information is applied to the original source stored in the original source storage unit, the location of the two or more instructions is determined, and a program corresponding to the location is stored in one instruction. The migration apparatus according to claim 2, wherein the migration apparatus converts the program into another language program.
前記ソースパターン情報は、
退避コードまたは復帰コードを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、退避コードまたは復帰コードの箇所を決定し、当該箇所に対応するプログラムを、前記原ソースまたは前記目的ソースから削除する請求項2記載のマイグレーション装置。
The source pattern information is
Contains information indicating the evacuation code or return code,
The readability improvement processing means includes:
The one or more source pattern information is applied to the original source stored in the original source storage unit, the location of the save code or the return code is determined, and the program corresponding to the location is stored in the source source. The migration apparatus according to claim 2, wherein the migration apparatus is deleted from the target source.
前記ソースパターン情報は、
2以上のジャンプ命令が構成する2以上のループの一部が重なっていることを示す情報を含み、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各ソースパターン情報を適用し、2以上のループの一部が重なっている箇所を決定し、当該箇所に対応するプログラムを、予め決められた条件を満たす一のループを優先し、ジャンプ命令を有さないループを示すプログラムに変更する請求項2記載のマイグレーション装置。
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 migration apparatus according to claim 2, wherein a first loop satisfying a predetermined condition is prioritized and a program indicating a loop having no jump instruction is changed.
前記箇所特定条件は、原ソース内において予め決められた条件を満たす箇所の範囲を特定するための条件である範囲条件であり、
前記可読性向上処理手段は、
前記原ソース格納部に格納されている原ソースに対して、前記1以上の各範囲条件を適用し、合致する範囲条件に対応する箇所に対して、前記合致する範囲条件に対応する処理であり、プログラムの可読性を向上させる処理である可読性向上処理を行う請求項1記載のマイグレーション装置。
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 migration apparatus according to claim 1, wherein a readability improving process that is a process for improving the readability of the program is performed.
前記範囲条件は、
実行され得ないプログラムの範囲を判定するための条件であり、
前記可読性向上処理手段は、
前記原ソースを静的解析し、前記合致する範囲条件に対応する箇所のプログラムを特定し、当該プログラムを削除する請求項8記載のマイグレーション装置。
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 migration apparatus according to claim 8, wherein the original source is statically analyzed, a program corresponding to the matching range condition is specified, and the program is deleted.
前記範囲条件は、
変数を特定するための条件であり、
前記可読性向上処理手段は、
前記原ソースまたは目的ソースから変数を取得し、当該変数の生存区間を取得し、当該変数を、当該生存区間におけるローカル変数として定義する可読性向上処理を行う請求項8記載のマイグレーション装置。
The range condition is
It is a condition to specify the variable,
The readability improvement processing means includes:
The migration apparatus according to claim 8, 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から請求項10いずれか一項に記載のマイグレーション装置。
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 migration apparatus according to any one of claims 1 to 10, wherein the assembler program acquired by the assembler program acquisition unit is converted into a target source.
記録媒体は、
アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、
原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である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 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;
A method of manufacturing a program that can be realized by a conversion unit and an output unit,
The conversion unit converts the original source stored in the original source storage unit into a target source which is a program in another language and is a target language program;
The output unit is a method for producing another language program comprising an output step of outputting the acquired target source after being converted in the conversion step,
The converter is
The one or more location specifying conditions are applied to the original source stored in the original source storage unit, and the location corresponding to the matching location specifying condition is applied to the matching location specifying condition. A method of manufacturing a program comprising a step of performing a readability improving process, which is a process for improving the readability of a program.
コンピュータアクセス可能な記録媒体は、
アセンブラ言語で記述されたアセンブラプログラムであり、マイグレーション対象のプログラムである原ソースを格納し得る原ソース格納部と、
原ソースに対して、プログラムの可読性を向上させるための処理を行う箇所を特定するための条件である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 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;
Computer
A conversion unit that converts the original source stored in the original source storage unit into a target source that is a program in another language and is a target language program;
A program for converting the conversion unit to function as an output unit that outputs the acquired target source,
The converter is
The one or more location specifying conditions are applied to the original source stored in the original source storage unit, and the location corresponding to the matching location specifying condition is applied to the matching location specifying condition. A program that causes a computer to function as a process that includes a readability improvement processing unit that performs a readability improvement process that is a process that improves the readability of a program.
JP2015177171A 2015-09-09 2015-09-09 Migration device, creation method of program and program Pending JP2017054277A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015177171A JP2017054277A (en) 2015-09-09 2015-09-09 Migration device, creation method of program and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015177171A JP2017054277A (en) 2015-09-09 2015-09-09 Migration device, creation method of program and program

Publications (1)

Publication Number Publication Date
JP2017054277A true JP2017054277A (en) 2017-03-16

Family

ID=58320810

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015177171A Pending JP2017054277A (en) 2015-09-09 2015-09-09 Migration device, creation method of program and program

Country Status (1)

Country Link
JP (1) JP2017054277A (en)

Similar Documents

Publication Publication Date Title
US8799299B2 (en) Schema contracts for data integration
US9424003B1 (en) Schema-less system output object parser and code generator
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
US20110209135A1 (en) Program Change Management Apparatus, Computer Readable Record Medium Storing Program Change Management Program, And Program Change Management Method
US8935657B2 (en) Model-to-model transformation by kind
US20100218200A1 (en) Method for programmatic editing of text files
JP2020060919A (en) System migration support device, system migration support method and program
JP4724387B2 (en) Program conversion program, program conversion apparatus, and program conversion method
JP2009169864A (en) Compile method and compile program
US20110296373A1 (en) Command line shell command generation based on schema
JP2017054277A (en) Migration device, creation method of program and program
JP2017062746A (en) Document generation device, generation method for document, and program
JP2014228990A (en) Control program creation apparatus and control program creation method
JP5932707B2 (en) Computer, program, and data generation method
JP6175306B2 (en) Control program dividing apparatus, control program dividing method and recording medium therefor
JP2017126176A (en) Migration apparatus, production method of target source, and program
KR101905675B1 (en) Module structural analysis supporting device and program
US9792197B2 (en) Apparatus and program
JP4405571B1 (en) program
CN113031952A (en) Method and device for determining execution code of deep learning model and storage medium
US20170344351A1 (en) Information processing apparatus, compiling management method, and recording medium
WO2021084657A1 (en) Conversion device, conversion method, and program
JP2009080681A (en) Program structure parsing method and device