JP2004021429A - Compiler program equipped with dummy argument multiple violation detection function, its recording medium, and compiler device - Google Patents

Compiler program equipped with dummy argument multiple violation detection function, its recording medium, and compiler device Download PDF

Info

Publication number
JP2004021429A
JP2004021429A JP2002173218A JP2002173218A JP2004021429A JP 2004021429 A JP2004021429 A JP 2004021429A JP 2002173218 A JP2002173218 A JP 2002173218A JP 2002173218 A JP2002173218 A JP 2002173218A JP 2004021429 A JP2004021429 A JP 2004021429A
Authority
JP
Japan
Prior art keywords
variable
argument
array
dummy
size
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2002173218A
Other languages
Japanese (ja)
Other versions
JP4228602B2 (en
Inventor
▲辻▼森 誘二
Yuuji Tsujimori
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2002173218A priority Critical patent/JP4228602B2/en
Publication of JP2004021429A publication Critical patent/JP2004021429A/en
Application granted granted Critical
Publication of JP4228602B2 publication Critical patent/JP4228602B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To improve the debug efficiency of a program by detecting a grammatical error related with multiple arguments when executing a program. <P>SOLUTION: This compiler program generates object codes to carry out processing to transfer the magnitude values of the array of actual arguments from a call origin procedure to a call destination procedure, processing to calculate the range of variables as dummy arguments from the magnitude values of the actual arguments when the dummy arguments are a magnitude succeeding array, and from the magnitude of the array of the actual arguments in the other case for all the actual arguments to be used by the call destination procedure, and to prepare dummy argument information including the identification information of the call destination procedure, the variable names, and information indicating the existing position of the array, and processing to refer to the dummy argument information of the actual arguments other than the dummy arguments to be used by the call destination procedure when the values of the variables are certified by the call destination procedure, and the certified variables are dummy arguments, and to determine whether or not the the variable range is overlapped with the variable range of the other dummy arguments. <P>COPYRIGHT: (C)2004,JPO

Description

【0001】
【発明の属する技術分野】
本発明は、Fortran、C言語など、仮引数と結合した要素に関する制限を持つ仕様が存在する計算機言語で記述されたプログラムが、その制限に違反するとプログラム実行時に検出可能なオブジェクトプログラムを生成するコンパイラに関し、特にランタイムライブラリと連携させて重複引数に関する文法エラーを検出する技術に関する。
【0002】
【従来の技術】
上記の、仮引数と結合した要素に関する言語仕様のもつ制限事項とは、以下を指す。
(イ)同じ手続の二つの異なる仮引数と結合された実引数が重なって結合された場合、重なった部分は、手続の実行中に確定してはならない。
(ロ)手続で仮引数と結合された実引数の変数は、手続の実行中に仮引数以外を通して確定してはならない。
【0003】
以下に図3、図4を用いて具体的に上記制限事項について説明する。
図3は、上記制限事項(イ)に関連するFortranで記述したソースプログラムの例が示してある。文(2)は、サブルーチンSUB1を呼び出す際に、第一引数は、A(1),A(2),・・・,A(10)と結合され、第二引数は、A(5),A(6),・・・,A(10)と結合されることを表している。文(5)は、サブルーチンSUB1の第一引数であるAの配列宣言である。Aは1次元の配列であり、要素数の上限値に*が指定されているため、配列の大きさは呼び出し元の配列の大きさが引き継がれる。そのため、A(1),A(2),・・・,A(10)は実引数ARRAY(1),ARRAY(2),・・・,ARRAY(10)と結合される。
【0004】
文(6)は、サブルーチンSUB1の第二引数であるBの配列宣言である。BもAと同様に、B(1),B(2),・・・B(6)は実引数ARRAY(5),ARRAY(6),・・・ARRAY(10)と結合される。実引数ARRAY(5),ARRAY(6),・・・ARRAY(10)は、同じ手続き(サブルーチンSUB1)の二つの異なる仮引数AとBで重なって結合されるため、手続きの実行中に確定してはならない。言い換えると、A(5),A(6),・・・A(10)、およびB(1),B(2),・・・B(6)は、値を確定してはならないことになり、文(8)と文(9)は文法上、誤った記述である。
【0005】
図4は、上記制限事項(ロ)に関連したFortranで記述したソースプログラムの例が示してある。文(2)は、サブルーチンSUB2を呼び出す際に、仮引数がA(3)と宣言されているため、引数はA(5),A(6),A(7)と結合することを表している。文(5)は、サブルーチンSUB2の引数であるAの配列宣言である。呼出元手続きと、呼出先手続き(サブルーチンSUB2)が親子結合の関係にあるため、ARRAYは呼出元手続きと、呼出先手続きで共有することが可能である。
【0006】
しかしながら、上記(ロ)の制限事項により手続(サブルーチンSUB2)で仮引数Aと結合された実引数(ARRAY(5),ARRAY(6),ARRAY(7))の変数は、手続の実行中に仮引数A以外を通して確定してはならない。言い換えると、ARRAY(1),ARRAY(2),ARRAY(3),ARRAY(4),ARRAY(8),ARRAY(9),ARRAY(10),A(1),A(2),A(3)はサブルーチンSUB2から値の確定が可能であり、ARRAY(5),ARRAY(6),ARRAY(7)はAを通してのみ確定することが可能であるため、文(7)は文法上、誤った記述である。
【0007】
しかしながら、2つの異なる仮引数と結合した実引数の間で重複する部分があっても、値を変更するのではなく、参照するだけでは上記制限事項には違反したことにはならない。また、呼び出された手続きから、更に他の手続きが呼び出され、そこで値が確定される場合があったり、コンパイル単位が呼出元手続きと呼出先手続きで異なる場合もあるので上記制限事項に違反したプログラムについて、すべてコンパイル時に文法エラーとすることはできない。
【0008】
第2502128号公報に記載の「コンパイラ装置」には、コンパイラは、ソースプログラムの翻訳(コンパイル)時に、プログラム中に他の手続きを引用する呼出文があると、複数の引数があるかどうかを判定し、複数の引数がある場合、さらにそれらの領域が重複する可能性があるかどうかを調べ、領域が重複する可能性がある場合、コンパイラは以下の処理を行うオブジェクトを生成することにより、上記仮引数と結合した要素に関する言語仕様のもつ制限事項(イ)に違反したプログラムを、実行時に文法エラーとして検出し、プログラムのデバッグを簡単に行うことを可能とする技術について開示されている。
(a)各実引数の領域の大きさを調べ、その大きさの新たな領域を動的に確保する。
(b)動的に確保した各領域に、対応する引数の内容を複写する。
(c)動的に確保した領域を引数として、指定された処理手続きを呼び出す。
(d)呼び出した処理手続きからの復帰時に、呼び出した処理手続きに渡した領域の内容の比較により、領域が重複する部分について値の変更があるか否かを判定する。
(e)重複する部分の値の変更があるとき、エラーメッセージを出力する。
【0009】
【発明が解決しようとする課題】
しかしながら、第2502128号公報に記載の「コンパイラ装置」では、上記の、仮引数と結合した要素に関する言語仕様のもつ制限事項(ロ)に違反したプログラムの実行時の検出は不可能であった。また、仮引数と結合した要素に関する言語仕様のもつ制限事項(イ)に違反したプログラムに対しても、制限事項を犯したことは判定できるが、手続きからの復帰時に、その手続きのどこで制限事項を犯したかは不明であった。
【0010】
更に、実引数に対して、新たに領域を動的に確保し、確保した領域に引数の内容を複写したり、呼び出した処理手続きからの復帰時に、呼び出した処理手続きに渡した領域の内容を比較する際にも、引数の複写が必要な場合がある。そのため、大きな配列を引数とするような処理においては、多量のメモリ領域を必要とし、かつメモリ領域の動的確保や複写のために非常に多くの実行時間を要する。特にDOループの中に、大きな配列を引数とする手続き呼び出しが存在する場合には、従来技術では実行時間が掛かり過ぎ、実質的には適用できない場合もある。
【0011】
本発明は、上記のような事情に鑑みて提案されたものであり、重複引数に関する文法エラーをプログラム実行時に検出し、プログラムのデバッグ効率を高めることを目的としている。
【0012】
【課題を解決するための手段】
図1は本発明の実施の形態1の全体構成図を示すものである。本発明のコンパイラプログラム10は、コンピュータを用いて利用者が作成したソースプログラム2を入力として、従来のコンパイラプログラムのソース解析部11に、新たに仮引数情報生成手段112と、重複判定手段113を追加して、既存の大きさ値生成手段111と連携させて重複引数に関する値変更エラーをプログラム実行時に検出できるように機能追加したオブェクトプログラム3を生成するものである。
【0013】
大きさ値生成手段111は、ソースプログラム2から実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する。仮引数情報生成手段112は、前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する。重複判定手段113は、前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する。
【0014】
このようにして翻訳されたオブジェクトプログラム3は、確定された変数が仮引数である場合、他の仮引数の変数範囲と重複しているかどうかを判定するオブジェクトコードが生成されるため、連係編集され実行形式プログラムに変換されると、仮引数と結合した要素に関する言語仕様のもつ制限事項(イ)に違反していた場合、実引数に対して、新たに領域を動的に確保し、確保した領域に引数の内容を複写したり、呼び出した処理手続きからの復帰時に、呼び出した処理手続きに渡した領域の内容を比較する際にも、引数の複写を行うことなく、プログラム実行時に文法エラーとして検出することが可能となる。
【0015】
なお、大きさ値生成手段が呼出元手続きから呼出先手続きに実引数の配列の大きさ値を受け渡すためには、呼出元手続きから呼出先手続きに渡すパラメタ内に含めるように実装してもよいし、呼出元プログラムを制御するための制御テーブルに格納しておき、呼出先プログラムが制御テーブルから取り出すように実装してもよい。
【0016】
また、重複判定手段113は、確定された変数が仮引数でない場合、呼出先手続きが使用するすべての仮引数情報を参照して、前記変数が仮引数の変数範囲と重複しているかどうかを判定するオブジェクトコードを生成すると、仮引数と結合した要素に関する言語仕様のもつ制限事項(ロ)に違反していた場合、プログラム実行時に文法エラーとして検出することが可能となる。
【0017】
更に、重複判定手段113は、確定された変数が他の仮引数の変数範囲と重複していることを判定すると、前記確定された変数の名前、変数が確定された文の行番号、前記確定された変数と結合されている仮引数の名前を含むメッセージを出力するオブジェクトコードを生成すると、利用者はメッセージを参照するだけで、利用者のプログラムが上記仮引数と結合した要素に関する言語仕様のもつ制限事項に違反した場合、変数を確定した文の行番号、確定された変数の名前、確定された変数と結合されている仮引数の名前が分かり、プログラムのデバッグ効率を高めることが可能となる。
【0018】
【発明の実施の形態】
図1は本発明の実施の形態1の全体構成図を示してある。コンパイラ装置1では、利用者が作成したソースプログラム2を入力として、オブジェクトプログラム3を生成するコンパイラプログラム10が実行される。コンパイラプログラム10は、従来よりソース解析部11、最適化部12、コード生成部13から構成されており、本発明では、ソース解析部11に新たに仮引数情報生成手段112と、重複判定手段113を追加して、既存の大きさ値生成手段111と連携させて重複引数に関する値変更エラーをプログラム実行時に検出できるように機能追加したオブェクトプログラム3を生成するようにしたものであり、コンピュータ読み取り可能な記録媒体に格納されている。
【0019】
大きさ値生成手段111は、ソースプログラム2から実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する。仮引数情報生成手段112は、前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する。
【0020】
重複判定手段113は、前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する。
なお、本実施例では、確定された変数が仮引数でない場合、呼出先手続きが使用するすべての仮引数情報を参照して、前記変数が仮引数の変数範囲と重複しているかどうかを判定するオブジェクトコード、確定された変数が他の仮引数の変数範囲と重複していることを判定すると、前記確定された変数の名前、変数が確定された文の行番号、前記確定された変数と結合されている仮引数の名前を含むメッセージを出力するオブジェクトコードも生成するようにしており、仮引数と結合した要素に関する言語仕様のもつ制限事項(イ)、(ロ)のいずれに違反していた場合でもプログラム実行時に文法エラーとして検出ができ、利用者はメッセージを参照するだけで、利用者のプログラムが上記仮引数と結合した要素に関する言語仕様のもつ制限事項に違反した場合、変数を確定した文の行番号、確定された変数の名前、確定された変数と結合されている仮引数の名前が分かり、プログラムのデバッグ効率を高めることが可能となる。
【0021】
図2は、仮引数情報テーブルのデータ形式が示してある。手続きの行番号には、仮引数を使用するサブルーチンなど呼出先手続きのソースリスト上の行番号が格納される。例えば図3で示すプログラム例1の場合、仮引数Aに対する仮引数情報テーブルでは、(4)で示す文の行番号が格納される。変数の名前は、仮引数の変数名が格納される。変数領域の開始位置と終了位置には、仮引数(配列)の変数領域の開始位置アドレスと終了位置アドレスが格納される。図3で示すプログラム例1の場合、変数の名前にはAが、変数領域の開始位置と終了位置には、それぞれARRAY(1)とARRAY(10)の終端のアドレス−1が格納される。
【0022】
また、次の仮引数情報テーブルのアドレスは次の仮引数に対する仮引数情報テーブルのアドレスが格納される。例えば図3で示すプログラム例1の場合、仮引数Aに対する仮引数情報テーブルには、次の仮引数Bに対する仮引数情報テーブルのアドレスが格納される。なお、次の仮引数が存在しなくなると、このフィールドの内容にはバイナリ0など次の仮引数情報テーブルが存在しないことが判別できる値が格納される。
【0023】
図3、および図4は仮引数と結合した要素に関する言語仕様のもつ制限事項(イ)、および(ロ)に違反したソースプログラムの例である。プログラムの詳細については、『従来の技術』の項で記述してあるので省略する。
図5、および図6は、本発明に係る実施の形態1におけるコンパイラプログラムの重複引数エラー検出のためのオブジェクトコード生成の処理の流れを示したフローチャートである。なお、本実施の形態では、本発明を利用者のプログラムに適用する際に以下の処理を共通ルーチンとしてランタイムライブラリで提供するようにしているため、オブジェクトプログラムではこれらのランタイムライブラリを呼び出すように生成されるが、これらの処理を行うオブジェクトコードを生成するように実装してもよい。(a)仮引数情報テーブル初期化処理、(b)仮引数情報テーブル作成処理、(c)変数確定検査処理、(d)仮引数情報テーブル消去処理。
【0024】
図5、および図6に基づき本発明に係る実施の形態1におけるコンパイラプログラムの重複引数エラー検出のためのオブジェクトコード生成の処理の流れについて説明する。なお、本処理は、従来のコンパイラのソース解析部に対して機能追加されるものであって、以下、今回の発明に係る部分についての説明を中心とし、従来技術に関する部分については処理の詳細は省略する。
【0025】
先ず本発明に係る処理を適用するかどうかを従来からサポートしているコンパイル時の検査オプションが指定されたかどうかで判断する(S501)。検査オプションが指定されなかった場合は本発明に係る処理は適用しない。検査オプションが指定された場合は、ソースプログラム内に仮引数が存在するかどうかを判定し、仮引数が存在しない場合は本発明に係る処理は終了する(S502)。
【0026】
仮引数の存在を検出すると、仮引数情報テーブルの初期設定ライブラリを呼び出すオブジェクトコードを生成する(S503)。なお、仮引数情報テーブルの初期設定ライブラリを呼び出す際には、コンパイル対象のソースプログラムが使用する仮引数の全数をパラメタとして渡す。次に仮引数を取り出し処理を行い(S504)、最後の仮引数まで取り出したかどうか判定する(S505)。仮引数の取り出しが終了すると図6の先頭の処理に進む。処理すべき仮引数が存在すると、その仮引数が大きさ引継ぎ配列かどうかを判定する(S506)。
【0027】
処理中の仮引数が大きさ引継ぎ配列でない場合は、S508の処理に進む。仮引数が大きさ引継ぎ配列の場合は、大きさ引継ぎ配列の大きさ値を確定する(S507)。仮引数情報テーブルを作成するために仮引数情報作成ライブラリの呼出のためのオブジェクトコードを生成し(S508)、次の仮引数に対する仮引数情報テーブル作成のためにS504の処理へ戻る。なお、仮引数情報テーブル作成ライブラリを呼び出す際には、仮引数名、仮引数の先頭アドレス、仮引数の配列の大きさ、仮引数を使用する手続の行番号をパラメタとして渡す。
【0028】
仮引数情報テーブルの作成のための処理が完了すると、ソースコードから1文取り出し(S601)、文が終了したかどうかを判定し(S602)、文が終了するまで、取り出した文が手続の呼出文かどうかを判定する(S603)。S602の判定で文が終了処理したことを検出すると、仮引数情報テーブルの消去のために仮引数情報テーブルの消去ライブラリの呼出すオブジェクトコードを生成する(S608)。
【0029】
S603の判定で手続の呼出を検出すると、その手続は配列の結合される引数が存在するかどうかを判定し(S604)、存在する場合には、引数の配列の大きさを計算し(S605)、この文で変数の値を確定するかどうかを判定する(S606)。S603の判定で手続の呼出しが存在しない場合には、S606の判定処理に進む。S606の判定処理で、この文で変数の値を確定していない場合には、次の文の取り出し処理S601に戻る。
【0030】
S606の判定処理で、この文で変数の値を確定している場合には、重複引数エラーをプログラム実行時に検出するために変数確定検査ライブラリを呼出すオブジェクトコードを生成し(S607)、次の文の取り出し処理S601に戻る。なお、変数確定検査ライブラリを呼出す際には、現在処理中の文、言い換えると誤って確定した変数の行番号、変数名、変数の先頭アドレス、S605で求めた確定した変数の配列の大きさをパラメタとして渡すことにより、重複引数に関する文法エラーをプログラム実行時に検出し、プログラムのデバッグ効率を高めることが可能となる。
【0031】
以下、図7、図8、図9、図10に基づき本発明を適用したコンパイラが生成するオブジェクトプログラムが呼び出すランタイムライブラリの処理について説明する。図7は、仮引数情報テーブルの初期化設定ライブラリの処理の流れを示すフローチャートである。このランタイムライブラリが呼び出される際に、パラメタとして処理対象のプログラムが使用する仮引数の数が渡されるため、この数に基づき仮引数情報テーブル領域を獲得し、テーブル領域内を初期化し、先頭仮引数情報テーブルのから順に次の仮引数情報テーブルへのリンクを張り、先頭仮引数情報テーブルのアドレスを記憶領域に記憶する(S701)。なお、最後の仮引数情報テーブルの次の仮引数情報テーブルのアドレスには、バイナリ0を設定し、最後であることを判定出来るようにする。
【0032】
図8は、仮引数情報テーブル作成ライブラリの処理の流れを示すフローチャートである。本ライブラリは、呼び出される際に指定されるパラメタに基づき、図2で示す仮引数情報テーブルを作成する(S801)。なお、本実施の形態では、パラメタとして仮引数の先頭アドレスと、配列の大きさが渡されるため、仮引数の先頭アドレスに(配列の大きさ−1)を加算して、仮引数の終了アドレスとする。
【0033】
また、仮引数情報テーブルのアドレスは、初めて仮引数情報テーブル作成ライブラリが呼び出された場合は、仮引数情報テーブルの初期化設定ライブラリが記憶したアドレスをカレントの仮引数情報テーブルアドレスとして記憶する。本ライブラリの処理が完了すると、次の仮引数情報テーブルの処理のために記憶しておいたカレントの仮引数情報テーブルアドレスを更新する。
【0034】
図9は、変数確定検査ライブラリの処理の流れを示すフローチャートである。先ず、仮引数情報テーブルの初期化設定ライブラリで記憶した仮引数情報テーブルの先頭アドレスから順に仮引数情報テーブルを取り出す(S901)。次の仮引数情報テーブルのアドレスを参照し(S902)、すべての仮引数情報テーブルの処理が完了すると本ライブラリの処理は終了する。この仮引数情報テーブルに格納されている変数の名前は、値を確定した変数の名前と同じかどうか判定する(S904)。同じであれば、重複引数に関する文法エラーとはならないため次の仮引数情報テーブルの取り出し処理S901に戻る。
【0035】
異なる場合、値を確定した変数は、この仮引数情報テーブルに格納されている変数の開始位置と終了位置で示されるアドレスの範囲であるかどうか判定し(S904)、範囲外であれば重複引数に関する文法エラーとはならないため、処理を終了する。値を確定した変数が仮引数情報テーブルで示される変数の範囲と重複していると、重複引数に関する文法エラーとなるため、誤って確定した変数の行番号、変数名、誤って確定した変数と結合されている仮引数の名前、手続の行番号をエラーメッセージとともに出力する(S905)。
【0036】
図10は、仮引数情報テーブルの消去ライブラリの処理を示すフローチャートである。本ライブラリは、仮引数情報テーブルの初期化設定ライブラリの処理で確保した仮引数情報テーブル領域の消去を行う。仮引数情報テーブルの初期化設定ライブラリの処理で記憶した仮引数情報テーブルの先頭アドレス、およびコンパイル対象のプログラムが使用する仮引数の数に基づき仮引数情報テーブル領域を解放することにより仮引数情報テーブルを消去する(S1001)。
【0037】
(付記1) ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
してコンピュータを機能させるコンパイラプログラム。
【0038】
(付記2) 前記重複判定手段は、確定された変数が仮引数でない場合、前記呼出先手続きが使用するすべての仮引数情報を参照して、前記変数が仮引数の変数範囲と重複しているかどうかを判定するオブジェクトコードを生成する、付記1記載のコンパイラプログラム。
(付記3) 前記重複判定手段は、確定された変数が他の仮引数の変数範囲と重複していることを判定すると、前記確定された変数の名前、変数が確定された文の行番号、前記確定された変数と結合されている仮引数の名前を含むメッセージを出力するオブジェクトコードを生成する、付記1、または付記2記載のコンパイラプログラム。
【0039】
(付記4) ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
してコンピュータを機能させるコンパイラプログラムを記録したコンピュータ読み取り可能な記録媒体。
【0040】
(付記5) ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
を有することを特徴とするコンパイラ装置。
【0041】
(付記6) 重複引数に関する文法エラーをプログラム実行時に検出するオブジェクトプログラムを生成するコンパイル方法であって、
ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成するステップと、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成するステップと、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成するステップと
を有することを特徴とするコンパイル方法。
【0042】
【発明の効果】
重複引数に関する文法エラーをプログラム実行時に検出し、プログラムのデバッグ効率を高めることが可能となる。
【図面の簡単な説明】
【図1】本発明の実施の形態1の全体構成図
【図2】仮引数情報テーブル
【図3】プログラム例1
【図4】プログラム例2
【図5】本発明に係る実施の形態1における重複引数エラー検出のためのコード生成処理の流れを示すフローチャートその1
【図6】本発明に係る実施の形態1における重複引数エラー検出のためのコード生成処理の流れを示すフローチャートその2
【図7】本発明に係る実施の形態1における仮引数情報テーブルの初期設定ライブラリの処理の流れを示すフローチャート
【図8】本発明に係る実施の形態1における仮引数情報テーブル作成ライブラリの処理の流れを示すフローチャート
【図9】本発明に係る実施の形態1における変数確定検査ライブラリの処理の流れを示すフローチャート
【図10】本発明に係る実施の形態1における仮引数情報テーブルの消去ライブラリの処理の流れを示すフローチャート
【符号の説明】
1 コンパイラ装置
2 ソースプログラム
3 オブジェクトプログラム
10 コンパイラプログラム
11 ソース解析部
12 最適化部
13 コード生成部
111 大きさ値生成手段
112 仮引数情報生成手段
113 重複判定手段
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a compiler that generates an object program that can be detected at the time of program execution when a program described in a computer language having a specification such as Fortran or C language that has a restriction on an element coupled to a dummy argument exists. In particular, the present invention relates to a technique for detecting a syntax error related to a duplicate argument in cooperation with a runtime library.
[0002]
[Prior art]
The above-mentioned restrictions of the language specification regarding the element combined with the dummy argument indicate the following.
(B) If actual arguments combined with two different formal arguments of the same procedure are overlapped and combined, the overlapped part must not be determined during the execution of the procedure.
(B) A variable of an actual argument combined with a dummy argument in a procedure must not be determined during execution of the procedure except through a dummy argument.
[0003]
Hereinafter, the above-mentioned restrictions will be specifically described with reference to FIGS.
FIG. 3 shows an example of a source program described in Fortran related to the restriction (a). In the statement (2), when calling the subroutine SUB1, the first argument is combined with A (1), A (2),..., A (10), and the second argument is A (5), , A (6),..., A (10). Statement (5) is an array declaration of A, which is the first argument of subroutine SUB1. A is a one-dimensional array, and * is specified as the upper limit of the number of elements, so that the size of the array is inherited from the size of the array at the call source. Therefore, A (1), A (2), ..., A (10) are combined with the actual arguments ARRAY (1), ARRAY (2), ..., ARRAY (10).
[0004]
Statement (6) is an array declaration of B, which is the second argument of subroutine SUB1. Similarly to A, B (1), B (2),... B (6) is combined with actual arguments ARRAY (5), ARRAY (6),. ARRAY (5), ARRAY (6),..., ARRAY (10) are overlapped by two different formal parameters A and B of the same procedure (subroutine SUB1), and are therefore determined during execution of the procedure. should not be done. In other words, A (5), A (6),... A (10), and B (1), B (2),. In other words, sentence (8) and sentence (9) are grammatically incorrect descriptions.
[0005]
FIG. 4 shows an example of a source program described in Fortran related to the restriction (b). Statement (2) indicates that the argument is combined with A (5), A (6), and A (7) because the dummy argument is declared as A (3) when calling the subroutine SUB2. I have. Statement (5) is an array declaration of A, which is an argument of subroutine SUB2. Since the calling procedure and the called procedure (subroutine SUB2) are in a parent-child relationship, the ARRAY can be shared by the calling procedure and the called procedure.
[0006]
However, the variables of the actual arguments (ARRAY (5), ARRAY (6), ARRAY (7)) combined with the dummy argument A in the procedure (subroutine SUB2) due to the restriction in (b) above during execution of the procedure It must not be determined through a parameter other than A. In other words, ARRAY (1), ARRAY (2), ARRAY (3), ARRAY (4), ARRAY (8), ARRAY (9), ARRAY (10), A (1), A (2), A ( In 3), the value can be determined from the subroutine SUB2, and since ARRAY (5), ARRAY (6), and ARRAY (7) can be determined only through A, the sentence (7) is grammatically incorrect. It is a description.
[0007]
However, even if there is an overlap between an actual argument combined with two different dummy arguments, merely referring to the value instead of changing the value does not violate the above restriction. In addition, another procedure may be called from the called procedure, and its value may be determined there, or the compilation unit may be different between the calling procedure and the called procedure. Cannot be all grammatical errors at compile time.
[0008]
In the “Compiler device” described in Japanese Patent Publication No. 2502128, the compiler determines whether there is a plurality of arguments when a source program is translated (compiled) and a program includes a call statement that refers to another procedure. If there are multiple arguments, further check whether or not those areas may overlap, and if there is a possibility that the areas may overlap, the compiler generates an object that performs the following processing, A technique is disclosed that detects a program that violates the restriction (a) of the language specification relating to an element coupled with a dummy argument as a syntax error at the time of execution, and makes it possible to easily debug the program.
(A) Check the size of the area of each actual argument and dynamically secure a new area of that size.
(B) Copy the contents of the corresponding argument into each dynamically secured area.
(C) The designated processing procedure is called with the dynamically secured area as an argument.
(D) Upon returning from the called processing procedure, a comparison is made between the contents of the areas passed to the called processing procedure to determine whether or not there is a change in the value of the part where the areas overlap.
(E) When there is a change in the value of the overlapping portion, an error message is output.
[0009]
[Problems to be solved by the invention]
However, in the "compiler device" described in Japanese Patent No. 2502128, it is impossible to detect a program at the time of execution that violates the restriction (b) of the language specification relating to the element coupled with the dummy argument. In addition, it is possible to determine that a program violated the restrictions (a) of the language specification for elements combined with dummy arguments, but when returning from the procedure, where in the procedure the restriction It was unknown if he committed the attack.
[0010]
Furthermore, for the actual argument, a new area is dynamically allocated, the contents of the argument are copied to the allocated area, and when returning from the called processing procedure, the contents of the area passed to the called processing procedure are copied. In some cases, it is necessary to copy the arguments for comparison. Therefore, in a process in which a large array is used as an argument, a large amount of memory area is required, and an extremely long execution time is required for dynamically securing and copying the memory area. In particular, in the case where a procedure call having a large array as an argument exists in a DO loop, the conventional technique takes too much execution time and may not be practically applicable.
[0011]
SUMMARY OF THE INVENTION The present invention has been proposed in view of the above circumstances, and has as its object to detect a syntax error relating to a duplicate argument at the time of program execution, and to improve the debugging efficiency of the program.
[0012]
[Means for Solving the Problems]
FIG. 1 shows an overall configuration diagram of Embodiment 1 of the present invention. The compiler program 10 of the present invention uses the source program 2 created by a user using a computer as an input, and newly adds a formal parameter information generation unit 112 and a duplication determination unit 113 to the source analysis unit 11 of the conventional compiler program. In addition, an object program 3 having a function added so that a value change error relating to a duplicate argument can be detected at the time of program execution in cooperation with the existing size value generating means 111.
[0013]
The size value generation means 111 calculates the size value of the array of actual arguments from the source program 2 and converts the size of the array of actual arguments from the calling procedure to the called procedure. Generate. Formal parameter information generating means 112, for all formal parameters used by the called procedure, if the formal parameter is an assumed-size array, converts the formal parameter to an assumed-size array from the size value of the actual argument. If not, a process of calculating a range of a variable as a formal parameter from the size of the formal parameter array, and creating formal parameter information including identification information of the called procedure, a variable name, and information indicating the location of the array. Generate object code that performs When the value of the variable is determined in the called procedure, if the determined variable is a dummy argument, the duplication determining means 113 determines that the dummy argument of the other formal parameter other than the formal parameter used by the called procedure is used. Referring to the information, an object code for determining whether or not it overlaps with the variable range of another dummy argument is generated.
[0014]
When the determined variable is a formal parameter, the object program 3 translated in this way generates an object code for determining whether or not the variable range overlaps with the variable range of another formal parameter. When converted to an executable program, if the restriction (a) of the language specification for the element combined with the dummy argument is violated, a new area is dynamically allocated for the actual argument. Even when copying the contents of the argument to the area or comparing the contents of the area passed to the called processing procedure when returning from the called processing procedure, a syntax error occurs during program execution without copying the argument. It becomes possible to detect.
[0015]
Note that in order for the magnitude value generating means to pass the magnitude value of the array of actual arguments from the calling procedure to the called procedure, it is necessary to include the parameter in the parameter passed from the calling procedure to the called procedure. Alternatively, the program may be stored in a control table for controlling the caller program, and the callee program may be implemented so as to be extracted from the control table.
[0016]
If the determined variable is not a dummy argument, the duplication determination means 113 refers to all the dummy argument information used by the called procedure and determines whether the variable overlaps the variable range of the dummy argument. When the object code is generated, if the restriction (b) of the language specification regarding the element combined with the dummy argument is violated, it can be detected as a syntax error when executing the program.
[0017]
Further, when the duplication determination means 113 determines that the determined variable overlaps with the variable range of another formal argument, the name of the determined variable, the line number of the statement in which the variable is determined, Generates an object code that outputs a message containing the name of the formal parameter associated with the specified variable, and the user only needs to refer to the message, and the user's program can use the language specification If you violate the restrictions, you can know the line number of the statement that fixed the variable, the name of the fixed variable, and the name of the formal parameter that is connected to the fixed variable, and improve the debugging efficiency of the program. Become.
[0018]
BEST MODE FOR CARRYING OUT THE INVENTION
FIG. 1 shows an overall configuration diagram of Embodiment 1 of the present invention. In the compiler device 1, a compiler program 10 for generating an object program 3 is executed with a source program 2 created by a user as an input. The compiler program 10 conventionally includes a source analyzing unit 11, an optimizing unit 12, and a code generating unit 13. In the present invention, the source analyzing unit 11 newly includes a dummy argument information generating unit 112 and a duplication determining unit 113. Is added to generate an object program 3 having a function added so that a value change error relating to a duplicate argument can be detected at the time of program execution in cooperation with the existing size value generating means 111. It is stored on a possible recording medium.
[0019]
The size value generation means 111 calculates the size value of the array of actual arguments from the source program 2 and converts the size of the array of actual arguments from the calling procedure to the called procedure. Generate. Formal parameter information generating means 112, for all formal parameters used by the called procedure, if the formal parameter is an assumed-size array, converts the formal parameter to an assumed-size array from the size value of the actual argument. If not, a process of calculating a range of a variable as a formal parameter from the size of the formal parameter array, and creating formal parameter information including identification information of the called procedure, a variable name, and information indicating the location of the array. Generate object code that performs
[0020]
When the value of the variable is determined in the called procedure, if the determined variable is a dummy argument, the duplication determining means 113 determines that the dummy argument of the other formal parameter other than the formal parameter used by the called procedure is used. Referring to the information, an object code for determining whether or not it overlaps with the variable range of another dummy argument is generated.
In this embodiment, if the determined variable is not a dummy argument, it is determined whether the variable overlaps the variable range of the dummy argument by referring to all the dummy argument information used by the called procedure. When it is determined that the object code and the determined variable overlap with the variable range of the other formal parameter, the name of the determined variable, the line number of the statement in which the variable is determined, and the connection with the determined variable Object code that outputs a message containing the name of the formal parameter is generated, which violates any of the restrictions (a) and (b) of the language specification for the element combined with the formal parameter Even in this case, it can be detected as a syntax error at the time of program execution, and the user only needs to refer to the message, and the user's program has the language specifications for the elements combined with the formal parameters. If you violate the matter, the line number of the statement that was to confirm the variable, the name of the defined variables, find the name of the formal argument that has been combined with the determined variable, it is possible to improve the debugging efficiency of the program.
[0021]
FIG. 2 shows the data format of the formal argument information table. The line number of the procedure stores the line number on the source list of the called procedure such as a subroutine using a dummy argument. For example, in the case of the program example 1 shown in FIG. 3, the line number of the sentence indicated by (4) is stored in the formal argument information table for the formal argument A. For the variable name, the variable name of the dummy argument is stored. The start position and the end position of the variable region of the temporary argument (array) are stored in the start position and the end position of the variable region, respectively. In the case of the program example 1 shown in FIG. 3, A is stored in the variable name, and the end address -1 of ARRAY (1) and ARRAY (10) is stored in the start position and the end position of the variable area, respectively.
[0022]
The address of the next formal argument information table stores the address of the formal argument information table for the next formal argument. For example, in the case of the program example 1 shown in FIG. 3, the address of the formal argument information table for the next formal argument B is stored in the formal argument information table for the formal argument A. When the next formal argument no longer exists, the value of this field stores a value, such as binary 0, for determining that the next formal argument information table does not exist.
[0023]
FIGS. 3 and 4 show examples of source programs that violate the restrictions (a) and (b) of the language specification relating to elements combined with dummy arguments. The details of the program have been described in the section of "Prior Art", and will not be described.
FIGS. 5 and 6 are flowcharts showing the flow of processing of object code generation for detecting duplicate argument errors in a compiler program according to the first embodiment of the present invention. In the present embodiment, when the present invention is applied to a user program, the following processing is provided as a common routine in a runtime library. Therefore, an object program is generated so as to call these runtime libraries. However, it may be implemented to generate an object code for performing these processes. (A) Formal argument information table initialization processing, (b) Formal argument information table creation processing, (c) Variable confirmation inspection processing, and (d) Formal argument information table deletion processing.
[0024]
A flow of a process of generating an object code for detecting a duplicate argument error of a compiler program according to the first embodiment of the present invention will be described with reference to FIGS. This processing is added to the function of the source analysis unit of the conventional compiler. Hereinafter, the description of the parts related to the present invention will be centered, and the details of the processing related to the related art will be described in detail. Omitted.
[0025]
First, it is determined whether or not the processing according to the present invention is applied, based on whether or not a conventionally supported inspection option at the time of compilation is specified (S501). When the inspection option is not specified, the processing according to the present invention is not applied. If the check option is specified, it is determined whether or not a dummy argument exists in the source program. If no dummy argument exists, the process according to the present invention ends (S502).
[0026]
When the existence of the formal parameter is detected, an object code for calling the initialization library of the formal parameter information table is generated (S503). When calling the initialization library of the formal parameter information table, the total number of formal parameters used by the source program to be compiled is passed as a parameter. Next, a formal argument is extracted (S504), and it is determined whether or not the last formal argument has been extracted (S505). When the extraction of the formal parameter is completed, the process proceeds to the first process in FIG. If there is a dummy argument to be processed, it is determined whether the dummy argument is an assumed-size array (S506).
[0027]
If the formal parameter being processed is not the assumed size array, the process proceeds to S508. If the dummy argument is an assumed-size array, the size value of the assumed-size array is determined (S507). An object code for calling the formal parameter information creation library is created to create the formal parameter information table (S508), and the process returns to S504 to create the formal parameter information table for the next formal parameter. When calling the formal parameter information table creation library, the formal parameter name, the formal parameter start address, the size of the formal parameter array, and the line number of the procedure using the formal parameter are passed as parameters.
[0028]
When the processing for creating the formal argument information table is completed, one sentence is extracted from the source code (S601), and it is determined whether or not the sentence is terminated (S602). It is determined whether the sentence is a sentence (S603). If it is determined in S602 that the statement has been completed, the object code for calling the library for deleting the temporary argument information table is generated to delete the temporary argument information table (S608).
[0029]
When the procedure call is detected in the determination of S603, the procedure determines whether there is an argument to which the array is to be combined (S604), and if so, calculates the size of the array of the argument (S605). Then, it is determined whether the value of the variable is determined by this statement (S606). If it is determined in step S603 that there is no procedure call, the process advances to step S606. In the determination processing of S606, if the value of the variable has not been determined in this statement, the process returns to the next statement fetch processing S601.
[0030]
If the value of the variable is determined by this statement in the determination processing of S606, an object code for calling the variable confirmation library is detected to detect a duplicate argument error at the time of executing the program (S607). It returns to the extraction processing S601. When calling the variable confirmation test library, the statement currently being processed, in other words, the line number, variable name, variable start address of the variable that was erroneously determined, and the size of the array of the determined variables determined in S605 are determined. By passing it as a parameter, it is possible to detect a syntax error relating to a duplicate argument at the time of program execution, and to improve the debugging efficiency of the program.
[0031]
Hereinafter, processing of a runtime library called by an object program generated by a compiler to which the present invention is applied will be described with reference to FIGS. 7, 8, 9, and 10. FIG. 7 is a flowchart showing the flow of the process of the initialization setting library of the temporary argument information table. When this runtime library is called, the number of formal parameters used by the program to be processed is passed as a parameter, so a formal parameter information table area is acquired based on this number, the table area is initialized, and the first formal parameter is set. The link to the next formal argument information table is established in order from the information table, and the address of the first formal argument information table is stored in the storage area (S701). It should be noted that binary 0 is set in the address of the formal parameter information table next to the last formal parameter information table so that it can be determined that the address is the last.
[0032]
FIG. 8 is a flowchart showing the flow of the processing of the temporary argument information table creation library. This library creates the formal argument information table shown in FIG. 2 based on the parameters specified when it is called (S801). In the present embodiment, since the start address of the dummy argument and the size of the array are passed as parameters, (the array size -1) is added to the start address of the dummy argument, and the end address of the dummy argument is added. And
[0033]
When the temporary argument information table creation library is called for the first time, the address of the temporary argument information table stores the address stored in the initialization setting library of the temporary argument information table as the current temporary argument information table address. When the processing of this library is completed, the current formal parameter information table address stored for the processing of the next formal parameter information table is updated.
[0034]
FIG. 9 is a flowchart showing the flow of processing of the variable confirmation test library. First, the temporary argument information table is extracted sequentially from the head address of the temporary argument information table stored in the initialization setting library of the temporary argument information table (S901). The address of the next formal argument information table is referred to (S902), and when the processing of all the formal argument information tables is completed, the processing of this library ends. It is determined whether the name of the variable stored in the formal argument information table is the same as the name of the variable whose value has been determined (S904). If they are the same, there is no grammatical error related to the duplicate argument, and the process returns to the next formal argument information table extraction processing S901.
[0035]
If not, it is determined whether the variable whose value has been determined falls within the range of addresses indicated by the start position and the end position of the variable stored in the temporary argument information table (S904). Since this does not result in a grammatical error regarding, the process ends. If the variable whose value has been determined overlaps with the range of the variable indicated in the formal parameter information table, a syntax error will occur regarding the duplicate argument, and the line number, variable name, and variable The name of the linked formal argument and the line number of the procedure are output together with an error message (S905).
[0036]
FIG. 10 is a flowchart showing the processing of the erase library of the temporary argument information table. This library deletes the formal parameter information table area secured by the processing of the formal parameter information table initialization setting library. Initialization of the formal parameter information table The formal parameter information table is released by releasing the formal parameter information table area based on the start address of the formal parameter information table stored in the processing of the library and the number of formal parameters used by the program to be compiled. Is erased (S1001).
[0037]
(Supplementary Note 1) A size value for generating an object code for performing a process of calculating a size value of an array of actual arguments from a source program and transferring the size value of the array of actual arguments from a calling procedure to a called procedure Generating means;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, Duplication determination means for generating an object code for determining whether the variable range overlaps with the variable range of another formal parameter;
Compiler program that causes the computer to function.
[0038]
(Supplementary Note 2) When the determined variable is not a dummy argument, the duplication determination means refers to all the dummy argument information used by the called procedure and determines whether the variable overlaps the variable range of the dummy argument. 2. The compiler program according to claim 1, wherein the compiler program generates an object code for determining whether the object code is valid or not.
(Supplementary Note 3) When the duplication determining means determines that the determined variable overlaps with the variable range of another formal parameter, the name of the determined variable, the line number of the statement in which the variable is determined, 3. The compiler program according to claim 1 or 2, wherein the compiler program generates an object code for outputting a message including a name of the formal parameter combined with the determined variable.
[0039]
(Supplementary Note 4) A size value for generating an object code for performing a process of calculating a size value of an array of actual arguments from a source program and transferring the size value of the array of actual arguments from a calling procedure to a called procedure Generating means;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, Duplication determination means for generating an object code for determining whether the variable range overlaps with the variable range of another formal parameter;
A computer-readable recording medium on which a compiler program for causing a computer to function is recorded.
[0040]
(Supplementary Note 5) A size value for generating an object code for performing a process of calculating a size value of an array of actual arguments from a source program and transferring the size value of the array of actual arguments from a calling procedure to a called procedure Generating means;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, Duplication determination means for generating an object code for determining whether the variable range overlaps with the variable range of another formal parameter;
A compiler device comprising:
[0041]
(Supplementary Note 6) A compilation method for generating an object program that detects a syntax error related to a duplicate argument at the time of program execution,
Calculating the size of the array of actual arguments from the source program, and generating object code for performing a process of passing the size of the array of actual arguments from the calling procedure to the called procedure;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. Generating an object code for performing a process of calculating a range of a variable as a dummy argument from the size and creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array; When,
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, Generating object code for determining whether the variable range overlaps with the variable range of another formal parameter; and
A compiling method, comprising:
[0042]
【The invention's effect】
A syntax error relating to a duplicate argument is detected at the time of program execution, so that the debugging efficiency of the program can be improved.
[Brief description of the drawings]
FIG. 1 is an overall configuration diagram of a first embodiment of the present invention.
FIG. 2 is a formal argument information table.
FIG. 3 is a program example 1
FIG. 4 is a program example 2
FIG. 5 is a flowchart showing a flow of a code generation process for detecting a duplicate argument error according to the first embodiment of the present invention;
FIG. 6 is a flowchart illustrating a flow of a code generation process for detecting a duplicate argument error according to the first embodiment of the present invention;
FIG. 7 is a flowchart showing a flow of processing of an initialization library of a formal argument information table according to the first embodiment of the present invention;
FIG. 8 is a flowchart showing a processing flow of a formal argument information table creation library according to the first embodiment of the present invention;
FIG. 9 is a flowchart showing a flow of processing of a variable confirmation test library according to the first embodiment of the present invention;
FIG. 10 is a flowchart showing the flow of processing of a temporary library information table deletion library according to the first embodiment of the present invention;
[Explanation of symbols]
1 Compiler device
2 Source program
3 Object program
10 Compiler program
11 Source analysis unit
12 Optimizer
13 Code generator
111 Size value generation means
112 Formal argument information generating means
113 Duplication judgment means

Claims (5)

ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
してコンピュータを機能させるコンパイラプログラム。
Size value generating means for calculating a size value of an array of actual arguments from a source program and generating object code for performing a process of passing the size value of the array of actual arguments from a calling procedure to a called procedure;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, A compiler program for causing a computer to function as duplication determination means for generating an object code for determining whether or not it overlaps with a variable range of another dummy argument.
前記重複判定手段は、確定された変数が仮引数でない場合、前記呼出先手続きが使用するすべての仮引数情報を参照して、前記変数が仮引数の変数範囲と重複しているかどうかを判定するオブジェクトコードを生成する、請求項1記載のコンパイラプログラム。If the determined variable is not a dummy argument, the duplication determination means determines whether the variable overlaps the variable range of the dummy argument by referring to all the dummy argument information used by the called procedure. 2. The compiler program according to claim 1, which generates an object code. 前記重複判定手段は、確定された変数が他の仮引数の変数範囲と重複していることを判定すると、前記確定された変数の名前、変数が確定された文の行番号、前記確定された変数と結合されている仮引数の名前を含むメッセージを出力するオブジェクトコードを生成する、請求項1、または請求項2記載のコンパイラプログラム。When the duplication determination means determines that the determined variable overlaps with the variable range of another formal argument, the name of the determined variable, the line number of the sentence in which the variable is determined, 3. The compiler program according to claim 1, wherein the compiler program generates an object code that outputs a message including a name of a dummy argument combined with a variable. ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
してコンピュータを機能させるコンパイラプログラムを記録したコンピュータ読み取り可能な記録媒体。
Size value generating means for calculating a size value of an array of actual arguments from a source program and generating object code for performing a process of passing the size value of the array of actual arguments from a calling procedure to a called procedure;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, A computer-readable recording medium on which a compiler program for causing a computer to function as duplication determination means for generating an object code for determining whether or not it overlaps with a variable range of another formal parameter is recorded.
ソースプログラムから実引数の配列の大きさ値を算出し、呼出元手続きから呼出先手続きに前記実引数の配列の大きさ値を受け渡す処理を行うオブジェクトコードを生成する大きさ値生成手段と、
前記呼出先手続きが使用するすべての仮引数に対して、仮引数が大きさ引継ぎ配列の場合には前記実引数の大きさ値から、仮引数が大きさ引継ぎ配列でない場合は仮引数の配列の大きさから、仮引数としての変数の範囲を算出し、前記呼出先手続きの識別情報、変数名、配列の存在位置を表す情報を含む仮引数情報を作成する処理を行うオブジェクトコードを生成する仮引数情報生成手段と、
前記呼出先手続きにおいて変数の値が確定されると、確定された変数が仮引数である場合、前記呼出先手続きが使用する前記仮引数を除く他の仮引数の仮引数情報を参照して、他の仮引数の変数範囲と重複しているかどうかを判定処理するオブジェクトコードを生成する重複判定手段と
を有することを特徴とするコンパイラ装置。
Size value generating means for calculating a size value of an array of actual arguments from a source program and generating object code for performing a process of passing the size value of the array of actual arguments from a calling procedure to a called procedure;
For all dummy arguments used by the called procedure, the size of the actual argument is used when the dummy argument is an assumed size array, and the array of the dummy argument is used when the dummy argument is not an assumed size array. From the size, a range of a variable as a dummy argument is calculated, and a temporary object code is generated to perform processing for creating dummy argument information including identification information of the called procedure, a variable name, and information indicating the location of an array. Means for generating argument information;
When the value of the variable is determined in the called procedure, if the determined variable is a formal parameter, by referring to the formal parameter information of other formal parameters except the formal parameter used by the called procedure, A compiler device comprising: a duplication determining means for generating an object code for determining whether the variable range overlaps with a variable range of another formal parameter.
JP2002173218A 2002-06-13 2002-06-13 Compiler program having dummy argument duplication violation detection function, recording medium thereof, and compiler apparatus Expired - Fee Related JP4228602B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002173218A JP4228602B2 (en) 2002-06-13 2002-06-13 Compiler program having dummy argument duplication violation detection function, recording medium thereof, and compiler apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2002173218A JP4228602B2 (en) 2002-06-13 2002-06-13 Compiler program having dummy argument duplication violation detection function, recording medium thereof, and compiler apparatus

Publications (2)

Publication Number Publication Date
JP2004021429A true JP2004021429A (en) 2004-01-22
JP4228602B2 JP4228602B2 (en) 2009-02-25

Family

ID=31172569

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002173218A Expired - Fee Related JP4228602B2 (en) 2002-06-13 2002-06-13 Compiler program having dummy argument duplication violation detection function, recording medium thereof, and compiler apparatus

Country Status (1)

Country Link
JP (1) JP4228602B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006172206A (en) * 2004-12-16 2006-06-29 Canon Inc Information processor and control method therefor, computer program and storage medium
US9336114B2 (en) 2012-07-24 2016-05-10 Samsung Electronics Co., Ltd. Apparatus and method for detecting error

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006172206A (en) * 2004-12-16 2006-06-29 Canon Inc Information processor and control method therefor, computer program and storage medium
JP4681868B2 (en) * 2004-12-16 2011-05-11 キヤノン株式会社 Information processing apparatus and control method therefor, computer program, and storage medium
US9336114B2 (en) 2012-07-24 2016-05-10 Samsung Electronics Co., Ltd. Apparatus and method for detecting error

Also Published As

Publication number Publication date
JP4228602B2 (en) 2009-02-25

Similar Documents

Publication Publication Date Title
US7398516B2 (en) Method and system for detecting race condition vulnerabilities in source code
Memarian et al. Exploring C semantics and pointer provenance
AU2004232058B2 (en) Method and system for detecting vulnerabilities in source code
US7308680B2 (en) Intermediate representation for multiple exception handling models
US8719802B2 (en) Interprocedural exception method
JP4057938B2 (en) Compiler, compiling method, and program development tool
US20050246693A1 (en) Automated safe secure techniques for eliminating undefined behavior in computer software
Stallman Using the gnu compiler collection
US8122440B1 (en) Method and apparatus for enumerating external program code dependencies
Noonan et al. Polymorphic type inference for machine code
JPH05257709A (en) Parallelism discriminating method and parallelism supporting method using the same
Amme et al. Data dependence analysis of assembly code
US10423397B2 (en) Systems and/or methods for type inference from machine code
US7036111B2 (en) Code verification system and method
JP4041248B2 (en) COMPILER DEVICE, COMPUTER-READABLE RECORDING MEDIUM CONTAINING COMPILING PROGRAM, AND COMPILING METHOD
JP2002024029A (en) Compiler, compiling method and computer readable recording medium with compile program recorded thereon
Chen et al. A refined decompiler to generate C code with high readability
JP4026940B2 (en) Program converter
Chen et al. A provably sound TAL for back-end optimization
US20070142929A1 (en) Specifying optional and default values for method parameters
JP6651977B2 (en) Information processing apparatus, compiling method, and compiling program
JP2008276735A (en) Program code converter and program code conversion method
JP2001325109A (en) Method for optimizing loop and complier
JP4228602B2 (en) Compiler program having dummy argument duplication violation detection function, recording medium thereof, and compiler apparatus
Huang et al. Catching and identifying bugs in register allocation

Legal Events

Date Code Title Description
RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20040610

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20040610

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20041124

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20071016

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20071206

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080527

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080714

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20081111

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20081124

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111212

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111212

Year of fee payment: 3

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121212

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121212

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131212

Year of fee payment: 5

LAPS Cancellation because of no payment of annual fees