JPS6398031A - Check system for suffix value - Google Patents

Check system for suffix value

Info

Publication number
JPS6398031A
JPS6398031A JP61243625A JP24362586A JPS6398031A JP S6398031 A JPS6398031 A JP S6398031A JP 61243625 A JP61243625 A JP 61243625A JP 24362586 A JP24362586 A JP 24362586A JP S6398031 A JPS6398031 A JP S6398031A
Authority
JP
Japan
Prior art keywords
array
subscript
source program
subscript expression
value
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
JP61243625A
Other languages
Japanese (ja)
Inventor
Tomoko Komatsu
小松 智子
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.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP61243625A priority Critical patent/JPS6398031A/en
Publication of JPS6398031A publication Critical patent/JPS6398031A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To easily check the propriety of a suffix value independently of the hardware by inserting a suffix check sentence produced by an arrangement reference means just before the execution sentence. CONSTITUTION:A source program 11 described by a high class language is inputted to a source program producing means 1 for suffix value checking. Then the producing means 1 uses a statement processing means 1a, an arrangement data storage table 1b, and an arrangement element reference processing means 1c to produce a suffix value check program 12, which is inserted just before an execution sentence and outputted. The program 12 is given to a compiler 2, a linker 3 and a program execution means 4 sequentially and a diagnostic message list 15. Thus, the suffix value propriety is checked easily independently of the hardware by referencing the list 15.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は添字式の値検査方式に関し、特に高級言語で記
述された原始プログラムにおける配列要素の各次元ごと
の添字式の不正値を検出するための添字式の値検査方式
に関する。
[Detailed Description of the Invention] [Field of Industrial Application] The present invention relates to a method for checking the value of a subscript expression, and in particular detects invalid values of a subscript expression for each dimension of an array element in a source program written in a high-level language. Concerning a value checking method for subscript expressions.

〔従来の技術〕[Conventional technology]

従来、この種の添字式の値検査方式では、原始プログラ
ム中で参照される配列要素の添字式の値が配列の宣言で
定義された添字式の上限値と下限値との間にあるか否か
の検査は、コンパイラが生成する目的プログラム中にそ
れを検査する命令列を挿入して実行することにより行わ
れていた。
Conventionally, this type of subscript expression value checking method checks whether the value of the subscript expression of an array element referenced in the source program is between the upper and lower limit values of the subscript expression defined in the array declaration. Such inspection is performed by inserting a sequence of instructions for inspection into the target program generated by the compiler and executing it.

このような従来の添字式の値検査方式では、コンパイラ
の目的プログラム生成部において配列要素の参照が目的
プログラムの生成のために配列の先頭番地と配列要素の
相対位置との形に変形されているので、各次元の添字式
の値が配列の宣言で定義された添字式の上限値と下限値
との間にあるか否かの検査を行うのではなく、各次元の
添字式の値から計算される配列要素位置が許される範囲
内にあるか否かの検査が行われていた。
In such conventional value checking methods for subscript expressions, references to array elements are transformed in the target program generation section of the compiler into the form of the starting address of the array and the relative position of the array element in order to generate the target program. Therefore, instead of checking whether the value of the subscript expression of each dimension is between the upper and lower limit values of the subscript expression defined in the array declaration, it is calculated from the value of the subscript expression of each dimension. A check was made to see if the array element position to be used was within the allowed range.

〔発明が解決しようとする問題点〕[Problem that the invention seeks to solve]

上述した従来の添字式の値検査方式では、コンパイラが
配列の配列要素位置を検査する命令列を目的プログラム
中に挿入するようになっているので、本来は原始プログ
ラムに依存する機能であるにもかかわらず、その目的プ
ログラムを実行できるハードウェア毎に配列の配列要素
位置の検査機構を作成する必要があるという欠点がある
In the conventional subscript expression value checking method described above, the compiler inserts into the target program an instruction sequence that checks the array element position of the array, so even though it is a function that originally depends on the source program, Regardless, there is a drawback that it is necessary to create a mechanism for checking the array element position of the array for each piece of hardware that can execute the target program.

また、コンパイラの最適化機能は原始プログラムの解析
結果に依存する部分が多いので、目的プログラム生成時
に挿入した命令列に対しては十分に最適化機能が利用で
きないという欠点がある。
Furthermore, since the optimization function of a compiler largely depends on the analysis results of the source program, there is a drawback that the optimization function cannot be fully utilized for the instruction sequence inserted when the target program is generated.

さらに、配列要素位置が許される範囲内にあるか否かの
検査しか行われず、その範囲の参照を認めると最適化手
法を実施したときに不都合が生じるという欠点がある。
Furthermore, only a check is made to see if the array element position is within a permissible range, and if reference to that range is allowed, problems will arise when an optimization method is implemented.

ここで、従来の添字式の値検査方式で最適化手法を実施
した場合に生じる不都合について具体例を用いて簡単に
説明する。例えば、 というプログラムfi+を実行すると、配列Aへの代入
は次の順序で行われる。
Here, the inconveniences that occur when an optimization method is implemented using the conventional subscript expression value checking method will be briefly explained using a specific example. For example, when the program fi+ is executed, assignments to array A are performed in the following order.

A(1,1)、A(1,2)、A(2,1)、A(2,
2)・・・・・・プログラム+11のA(1,1)およ
びA(1,2)の配列要素の参照は、それぞれ配列Aの
先頭から1番目および10+1番目の要素を参照するこ
とにより行われる。よって、配列Aの1次元目の添字式
の値が配列の宣言で定義された添字式の上限値10と下
限値1との間にあれば、A(1,1)とA(1,2)と
で示される部分に重なりはないことになり、プログラム
filを次に示すプログラム(2)の形に変形すること
ができる。
A(1,1), A(1,2), A(2,1), A(2,
2) ......The array elements of A(1,1) and A(1,2) in Program+11 can be referenced by referring to the 1st and 10+1th elements from the beginning of array A, respectively. be exposed. Therefore, if the value of the subscript expression of the first dimension of array A is between the upper limit value 10 and the lower limit value 1 of the subscript expression defined in the array declaration, A(1,1) and A(1,2 ) and there is no overlap, and the program fil can be transformed into the following program (2).

このプログラム(2)の配列Aへの代入は、次の順序で
行われる。
Assignment to array A in program (2) is performed in the following order.

