JP3085956B2 - Object oriented language translation processor - Google Patents

Object oriented language translation processor

Info

Publication number
JP3085956B2
JP3085956B2 JP63147181A JP14718188A JP3085956B2 JP 3085956 B2 JP3085956 B2 JP 3085956B2 JP 63147181 A JP63147181 A JP 63147181A JP 14718188 A JP14718188 A JP 14718188A JP 3085956 B2 JP3085956 B2 JP 3085956B2
Authority
JP
Japan
Prior art keywords
program
mode
translation
language
dynamic
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.)
Expired - Fee Related
Application number
JP63147181A
Other languages
Japanese (ja)
Other versions
JPH022426A (en
Inventor
文雄 鈴木
博 石川
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 JP63147181A priority Critical patent/JP3085956B2/en
Publication of JPH022426A publication Critical patent/JPH022426A/en
Application granted granted Critical
Publication of JP3085956B2 publication Critical patent/JP3085956B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

【発明の詳細な説明】 〔概要〕 オブジェクト指向言語で記述されたソースプログラム
を翻訳処理することで、所定の言語で記述された翻訳プ
ログラムを生成するオブジェクト指向言語の翻訳処理装
置に関し、 プログラムの実行速度を上げるとともに、アプリケー
ションプログラムの開発が容易となることを目的とし、 翻訳処理装置が、ソースプログラムを動的結合モード
と静的結合モードとのいずれでコンパイルするかを指示
するための情報にもとづいて当該ソースプログラムをい
ずれのモードの下でコンパイルするかを判断するモード
判断部(11)と、 このモード判断部(11)が動的結合モードであること
を判断したときに、ソースプログラムの複数個のオブジ
ェクトにおける個々のオブジェクトの継承情報の探索が
実行段階で行われるような形式をもって翻訳プログラム
を展開する動的展開部(12)と、 上記モード判断部(11)が静的結合モードであること
を判断したときに、ソースプログラムの複数個のオブジ
ェクトにおける個々のオブジェクトの継承情報の探索が
翻訳情報に従って実行できるような形式をもって翻訳プ
ログラムを展開する静的展開部(13)と を備えてなるよう構成する。
DETAILED DESCRIPTION OF THE INVENTION [Summary] The present invention relates to an object-oriented language translation processing apparatus that generates a translation program written in a predetermined language by translating a source program written in an object-oriented language. For the purpose of increasing the speed and facilitating the development of application programs, the translation processing apparatus is based on information for instructing whether to compile a source program in a dynamic binding mode or a static binding mode. A mode judging unit (11) for judging in which mode the source program is to be compiled, and a plurality of source programs when the mode judging unit (11) judges that the mode is the dynamic combination mode. Search for inheritance information of individual objects in the object is performed at the execution stage When the dynamic expansion unit (12) that expands the translation program in such a format and the mode determination unit (11) determines that the mode is the static combination mode, the individual A static expansion unit (13) that expands the translation program in a format that allows the search for the inheritance information to be executed according to the translation information.

〔産業上の利用分野〕[Industrial applications]

本発明は、オブジェクト指向言語で記述されたソース
プログラムを翻訳処理することで、所定の言語で記述さ
れた翻訳プログラムを生成するオブジェクト指向言語の
翻訳処理装置に関するものである。
The present invention relates to an object-oriented language translation processing apparatus that translates a source program described in an object-oriented language to generate a translation program described in a predetermined language.

近年、データと手続きを1つにしたオブジェクト指向
言語が実用化されつつある。この言語は、同一名のメッ
セージ送信で様々な処理が行えるとともに、メッセージ
名とパラメータの渡し方が関数のそれよりも簡単で、か
つクラスの更新に対して他のモジュールが変更を受けな
いという特性がある。これから、プログラムのモジュリ
テイが高く、インタフェースの厳密さが不要となって、
アプリケーションのプログラミングが容易になり、拡張
性が良くなるという利点がある。このような利点を持つ
オブジェクト指向言語の実用性を高めるためにも、オブ
ジェクト指向言語で記述されたプログラムの実行速度を
上げる工夫をしていく必要があるとともに、アプリケー
ションプログラムの開発が容易となるような工夫をして
いく必要があるのである。
In recent years, an object-oriented language that integrates data and a procedure has been put into practical use. This language can perform various processes by sending a message with the same name, passing the message name and parameters is easier than that of the function, and the other modules are not changed by class update. There is. From now on, program modularity is high and interface strictness is no longer necessary.
There is an advantage that the programming of the application is facilitated and the extensibility is improved. In order to improve the practicality of an object-oriented language having such advantages, it is necessary to devise ways to increase the execution speed of a program written in the object-oriented language, and to facilitate the development of application programs. It is necessary to make creative efforts.

〔従来の技術〕[Conventional technology]

オブジェクト指向言語で記述されたプログラムの実行
は、従来、インタプリタ形式で実行されるようにとなさ
れていた。すなわち、従来では、プログラムの実行時
に、オブジェクトのクラス/インスタンス関係とスーパ
ー/サブ関係をたどることで、処理対象となるメソッド
(手続き)や属性データを得て、処理を実行するように
としていたのである。ここで、クラス/インスタンス関
係とは、ある1つの概念が表す集合とその集合に属する
要素との関係(上層・下層の関係)を表し、スーパー/
サブ関係とは、クラスレベルのオブジェクト間の大小関
係(上位・下位の関係)を表している。
Conventionally, execution of a program described in an object-oriented language has been performed in an interpreter format. That is, conventionally, when a program is executed, a method (procedure) and attribute data to be processed are obtained by following a class / instance relation and a super / sub relation of an object, and the processing is executed. is there. Here, the class / instance relationship indicates a relationship between a set represented by a certain concept and an element belonging to the set (upper / lower layer relationship).
The sub-relationship indicates a magnitude relation (upper / lower relation) between class-level objects.

〔発明が解決しようとする課題〕[Problems to be solved by the invention]

しかしながら、プログラムの実行時にオブジェクトを
たどることで、要求のあるメソッドや属性データを探し
ていくというこのような従来技術では、メソッドや属性
データをサーチングするための時間がかかることから、
プログラムの実行速度が遅くなってしまうという問題点
があった。特に、この問題は、同一のオブジェクトのメ
ソッドや属性データを何回もサーチングすることになる
定型業務のプログラムの実行において、大きな問題とな
っていた。
However, in such a conventional technique of searching for a requested method or attribute data by tracing an object during execution of a program, it takes a long time to search for the method or attribute data.
There has been a problem that the execution speed of the program is reduced. In particular, this problem has been a serious problem in the execution of a routine business program in which the method and attribute data of the same object are searched many times.

本発明は、かかる事情に鑑みてなされたものであっ
て、オブジェクト指向言語で記述されたプログラムの実
行速度を上げるために、コンパイル処理を提案するとと
もに、このコンパイル処理にあたって、開発時のプログ
ラムの変更を容易に実現できるようにするオブジェクト
指向言語の翻訳処理装置の提供を目的とするものであ
る。
The present invention has been made in view of such circumstances, and proposes a compile process in order to increase the execution speed of a program described in an object-oriented language. It is an object of the present invention to provide an object-oriented language translation processing device that can easily realize the translation processing.

〔課題を解決するための手段〕[Means for solving the problem]

第1図は、本発明の原理構成図である。 FIG. 1 is a diagram showing the principle of the present invention.

図中、10は翻訳部であって、オブジェクト指向言語で
記述されたソースプログラムを翻訳するもの、11はモー
ド判断部であって、ソースプログラム上の例えば当該ソ
ースプログラムのヘッド記述部上で設定されることにな
る動的結合モードと静的結合モードとを判断するもの、
12は動的展開部であって、モード判断部11が動的結合モ
ードであることを判断したときに、ソースプログラムの
オブジェクトの継承情報の探索が実行段階で行われるよ
うな形式をもって翻訳プログラムを展開するもの、13は
静的展開部であって、モード判断部11が静的結合モード
であることを判断したときに、ソースプログラムのオブ
ジェクトの継承情報の探索が翻訳情報に従って実行でき
るような形式をもって翻訳プログラムを展開するもの、
20は後段翻訳部であって、動的展開部12及び静的展開部
13により展開された翻訳プログラムを実行プログラムに
と翻訳するもの、30は実行モジュールであって、後段翻
訳部20により求められた実行プログラムを実行するも
の、40はソースプログラムファイルであって、オブジェ
クト指向言語で記述されたソースプログラムを格納する
もの、50は動的中間ファイルであって、動的展開部12に
より展開された翻訳プログラムを格納するもの、60は静
的中間ファイルであって、静的展開部13により展開され
た翻訳プログラムを格納するもの、70は実行プログラム
ファイルであって、後段翻訳部20により翻訳された実行
プログラムを格納するものである。
In the figure, reference numeral 10 denotes a translation unit which translates a source program described in an object-oriented language, and 11 denotes a mode determination unit which is set on a source program, for example, on a head description unit of the source program. To determine the dynamic and static binding modes that will result in
Reference numeral 12 denotes a dynamic expansion unit which, when the mode determination unit 11 determines that the mode is the dynamic combination mode, converts the translation program in a format such that the search for the inheritance information of the object of the source program is performed in the execution stage. The expansion unit 13 is a static expansion unit that can search for inheritance information of the object of the source program according to the translation information when the mode determination unit 11 determines that the mode is the static combination mode. To develop a translation program with
Reference numeral 20 denotes a post-translation unit, which includes a dynamic expansion unit 12 and a static expansion unit.
13 translates the translation program expanded by 13 into an execution program, 30 is an execution module that executes the execution program obtained by the post-translation unit 20, 40 is a source program file, and is an object-oriented program. A language storing a source program described in a language, 50 is a dynamic intermediate file, storing a translation program expanded by the dynamic expansion unit 12, 60 is a static intermediate file, The one that stores the translation program expanded by the expansion unit 13 and the execution program file 70 that stores the execution program translated by the post-stage translation unit 20.

〔作用〕[Action]

例えば、オブジェクト指向言語で記述されたソースプ
ログラム中に「patientの年令はいくつですか。」と問
い合わせるメッセージ送信 i=patient.get(“age"); があるとしてみる。
For example, suppose that a source program written in an object-oriented language has a message transmission i = patient.get ("age");

このメッセージ送信が動的結合モードを設定する“dy
namic"とともに記述されているときには、動的展開部12
は、このメッセージ送信を、 i=get(patient,“age"); と展開する。すなわち、プログラムの実行時に、“get"
という手続きを通してオブジェクトをたどって、“pati
entの年令”を参照するようにと展開する。このように
展開される動的結合モードは、コンパイル量が少ないこ
とからコンパイル時間が速くできる。
This message transmission sets the dynamic binding mode “dy
namic ", the dynamic expansion unit 12
Expands this message transmission as i = get (patient, “age”); That is, when the program is executed, “get”
Tracing the object through the procedure "pati
The dynamic binding mode that is expanded in this way can reduce the amount of compilation and speed up the compilation time.

一方、このメッセージ送信が静的結合モードを設定す
る“nodynamic"とともに記述されているときには、静的
展開部13は、このメッセージ送信を、コンパイル情報を
参照することで“age"のアドレスに直接アクセスする形
式である、 i=patient→age; にと展開する。すなわち、プログラムの実行時に、オブ
ジェクトをたどらずに“patientの年令”を直接参照で
きるようにと展開する。このように展開される静的結合
モードは、実行時にオブジェクトをたどらないことから
実行速度を速くできる。
On the other hand, when this message transmission is described with “nodynamic” that sets the static binding mode, the static expansion unit 13 directly accesses the address of “age” by referring to the compilation information. Expands to the form i = patient → age; That is, when the program is executed, it is expanded so that the "age of patient" can be directly referred to without following the object. The static binding mode expanded in this way can increase the execution speed because the object is not traced at the time of execution.

これから、本発明によれば、プログラムの開発時に
は、動的結合モードに設定してコンパイル効率を優先し
てデバックを行い、プログラムの実行時には、静的結合
モードに設定して実行速度を優先するようにできる。従
って、オブジェクト指向言語の実用性を高めることがで
きるのである。
From now on, according to the present invention, at the time of developing a program, debugging is performed with priority given to compile efficiency by setting to the dynamic coupling mode, and at the time of program execution, priority is given to execution speed by setting to the static coupling mode. Can be. Therefore, the practicality of the object-oriented language can be improved.

〔実施例〕〔Example〕

以下、実施例に従って本発明を詳細に説明する。 Hereinafter, the present invention will be described in detail with reference to examples.

オブジェクト指向言語では、データ処理の実行のため
に必要となる対象分野の知識モデルを、第2図に示すよ
うに、オブジェクトの階層構造をもって表すことにな
る。そして、これらのオブジェクトが、属性データとそ
の属性データに対するメソッドを1つにまとめて持つよ
う構成されるとともに、上位・上層のオブジェクトの持
つ属性データとメソッドは、下位・下層のオブジェクト
へと継承されるよう構成されることになる。
In an object-oriented language, a knowledge model of a target field required for executing data processing is represented by a hierarchical structure of objects as shown in FIG. These objects are configured to have attribute data and methods for the attribute data collectively, and the attribute data and methods of the upper and upper layer objects are inherited by the lower and lower layer objects. It will be configured to be.

このようなデータ構造を持つオブジェクト指向言語で
は、メッセージ送信に従って、下位・下層に位置するオ
ブジェクトに対してメソッドの起動要求があると、上位
・上層に位置するオブジェクトをたどって、継承元のオ
ブジェクトを捜し出していくという必要があるのであ
る。しかしながら、このような探索処理を実行時に委ね
ると、実行速度の低下を招くことになる。そこで、本発
明は、オブジェクト指向言語で記述されたプログラムを
コンパイル処理し、そのとき作成されるコンパイル時情
報に従って、起動要求のあるメソッドを直接アクセスで
きるようにすることで、実行速度を上げることを提案す
るものである。
In an object-oriented language having such a data structure, when a method activation request is issued to an object located at a lower or lower layer according to a message transmission, the object located at an upper layer or an upper layer is traced, and an object of an inheritance source is determined. You need to find it. However, if such a search process is left at the time of execution, the execution speed will be reduced. Therefore, the present invention proposes to increase the execution speed by compiling a program described in an object-oriented language and enabling direct access to a method having an activation request according to compile-time information created at that time. Is what you do.

第3図に、プリプロセッサをもって本発明を実現した
ときの実施例構成図を示す。図中、100は、入力ファイ
ルに格納されてあるオブジェクト指向言語で記述された
プログラムをプリコンパイル処理するプリプロセッサ、
200は、プリプロセッサ100のプリコンパイル処理の実行
のために用いられる解析ルーチン群、300は、プリプロ
セッサ100のプリコンパイル処理時に参照され、更新さ
れ、そして登録されることになるコンパイル時情報を管
理するコンパイル時情報モジュールである。このプリプ
ロセッサ100は、プリコンパイル処理の実現のために、
スキャナ101、分類部102、解析部103、生成部104及びC
プリプロセッサ105を備えることになる。そして、解析
ルーチン群200は、オブジェクト指向言語文のシンタク
スに合わせて、ドット式参照解析ルーチン201、ドット
式置換解析ルーチン202、メッセージ送信式解析ルーチ
ン203、指定文解析ルーチン204、制御文解析ルーチン20
5、インスタンス型変数宣言文解析ルーチン206、生成文
解析ルーチン207を備えることになる。
FIG. 3 shows a configuration diagram of an embodiment when the present invention is realized by a preprocessor. In the figure, reference numeral 100 denotes a preprocessor that precompiles a program described in an object-oriented language stored in an input file,
Reference numeral 200 denotes a group of analysis routines used for executing the precompile process of the preprocessor 100, and reference numeral 300 denotes a compile that manages compile time information to be referred, updated, and registered at the time of the precompile process of the preprocessor 100. Time information module. This preprocessor 100 is used to realize a precompile process.
Scanner 101, classification unit 102, analysis unit 103, generation unit 104, and C
A preprocessor 105 will be provided. The analysis routine group 200 includes a dot expression reference analysis routine 201, a dot expression replacement analysis routine 202, a message transmission expression analysis routine 203, a designated statement analysis routine 204, and a control statement analysis routine 20 according to the syntax of the object-oriented language sentence.
5, an instance type variable declaration statement analysis routine 206 and a generated statement analysis routine 207 are provided.

次に、プリプロセッサ100の処理内容について説明す
る。プリプロセッサ100は、入力ファイルに格納されて
あるユーザソースを順次読み取るとともに、スキャナ10
1でスキャンして、オブジェクト指向言語の部分とそれ
以外の言語の部分を切り出す処理を行う。例えば親言語
となるC言語上にオブジェクト指向言語が記述されてい
るときには、C言語の部分とオブジェクト指向言語の部
分とを分離するのである。そして、分類部102で切り出
されたオブジェクト指向言語文のタイプを分類し、次の
解析部103で、解析ルーチン群200中にあるこの分類され
たタイプの解析ルーチンに従ってその文を解析し、続く
生成部104で、解析結果に従ってマクロ文を含む展開ソ
ースを生成して、出力ファイルにと格納するよう処理す
る。そして、最後に、Cプリプロセッサ105(親言語が
C言語であるのでCプリプロセッサとなる)は、システ
ム定義のマクロ定義文を参照することで、出力ファイル
に格納されたマクロ文を含む展開ソースから展開ソース
を生成して処理を終了する。
Next, processing contents of the preprocessor 100 will be described. The preprocessor 100 sequentially reads the user source stored in the input file, and
Scanning is performed in step 1 to cut out parts of the object-oriented language and parts of other languages. For example, when an object-oriented language is described in the parent language C, the C language part and the object-oriented language part are separated. Then, the type of the object-oriented language sentence cut out by the classification unit 102 is classified, and the next analysis unit 103 analyzes the sentence according to the analysis routine of the classified type in the analysis routine group 200, and generates the next sentence. The unit 104 generates an expansion source including a macro sentence according to the analysis result, and stores the generated expansion source in an output file. Finally, the C preprocessor 105 (which becomes a C preprocessor because the parent language is C language) expands from the expansion source including the macro statement stored in the output file by referring to the system-defined macro definition statement. Generate the source and end the process.

この解析部103と生成部104の処理の際に、コンパイル
時情報モジュール300の管理するコンパイル時情報が参
照され、更新され、登録されることになるのである。こ
のコンパイル時情報としては、オブジェクト情報に関す
るものでは、例えばオブジェクト名、スーパークラス
名、属性情報リスト、メソッド情報リスト等があり、ま
た変数管理表に関するものでは、例えば変数名、属する
クラス名等がある。
At the time of processing by the analysis unit 103 and the generation unit 104, the compile time information managed by the compile time information module 300 is referred to, updated, and registered. The compile-time information includes, for example, an object name, a superclass name, an attribute information list, and a method information list in the case of object information, and includes, for example, a variable name and a class name to which the variable management table belongs. .

このように、本発明では、オブジェクト指向言語で記
述されたプログラムを、コンパイルしてから実行に移そ
うとするものである。これから、オブジェクトの属性デ
ータやメソッドの継承情報がコンパイル時情報として蓄
えられているので、実行時に、継承元のオブジェクトを
探索していくという処理の必要がなくなり、実行速度が
上がるのである。
As described above, according to the present invention, a program described in an object-oriented language is compiled and then executed. From now on, since the attribute data of the object and the inheritance information of the method are stored as the compile time information, it is not necessary to search for the inheritance source object at the time of execution, and the execution speed is increased.

しかしながら、継承情報の遺伝処理をすべてコンパイ
ル時に静的な結合で解決してしまう上記の方法では、コ
ンパイル時間がかかり過ぎるという面がででくる。従っ
て、デバックの処理を必ず要求されることになるユーザ
ソースの開発には適さないのである。そして、このよう
なことが起こると、モジュリテイが高いというオブジェ
クト指向言語の長所を台無しにしてしまうことになる。
そこで、本発明では、継承情報の遺伝処理を実行時に委
ねるという動的な結合モードを、併せ持つようにとする
ことを提案するのである。この動的結合モードでは、オ
ブジェクト指向言語で記述された文は、“put"“getvst
r"“send"等の探索処理を実行する関数に展開されるこ
とになる。
However, in the above-described method in which all the genetic processing of the inheritance information is solved by static combination at the time of compilation, there is a problem that compilation time is excessively long. Therefore, it is not suitable for the development of a user source that requires debugging processing. When this happens, the advantage of an object-oriented language with high modularity is ruined.
Therefore, the present invention proposes to have a dynamic connection mode in which genetic processing of inheritance information is entrusted at the time of execution. In this dynamic binding mode, statements written in an object-oriented language are “put” “getvst
The function is expanded to a function that executes search processing such as r "" send ".

静的結合モードの設定は、具体的には、ユーザソース
の例えばヘッド記述部に“nodynamic"と記述することで
実現され、動的結合モードの設定は、具体的には、ユー
ザソースの例えばヘッド記述部に“dynamic"と記述する
ことで実現される。そして、解析部103は、ユーザソー
スが“nodynamic"か“dynamic"のいずれに設定されてい
るかを判断し、その判断結果に従って、生成部104は、
展開ソースの展開方式を決定することになる。
The setting of the static binding mode is specifically realized by writing “nodynamic” in, for example, the head description section of the user source, and the setting of the dynamic binding mode is specifically, for example, the head description of the user source. This is realized by writing "dynamic" in the description part. Then, the analysis unit 103 determines whether the user source is set to “nodynamic” or “dynamic”, and according to the determination result, the generation unit 104
This will determine the deployment method of the deployment source.

このような2つのモードを持つことで、ユーザソース
の開発時には、第4図に示すように、デバックの対象と
なるユーザソースを動的結合モードに設定し、コンパイ
ル速度を優先する形式でプリプロセッサ100によるプリ
コンパイル処理を実行する。そして、Cコンパイラで、
デバックの終了している目的プログラムとリンクさせる
ことで実行プログラムを生成し、プログラムのデバッキ
ングを効率的に行っていくことになる。このようにし
て、ユーザソースのデバッキングが終了すると、今度は
第5図に示すように、ユーザソースを静的結合モードに
設定し、実行速度を優先する形式でプリプロセッサ100
によるコンパイル処理を実行する。そして、Cコンパイ
ラでリンクさせて、最終的な実行プログラムを生成する
のである。
By having such two modes, at the time of developing the user source, the user source to be debugged is set to the dynamic binding mode as shown in FIG. Execute the pre-compile process. And with a C compiler,
The execution program is generated by linking with the target program for which debugging has been completed, and the program is efficiently debugged. In this manner, when the debugging of the user source is completed, the user source is set to the static binding mode, and the preprocessor 100 is executed in a format giving priority to the execution speed, as shown in FIG.
Compile processing by. Then, a final executable program is generated by linking with a C compiler.

次に、第6図に示す具体的なプログラム例に従って、
本発明の処理内容についてみてみることにする。ここ
で、この第6図に示すプログラムは、C言語を親言語に
している。
Next, according to the specific program example shown in FIG.
The processing contents of the present invention will be described. Here, the program shown in FIG. 6 uses C language as a parent language.

第6図中の部分に示すプログラムは、医療kb(kb
は、ノリッジベースのこと)において、患者クラスを生
成するというプログラムである。スーパークラスが“人
間”であり、属性データとして“病名”と“担当医”を
有し、メソッドとして“診断証明書作成”を有している
ことを定義している。また第6図中の部分に示すプロ
グラムは、医療kbにおいて、エイズ患者の診断証明書を
3部作成するというプログラムである。
The program shown in the part in FIG.
Is a program that generates a patient class based on the knowledge base. It is defined that the superclass is "human", has "disease name" and "medical doctor" as attribute data, and has "create diagnosis certificate" as a method. The program shown in FIG. 6 is a program for creating three copies of a medical certificate for an AIDS patient in a medical kb.

この第6図のプログラムが静的結合モードの下でコン
パイルするよう指示されているときに、プリプロセッサ
100がプリコンパイルしたC言語のプログラムが第7図
に示すプログラムであり、動的結合モードの下でコンパ
イルするよう指示されているときに、プリプロセッサ10
0がプリコンパイルしたC言語のプログラムが第8図に
示すプログラムである。但し、第6図に示すプログラム
では診断証明書クラスの定義部分を省略してあるので、
第7図及び第8図中の部分に対応する部分は第6図に
存在しない。また第6図の部分のプログラムは、第7
図及び第8図の部分のプログラムにプリコンパイルさ
れ、第6図の部分のプログラムは、第7図及び第8図
の部分のプログラムにプリコンパイルされることにな
る。
When the program of FIG. 6 is instructed to compile under static binding mode, the preprocessor
When the precompiled C language program 100 is the program shown in FIG. 7 and is instructed to compile under the dynamic binding mode, the preprocessor 10
0 is the precompiled C language program shown in FIG. However, in the program shown in FIG. 6, since the definition part of the diagnostic certificate class is omitted,
Parts corresponding to those in FIGS. 7 and 8 are not present in FIG. The program in the part of FIG.
The program shown in FIG. 6 is precompiled into the program shown in FIGS. 7 and 8, and the program shown in FIG. 6 is precompiled into the program shown in FIGS.

次に、第6図の部分 $doc.患者氏名=$self.氏名; が、静的結合モードであるときのプリコンパイル処理を
具体的に説明することにする。ここで部分は、患者ク
ラスの属性データの“氏名”を、診断証明書クラスの属
性データの“患者氏名”に代入するというプログラムで
ある。
Next, the precompilation processing when the part {doc.patient name = $ self.name; in FIG. 6 is in the static binding mode will be specifically described. Here, the part is a program for substituting the “name” of the attribute data of the patient class into the “patient name” of the attribute data of the diagnostic certificate class.

スキャナ101により切り出された部分は、分類部102
の実行するシンタクス解析により、ドット式置換である
ことが求まることになる。ここで、ドット式置換とは、 オブジェクト式=オブジェクト式; というシンタクスをとるものであり、いわゆる代入文で
ある。これから、解析部103はドット式置換解析ルーチ
ン202を使って、左右のドット式を解析する。まず、オ
ブジェクト式のオブジェクト指定からインスタンス型変
数を取り出し、その変数がすでに宣言されているかを調
べ、宣言されていればそのクラスを調べる。この処理に
より、“doc"が診断証明書クラスに属するインスタンス
型変数であることが求まる。次に、オブジェクト式のド
ット列を解析して属性情報を検索し、そのリストを解析
結果として保存する。この処理により、診断証明書クラ
スの属性データである“患者氏名”がドット解析情報の
リストに加えられる。
The portion cut out by the scanner 101 is a classification unit 102
Will be found to be dot-type replacement. Here, the dot expression replacement has a syntax of object expression = object expression; it is a so-called assignment statement. From now on, the analysis unit 103 analyzes the left and right dot expressions using the dot expression replacement analysis routine 202. First, the instance type variable is extracted from the object specification of the object expression, and it is checked whether the variable is already declared. If so, the class is checked. By this processing, it is determined that “doc” is an instance type variable belonging to the diagnostic certificate class. Next, the dot row of the object expression is analyzed to search for attribute information, and the list is stored as an analysis result. By this processing, “patient name” which is attribute data of the diagnostic certificate class is added to the list of dot analysis information.

続いて生成部104は、この解析結果に従ってCプログ
ラムを生成する。まず左辺から生成し、インスタンス型
変数が、対応するドット解析情報リストの属性名をアク
セスするよう生成される。この処理により、ここでは、
“doc→患者氏名”が生成される。次に、等号を生成
し、続いて右辺を、左辺と同様に展開する。そして、セ
ミコロンを生成して、 doc→患者氏名=self→氏名; を生成する。これが、第7図の部分である。
Subsequently, the generation unit 104 generates a C program according to the analysis result. First, the variable is generated from the left side, and an instance type variable is generated to access the attribute name of the corresponding dot analysis information list. By this processing, here,
“Doc → patient name” is generated. Next, an equal sign is generated, and then the right side is expanded in the same manner as the left side. Then, a semicolon is generated, and doc → patient name = self → name; is generated. This is the part of FIG.

次に、第6図の部分 $doc.print(); が、静的結合モードであるときのプリコンパイル処理を
具体的に説明することにする。ここで、部分は、診断
証明書をプリントするというプログラムである。
Next, the precompilation processing when the part {doc.print (); in FIG. 6 is in the static binding mode will be specifically described. Here, the part is a program for printing a diagnostic certificate.

スキャナ101により切り出された部分は、分類部102
の実行するシンタクス解析により、メッセージ送信式で
あることが求まることになる。ここで、メッセージ送信
式とは、 オブジェクト式.セレクタ名(パラメータ列); というシンタクスをとるものである。これから、解析部
103はメッセージ送信式解析ルーチン203を使って、メッ
セージ受信オブジェクトのクラスを求め、そして、セレ
クタ名に対応するメソッドの関数定義名を求める。続い
て生成部104は、この解析結果に従ってCプログラムを
生成する。具体的には、メッセージ送信式を、 関数名(オブジェクト式,パラメータ列) に変換することで生成する。この処理により、 _m_1_診断証明書(doc); が生成される。これが、第7図の部分である。
The portion cut out by the scanner 101 is a classification unit 102
Is determined to be a message transmission type by the syntax analysis performed by Here, the message transmission expression is an object expression. The syntax is as follows: selector name (parameter string); From now on, the analysis unit
103 obtains the class of the message receiving object by using the message transmission expression analysis routine 203, and obtains the function definition name of the method corresponding to the selector name. Subsequently, the generation unit 104 generates a C program according to the analysis result. Specifically, it is generated by converting a message transmission expression into a function name (object expression, parameter string). By this processing, _m_1_diagnosis certificate (doc); is generated. This is the part of FIG.

一方、部分と部分が動的結合モードであるときに
は、第8図に示すように、“put"“getvstr"“send"を
使ってプリコンパイルすることになる。ここで、“put"
は、オブジェクト(第1引数)の属性(第2引数)に値
(第3引数)を追加する関数、“getvstr"は、オブジェ
クト(第1引数)の属性(第2引数)の値を求める関
数、“send"は、オブジェクト(第1引数)のセレクタ
(第2引数)に相当するメソッドのアドレスを求める関
数である。すなわち、動的結合モードのときには、汎用
関数に従ってメソッドや属性データをサーチングするよ
うな形式で、プログラムを展開するのである。
On the other hand, when the parts are in the dynamic connection mode, as shown in FIG. 8, pre-compilation is performed using "put", "getvstr", and "send". Where “put”
Is a function that adds a value (third argument) to the attribute (second argument) of the object (first argument), and "getvstr" is a function that calculates the value of the attribute (second argument) of the object (first argument) , "Send" is a function for obtaining the address of the method corresponding to the selector (second argument) of the object (first argument). That is, in the dynamic binding mode, the program is developed in such a form as to search for a method or attribute data according to a general-purpose function.

このように、ユーザソースが静的結合モードに設定さ
れているときには、オブジェクトの属性データやメソッ
ドの継承情報をコンパイル時情報として蓄え、それをも
とに遺伝処理を反映したようなプログラム列に展開する
のである。これから、実行時に、属性データやメソッド
の遺伝処理が高速になされることになるのである。そし
て、グローバルメソッドにあっても、従来では必要とさ
れていた、どのグローバルメソッドであるかを特定する
ためのマッチング処理が不要となる。また、ポリモルフ
ィズムも、クラスのサーチングさえ終了すれば後はダイ
レクトにアクセスできることになる。更に、デモンやデ
フォルト値の遺伝処理も同様に高速化できることになる
のである。
As described above, when the user source is set to the static binding mode, the attribute data of the object and the inheritance information of the method are stored as compile-time information, and based on the information, are expanded into a program sequence that reflects genetic processing. You do it. From now on, at the time of execution, genetic processing of attribute data and methods will be performed at high speed. In addition, even in the case of a global method, the matching process for specifying which global method is conventionally required is unnecessary. In addition, polymorphism can be directly accessed after the class search is completed. Furthermore, genetic processing of demons and default values can be similarly accelerated.

以上、図示実施例について説明したが、本発明はこれ
に限定されるものではない。例えば、プリプロセッサに
対しての適用で説明したが、コンパイラであってもよい
のである。また、親言語はC言語に限られるものではな
い。
Although the illustrated embodiment has been described above, the present invention is not limited to this. For example, as described in the application to the preprocessor, a compiler may be used. The parent language is not limited to the C language.

〔発明の効果〕〔The invention's effect〕

以上説明したように、本発明によれば、開発時には、
動的結合モードによるコンパイル処理で開発効率を上
げ、稼働時には、静的結合モードによるコンパイル処理
で実行速度の速いプログラムを生成できるようになるこ
とから、オブジェクト指向言語の実用性を高めることが
できることになる。
As described above, according to the present invention, at the time of development,
Compile processing in the dynamic binding mode increases development efficiency, and in operation, compile processing in the static binding mode makes it possible to generate a program with a high execution speed, thereby improving the practicality of an object-oriented language. Become.

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

第1図は本発明の原理構成図、 第2図はオブジェクトの階層構造の説明図、 第3図は本発明の実施例構成図、 第4図及び第5図は本発明のプリプロセッサの使用方法
の説明図、 第6図はプログラムの具体例、 第7図は静的結合モードにある第6図のプログラムのコ
ンパイル処理の説明図、 第8図は動的結合モードにある第6図のプログラムのコ
ンパイル処理の説明図である。 図中、10は翻訳部、11はモード判断部、12は動的展開
部、13は静的展開部、20は後段翻訳部、30は実行モジュ
ール、40はソースプログラムファイル、50は動的中間フ
ァイル、60は静的中間ファイル、70は実行プログラムフ
ァイル、100はプリプロセッサ、101はスキャナ、102は
分類部、103は解析部、104は生成部、105はCプリプロ
セッサ、200は解析ルーチン群、300はコンパイル時情報
モジュールである。
FIG. 1 is a diagram showing the principle of the present invention, FIG. 2 is an explanatory diagram of the hierarchical structure of an object, FIG. 3 is a diagram showing an embodiment of the present invention, and FIGS. 4 and 5 are methods for using the preprocessor of the present invention. , FIG. 6 is a specific example of a program, FIG. 7 is an explanatory diagram of a compile process of the program in FIG. 6 in a static binding mode, and FIG. 8 is a program in FIG. 6 in a dynamic binding mode. FIG. 9 is an explanatory diagram of a compiling process of FIG. In the figure, 10 is a translation unit, 11 is a mode determination unit, 12 is a dynamic expansion unit, 13 is a static expansion unit, 20 is a post-stage translation unit, 30 is an execution module, 40 is a source program file, and 50 is a dynamic intermediate File, 60 is a static intermediate file, 70 is an execution program file, 100 is a preprocessor, 101 is a scanner, 102 is a classifier, 103 is an analyzer, 104 is a generator, 105 is a C preprocessor, 200 is a group of analysis routines, 300 Is a compile-time information module.

フロントページの続き (56)参考文献 電子情報通信学会全国大会(昭和62 年)講演論文集(1987−3)P.7−51 1707「オブジェクト指向型言語spi ce Cのメッセージパッシング」 インターフェース、13[1](NO. 116)(1987−1)、CQ出版社、p. 188−206. 発明協会公開技報 公技番号 85− 14095Continuation of the front page (56) References Proceedings of the IEICE National Convention (1987), 1987-3, p. 7-51 1707 "Message passing of object-oriented language space C" Interface, 13 [1] (NO. 116) (1987-1), CQ Publishing Co., p. 188-206. No. 85− 14095

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】オブジェクト指向言語で記述されたソース
プログラムを翻訳処理することで、所定の言語で記述さ
れた翻訳プログラムを生成するための翻訳処理装置であ
って、 この翻訳処理装置が、 ソースプログラムを動的結合モードと静的結合モードと
のいずれでコンパイルするかを指示するための情報にも
とづいて当該ソースプログラムをいずれのモードの下で
コンパイルするかを判断するモード判断部(11)と、 このモード判断部(11)が動的結合モードであることを
判断したときに、ソースプログラムの複数個のオブジェ
クトにおける個々のオブジェクトの継承情報の探索が実
行段階で行われるような形式をもって翻訳プログラムを
展開する動的展開部(12)と、 上記モード判断部(11)が静的結合モードであることを
判断したときに、ソースプログラムの複数個のオブジェ
クトにおける個々のオブジェクトの継承情報の探索が翻
訳情報に従って実行できるような形式をもって翻訳プロ
グラムを展開する静的展開部(13)と を備えてなる ことを特徴とするオブジェクト指向言語の翻訳処理装
置。
1. A translation processing apparatus for generating a translation program described in a predetermined language by translating a source program described in an object-oriented language, the translation processing apparatus comprising: A mode judging unit (11) for judging under which mode the source program is to be compiled based on information for indicating whether to compile the source program in the dynamic binding mode or the static binding mode; When the mode determination unit (11) determines that the mode is the dynamic combination mode, the translation program is formatted in such a manner that the search for the inheritance information of each object in the plurality of objects of the source program is performed in the execution stage. When the dynamic expansion unit (12) to be expanded and the mode determination unit (11) determine that the mode is the static binding mode And a static expansion unit (13) for expanding the translation program in a format in which search for inheritance information of each object in a plurality of objects of the source program can be executed according to the translation information. Language translation processor.
JP63147181A 1988-06-15 1988-06-15 Object oriented language translation processor Expired - Fee Related JP3085956B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP63147181A JP3085956B2 (en) 1988-06-15 1988-06-15 Object oriented language translation processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63147181A JP3085956B2 (en) 1988-06-15 1988-06-15 Object oriented language translation processor

Publications (2)

Publication Number Publication Date
JPH022426A JPH022426A (en) 1990-01-08
JP3085956B2 true JP3085956B2 (en) 2000-09-11

Family

ID=15424413

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63147181A Expired - Fee Related JP3085956B2 (en) 1988-06-15 1988-06-15 Object oriented language translation processor

Country Status (1)

Country Link
JP (1) JP3085956B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08249185A (en) 1995-03-15 1996-09-27 Fujitsu Ltd Object data processor
KR100788212B1 (en) * 2007-09-21 2007-12-26 (주) 이지가스터빈 알앤디 Creation method for airpalne's gas turbine engine

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
1707「オブジェクト指向型言語spice Cのメッセージパッシング」
インターフェース、13[1](NO.116)(1987−1)、CQ出版社、p.188−206.
発明協会公開技報 公技番号 85−14095
電子情報通信学会全国大会(昭和62年)講演論文集(1987−3)P.7−51

Also Published As

Publication number Publication date
JPH022426A (en) 1990-01-08

Similar Documents

Publication Publication Date Title
JP3041222B2 (en) Source code creation system and method
US5675801A (en) Object oriented system and method for generating target language code
US5946488A (en) Method for selectively and incrementally displaying the results of preprocessing
US6063133A (en) No preprocessor for embedded SQL in a 3GL
US6874140B1 (en) Debug annotations
US6467082B1 (en) Methods and apparatus for simulating external linkage points and control transfers in source translation systems
JPH04247536A (en) Computer software compile system assisting discrimination of data type at time of execution of object
JPH11501421A (en) Tree data structure manipulation and method and apparatus for translating source code from one high-level computer language to another
JP6651977B2 (en) Information processing apparatus, compiling method, and compiling program
JP3085956B2 (en) Object oriented language translation processor
US5404531A (en) Method and apparatus for compiler processing on program related to data transfer and calculation, and method of managing memory
Chiba A study of compile-time metaobject protocol
GB2420638A (en) Method of substituting code fragments in Internal Representation
Faith Debugging programs after structure-changing transformation
EP0706125A1 (en) Object oriented system and method for generating target language code
JP2002132502A (en) Automatic creating system and method of distributed object with interpretation of language function
Grabmüller Constraint-imperative Programmierung
Walker et al. An optimizing compiler for the Icon programming language
O'Regan et al. History of programming languages
Benson Libscheme: Scheme as a C library
Budd et al. Why A Compiler?
Dévai et al. The EDSL’s struggle for their sources
JP3551352B2 (en) Loop splitting method
Rhiger Higher-Order program generation
JPH10207738A (en) Language processing system

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees