JPH0981411A - Compiler - Google Patents

Compiler

Info

Publication number
JPH0981411A
JPH0981411A JP7241059A JP24105995A JPH0981411A JP H0981411 A JPH0981411 A JP H0981411A JP 7241059 A JP7241059 A JP 7241059A JP 24105995 A JP24105995 A JP 24105995A JP H0981411 A JPH0981411 A JP H0981411A
Authority
JP
Japan
Prior art keywords
program
intermediate code
data area
compiler
inspection
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.)
Withdrawn
Application number
JP7241059A
Other languages
Japanese (ja)
Inventor
Masaharu Nakazawa
正治 中澤
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 JP7241059A priority Critical patent/JPH0981411A/en
Publication of JPH0981411A publication Critical patent/JPH0981411A/en
Withdrawn legal-status Critical Current

Links

Landscapes

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

Abstract

PROBLEM TO BE SOLVED: To generate an object program inspecting the citing of a data area without depending on the specification of a source program, regarding a compiler. SOLUTION: In a compiler 2 generating an object program 11 of an executable form on the basis of a source program 1, a program analysis part 2' analyzing the source program 1 and generating the set of intermediate codes and an object program generation part 6 coupling the intermediate codes and generating the object program 11 are provided. The object program generation part 6 has a constitution that the generated intermediate codes are retrieved, based on the citing of the data area included in the set of the intermediate codes and the intermediate code calling the inspection program inspecting the justification of the citing of a definition based on the intermediate code is incorporated into the set of the intermediate codes.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】データ領域の引用の正当性を
検査するコンパイラに関する。コンピュータ用高級言語
プログラムはソースプログラムをコンパイラにより実行
可能な形式のオブジェクトプログラムに翻訳する必要が
ある。このような高級言語で作成したソースプログラム
に,例えばデータ領域の定義外の領域を引用する等の誤
りが含まれていると,オブジェクトプログラムが正しく
動作しない。そのため,コンパイラによりオブジェクト
プログラムに翻訳する際にその誤りを指摘して表示する
必要がある。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a compiler for checking the validity of data area quoting. A high-level language program for a computer needs to translate a source program into an object program in a form executable by a compiler. If the source program created in such a high-level language contains an error such as quoting an area outside the definition of the data area, the object program will not operate properly. Therefore, it is necessary to point out and display the error when translating it into an object program by the compiler.

【0002】[0002]