A(1,1)、A(2,1)、・・・、A(1,2)、
A(2,2)、・・・ところが、N=11としてプログ
ラム(11および(2)を実行すると、配列Aの1次元
目の添字式の値として許されない値11が使われること
になり、プログラム(11および(2)はそれぞれ配列
Aに対して次の順に代入を行うことになる。すなわち、
プログラム+11では、 A(1,1)、A(1,2)、A(2,1)、A(2,
2)、・・・。
A(1,1), A(2,1),..., A(1,2),
A(2,2),...However, if you run the program (11 and (2) with N=11), the value 11, which is not allowed, will be used as the value of the subscript expression for the first dimension of array A. Programs (11 and (2) each make assignments to array A in the following order. That is,
In program +11, A(1,1), A(1,2), A(2,1), A(2,
2),...

A(10,1)、A(10,2)、A(11,1)、A
(11,2)となり、プログラム(2)では、 A(1,1)、A(2,1)、・・・、A(10,1)
、A(11,1)。
A(10,1), A(10,2), A(11,1), A
(11,2), and in program (2), A(1,1), A(2,1), ..., A(10,1)
, A(11,1).

A(1,2>、A(2,2)、・・・、AClo、2)
、A(11,2)となる。
A(1,2>, A(2,2),..., AClo, 2)
, A(11,2).

このとき、A(11,1)は配列Aの先頭から11番目
として求められるので、A(1,2)と同じ位置になり
、A(Ll)で代入される部分とA(r、2)で代入さ
れる部分とに重なりが生じ、プログラム(11とプログ
ラム(2)との実行結果に差が生じる。
At this time, A(11,1) is found as the 11th from the beginning of array A, so it is in the same position as A(1,2), and the part assigned by A(Ll) and A(r,2) An overlap occurs between the portions substituted in , and a difference arises in the execution results of program (11) and program (2).

プログラム11)をプログラム(2)に変形する処理は
自動ベクトル化手法の基本処理であり、配列要素の参照
で各次元の添字式の値が配列の宣言の上限値と下限値と
の間に存在することが保証されないことは最適化の適用
範囲をせばめることになる。
The process of transforming program 11) into program (2) is the basic process of the automatic vectorization method, and by referencing array elements, the value of the subscript expression of each dimension exists between the upper and lower limit values of the array declaration. Not being able to guarantee that the optimization will take place will limit the scope of optimization.

したがって、最適化処理として各次元の添字式の値が正
しく使われていることを前提としてコード生成を行うた
めにも、このような誤りを含んだプログラムに対して各
次元ごとに添字式の値の正当性を検査できないのは不都
合である。
Therefore, in order to generate code on the assumption that the value of the subscript expression of each dimension is used correctly in the optimization process, the value of the subscript expression of each dimension is It is inconvenient that it is not possible to check the validity of

本発明の目的は、上述の点に鑑み、添字式の値の正当性
をハードウェアに依存することなしに容易に検査可能な
添字式の値検査方式を提供することにある。
In view of the above-mentioned points, an object of the present invention is to provide a method for checking the value of a subscript expression that can easily check the validity of the value of a subscript expression without depending on hardware.

C問題点を解決するための手段〕 本発明の添字式の値検査方式は、高級言語で記述された
原始プログラムを入力しこの原始プログラムの中から配
列の宣言を検出して宣言された配列の次元数ならびに各
次元の添字式の上限値および下限値を配列データ格納テ
ーブルに格納する宣言処理手段と、前記原始プログラム
中に現れた配列要素の参照を含む実行文の直前でその配
列要素の各次元の添字式の値が前記配列データ格納テー
ブルに格納された配列の各次元の添字式の上限値と下限
値との間にあるか否かを検査し前記配列要素の各次元の
添字式の値が前記配列データ格納テーブルに格納された
配列の各次元の添字式の上限値と下限値との間にない場
合にその配列要素の参照を含む実行文に対して診断メツ
セージを出力する添字式検査文を作成する配列参照処理
手段と、この配列参照処理手段で作成された添字式検査
文を前記原始プログラムの配列要素の参照を含む実行文
の直前に挿入して添字式検査用原始プログラムを生成す
る添字式検査用原始プログラム生成手段とを有する。
Means for Solving Problem C] The subscript expression value checking method of the present invention inputs a source program written in a high-level language, detects array declarations from this source program, and checks the declared array. a declaration processing means for storing the number of dimensions and the upper and lower limit values of the subscript expressions of each dimension in an array data storage table; It is checked whether the value of the subscript expression of the dimension is between the upper limit value and the lower limit value of the subscript expression of each dimension of the array stored in the array data storage table, and the value of the subscript expression of each dimension of the array element is checked. A subscript expression that outputs a diagnostic message for an executable statement that includes a reference to an array element if the value is not between the upper and lower limit values of the subscript expression for each dimension of the array stored in the array data storage table. An array reference processing means for creating a test statement, and a subscript expression test statement created by the array reference processing means are inserted immediately before an executable statement that includes a reference to an array element in the source program to create a subscript expression test source program. and generating means for generating a subscript expression checking source program.

〔作用〕[Effect]

本発明の添字式の値検査方式では、宣言処理手段が高級
言語で記述された原始プログラムを入力しこの原始プロ
グラムの中から配列の宣言を検出して宣言された配列の
次元数ならびに各次元の添字式の上限値および下限値を
配列データ格納テーブルに格納し、配列参照処理手段が
原始プログラム中に現れた配列要素の参照を含む実行文
の直前でその配列要素の各次元の添字式の値が配列デー
タ格納テーブルに格納された配列の各次元の添字式の上
限値と下限値との間にあるか否かを検査し配列要素の各
次元の添字式の値が配列データ格納テーブルに格納され
た配列の各次元の添字式の上限値と下限値との間にない
場合にその配列要素の参照を含む実行文に対して診断メ
ツセージを出力する添字式検査文を作成し、添字式検査
用原始プログラム生成手段が配列参照処理手段で作成さ
れた添字式検査文を原始プログラムの配列要素の参照を
含む実行文の直前に挿入して添字式検査用原始プログラ
ムを生成する。
In the subscript expression value checking method of the present invention, the declaration processing means inputs a source program written in a high-level language, detects array declarations from this source program, and determines the number of dimensions of the declared array and each dimension. The upper and lower limit values of the subscript expression are stored in the array data storage table, and the array reference processing means stores the value of the subscript expression of each dimension of the array element immediately before an executable statement that includes a reference to the array element that appears in the source program. is between the upper and lower limit values of the subscript expression of each dimension of the array stored in the array data storage table, and the value of the subscript expression of each dimension of the array element is stored in the array data storage table. Create a subscript expression check statement that outputs a diagnostic message for an executable statement that includes a reference to an array element if it is not between the upper and lower limit values of the subscript expression for each dimension of the array. The checking source program generating means generates a subscript type checking source program by inserting the subscript type checking statement created by the array reference processing means immediately before an executable statement including a reference to an array element of the source program.

〔実施例〕〔Example〕

次に、本発明について図面を参照して詳細に説明する。 Next, the present invention will be explained in detail with reference to the drawings.

第1図を参照すると、本発明の一実施例は、高級言語で
記述された原始プログラム11を入力してこの原始プロ
グラム11に配列要素の各次元の添字式の値の範囲を検
査する文(以下、単に添字式検査文と称する)を挿入し
た添字式検査用原始プログラム12を出力する添字式検
査用原始プログラム生成手段lと、添字式検査用原始プ
ログラム12を入力して翻訳しコンパイルユニット13
を出力するコンパイラ2と、コンパイルユニット13を
入力して結合しロードモジエール14を出力するリンカ
3と、ロードモジュール14を実行して診断メツセージ
リスト15を出力するプログラム実行手段4とから構成
されている。
Referring to FIG. 1, one embodiment of the present invention inputs a source program 11 written in a high-level language and adds a statement ( A subscript expression checking source program generating means 1 outputs a subscript expression checking source program 12 into which a subscript expression checking source program 12 (hereinafter simply referred to as a subscript expression checking statement) is inserted, and a compiling unit 13 inputs and translates the subscript expression checking source program 12
, a linker 3 that inputs and combines compile units 13 and outputs a load module 14, and a program execution means 4 that executes the load module 14 and outputs a diagnostic message list 15. There is.

添字式検査用原始プログラム生成手段1は、宣言処理手
段1aと、配列データ格納テーブル1bと、配列要素参
照処理手段ICとを含んで構成されている。
The subscript expression checking source program generation means 1 is configured to include a declaration processing means 1a, an array data storage table 1b, and an array element reference processing means IC.

第2図を参照すると、配列データ格納テーブル1bは、
原始プログラム11中の配列の宣言文を解析して得られ
た配列ごとに配列者9次元数ならびに各次元の添字式の
上限値および下限値を格納するテーブルである。
Referring to FIG. 2, the array data storage table 1b is
This is a table that stores the number of nine dimensions of the array operator and the upper and lower limit values of the subscript expressions of each dimension for each array obtained by analyzing the declaration statement of the array in the source program 11.

第3図を参照すると、添字式検査用原始プログラム生成
手段1における処理は、入力文有無判定ステップ31と
、文人カステップ32と、宣言文判定ステップ33と、
配列参照実行文判定ステップ34と、添字式検査文作成
ステップ35と、配列宣言文判定ステップ36と、配列
データ格納ステップ37と、添字式検査文および入力文
の出力ステップ38とからなる。
Referring to FIG. 3, the processing in the subscript expression checking source program generation means 1 includes an input sentence presence/absence determination step 31, a literate sentence determination step 32, a declarative sentence determination step 33,
It consists of an array reference executable statement determination step 34, a subscript expression check statement creation step 35, an array declaration statement determination step 36, an array data storage step 37, and a subscript expression check statement and input statement output step 38.

なお、配列宣言文判定ステップ36と配列データ格納ス
テップ37とが宣言処理手段1aの処理であり、配列参
照実行文判定ステップ34と添字式検査文作成ステップ
35とが配列要素参照処理手段ICの処理である。
Note that the array declaration statement judgment step 36 and the array data storage step 37 are the processes of the declaration processing means 1a, and the array reference executable statement judgment step 34 and the subscript expression check statement creation step 35 are the processes of the array element reference processing means IC. It is.

次に、このように構成された本実施例の添字式の値検査
方式の動作について第4図および第5図を参照しながら
説明する。
Next, the operation of the subscript expression value checking method of this embodiment configured as described above will be explained with reference to FIGS. 4 and 5.

添字式検査用原始プログラム生成手段1が起動されると
、例えば第4図に示すFORTRANなどの高級言語で
記述された原始プログラム11に入力すべき文があるか
否かがまず調べられる(ステップ31)、いまの場合、
入力すべき文X1があるので文X1が入力される(ステ
ップ32)。次に、入力された文x1が宣言文か否かが
調べられ(ステップ33)、文x1は宣言文なので宣言
処理手段1aの処理に移行する。
When the subscript expression checking source program generation means 1 is activated, it is first checked whether there is a sentence to be input in the source program 11 written in a high-level language such as FORTRAN as shown in FIG. 4 (step 31). ), in this case,
Since there is a sentence X1 to be input, sentence X1 is input (step 32). Next, it is checked whether the inputted sentence x1 is a declarative sentence (step 33), and since the sentence x1 is a declarative sentence, the process shifts to the declaration processing means 1a.

宣言処理手段1aでは、文X1が配列の宣言文であるか
否かが調べられる(ステップ36)0文Xlは配列の宣
言文ではないので、ステップ37をスキップしてステッ
プ38に移行され、文X1が第5図に示すようにそのま
ま出力される。
In the declaration processing means 1a, it is checked whether the statement X1 is an array declaration statement (step 36). Since the 0 sentence X1 is output as is as shown in FIG.

ステップ31に戻り再び入力すべき文があるか否かが調
べられ、文X2があるので文X2が入力され(ステップ
32)、文X2が宣言文か否かが調べられる(ステップ
33)1文X2は宣言文なので、宣言処理手段1aの処
理に移行する。
Returning to step 31, it is checked whether there is a sentence to be input again. Since there is a sentence X2, sentence X2 is input (step 32), and it is checked whether or not sentence X2 is a declarative sentence (step 33) 1 sentence Since X2 is a declaration sentence, the process moves to the declaration processing means 1a.

宣言処理手段1aでは、文X2が配列の宣言文であるか
否かが調べられる(ステップ36)0文X2はA(10
0,100)と8(−1(hlo)との2つの配列を宣
言しているので、次に各配列宣言に基づく配列データが
配列データ格納テーブル1bに格納される(ステップ3
7)、詳しくは、第2図に示すように、配列データ格納
テーブル1bの配列基にはAおよびBが、次元数には2
および1が、1次元目の上限値には100およびlOが
、1次元目の下限値には1および−10が、配列基Aに
対応する2次元口の上限値には100が、配列基Aに対
応する2次元目の下限値には1がそれぞれ格納される0
次に、文X2が、第5図に示すように出力される(ステ
ップ38)。
In the declaration processing means 1a, it is checked whether or not the statement X2 is an array declaration statement (step 36).
Since two arrays, 0,100) and 8(-1(hlo)), are declared, the array data based on each array declaration is stored in the array data storage table 1b (step 3).
7), in detail, as shown in Figure 2, the array bases of the array data storage table 1b are A and B, and the number of dimensions is 2.
and 1, the upper limit of the first dimension is 100 and lO, the lower limit of the first dimension is 1 and -10, the upper limit of the second dimension corresponding to array group A is 100, and the upper limit of array group A is 1 is stored in the lower limit value of the second dimension corresponding to 0.
Next, sentence X2 is output as shown in FIG. 5 (step 38).

このようにして原始プログラム11の文が順次入力され
て文X3が入力されると(ステップ32)、次に文X3
が宣言文か否かが調べられる(ステップ33)0文X3
は宣言文ではないので、配列要素参照処理手段ICの処
理に移行する。
In this way, when the sentences of the source program 11 are input in sequence and the sentence X3 is input (step 32), next the sentence
It is checked whether or not is a declaration statement (step 33) 0 sentence X3
Since is not a declaration statement, the process shifts to the array element reference processing means IC.

配列要素参照処理手段ICでは、まず文X3が配列の参
照を含む実行文か否かが調べられる(ステップ34)0
文X3は配列AおよびBの参照を含む実行文なので、配
列データ格納テーブルlb中から配列AおよびBの配列
基を検索して、配列データ格納テーブルIb中の対応す
る配列Aの1次元目の上限値100と実行文中の配列A
の1次元目の添字式りとを比較するとともに配列データ
格納テーブルlb中の配列Aの1次元目の下限値1と添
字式りとを比較することにより1次元目の添字式りの値
が配列の宣言で定義された上限値と下限値との間にある
か否かを検査する添字式検査文Ylが作成される。また
、実行文中の配列Aは配列データ格納テーブルlb中の
対応する配列Aより2次元であることがわかるので、配
列データ格納テーブルlb中の対応する配列基Aの2次
元目の上限値と実行文中の配列Aの2次元目の添字式M
とを比較するとともに配列データ格納テーブルlb中の
配列Aの2次元目の下限(alと添字式Mとを比較する
ことにより2次元目の添字式Mの値が配列の宣言で定義
された上限値と下限値との間にあるか否かを検査する添
字式検査文Y2が作成される。さらに、配列データ格納
テーブルlb中の対応する配列Bの1次元目の上限値1
0と実行文中の配列Bの添字式Nとを比較するとともに
配列データ格納テーブルlb中の配列Bの1次元目の下
限値−10と添字式Nとを比較することによりその次元
の添字式Nの値が配列の宣言で定義された上限値と下限
値との間にあるか否かを検査する添字式検査文Y3が作
成される(ステップ35)。
The array element reference processing means IC first checks whether the statement X3 is an executable statement that includes an array reference (step 34).
Since statement X3 is an executable statement that includes references to arrays A and B, it searches for the array bases of arrays A and B in array data storage table lb, and returns the first dimension of the corresponding array A in array data storage table Ib. Upper limit value 100 and array A in executable statement
The value of the first dimension subscript formula is determined by comparing the subscript formula with the first dimension subscript formula of the array A and the lower limit value 1 of the first dimension of the array A in the array data storage table lb. A subscript expression test statement Yl is created to check whether the value is between the upper limit value and the lower limit value defined in the declaration of . Also, since it can be seen that the array A in the executable statement is two-dimensional than the corresponding array A in the array data storage table lb, the upper limit value of the second dimension of the corresponding array base A in the array data storage table lb and the execution Subscript expression M of the second dimension of array A in the sentence
By comparing the lower limit of the second dimension of the array A in the array data storage table lb (al and the subscript expression M, the value of the second dimension subscript expression M is the upper limit value defined in the array declaration. A subscript-type test statement Y2 is created to check whether the value is between
By comparing 0 with the subscript expression N of the array B in the executable statement and comparing the lower limit value -10 of the first dimension of the array B in the array data storage table lb with the subscript expression N, the subscript expression N of that dimension is determined. A subscript expression test statement Y3 is created to check whether the value is between the upper and lower limits defined in the array declaration (step 35).

次に、ステップ35で作成された添字式検査文Y1、Y
2およびY3ならびにステップ32で入力した実行文X
3が、第5図に示すようにそれぞれ出力される(ステッ
プ38)。
Next, the subscript type test sentences Y1 and Y created in step 35
2 and Y3 and the executable statement X input in step 32
3 are respectively output as shown in FIG. 5 (step 38).

このようにして、原始プログラム11の文が順次入力さ
れ入力された文が配列の参照を含む実行文であるたびに
この実行文の直前に配列の各次元の添字式の値が配列の
宣言で定義された上限値と下限値との範囲にあるかどう
かを検査する添字式検査文が挿入される。
In this way, the statements of the source program 11 are input sequentially, and every time the input statement is an executable statement that includes an array reference, the value of the subscript expression of each dimension of the array is declared as an array declaration immediately before this executable statement. A subscript expression check statement is inserted to check whether the value is within the defined upper and lower limit values.

この後、原始プログラム11の最後の文X4が入力され
ると(ステップ32)、文X4は宣言文であるか否かが
調べられる(ステップ33)。文X4は宣言文ではない
ので、配列要素参照処理手段1aに移行し、配列を含む
実行文か否かが調べられる(ステップ34)。文X4は
配列を含む実行文でもないので、ステップ35をスキッ
プしてステップ38に移行し、文X4が第5図に示すよ
うに出力される。
Thereafter, when the last sentence X4 of the source program 11 is input (step 32), it is checked whether the sentence X4 is a declarative sentence (step 33). Since the statement X4 is not a declaration statement, the process moves to the array element reference processing means 1a, and it is checked whether it is an executable statement that includes an array (step 34). Since the statement X4 is not an executable statement including an array, step 35 is skipped and the process moves to step 38, where the statement X4 is output as shown in FIG.

最後にステップ31に戻り入力すべき文があるか否かを
調べると、入力すべき文がないので添字式検査用原始プ
ログラム生成手段1における処理が終了される。
Finally, the process returns to step 31 to check whether there is a sentence to be input. Since there is no sentence to be input, the processing in the subscript expression checking source program generating means 1 is ended.

以上のようにして添字式検査用原始プログラム生成手段
1から出力された大全体が、添字式検査用原始プログラ
ム12となる。
The entire output from the subscript expression checking source program generating means 1 as described above becomes the subscript expression checking source program 12.

添字式検査用原始プログラム生成手段1により作成され
た原始プログラム12は、高級言語のコンパイラ2によ
り翻訳されてコンパイルユニット13として出力され、
コンパイルユニット13はリンカ3により結合されてロ
ードモジュール14として出力され、ロードモジュール
14はプログラム実行手段4により実行されて診断メツ
セージリスト15を出力する。
The source program 12 created by the subscript expression checking source program generation means 1 is translated by a high-level language compiler 2 and output as a compilation unit 13.
The compile units 13 are combined by the linker 3 and output as a load module 14, and the load module 14 is executed by the program execution means 4 and outputs a diagnostic message list 15.

したがって、この診断メツセージリスト15を見ること
により、原始プログラム11中に含まれる配列要素の添
字式の不正値を検出することができる。
Therefore, by looking at this diagnostic message list 15, it is possible to detect invalid values in the subscript expressions of array elements included in the source program 11.

〔発明の効果〕〔Effect of the invention〕

以上説明したように本発明は、高級言語で記述された原
始プログラム中に配列の宣言で定義された各次元ごとの
添字式の上限値および下限値と実行文中で参照された配
列要素の添字式の値とを比較する添字式検査文をその実
行文の直前に挿入することにより、ハードウェアに依存
することなしに原始プログラム中に含まれる配列要素の
添字式の不正値を容易に検出することができるという効
果がある。
As explained above, the present invention combines the upper and lower limit values of the subscript expression for each dimension defined in the declaration of an array in a source program written in a high-level language, and the subscript expression of an array element referenced in an executable statement. By inserting a subscript expression check statement that compares the value with the value of the subscript expression immediately before the executable statement, it is possible to easily detect invalid values of subscript expressions of array elements included in the source program without depending on the hardware. It has the effect of being able to.

また、目的プログラムの生成前の原始プログラムの段階
で添字式検査文が挿入されるようにしたことにより、コ
ンパイラの最適化機能を有効に利用することができると
いう効果がある。
Furthermore, by inserting the subscript expression check statement at the stage of the source program before generating the target program, there is an effect that the optimization function of the compiler can be effectively utilized.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の一実施例を示す構成図、第2図は第1
図中の配列データ格納テーブルの一例を示す図、 第3図は第1図中に示した添字式検査用原始プログラム
作成手段における処理を示す流れ図、第4図は第1図中
に示した原始プログラムの一例を示す図、 第5図は第4図中に示した原始プログラムに本実施例の
添字式の値検査方式を適用することにより得られた添字
式検査用原始プログラムの一例を示す図である。 図において、 1・・・添字式検査用原始プログラム生成手段、1a・
・宣言処理手段、 1b・・配列データ格納テーブル、 1c・・配列要素参照処理手段、 2・・・コンパイラ、 3・・・リンカ、 4・・・プログラム実行手段、 11・・・原始プログラム、 12・・・添字式検査用原始プログラム、13・・・コ
ンパイルユニット、 14・・・ロードモジュール、 15・・・診断メソセージリストである。
FIG. 1 is a configuration diagram showing one embodiment of the present invention, and FIG.
A diagram showing an example of the array data storage table in the figure, FIG. 3 is a flowchart showing the processing in the subscript type checking source program creation means shown in FIG. 1, and FIG. FIG. 5 is a diagram showing an example of a subscript expression checking source program obtained by applying the subscript expression value checking method of this embodiment to the source program shown in FIG. 4. It is. In the figure, 1... source program generation means for subscript expression checking, 1a.
・Declaration processing means, 1b: Array data storage table, 1c: Array element reference processing means, 2: Compiler, 3: Linker, 4: Program execution means, 11: Source program, 12 . . . Primitive program for subscript expression checking, 13. Compilation unit, 14. Load module, 15. Diagnosis message list.

Claims (1)

【特許請求の範囲】 高級言語で記述された原始プログラムを入力しこの原始
プログラムの中から配列の宣言を検出して宣言された配
列の次元数ならびに各次元の添字式の上限値および下限
値を配列データ格納テーブルに格納する宣言処理手段と
、 前記原始プログラム中に現れた配列要素の参照を含む実
行文の直前でその配列要素の各次元の添字式の値が前記
配列データ格納テーブルに格納された配列の各次元の添
字式の上限値と下限値との間にあるか否かを検査し前記
配列要素の各次元の添字式の値が前記配列データ格納テ
ーブルに格納された配列の各次元の添字式の上限値と下
限値との間にない場合にその配列要素の参照を含む実行
文に対して診断メッセージを出力する添字式検査文を作
成する配列参照処理手段と、 この配列参照処理手段で作成された添字式検査文を前記
原始プログラムの配列要素の参照を含む実行文の直前に
挿入して添字式検査用原始プログラムを生成する添字式
検査用原始プログラム生成手段と、 を有することを特徴とする添字式の値検査方式。
[Claims] A source program written in a high-level language is input, an array declaration is detected in the source program, and the number of dimensions of the declared array and the upper and lower limit values of the subscript expression of each dimension are determined. a declaration processing means for storing in an array data storage table; and immediately before an executable statement that includes a reference to an array element appearing in the source program, a value of a subscript expression of each dimension of the array element is stored in the array data storage table. The value of the subscript expression of each dimension of the array element is between the upper limit value and the lower limit value of the subscript expression of each dimension of the array element stored in the array data storage table. an array reference processing means for creating a subscript expression check statement that outputs a diagnostic message for an executable statement that includes a reference to an array element when the subscript expression is not between the upper limit value and the lower limit value; subscript expression checking source program generation means for generating a subscript expression checking source program by inserting the subscript expression checking statement created by the means immediately before an executable statement including a reference to an array element of the source program; A value checking method for subscript expressions characterized by:
JP61243625A 1986-10-14 1986-10-14 Check system for suffix value Pending JPS6398031A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP61243625A JPS6398031A (en) 1986-10-14 1986-10-14 Check system for suffix value

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP61243625A JPS6398031A (en) 1986-10-14 1986-10-14 Check system for suffix value

Publications (1)

Publication Number Publication Date
JPS6398031A true JPS6398031A (en) 1988-04-28

Family

ID=17106608

Family Applications (1)

Application Number Title Priority Date Filing Date
JP61243625A Pending JPS6398031A (en) 1986-10-14 1986-10-14 Check system for suffix value

Country Status (1)

Country Link
JP (1) JPS6398031A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02148330A (en) * 1988-11-30 1990-06-07 Nec Corp Inspection system for unauthorized use of superscription

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02148330A (en) * 1988-11-30 1990-06-07 Nec Corp Inspection system for unauthorized use of superscription

Similar Documents

Publication Publication Date Title
EP0643851B1 (en) Debugger program which includes correlation of computer program source code with optimized objet code
US6253371B1 (en) Method for supporting parallelization of source program
US6434742B1 (en) Symbol for automatically renaming symbols in files during the compiling of the files
US5606697A (en) Compiler system for language processing program
JPH04247536A (en) Computer software compile system assisting discrimination of data type at time of execution of object
US6553362B2 (en) Case-reduced verification condition generation system and method using weakest precondition operator expressed using strongest postcondition operators
EP0537257A1 (en) Integrated hierarchical representation of computer programs for a software development system
JPH11242597A (en) Method for generation of flow graph of java byte code data
US6314557B1 (en) Hybrid computer programming environment
US6381736B1 (en) Method for compile-time type-checking of arguments for externally-specified format strings
US6086622A (en) Method and apparatus for converting an architecture of a program and method, and apparatus for debugging a program by using them
JPS6398031A (en) Check system for suffix value
Stepney Incremental development of a high integrity compiler: experience from an industrial development
JPH09282173A (en) Static analysis method for program
JPH01177165A (en) Definition-quotation relation checking system for array
JP3064331B2 (en) Processing method of language processing program
JP3167386B2 (en) Automatic program parallelization method
JP3018783B2 (en) Compilation method
JPS58169637A (en) Compile processing system
Islam et al. Teaching compiler development to undergraduates using a template based approach
JPH08194624A (en) Executing form program preparing method
JP2807162B2 (en) Program translator
JPH07192034A (en) Interpreter type simulation method
JPH0196741A (en) Common section system in debugger
JPH05120025A (en) Inline development method for source program