【従来の技術】ソースプログラムはデータ領域に関する
宣言文(データ領域の定義)およびそれらを引用する実
行文により構成される。また,コンパイラによりオブジ
ェクトプログラムを生成して実行する時に,データ領域
の引用の正当性の検査(プログラムの実行においてデー
タ領域の位置を表す値が得られた時,その値がデータ領
域の定義の範囲内にあるかないかの検査)等の検査を行
うか,あるいは行わないかを指定することができる。そ
して,検査することが指定されている場合には,例えば
データ領域の引用の正当性の検査をするような時,検査
をしない場合のオブジェクトプログラムとは別にそれら
のデータ領域に関する情報およびその検査プログラムを
呼び出す中間コードを含むオブジェクトプログラムを生
成し,実行時に検査プログラムを呼び出して検査するよ
うにしていた。
2. Description of the Related Art A source program is composed of declarative statements (definition of a data area) relating to a data area and execution statements that cite them. Also, when an object program is generated and executed by the compiler, the correctness of the quotation of the data area is checked (when a value indicating the position of the data area is obtained during the execution of the program, that value is the range of the definition It is possible to specify whether or not to perform inspection such as (inspection of whether or not it is inside). When the inspection is specified, for example, when the validity of the citation of the data area is inspected, the information about the data area and the inspection program are provided separately from the object program when the inspection is not performed. The object program containing the intermediate code that calls is generated, and the inspection program is called at the time of execution for inspection.

【0003】図9は従来のコンパイラを示す。図9にお
いて,110はソースプログラムである。
FIG. 9 shows a conventional compiler. In FIG. 9, 110 is a source program.

【0004】111は,データ領域の定義である(宣言
文)。例えば,配列,文字列,構造体(定義Aに要素
b,cが含まれる等)である。111’はデータ領域の
引用文である(プログラムの実行文であって,データ領
域の位置を表す値が含まれるか,もしくは演算結果とし
てその値が得られるもの等)。
Reference numeral 111 is a definition of a data area (declaration statement). For example, an array, a character string, or a structure (the definition A includes the elements b and c). Reference numeral 111 ′ is a quoted sentence of the data area (execution sentence of the program, which includes a value indicating the position of the data area, or whose value is obtained as a calculation result).

【0005】112はコンパイラである。114はソー
ス解析部であって,ソースプログラムを解析するもので
ある。115は意味解析部であって,ソースプログラム
の意味を解析するものである。
Reference numeral 112 is a compiler. Reference numeral 114 denotes a source analysis unit, which analyzes a source program. A semantic analysis unit 115 analyzes the meaning of the source program.

【0006】116は中間コード生成部であって,ソー
スプログラムの意味解析結果に基づいて機械語に近い言
語である中間コードを生成するものである。117は最
適化処理部であって,引用されていない数式等のプログ
ラムの実行に必要のない中間コードを削除する等でプロ
グラムの最適化を行うものである。
Reference numeral 116 is an intermediate code generation unit which generates an intermediate code which is a language close to a machine language based on the result of semantic analysis of the source program. An optimization processing unit 117 optimizes the program by, for example, deleting intermediate codes that are not required to execute the program, such as unquoted mathematical formulas.

【0007】118はオブジェクトプログラム生成部で
あって,中間コードの集合を基にオブジェクトプログラ
ムを生成するものである。120はオブジェクトプログ
ラム実行部である。
Reference numeral 118 is an object program generation unit, which generates an object program based on a set of intermediate codes. 120 is an object program execution unit.

【0008】121は実行結果出力部である。125は
検査プログラムライブラリであって,各種検査プログラ
ムを備えているライブラリである。
Reference numeral 121 is an execution result output unit. Reference numeral 125 is an inspection program library, which is a library provided with various inspection programs.

【0009】図10は従来のコンパイラのフローチャー
トである。図10により図9の従来のコンパイラの動作
を説明する。 コンパイルにおいて検査指定がない場合。
FIG. 10 is a flowchart of a conventional compiler. The operation of the conventional compiler shown in FIG. 9 will be described with reference to FIG. If there is no check specification in compilation.

【0010】S1 コンパイラ112はソースプログラ
ム110を入力する。 S2 データ領域の引用の正当性等の検査をするかしな
いかを判定する。今の場合,検査の指定がないのでS3
に進む。検査の指定があればS10に進む。
The S1 compiler 112 inputs the source program 110. S2 Determine whether or not to check the validity of the citation in the data area. In this case, there is no inspection specified, so S3
Proceed to. If the inspection is designated, the process proceeds to S10.

【0011】S3 ソース解析部114は入力されたプ
ログラムの文字列からプログラム文を抽出する等の構文
解析をする。 S4 意味解析部115はソース解析して得られたプロ
グラム文の意味を解析する。
The S3 source analysis unit 114 performs syntax analysis such as extracting a program sentence from the input character string of the program. S4 The semantic analysis unit 115 analyzes the meaning of the program statement obtained by source analysis.

【0012】S5 中間コード生成部116は意味解析
結果に基づいて中間コードを生成する。 S6 最適化処理部117はソースプログラム110の
中間コード群に対して,無駄がなく最適にプログラムが
実行できるように最適化処理をする。
The intermediate code generator S5 generates an intermediate code based on the result of the semantic analysis. S6 The optimization processing unit 117 performs optimization processing on the intermediate code group of the source program 110 so that the program can be optimally executed without waste.

【0013】S7 オブジェクトプログラム生成部11
8は中間コード群の各中間コードを結合(リンク)する
等でオブジェクトプログラムを生成する。 S8 オブジェクトプログラム実行部120は生成され
たオブジェクトプログラムを実行する。
S7 object program generator 11
Reference numeral 8 generates an object program by combining (linking) each intermediate code of the intermediate code group. The S8 object program execution unit 120 executes the generated object program.

【0014】S9 実行結果出力部121は実行結果を
出力する。 コンパイルにおいて検査指定がある場合。 S1 コンパイラ112はソースプログラム110を入
力する。
The execution result output section 121 outputs the execution result. When there is a check specification in compilation. The S1 compiler 112 inputs the source program 110.

【0015】S2 検査指定があるか判断する。今の場
合,検査指定があるのでS11に進む。 S11 ソース解析部114は入力されたソースプログ
ラム110に対してソース解析をする。
S2: It is judged whether or not there is an inspection designation. In this case, since the inspection is designated, the process proceeds to S11. The S11 source analysis unit 114 performs source analysis on the input source program 110.

【0016】S12 意味解析部115はソース解析に
より得られたプログラム文に対して意味解析をする。 S13 中間コード生成部116は意味解析結果に基づ
いて中間コードを生成する。
S12 The semantic analysis unit 115 performs semantic analysis on the program statement obtained by the source analysis. S13 The intermediate code generation unit 116 generates an intermediate code based on the semantic analysis result.

【0017】S14 検査指定があるので,ソース解析
結果,意味解析結果を基にデータ領域等の検査対象の情
報に関する中間コードを生成する。例えば,データ領域
の引用の正当性の検査であれば,データ領域の先頭番
地,データ領域の大きさ,データを配列する番地,デー
タの大きさ等を表す中間コードを生成する。
S14: Since there is an inspection designation, an intermediate code relating to information to be inspected such as a data area is generated based on the source analysis result and the semantic analysis result. For example, in the case of checking the validity of quoting the data area, an intermediate code representing the start address of the data area, the size of the data area, the address where the data is arranged, the size of the data, etc. is generated.

【0018】S15 対象とする検査プログラムを呼び
出す中間コードを生成する。 S6 最適化処理部117はソースプログラム110の
中間コード群に対して,プログラムの実行に無駄がなく
最適に実行できるように最適化処理をする。
S15 An intermediate code for calling the target inspection program is generated. S6 The optimization processing unit 117 performs optimization processing on the intermediate code group of the source program 110 so that the program can be executed optimally without waste.

【0019】S7 オブジェクトプログラム生成部11
8は中間コードを係合し,オブジェクトプログラムを生
成する。このとき,S14,S15で生成した検査のた
めの中間コードがS13で生成した中間コード群に挿入
されるように結合する。
S7 object program generator 11
8 engages the intermediate code to generate an object program. At this time, the intermediate codes for inspection generated in S14 and S15 are combined so as to be inserted into the intermediate code group generated in S13.

【0020】S8 オブジェクトプログラム実行部12
0は検査プログラムを呼び出す中間コードを含むオブジ
ェクトプログラムを実行する。実行において,検査プロ
グラムを呼び出す中間コードにより検査プログラムライ
ブラリ125から指定する検査プログラムを呼出してデ
ータ領域の引用文で引用されているデータ領域が定義さ
れた範囲内にあるか,ないか等を検査する。
S8 object program execution unit 12
0 executes the object program containing the intermediate code that calls the check program. During execution, an inspection program specified by the inspection program library 125 is called by an intermediate code that calls the inspection program, and it is checked whether or not the data area quoted by the quoted text of the data area is within a defined range. .

【0021】S9 実行結果出力部121は実行結果を
出力する。
S9 The execution result output unit 121 outputs the execution result.

【0022】[0022]

【発明が解決しようとする課題】上記のように,データ
領域の検査を指定してソースプログラムをコンパイラす
る時は,ソースプログラムのデータ領域の定義の宣言文
を基にそれぞれの検査をする検査プログラムを呼び出す
中間コードを生成し,ソースプログラムを翻訳したオブ
ジェクトプログラム中に挿入するようにしていた。そし
て,プログラム実行時に検査プログラムのルーチンを呼
び出して,検査プログラムによりデータ領域の引用の正
当性を検査していた。そのため,従来のコンパイラでは
検査がプログラム言語の仕様に依存し,言語仕様の変
更,拡張等がなされる度に,コンパイラもしくは検査プ
ログラムの側にも変更を必要とした。
As described above, when the source program is compiled by designating the data area check, the check program performs each check based on the declaration statement of the data area definition of the source program. The intermediate code to call is generated and inserted into the translated object program of the source program. Then, the routine of the inspection program is called when the program is executed, and the inspection program verifies the validity of the citation of the data area. Therefore, in the conventional compiler, the checking depends on the specification of the programming language, and it is necessary to change the compiler or the checking program every time the language specification is changed or extended.

【0023】また,従来のコンパイラで検査を指定した
場合には,ソースプログラムの定義(宣言文)および実
行文に対応する本来のオブジェクトコードとは別に,デ
ータ領域の引用の正当性を検査する仕組み(中間コー
ド)がオブジェクトプログラムに生成される。そのた
め,例えば,データ領域のアドレス計算をする中間コー
ド群は本来のオブジェクトコードと検査のためのオブジ
ェクトコードの双方に含まれて双方でアドレス計算をす
る等のように処理が重複し,実行時間を低下させてい
た。
In addition, when the check is specified by the conventional compiler, a mechanism for checking the correctness of the data area quoting, in addition to the original object code corresponding to the definition (declaration statement) of the source program and the execution statement (Intermediate code) is generated in the object program. Therefore, for example, the intermediate code group that calculates the address of the data area is included in both the original object code and the object code for inspection, and the processing is duplicated such that the address calculation is performed by both of them, which reduces the execution time. Had lowered.

【0024】さらに,従来のコンパイラは,コンパイラ
内において検査を行う場合と検査を行わない場合の2系
統の翻訳機構が必要であった。本発明は,言語仕様の変
更,拡張等に依存することなくデータ領域の引用の正当
性を検査することができ,かつ検査指定があった場合に
も高速に実行できるコンパイラを提供することを目的と
する。
Further, the conventional compiler requires the translation system of two systems, that is, the case where the checking is performed and the case where the checking is not performed in the compiler. It is an object of the present invention to provide a compiler that can check the validity of a data area reference without depending on changes or extensions of language specifications, and that can be executed at high speed even when a check is specified. And

【0025】[0025]

【課題を解決するための手段】ソースプログラムを翻訳
して得られる実行可能な形式のオブジェクトプログラム
は,配列の要素,文字列の要素および構造体の要素等の
集合データの中の要素を引用する場合,集合データの先
頭番地にその先頭番地からの変移を加えることによって
目的の要素の番地を求める。これらのデータの引用は中
間コードのオペランドにおいて,ベース(集合データの
先頭番地)とインデックス(集合データの先頭番地から
の変移)で表現される特殊な構成をもつ。
An executable object program obtained by translating a source program refers to elements in aggregate data such as array elements, character string elements, and structure elements. In this case, the address of the target element is obtained by adding the transition from the start address of the set data. The citation of these data has a special structure represented by a base (start address of set data) and an index (shift from start address of set data) in the operand of the intermediate code.

【0026】中間コード群は,ソースプログラムの記述
内容がコンピュータの機械語に近い形式で変換された情
報の集合であり,この情報は最終的にオブジェクトプロ
グラムに変換される。各中間コードは,一つの機能と定
義および引用されるデータ領域情報を指す複数のオペラ
ンドで構成される。
The intermediate code group is a set of information in which the description content of the source program is converted in a format close to the machine language of the computer, and this information is finally converted into an object program. Each intermediate code is composed of one operand and a plurality of operands that point to the definition and data area information to be quoted.

【0027】ここで,データ領域の引用の正当性の検査
をする場合には,中間コードの並びの中から,ベースと
インデックスを使用してデータ領域を引用している中間
コードに着目して該当するものをすべて検出する。この
中間コードは引用されるデータ領域の先頭番地,データ
領域全体の大きさおよび引用されるデータの長さを,該
当する中間コードのオペランドに指定されているデータ
領域情報から求めることができる。これらの情報は,プ
ログラムの実行上必要なものであり,データ領域情報に
は必ず存在する。
Here, in the case of checking the validity of the citation of the data area, attention is paid to the intermediate code that cites the data area using the base and the index from the sequence of the intermediate codes. Detect everything you do. With this intermediate code, the start address of the data area to be quoted, the size of the entire data area, and the length of the data to be quoted can be obtained from the data area information specified in the operand of the corresponding intermediate code. These pieces of information are necessary for executing the program, and are always present in the data area information.

【0028】この中間コードの検索方法は,ソースプロ
グラムの情報を直接参照しないため,言語仕様に依存す
ることなく目的の中間コードを検索できる。以上の結果
得られた情報に基づいて,検査を行う命令列または検査
手続きの呼出しの機能を持つ中間コードをそれぞれの該
当の中間コードの直前に挿入する。
Since this intermediate code search method does not directly refer to the information of the source program, the target intermediate code can be searched without depending on the language specifications. Based on the information obtained as a result of the above, an intermediate code having a function of calling an instruction sequence to be inspected or an inspection procedure is inserted immediately before each corresponding intermediate code.

【0029】そして,検査は下記のように行い結果を出
力する。 ベース,インデックスおよび引用されるデータの長
さの加算結果が,データ領域の先頭番地とデータ領域全
体の大きさの加算結果より大きいならば,データ領域の
不等な引用であるので,その旨を利用者に通知する。
Then, the inspection is performed as follows and the result is output. If the addition result of the base, index, and the length of the data to be quoted is larger than the addition result of the start address of the data area and the size of the entire data area, it means that the data area is unequally quoted. Notify the user.

【0030】 ベース及びインデックスの加算結果
が,データ領域の先頭番地とデータ領域全体の大きさの
加算結果より大きいならば,データ領域の不等な引用で
あるので,その旨を利用者に通知する。
If the addition result of the base and the index is larger than the addition result of the start address of the data area and the size of the entire data area, it is an unequal reference to the data area, and the user is notified of that fact. .

【0031】 ベース及びインデックスの加算結果
が,データ領域の先頭番地より小さいならば,データ領
域の不等な引用であるので,その旨を利用者に通知す
る。これらの検査において,ベースの値とインデックス
の値の加算結果を,本来該当データを引用するための計
算結果と共有することにより実行性能を向上させること
ができる。
If the addition result of the base and the index is smaller than the start address of the data area, it is an unequal citation of the data area, and the user is notified to that effect. In these checks, the execution performance can be improved by sharing the addition result of the base value and the index value with the calculation result for quoting the corresponding data.

【0032】また,コンパイラは一般的に,ソース解析
部,意味解析部,中間コード生成部,中間コード最適化
部及びオブジェクトプログラム生成部で構成され,この
順番に動作する。本発明は,検査プログラムを呼び出す
中間コードをオブジェクトプログラム生成部において作
成するようにする。そのため,中間コードの形式は,デ
ータ領域の引用の正当性を検査する命令列に対して,命
令列を生成する場合と生成しない場合で共通にすること
ができる。
The compiler is generally composed of a source analysis unit, a semantic analysis unit, an intermediate code generation unit, an intermediate code optimization unit and an object program generation unit, and they operate in this order. According to the present invention, the intermediate code for calling the inspection program is created in the object program generation unit. Therefore, the format of the intermediate code can be made common to the instruction sequence for checking the validity of the citation of the data area when the instruction sequence is generated and when it is not generated.

【0033】そこで,本発明は,ソースプログラムを基
に実行可能な形式のオブジェクトプログラムを生成する
コンパイラにおいて,ソースプログラムを解析して中間
コードの集合を生成するプログラム解析部と,中間コー
ドを結合してオブジェクトプログラムを生成するオブジ
ェクトプログラム生成部とを備え,該オブジェクトプロ
グラム生成部は中間コードの集合に含まれるデータ領域
の引用に基づいて生成された中間コードを検索し,該中
間コードを基に該定義の引用の正当性を検査する検査プ
ログラムを呼び出す中間コードを該中間コードの集合に
組み込むようにした。
Therefore, the present invention combines an intermediate code with a program analysis unit that analyzes the source program and generates a set of intermediate codes in a compiler that generates an executable object program based on the source program. And an object program generation unit that generates an object program by means of the object program generation unit, the object program generation unit searches for an intermediate code generated based on a citation of a data area included in a set of intermediate codes, and based on the intermediate code, The intermediate code for calling a check program for checking the correctness of the definition citation is incorporated in the set of the intermediate code.

【0034】図1は本発明の基本構成を示す。図1にお
いて,1はソースプログラムである。
FIG. 1 shows the basic configuration of the present invention. In FIG. 1, 1 is a source program.

【0035】2はコンパイラである。2’はプログラム
解析部であって,ソースプログラム1の構文解析,構文
解析により求められたプログラム文の意味解析,中間コ
ード群の生成をするものである。
Reference numeral 2 is a compiler. Reference numeral 2'denotes a program analysis unit, which performs syntax analysis of the source program 1, semantic analysis of program statements obtained by the syntax analysis, and generation of intermediate code groups.

【0036】3はソース解析部であって,ソースプログ
ラム1の構文解析(文字列を解析してプログラム文を求
める等の処理)をするものである。4は意味解析部であ
って,構文解析の結果求められたプログラム文の意味を
解析するものである。
Reference numeral 3 denotes a source analysis unit for performing syntax analysis of the source program 1 (processing such as analyzing a character string to obtain a program statement). Reference numeral 4 denotes a semantic analysis unit that analyzes the meaning of the program statement obtained as a result of the syntax analysis.

【0037】5は中間コード生成部であって,意味解析
の結果に基づいて中間コードを生成するものである。6
はオブジェクトプログラム生成部であって,プログラム
解析部2’で生成した中間コードの集合(中間コード
群)を結合して実行可能な形式のプログラムを生成する
ものである。その時,オブジェクトプログラム生成部6
は,コンパイラにおいて検査することが指定されている
場合には,プログラム解析部2’で生成された中間コー
ド群を解析して検査に必要な情報を求め,その情報につ
いての中間コードおよび検査プログラムを呼び出す中間
コードを生成してプログラム解析部2’で生成した中間
コード群に挿入する。検査が指定されている場合には,
そのようにして検査情報,検査プログラムの呼出しの中
間コードを実行文の中間コード群に結合して実行形式プ
ログラムを作成する。
An intermediate code generator 5 generates an intermediate code based on the result of the semantic analysis. 6
Is an object program generation unit, which combines a set of intermediate codes (intermediate code group) generated by the program analysis unit 2'to generate an executable program. At that time, the object program generator 6
If the compiler specifies to inspect, the intermediate code group generated by the program analysis unit 2'is analyzed to obtain information necessary for inspection, and the intermediate code and the inspection program for the information are analyzed. The intermediate code to be called is generated and inserted into the intermediate code group generated by the program analysis unit 2 '. If an inspection is specified,
In this way, the inspection information and the intermediate code for calling the inspection program are combined with the intermediate code group of the executable statement to create an executable program.

【0038】7は検査をするか,しないかの判定の処理
である。8はデータ領域の引用の正当性の検査に必要な
情報を検索して,その中間コードを生成する処理であ
る。
Reference numeral 7 is a process for determining whether or not to inspect. Reference numeral 8 is a process for retrieving information necessary for checking the validity of the citation of the data area and generating an intermediate code thereof.

【0039】9はデータ領域の引用の正当性の検査プロ
グラムを呼び出す中間コードを生成するものである。1
0はオブジェクトプログラムを生成する処理であって,
中間コード群の各中間コードを結合して実行形式プログ
ラムを作成する処理である。
Reference numeral 9 is for generating an intermediate code for calling a program for checking the validity of quoting the data area. 1
0 is a process for generating an object program,
This is a process of combining each intermediate code of the intermediate code group to create an executable program.

【0040】11は実行形式のオブジェクトプログラム
である。12は検査プログラムライブラリであって,各
種検査プログラムを備えるものである。
Reference numeral 11 is an executable object program. An inspection program library 12 includes various inspection programs.

【0041】図2は本発明の基本構成の説明図である。
図2において,1はソースプログラムである。
FIG. 2 is an explanatory diagram of the basic configuration of the present invention.
In FIG. 2, 1 is a source program.

【0042】11’はデータ領域の定義(宣言文)であ
る。12’はデータ領域を引用する文である。実行文で
あって,データ領域の定義文で定義された値を含む文,
もしくは演算により定義された値が得られるものであ
る。データ領域の位置を表す値を含む文,もしくは演算
によりデータ領域の位置を表す値が得られるものであ
る。
Reference numeral 11 'is a data area definition (declaration statement). 12 'is a sentence that cites the data area. An executable statement that contains the value defined in the data area definition statement,
Alternatively, the value defined by the operation can be obtained. A sentence including a value indicating the position of the data area, or a value indicating the position of the data area is obtained by calculation.

【0043】13,13’は中間コード群である(中間
コードの集合)。中間コード群13’は検査のための中
間コードを含まないものである。14はデータ領域の引
用に基づく中間コードである。
Reference numerals 13 and 13 'denote intermediate code groups (intermediate code sets). The intermediate code group 13 'does not include an intermediate code for inspection. Reference numeral 14 is an intermediate code based on the citation of the data area.

【0044】中間コード群13’において,15はデー
タ領域の引用の正当性検査に必要な情報の中間コードで
ある。16はデータ領域の引用の正当性を検査する検査
プログラムを呼び出す中間コードである。
In the intermediate code group 13 ', 15 is an intermediate code of information necessary for checking the validity of the citation of the data area. Reference numeral 16 is an intermediate code for calling a check program for checking the validity of the citation of the data area.

【0045】14はデータ領域の引用に基づく中間コー
ドである(中間コード群13のデータ領域の引用に基づ
く中間コードに同じ)。図2を参照して図1の本発明の
基本構成の説明する。
Reference numeral 14 is an intermediate code based on the citation of the data area (same as the intermediate code based on the citation of the data area of the intermediate code group 13). The basic configuration of the present invention shown in FIG. 1 will be described with reference to FIG.

【0046】コンパイラ2はソースプログラム1を入力
する。ソース解析部3はソースプログラム1の構文解析
をする。そして,その構文解析により求められたプログ
ラム文に対して意味解析部4は意味解析をし,中間コー
ド生成部5はその中間コードを生成する。
The compiler 2 inputs the source program 1. The source analysis unit 3 analyzes the syntax of the source program 1. Then, the semantic analysis unit 4 performs semantic analysis on the program statement obtained by the syntactic analysis, and the intermediate code generation unit 5 generates the intermediate code.

【0047】オブジェクトプログラム生成部6は検査の
指示の有無を判定する。データ領域の引用の正当性の検
査の指示がなければ,プログラム解析部2’の作成した
中間コード群13に対して結合処理を行いオブジェクト
プログラムを生成する。あるいは,その検査の指示があ
れば,中間コード群13の中間コードを分析して,デー
タ領域の引用に基づく中間コード14の有無を検索す
る。そして,その中間コード14が有れば,その中間コ
ード14を基に定義の引用の正当性検査に必要な情報
(引数等)の中間コード15を作成する。さらに,その
検査をする検査プログラムを呼び出す中間コード16を
生成し,中間コード群13’を得る。
The object program generator 6 determines whether or not there is an inspection instruction. If there is no instruction to check the validity of quoting the data area, the intermediate code group 13 created by the program analysis unit 2'is combined to generate an object program. Alternatively, if the inspection instruction is given, the intermediate code of the intermediate code group 13 is analyzed to search for the presence or absence of the intermediate code 14 based on the citation of the data area. Then, if the intermediate code 14 exists, an intermediate code 15 of information (arguments etc.) necessary for the validity check of the definition citation is created based on the intermediate code 14. Further, the intermediate code 16 for calling the inspection program for the inspection is generated, and the intermediate code group 13 'is obtained.

【0048】そして,それらの中間コード15,16が
データ領域の引用に基づく中間コード14の前に挿入さ
れるように中間コード群13’の各中間コードを結合
し,実行形式のオブジェクトプログラム11を作成す
る。オブジェクトプログラム11を実行する場合,検査
プログラムを呼び出すオブジェクトプログラムにより検
査プログラムが検査プログラムライブラリ12から呼び
出され,データ領域の引用の正当性の検査がされる。
Then, the intermediate codes of the intermediate code group 13 'are combined so that the intermediate codes 15 and 16 are inserted before the intermediate code 14 based on the reference of the data area, and the object program 11 of the execution format is formed. create. When the object program 11 is executed, the object program that calls the inspection program calls the inspection program from the inspection program library 12 to inspect the validity of the citation of the data area.

【0049】本発明によれば,ソースプログラムに基づ
いて生成された中間コードの集合(中間コード群)か
ら,データ領域の引用の正当性の検査に必要な中間コー
ドを生成するので,検査のための中間コードの生成処理
がソースプログラムの仕様に依存することがない。その
ため,言語仕様の変更,拡張等があっても,コンパイ
ラ,検査プログラムライブラリを変更することなくコン
パイルすることができる。
According to the present invention, the intermediate code necessary for checking the validity of the citation of the data area is generated from the set of intermediate codes (intermediate code group) generated based on the source program. The intermediate code generation process of does not depend on the specifications of the source program. Therefore, even if the language specification is changed or expanded, it is possible to compile without changing the compiler and the inspection program library.

【0050】また,本発明では,オブジェクトプログラ
ムにおいて,ソースプログラムの定義(宣言文)および
実行文に対応する命令列とデータ領域の正当性を検査す
る命令列の一部を共通に利用しているので,コンパイル
から実行結果が得られるまでの時間が短縮される。例え
ば,データ領域の引用にはプログラム実行時にその領域
の番地の計算をするが,本発明ではその計算結果をデー
タ領域の引用の正当性検査にも利用する。そのため,本
発明によればデータ領域の引用の正当性検査をする場合
にも,プログラムの実行時間を高速に行うことができ
る。
Further, in the present invention, in the object program, a part of the instruction sequence corresponding to the definition (declaration statement) and the execution statement of the source program and the instruction sequence for checking the correctness of the data area are commonly used. Therefore, the time from compiling to obtaining the execution result is shortened. For example, for quoting a data area, the address of the area is calculated when the program is executed. In the present invention, the calculation result is also used for checking the validity of quoting the data area. Therefore, according to the present invention, the program execution time can be shortened even when the validity check of the data area citation is performed.

【0051】また,本発明では,定義の引用の正当性検
査に必要な中間コードの生成をコンパイラの終了部分で
あるオブジェクトプログラム生成部において生成するの
で,それ以前のプログラム解析部におけるコンパイラの
内部インタフェースが,検査をする場合としない場合と
で共通であるので,本発明によれば検査のために必要な
機能を実現するためのコンパイラの負担が少ない。
Further, according to the present invention, since the intermediate code necessary for checking the validity of the definition citation is generated in the object program generating section which is the end section of the compiler, the internal interface of the compiler in the program analyzing section before that is generated. However, according to the present invention, the load on the compiler for realizing the functions required for the check is small because the check is common to the case where it is not checked.

【0052】[0052]

【発明の実施の形態】図3は本発明の実施例構成であ
る。図3において,1はソースプログラムである。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS FIG. 3 shows the configuration of an embodiment of the present invention. In FIG. 3, 1 is a source program.

【0053】2はコンパイラである。21はプログラム
解析部であって,部名として,ソース解析部,意味解析
部,中間コード生成部を含み,ソースプログラムの記述
を中間コードに変換するものである。
Reference numeral 2 is a compiler. Reference numeral 21 denotes a program analysis unit, which includes a source analysis unit, a semantic analysis unit, and an intermediate code generation unit as part names, and converts the description of the source program into an intermediate code.

【0054】22,22’,22”は中間コード群であ
る。中間コード群22’は最適化処理を実施済みのもの
である。中間コード群22”は検査プログラムを引用す
る中間コードを挿入済みのものである。
Reference numerals 22, 22 ′ and 22 ″ are intermediate code groups. Intermediate code group 22 ′ has been subjected to optimization processing. Intermediate code group 22 ″ has been inserted with intermediate code that cites a check program. belongs to.

【0055】23は最適化部であって,部名として中間
コード最適化部を持ち,不要な記述(使用されていない
演算式等)を削除する等でプログラムの性能を改善する
ものである。
Reference numeral 23 denotes an optimizing unit which has an intermediate code optimizing unit as the name of the unit and improves the performance of the program by deleting unnecessary descriptions (such as unused arithmetic expressions).

【0056】25はオブジェクトプログラム生成部であ
って,部名としてコード生成部を持つものである。オブ
ジェクトプログラム生成部25は,中間コード群から集
合データ(配列,文字列,構造体)の要素引用部分を抽
出する処理,データ領域の引用の正当性検査プログラム
を呼び出す中間コードを挿入する処理,中間コード群か
らオブジェクトプログラムを生成する処理等を行うもの
である。
Reference numeral 25 denotes an object program generating section having a code generating section as a section name. The object program generation unit 25 extracts the element reference part of the aggregate data (array, character string, structure) from the intermediate code group, inserts the intermediate code that calls the data area reference validity check program, It is a process for generating an object program from a code group.

【0057】26はオブジェクトプログラムである。図
4は定義されたデータ領域の例であって,「INTEG
ER A(10),ISUB」で定義されるデータ領域
である。
26 is an object program. FIG. 4 shows an example of the defined data area.
This is a data area defined by "ERA (10), ISUB".

【0058】30は定義されたデータ領域である。A
(1),A(2),・・・,A(10)は配列要素であ
る。ad2は定義されたデータ領域の先頭番地である。
配列要素の一個のデータ領域の幅は4であり,データ領
域の全体の幅は40である。ad2+t2は先頭番地か
らの変移であって,配列要素A(3)の引用番地である
(図4の場合t2=8である)。
Reference numeral 30 is a defined data area. A
(1), A (2), ..., A (10) are array elements. ad2 is the start address of the defined data area.
The width of one data area of the array element is 4, and the total width of the data area is 40. ad2 + t2 is a shift from the head address and is a quoted address of the array element A (3) (t2 = 8 in the case of FIG. 4).

【0059】コンパイラの起動時に検査(翻訳オプショ
ンDEBUG(RAGE))を指定すると次の動作をす
る。コンパイラ内のオブジェクトプログラム生成部25
は,この翻訳オプションの有効の指定があると,次の動
作をする。
If a check (translation option DEBUG (RAGE)) is specified when the compiler is activated, the following operation is performed. Object program generator 25 in the compiler
Performs the following operations when this translation option is specified to be valid.

【0060】(1) 各中間コードを先頭から順次検索
して,中間コードの各オペランドにおいて,ベース+イ
ンデックスの形式でデータ領域を引用している中間コー
ド(集合体の中間コード)を探す。
(1) Each intermediate code is sequentially searched from the beginning, and in each operand of the intermediate code, the intermediate code (intermediate code of the aggregate) that refers to the data area in the format of base + index is searched.

【0061】(2) その中間コードの直前に,次の情
報を引数とするライブラリ呼出しの機能を持つ中間コー
ドを挿入する。 (a) データ領域の引用番地(ベース(先頭番地)+イ
ンデックス) (b) 引用されるデータ領域の先頭番地(ベース) (c) データ領域全体の大きさ (d) 引用されるデータの長さ (e) データ名 これらの情報は,現在処理中の中間コードのオペランド
で指定されているデータ領域情報から獲得する。図4の
例の場合, (a) データ領域の引用番地はad2+t
2である。 (b) 引用されるデータ領域の先頭番地はa
d2である。 (c) データ領域全体の大きさは40であ
る。 (d) 引用されるデータの長さは4である。(e)
データ名はAである。
(2) Immediately before the intermediate code, the intermediate code having the function of calling the library with the following information as an argument is inserted. (a) Quoted address of data area (base (starting address) + index) (b) Start address of referenced data area (base) (c) Total size of data area (d) Length of quoted data (e) Data name These pieces of information are acquired from the data area information specified by the operand of the intermediate code currently being processed. In the case of the example in FIG. 4, (a) the quoted address of the data area is ad2 + t
2. (b) The start address of the data area quoted is a
d2. (c) The size of the entire data area is 40. (d) The length of the data quoted is 4. (E)
The data name is A.

【0062】(3) 上記の動作を中間コードが終了す
るまで繰り返す。 これらの過程を経て生成されたオブジェクトプログラム
は実行時にデータ領域の引用の正当性を検査するライブ
ラリを呼び出す。呼び出されたライブラリは引数で与え
られた情報に基づいて次の検査を行う。
(3) The above operation is repeated until the intermediate code ends. The object program generated through these processes calls a library for checking the validity of the data area reference at execution time. The called library performs the following checks based on the information given in the argument.

【0063】 ベース,インデックスおよび引用され
るデータの長さの加算結果が,データ領域の先頭番地と
データ領域全体の大きさの加算結果より大きいならば,
データ領域の不等な引用であるので,その旨を利用者に
通知する。
If the addition result of the base, the index, and the length of the data to be quoted is larger than the addition result of the start address of the data area and the size of the entire data area,
Since it is an unequal citation of the data area, notify the user accordingly.

【0064】 ベース及びインデックスの加算結果
が,データ領域の先頭番地とデータ領域全体の大きさの
加算結果より大きいならば,データ領域の不等な引用で
あるので,その旨を利用者に通知する。
If the addition result of the base and the index is larger than the addition result of the start address of the data area and the size of the entire data area, it is an unequal citation of the data area, and the user is notified to that effect. .

【0065】 ベース及びインデックスの加算結果
が,データ領域の先頭番地より小さいならば,データ領
域の不等な引用であるので,その旨を利用者に通知す
る。次に,図3の構成の動作を詳述する。
If the addition result of the base and the index is smaller than the start address of the data area, it is an unequal citation of the data area, and the user is notified to that effect. Next, the operation of the configuration of FIG. 3 will be described in detail.

【0066】図5は本発明の中間コードの実施例である
(検査プログラムを呼び出す中間コードを挿入する以前
のもの)。図5において,1はソースプログラムであ
る。
FIG. 5 shows an embodiment of the intermediate code of the present invention (before inserting the intermediate code for calling the inspection program). In FIG. 5, 1 is a source program.

【0067】22は中間コード群である。ソースプログ
ラム1は,10個の要素を持つ配列Aを定義するもので
ある。「INTEGER A(10),ISUB」の意
味は,データが整数型であり,配列名がAであり,要素
数が10であることを表す。ISUBは整数のパラメー
タである。
Reference numeral 22 is an intermediate code group. The source program 1 defines an array A having 10 elements. The meaning of "INTEGER A (10), ISUB" indicates that the data is an integer type, the array name is A, and the number of elements is 10. ISUB is an integer parameter.

【0068】ISUB=3でISUBに3を代入する
(この行はデータ領域の正当性検査対象外である)。A
(ISUB)=3はA(ISUB=3)=3であること
を表す。この行はデータ領域の引用の正当性検査対象と
なるものである。A(ISUB)の引用番地はAの先頭
番地(ベース)+(ISUB−1)×4である。
Substitute 3 for ISUB when ISUB = 3 (this line is not subject to the validity check of the data area). A
(ISUB) = 3 means that A (ISUB = 3) = 3. This line is the subject of validity checking for citation in the data area. The quoted address of A (ISUB) is the start address (base) of A + (ISUB-1) × 4.

【0069】中間コード群22はソースプログラム1を
コンパイルした中間コードである。「MOVE ISU
B,CC3」は,第2オペランドのCC3(定数であっ
て値3)を第1オペランドのISUBに代入する演算を
表す。
The intermediate code group 22 is an intermediate code obtained by compiling the source program 1. "MOVE ISU
"B, CC3" represents an operation for substituting CC3 (a constant and value 3) of the second operand into ISUB of the first operand.

【0070】「SUB t1,ISUB,CC1」は,
ISUBからCC1(定数であって値1)を引いて,レ
ジスタt1に保持する演算を表す。「MULT t2,
t1,CC4」は,t1にCC4(定数であって値4)
を掛けて,結果をレジスタt2に保持することを演算す
るものである。
"SUB t1, ISUB, CC1" is
It represents an operation of subtracting CC1 (a constant and a value of 1) from ISUB and holding it in the register t1. "MULT t2,
t1, CC4 "is CC4 at t1 (constant and value 4)
Is multiplied and the result is held in the register t2.

【0071】「ST bxop,CC3」はCC3(=
3)をbxopにストアすることを表すものである。b
xopはad2(Aの先頭番地)にレジスタt2に保持
されている値を加算したものであって,A(ISUB)
のアドレスである。即ち,CC3=3をA(3)のアド
レスに代入することを表し,A(3)=3とすることを
指示するものである。
"ST bxop, CC3" is CC3 (=
3) is stored in bxop. b
xop is a value obtained by adding the value held in the register t2 to ad2 (the head address of A), and A (ISUB)
Is the address of. That is, it indicates that CC3 = 3 is substituted into the address of A (3), and indicates that A (3) = 3.

【0072】データ領域情報において,ISUBは先頭
番地がad1であって,データの大きさが4(単位はバ
イトである。以下同じ)の利用者定義変数である。
In the data area information, ISUB is a user-defined variable whose head address is ad1 and whose data size is 4 (unit is byte. The same applies hereinafter).

【0073】Aは先頭番地がad2であって,データの
大きさが40の利用者定義変数である。CC1は先頭番
地がad3であって,データの大きさが4の定数であ
る。
A is a user-defined variable whose head address is ad2 and whose data size is 40. CC1 is a constant whose head address is ad3 and whose data size is 4.

【0074】CC3は先頭番地がad4であって,デー
タの大きさが4の定数である。CC4は先頭番地がad
5であって,データの大きさが4の定数である。t1は
先頭番地なしであって,データの大きさが4の一時名で
ある。
CC3 is a constant whose head address is ad4 and whose data size is 4. CC4 has a head address of ad
5, the data size is a constant of 4. t1 is a temporary name with no head address and a data size of 4.

【0075】t2は先頭番地なしであって,データの大
きさが4の一時名である。bxopはベース(A)(A
の先頭番地)+インデックス(t2)である集合データ
(配列,文字列,構造体)の要素を引用するものである
(A(ISUB)のアドレスを引用するものである)。
T2 is a temporary name with no head address and a data size of 4. bxop is the base (A) (A
Of the set data (array, character string, structure) that is (the start address of the) + index (t2) (refers to the address of A (ISUB)).

【0076】図6は本発明の中間コードの実施例であっ
て,検査プログラムを呼び出す中間コードを挿入した状
態である。22’は中間コード群であって,検査プログ
ラムを呼び出す中間コードを挿入した後の状態である。
FIG. 6 shows an embodiment of the intermediate code of the present invention, in which the intermediate code for calling the inspection program is inserted. Reference numeral 22 'denotes an intermediate code group, which is a state after the intermediate code for calling the inspection program is inserted.

【0077】「CALL 0,lib,arg」はデー
タ領域の正当性検査プログラムを呼び出す中間コードで
ある。argはデータ領域の定義に基づく中間コードb
xopをもとに生成される。
"CALL 0, lib, arg" is an intermediate code for calling the validity checking program for the data area. arg is an intermediate code b based on the definition of the data area
It is generated based on xop.

【0078】libは先頭番地がad6でデータの大き
さが4である。ad6はデータ領域の正当性検査のプロ
グラムの先頭番地である。argは先頭番地がad7で
あって,データの大きさが20のものである。argの
内容は,実引数の並び(bxop,ad2,40,4,
A)である。
In the lib, the head address is ad6 and the data size is 4. ad6 is the start address of the data area validity checking program. The head address of arg is ad7 and the data size is 20. The contents of arg are the sequence of actual arguments (bxop, ad2, 40, 4,
A).

【0079】ここでbxopは前述した集合体の要素を
引用するものであり,アドレス(大きさ4)である。a
d2は配列Aの先頭番地(大きさ4)であり,40は配
列Aの領域の幅(4バイトが10個)を表すものである
(大きさは4)。4は1要素の大きさであり Aはエラ
ーメッセージを表示する時に配列Aにエラーがあること
を表示するためのものである。
Here, bxop refers to the element of the above-mentioned aggregate and is an address (size 4). a
d2 is the head address of the array A (size 4), and 40 represents the width of the area of the array A (10 4 bytes) (size 4). 4 is the size of one element, and A is for displaying that there is an error in array A when displaying an error message.

【0080】中間コード群22”の「CALL 0,l
ib,arg」により(0は第1オペランドにデータが
ないことを表す),argの実引数の並び(bxop,
ad2,40,4,A)を引数としてad6の検査プロ
グラム(liblary)が呼び出される。そして,検
査プログラムはarg(bxop,ad2,40,4,
A)に従って,「ST bxop,CC3」の演算結果
が定義されたデータ領域の範囲に収まっているかいない
かを判定する。
"CALL 0, l of the intermediate code group 22"
ib, arg ”(0 indicates that there is no data in the first operand), the array of actual arguments of arg (bxop,
The inspection program (library) of ad6 is called by using ad2, 40, 4, A) as an argument. And the inspection program is arg (bxop, ad2, 40, 4,
According to A), it is determined whether or not the calculation result of "ST bxop, CC3" is within the range of the defined data area.

【0081】図7,図8は本発明のコンパイラのフロー
チャートである。図7,図8により図3の本発明の実施
例構成の動作を説明する(必要に応じて図5,図6を参
照する)。
7 and 8 are flowcharts of the compiler of the present invention. The operation of the embodiment of the present invention shown in FIG. 3 will be described with reference to FIGS. 7 and 8 (refer to FIGS. 5 and 6 as necessary).

【0082】S1 コンパイラ2はソースプログラム1
を入力する。 S2 ソース解析部は,ソースプログラム1の構文解析
をする。 S3 意味解析部は構文解析により求められたプログラ
ム文の意味解析をする。
S1 The compiler 2 is the source program 1
Enter The S2 source analysis unit analyzes the syntax of the source program 1. S3 The semantic analysis unit analyzes the semantics of the program sentence obtained by the syntax analysis.

【0083】S4 中間コード生成部は意味解析の結果
により中間コードを生成する。そしてプログラム全部の
中間コードにより構成される中間コード群22を得る。 S5 最適化部23により,中間コード群22の最適化
を行う(図3の中間コード群22’を得る)。
S4 The intermediate code generating section generates an intermediate code according to the result of the semantic analysis. Then, the intermediate code group 22 composed of the intermediate codes of all the programs is obtained. The intermediate code group 22 is optimized by the S5 optimizing unit 23 (obtaining the intermediate code group 22 'in FIG. 3).

【0084】S6,S7 オブジェクトプログラム生成
部25は中間コードを1個入力する。中間コードがあれ
ばS8に進み,なければS12に進む。 S8はデータ領域の引用の正当性検査の指定があるかな
いかを判定し,その検査の指定があればS9に進み,そ
の検査の指定がなければS6以降の処理を繰り返す。
S6, S7 The object program generator 25 inputs one intermediate code. If there is an intermediate code, the process proceeds to S8, and if not, the process proceeds to S12. In S8, it is determined whether or not there is a designation of the validity check of the citation of the data area, and if there is the designation of the check, the process proceeds to S9.

【0085】S9 中間コードは集合データを引用して
いるかあるいは引用していなかを判定する(例えば,b
xopの記述の有無で判定する)。引用していればS1
0に進み,引用していなければS6以降の処理を繰り返
す。
S9 The intermediate code determines whether or not the set data is quoted (for example, b
Judgment based on the presence or absence of the description of xop). If quoted, S1
The process proceeds to 0, and if not quoted, the processes from S6 are repeated.

【0086】S10 データ引用の正当性の検査のため
の実引数の並びを作成する。図6の中間コードの実施例
の場合,検査プログラムの実引数の並び(bxop,a
d2,40,4,A)を作成する。
S10 A sequence of actual arguments for checking the validity of data citation is created. In the case of the embodiment of the intermediate code of FIG. 6, the sequence of actual arguments of the inspection program (bxop, a
Create d2, 40, 4, A).

【0087】S11 集合データの引用の中間コード
(bxop等)の直前にデータ引用の正当性検査プログ
ラムを呼び出す中間コードを挿入する。例えば,図6の
中間コードの実施例の場合「CALL 0,lib,a
rg」を作成する。その後,S6以降の処理を繰り返
す。
S11 Immediately before the intermediate code (bxop or the like) for quoting the set data, an intermediate code for calling the data citation validity checking program is inserted. For example, in the case of the embodiment of the intermediate code of FIG. 6, “CALL 0, lib, a
rg "is created. After that, the processing from S6 is repeated.

【0088】S7 以上の処理を各中間コードについて
行い,中間コードを全て検索したら,求めた中間コード
群に対して結合処理(リンク)を行い,S12以降の処
理で実行形式のオブジェクトプログラムを生成する。
S8 The above processing is performed for each intermediate code, and when all the intermediate codes are searched, the obtained intermediate code group is subjected to the combining processing (link), and the object program in the execution format is generated by the processing from S12. .

【0089】S12,S13 データ引用の正当性検査
プログラムの呼出しがあるか判定し,なければS15に
進み,あれば,S14でデータ引用の正当性の検査プロ
グラムを参照するためのオブジェクトを生成する(検査
のために挿入した中間コードを実行形式プログラムに結
合するオブジェクトプログラムを生成する)。
S12, S13 It is judged whether or not the data citation validity checking program is called. If not, the process proceeds to S15. If there is, an object for referring to the data citation validity checking program is generated (S14). Generate an object program that combines the intermediate code inserted for inspection with the executable program).

【0090】S15 全ての中間コードを機械語に変換
する。 S16 実行形式プログラム(オブジェクトプログラ
ム)を実行する。 オブジェクトプログラムの実行において, ベース,インデックスおよび引用されるデータの長
さの加算結果が,データ領域の先頭番地とデータ領域全
体の大きさの加算結果より大きいならば,データ領域の
不等な引用であるので,その旨を利用者に通知する。
S15 All intermediate codes are converted into machine language. S16 The execution format program (object program) is executed. In the execution of the object program, if the addition result of the base, index, and the length of the data to be quoted is larger than the addition result of the start address of the data area and the size of the entire data area, the data area is unequally quoted. Since there is, notify the user to that effect.

【0091】 ベース及びインデックスの加算結果
が,データ領域の先頭番地とデータ領域全体の大きさの
加算結果より大きいならば,データ領域の不等な引用で
あるので,その旨を利用者に通知する。
If the addition result of the base and the index is larger than the addition result of the start address of the data area and the size of the entire data area, it is an unequal reference to the data area, and the user is notified of that fact. .

【0092】 ベース及びインデックスの加算結果
が,データ領域の先頭番地より小さいならば,データ領
域の不等な引用であるので,その旨を利用者に通知す
る。
If the addition result of the base and the index is smaller than the start address of the data area, it indicates that the data area is unequal, and the user is notified to that effect.

【0093】[0093]

【発明の効果】本発明によれば,ソースプログラムに基
づいて生成された中間コードの集合から,ソースプログ
ラムの仕様に依存することなく,データ領域の引用の正
当性の検査のための中間コードを生成できる。そのた
め,言語仕様の変更,拡張等があっても,コンパイラ,
検査プログラムライブラリを変更する必要がなく,プロ
グラム開発の能率が大幅に向上する。
According to the present invention, the intermediate code for checking the validity of the citation of the data area is extracted from the set of intermediate code generated based on the source program, without depending on the specifications of the source program. Can be generated. Therefore, even if the language specifications are changed or expanded, the compiler,
There is no need to change the inspection program library, greatly improving the efficiency of program development.

【0094】また,本発明では,オブジェクトプログラ
ムにおいて,ソースプログラムの定義(宣言文)および
実行文に対する命令列とデータ領域の引用の正当性の検
査をする命令列の一部を共通に利用しているので,デー
タ領域の引用の正当性の検査をするコンパイルの実行時
間が短縮される。
Further, in the present invention, in the object program, a part of the instruction sequence for the definition (declaration statement) and the execution statement of the source program and the instruction sequence for checking the validity of the citation of the data area are commonly used. Therefore, the execution time of the compile for checking the validity of the citation of the data area is shortened.

【0095】また,本発明では,データ領域の引用の正
当性検査に必要な中間コードをコンパイラの終了部分で
あるオブジェクトプログラム生成部において行うので,
それ以前のプログラム解析部におけるコンパイラの内部
インタフェースは検査をする場合としない場合とで共通
化できる。そのため,本発明によれば検査のために必要
な機能を実現するためのコンパイラの負担が少ない。
Further, according to the present invention, since the intermediate code necessary for checking the validity of the citation of the data area is performed in the object program generation unit which is the end portion of the compiler,
The internal interface of the compiler in the program analysis unit before that can be made common in the case of checking and the case of not checking. Therefore, according to the present invention, the load on the compiler for realizing the functions required for the inspection is small.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の基本構成を示す図である。FIG. 1 is a diagram showing a basic configuration of the present invention.

【図2】本発明の基本構成の説明図である。FIG. 2 is an explanatory diagram of a basic configuration of the present invention.

【図3】本発明の実施例構成を示す図である。FIG. 3 is a diagram showing a configuration of an embodiment of the present invention.

【図4】定義されたデータ領域の例を示す図である。FIG. 4 is a diagram showing an example of a defined data area.

【図5】本発明の中間コードの実施例を示す図である。FIG. 5 is a diagram showing an embodiment of an intermediate code of the present invention.

【図6】本発明の中間コードの実施例を示す図である。FIG. 6 is a diagram showing an embodiment of an intermediate code of the present invention.

【図7】本発明のコンパイラのフローチャートを示す図
である。
FIG. 7 is a diagram showing a flowchart of a compiler of the present invention.

【図8】本発明のコンパイラのフローチャートを示す図
である。
FIG. 8 is a diagram showing a flowchart of a compiler of the present invention.

【図9】従来のコンパイラを示す図である。FIG. 9 is a diagram showing a conventional compiler.

【図10】従来のコンパイラのフローチャートを示す図
である。
FIG. 10 is a diagram showing a flowchart of a conventional compiler.

【符号の説明】[Explanation of symbols]

1:ソースプログラム 2:コンパイラ 2’:プログラム解析部 3:ソース解析部 4:意味解析部 5:中間コード生成部 6:オブジェクトプログラム生成部 7:データ領域の引用の正当性検査の指定の有無を判定
する処理 8:データ領域の引用の正当性の検査に必要な情報を検
索して,その中間コードを生成する処理 9:データ領域の引用の正当性の検査プログラムを呼び
出す中間コードを生成する処理 10:オブジェクトプログラムを生成する処理 11:オブジェクトプログラム 12:検査プログラムライブラリ
1: Source program 2: Compiler 2 ': Program analysis unit 3: Source analysis unit 4: Semantic analysis unit 5: Intermediate code generation unit 6: Object program generation unit 7: Whether or not the validity check of the data area citation is specified Judgment process 8: Process for retrieving information necessary for checking validity of data area citation and generating intermediate code thereof 9: Process for generating intermediate code for calling data area citation validity checking program 10: Process for generating object program 11: Object program 12: Inspection program library

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムを基に実行可能な形式
のオブジェクトプログラムを生成するコンパイラにおい
て,ソースプログラムを解析して中間コードの集合を生
成するプログラム解析部と,中間コードを結合してオブ
ジェクトプログラムを生成するオブジェクトプログラム
生成部とを備え,該オブジェクトプログラム生成部は中
間コードの集合に含まれるデータ領域の引用に基づいて
生成された中間コードを検索し,該中間コードを基に該
定義の引用の正当性を検査する検査プログラムを呼び出
す中間コードを該中間コードの集合に組み込むことを特
徴とするコンパイラ。
1. A compiler for generating an executable object program based on a source program, a program analysis unit for analyzing a source program to generate a set of intermediate code, and an object program by combining the intermediate code. And an object program generation unit for generating, wherein the object program generation unit searches for an intermediate code generated based on a reference of a data area included in a set of intermediate codes, and based on the intermediate code, searches for the reference of the definition. A compiler characterized by incorporating intermediate code for calling a check program for checking correctness into a set of the intermediate code.
【請求項2】 データ領域の定義が配列もしくは文字列
もしくは構造体の定義であることを特徴とする請求項1
に記載のコンパイラ。
2. A data area definition is an array, a character string, or a structure definition.
Compiler as described in.
【請求項3】 データ領域の定義情報を引数として検査
プログラムを呼び出す中間コードを検査対象の中間コー
ドの直前に組み込むことを特徴とする請求項1に記載の
コンパイラ。
3. The compiler according to claim 1, wherein the intermediate code for calling the inspection program with the definition information of the data area as an argument is incorporated immediately before the intermediate code to be inspected.
【請求項4】 該定義の引用の正当性の検査は,引用さ
れたデータ領域の位置を表す値が定義された範囲内にあ
るかないかを検査するものであることを特徴とする請求
項1もしくは2に記載のコンパイラ。
4. The validity check of the citation of the definition is to check whether or not the value representing the position of the quoted data area is within a defined range. Alternatively, the compiler described in 2.
JP7241059A 1995-09-20 1995-09-20 Compiler Withdrawn JPH0981411A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7241059A JPH0981411A (en) 1995-09-20 1995-09-20 Compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7241059A JPH0981411A (en) 1995-09-20 1995-09-20 Compiler

Publications (1)

Publication Number Publication Date
JPH0981411A true JPH0981411A (en) 1997-03-28

Family

ID=17068702

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7241059A Withdrawn JPH0981411A (en) 1995-09-20 1995-09-20 Compiler

Country Status (1)

Country Link
JP (1) JPH0981411A (en)

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
JP2014219969A (en) * 2013-04-30 2014-11-20 富士通株式会社 Method and system for analyzing software program and non-temporary computer readable medium
JP2016162460A (en) * 2015-03-05 2016-09-05 富士通株式会社 Determination of effective input sequence to unknown binary program

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
JP2014219969A (en) * 2013-04-30 2014-11-20 富士通株式会社 Method and system for analyzing software program and non-temporary computer readable medium
JP2016162460A (en) * 2015-03-05 2016-09-05 富士通株式会社 Determination of effective input sequence to unknown binary program

Similar Documents

Publication Publication Date Title
EP0643851B1 (en) Debugger program which includes correlation of computer program source code with optimized objet code
US7917899B2 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
US8151254B2 (en) Compiler, compiler apparatus and compilation method
US6588009B1 (en) Method and apparatus for compiling source code using symbolic execution
US20020019973A1 (en) Compiler and method for compiling easily adaptable to processor specifications
US7657878B2 (en) Compiler, method of compiling and program development tool
US20050204344A1 (en) Program analysis device, analysis method and program of same
US20060195828A1 (en) Instruction generator, method for generating instructions and computer program product that executes an application for an instruction generator
JPH05257709A (en) Parallelism discriminating method and parallelism supporting method using the same
JP4157016B2 (en) Compiler apparatus and compiling method
US7509634B2 (en) SIMD instruction sequence generating program, SIMD instruction sequence generating method and apparatus
JP2003050715A (en) Compiler and debugging device
US6539543B1 (en) Method and apparatus for compiling source code by flattening hierarchies
Watson A practical approach to compiler construction
US7120905B2 (en) System and method for transformation of assembly code for conditional execution
US20040010780A1 (en) Method and apparatus for approximate generation of source code cross-reference information
JPH0981411A (en) Compiler
KR102614967B1 (en) Automation system and method for extracting intermediate representation based semantics of javascript
Housel et al. A methodology for machine language decompilation
Bülow Proof visualization for the lean 4 theorem prover
JP3167386B2 (en) Automatic program parallelization method
Volovshchіkov et al. THE C++ LANGUAGE IN PROGRAMMING AND COMPUTER SCIENCE
JP2000132405A (en) In-line expansion processing device and method
JPH05204705A (en) Processing method for detecting undefined parameter
JPH04364537A (en) Method, device, and compiler for optimizing program for parallel process

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20021203