JP2002108628A - Program converter - Google Patents

Program converter

Info

Publication number
JP2002108628A
JP2002108628A JP2000304148A JP2000304148A JP2002108628A JP 2002108628 A JP2002108628 A JP 2002108628A JP 2000304148 A JP2000304148 A JP 2000304148A JP 2000304148 A JP2000304148 A JP 2000304148A JP 2002108628 A JP2002108628 A JP 2002108628A
Authority
JP
Japan
Prior art keywords
area
statement
object generation
program
size
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2000304148A
Other languages
Japanese (ja)
Inventor
Toshiyuki Sakata
俊幸 坂田
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co 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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2000304148A priority Critical patent/JP2002108628A/en
Publication of JP2002108628A publication Critical patent/JP2002108628A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a program converter to convert a source program in which an object generating function including a dynamic area securing sentence consisting of a new operator, etc., to dynamically secure an area and to be substituted for a variable is described into a machine language program with high execution speed and a low execution cost. SOLUTION: When the dynamic area securing sentence exists in the object generating function, an object generating function converting part 103 adds a pointer type tentative argument to the object generating function and generates a static object generating function by replacing the dynamic area securing sentence with a substitution sentence for the variable of the pointer type tentative argument. An object generating sentence converting part 106, etc., create data of attributes to secure an area with the size to be secured by the dynamic area securing sentence when the size is calculated, translates the object generating sentence by converting an address of its data into a sentence to be provided to the static object generating function as an actual argument, and converts it into data of a ROM area arrangement attribute when all the member variables are calculated and remain unchanged in the case of translation.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、ソースプログラム
を機械語命令列に変換するプログラム変換装置に関し、
特にオブジェクト生成文を含むオブジェクト指向言語の
ソースプログラムを変換対象とするプログラム変換装置
に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a program conversion device for converting a source program into a machine language instruction sequence.
In particular, the present invention relates to a program conversion device for converting an object-oriented language source program including an object generation statement into a conversion target.

【0002】[0002]

【従来の技術】オブジェクト指向言語において、オブジ
ェクト(インスタンス)は、使用する前に生成する必要
があり、オブジェクト生成関数を呼び出すオブジェクト
生成文により生成される。ここで、オブジェクト生成関
数は、オブジェクトのメンバ関数の1つであり、一般に
オブジェクトの初期設定等の処理を内容とするように設
計されるものである。なお、オブジェクト生成関数の名
称は、オブジェクト名に関する情報を含む。
2. Description of the Related Art In an object-oriented language, an object (instance) must be generated before use, and is generated by an object generation statement that calls an object generation function. Here, the object generation function is one of the member functions of the object, and is generally designed to include processing such as initial setting of the object. Note that the name of the object generation function includes information on the object name.

【0003】以下、オブジェクト指向言語C++(以
下、「C++言語」という。)で記述されたソースプロ
グラムを機械語プログラムに変換(翻訳)する従来のプ
ログラム変換装置の説明を行なう。ここで、変換の語
は、ソースプログラム等の変換対象に基づいて機械語プ
ログラム等の結果物を生成することを意味するものとし
て用いており、変換対象自体を更新することを意味する
ものではない。
Hereinafter, a conventional program conversion apparatus for converting (translating) a source program described in an object-oriented language C ++ (hereinafter, referred to as "C ++ language") into a machine language program will be described. Here, the term of conversion is used to mean that a result such as a machine language program is generated based on a conversion target such as a source program, and does not mean that the conversion target itself is updated. .

【0004】図12は、オブジェクト生成関数を含むク
ラスIntArrayの定義と、クラスIntArra
yのオブジェクトを生成するオブジェクト生成文とを含
むC++言語のソースプログラムの一部を示す図であ
る。C++言語では、オブジェクト生成関数はコンスト
ラクタと呼ばれ、クラス名と同じ名前の関数で表され
る。同図に示す「IntArray(int siz
e)」がクラスIntArrayのオブジェクト生成関
数である。
FIG. 12 shows a definition of a class IntArray including an object generation function and a class IntArray.
FIG. 14 is a diagram illustrating a part of a source program in the C ++ language including an object generation statement for generating an object of y. In the C ++ language, an object generation function is called a constructor and is represented by a function having the same name as a class name. "IntArray (int siz
e) "is an object generation function of the class IntArray.

【0005】このオブジェクト生成関数中の「memp
=new int[size];」は、int型の変数
がsizeで示された個数分からなる配列用のメモリ領
域を動的に確保して、そのメモリ領域の先頭アドレスを
mempに代入する意味の文である。以下、演算子ne
wを含む文等、実行時に動的にメモリ領域を確保してそ
のメモリ領域の先頭アドレスをポインタ型の変数に代入
する文を動的領域確保文という。なお、同図中には示し
ていないが、クラスIntArrayには、ポインタ型
のメンバ変数mempを利用してメモリにアクセスする
ようなメンバ関数がオブジェクト生成関数以外にも存在
する。
[0005] In this object generation function, "mem"
== new int [size]; ”is a statement that dynamically allocates a memory area for an array having the number of int-type variables indicated by size and substitutes the start address of the memory area into memp. It is. Hereinafter, the operator ne
A statement that dynamically allocates a memory area at the time of execution and assigns the start address of the memory area to a pointer-type variable, such as a statement including w, is called a dynamic area allocation statement. Although not shown in the figure, the class IntArray has a member function other than the object generation function that accesses the memory using the pointer-type member variable memp.

【0006】また、C++言語では、オブジェクト生成
文は、オブジェクトの宣言文として記述され、同図に示
すオブジェクトの宣言文「const IntArra
yArrayObj(10);」がクラスIntArr
ayのオブジェクト「ArrayObj」を生成する意
味を有する。このオブジェクトの宣言文において「Ar
rayobj」の後の「(10)」は、オブジェクト生
成関数に渡す実引数である。
In the C ++ language, an object creation statement is described as an object declaration statement, and the object declaration statement “const IntArra” shown in FIG.
yArrayObj (10); "is the class IntArr
It has the meaning of generating the object “ArrayObj” of “ay”. In the declaration of this object, "Ar
“(10)” after “rayobj” is an actual argument to be passed to the object generation function.

【0007】また、「const IntArray
ArrayObj(10)」の先頭の修飾子「cons
t」は生成されるオブェクトが値の変化しないオブジェ
クトであることを表している。以下、このような値の変
化しないオブジェクトを、constオブジェクトとい
う。なお、このオブジェクト「Arrayobj」は、
関数や他のオブジェクトから参照可能な大域的なオブジ
ェクトであるため、このソースプログラムが機械語に翻
訳されて実行され始めるまでには、必ずメモリに確保さ
れるものである。
[0007] Also, "const IntArray
ArrayObj (10) "at the beginning of the qualifier" cons
"t" indicates that the generated object is an object whose value does not change. Hereinafter, an object whose value does not change is referred to as a const object. Note that this object "Arrayobj" is
Since this is a global object that can be referenced from functions and other objects, it is always secured in memory before this source program is translated into machine language and started to be executed.

【0008】プログラム変換装置は、ソースプログラム
を機械語に翻訳するいわゆるコンパイラであり、ソース
プログラムを参照することにより、特定のプロセッサ上
で実行可能な機械語プログラムを生成する。家電機器等
への組み込み用マイクロコンピュータの分野でのプログ
ラムの開発においては、ソースプログラム中のデータ
は、プログラム変換装置により、RAM領域に配置され
るべき属性を有するデータ又はROM領域に配置される
べき属性を有するデータに翻訳され、ソースプログラム
中の各手続きは、ROM領域に配置されるべき属性を有
するコードに翻訳される。
The program conversion device is a so-called compiler that translates a source program into a machine language, and generates a machine language program executable on a specific processor by referring to the source program. In the development of programs in the field of microcomputers for embedding in home electric appliances and the like, data in a source program should be allocated to data having attributes to be allocated to a RAM area or to a ROM area by a program conversion device. Each procedure in the source program is translated into data having the attribute, and is translated into a code having the attribute to be arranged in the ROM area.

【0009】ここで、RAM領域とは読み書き可能なメ
モリ領域をいい、ROM領域とは読み出しのみが可能な
メモリ領域をいう。プログラム変換装置によって出力さ
れた機械語プログラムは、コードやデータがそれぞれの
配置属性に基づきROM領域やRAM領域に配置され
て、特定のプロセッサ上においてオペレーティングシス
テム(OS)等の制御下で、実行されることになる。つ
まり、ここでいうコードはCPUに実行されることにな
る機械語命令列であり、データはOSによってコードの
実行前にメモリに配置されるものである。
Here, the RAM area refers to a readable / writable memory area, and the ROM area refers to a readable only memory area. The machine language program output by the program conversion device has codes and data arranged in a ROM area or a RAM area based on the respective arrangement attributes, and is executed on a specific processor under the control of an operating system (OS) or the like. Will be. That is, the code here is a machine language instruction sequence to be executed by the CPU, and the data is arranged in the memory before the OS executes the code.

【0010】従来のプログラム変換装置は、図12に示
すようなオブジェクト生成文をオブジェクトデータとオ
ブジェクト生成関数を呼び出すサブルーチンコール命令
とに翻訳する。ここで、オブジェクトデータとは、オブ
ジェクトのメンバ変数の集合をいう。従来のプログラム
変換装置は、上述のサブルーチンコール命令をROM領
域に配置されるべき属性を有するコードとして生成し、
オブジェクトデータについては、常にRAM領域に配置
されるべき属性を有するデータとして生成する。
A conventional program conversion device translates an object generation statement as shown in FIG. 12 into object data and a subroutine call instruction for calling an object generation function. Here, the object data refers to a set of member variables of the object. A conventional program conversion device generates the above-described subroutine call instruction as a code having an attribute to be arranged in a ROM area,
The object data is always generated as data having an attribute to be arranged in the RAM area.

【0011】かかるオブジェクトデータが常にRAM領
域に配置されるべき属性を有するデータとして生成され
る理由は、オブジェクトが生成されるときに実行される
オブジェクト生成関数の動作によって、オブジェクトの
メンバ変数に対して動的に値が設定される得るからであ
る。このことは、生成されるオブジェクトがconst
オブジェクトであっても変わらない。
[0011] The reason that such object data is always generated as data having an attribute to be arranged in the RAM area is that the operation of the object generation function executed when the object is generated causes the member variable of the object to be generated. This is because the value can be set dynamically. This means that the object created is const
It does not change even if it is an object.

【0012】図13は、従来のプログラム変換装置が図
12に示したオブジェクト生成文を翻訳した結果である
機械語命令列を示す図である。これは、従来のプログラ
ム変換装置が図12に示したソースプログラムに基づい
て生成する機械語プログラムの一部に相当する。なお、
同図では、わかり易くするため機械語をニモニックコー
ドで示している。
FIG. 13 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. 12 by the conventional program conversion device. This corresponds to a part of a machine language program generated by the conventional program conversion device based on the source program shown in FIG. In addition,
In the figure, the machine language is indicated by a mnemonic code for easy understanding.

【0013】ここで、「.section RAMAR
EA」から「.section END」に挟まれた部
分は、RAM領域に配置されるべき属性のデータを表
し、「Arrayobj:8」は、オブジェクトArr
ayobjが8バイトのサイズであることを表してい
る。従って、機械語プログラムが実行される時には、ま
ずRAM領域に8バイトの領域が確保されることにな
る。
Here, “.section RAMAR”
The portion between “EA” and “.section END” indicates attribute data to be arranged in the RAM area, and “Arrayobj: 8” indicates the object Arr
aobj represents a size of 8 bytes. Therefore, when the machine language program is executed, first, an 8-byte area is secured in the RAM area.

【0014】また、「.section TEXT」か
ら「.section END」に挟まれた部分は、R
OM領域に配置されるべき属性のコードを表し、「_I
nitObj()」は、オブジェクトを生成する時に実
行するものとしてプログラム変換装置が生成する関数を
表し、「mov &ArrayObj,R0」は、オブ
ジェクトArrayObjのアドレスをレジスタR0に
格納する機械語命令を表し、「mov#10,R1」
は、実引数である10をレジスタR1に格納する機械語
命令を表し、「call InitArray」は、オ
ブジェクト生成関数を呼び出すサブルーチンコールの機
械語命令を表し、retは関数からの復帰命令を表して
いる。
The portion between “.section TEXT” and “.section END” is R
Represents the code of the attribute to be placed in the OM area, "_I
“nitObj ()” indicates a function generated by the program conversion device as an object to be executed when generating an object, “mov & ArrayObj, R0” indicates a machine language instruction for storing the address of the object ArrayObj in the register R0, mov # 10, R1 "
Represents a machine language instruction for storing the actual argument 10 in the register R1, "call InitArray" represents a machine language instruction of a subroutine call for calling an object generation function, and ret represents a return instruction from the function. .

【0015】また、「IntArray()」は、オブ
ジェクト生成関数を表し、「movR0,R2」はレジ
スタR0に格納されて渡されるオブジェクトの先頭アド
レスをレジスタR2に格納する機械語命令を表し、「m
ov R1,M(R2,0)」は、レジスタR2で示さ
れるアドレスからオフセット0の位置のメモリにレジス
タR1の値を格納する機械語命令を表し、「lshif
t R1,#2,R0」は、レジスタR1の値を左に2
ビットシフトした値をレジスタR0に格納する機械語命
令を表し、「call _memory_alloc_
func」は、レジスタR0の内容が示すサイズの領域
を実行時に動的に確保しその領域の先頭アドレスをレジ
スタR0に格納して返す動的領域確保関数を呼び出すサ
ブルーチンコールの機械語命令を表し、「mov R
0,M(R2,4)」は、レジスタR2で示されるアド
レスからオフセット4の位置のメモリ内容としてレジス
タR0の値を格納する機械語命令を表し、retは関数
からの復帰命令を表している。
"IntArray ()" represents an object generation function, "movR0, R2" represents a machine language instruction for storing the head address of an object stored and passed in the register R0 in the register R2,
“ov R1, M (R2, 0)” indicates a machine language instruction that stores the value of the register R1 in the memory at the position of offset 0 from the address indicated by the register R2, and “lshift
“t R1, # 2, R0” indicates that the value of the register R1 is 2
A machine language instruction that stores the bit-shifted value in the register R0 is described as “call_memory_alloc_
"func" represents a machine language instruction of a subroutine call that calls a dynamic area securing function that dynamically secures an area of the size indicated by the contents of the register R0 at the time of execution and stores the start address of the area in the register R0 and returns "Mov R
“0, M (R2, 4)” represents a machine language instruction that stores the value of the register R0 as the memory content at the position of the offset 4 from the address indicated by the register R2, and ret represents a return instruction from the function. .

【0016】このように、従来のプログラム変換装置
は、ソースプログラム中のオブジェクト生成文を、オブ
ジェクト生成関数を呼び出すためのコードと、RAM領
域に配置されるべき属性のオブジェクトデータとに翻訳
する。一般に、機械語プログラムのコードサイズが大き
ければ、このプログラムの実行には容量の大きなメモリ
が必要になり、実行に要するコストが高くなる。
As described above, the conventional program conversion device translates an object generation statement in a source program into a code for calling an object generation function and object data having attributes to be arranged in a RAM area. Generally, if the code size of a machine language program is large, a large-capacity memory is required to execute this program, and the cost required for the execution increases.

【0017】従って、コスト面からは機械語プログラム
のコードサイズは小さい方が望ましい。また、家電機器
等への組み込み用マイクロコンピュータの分野において
は、RAMのコストは、ROMのコストより高く、RO
Mの4倍以上のコストがかかる場合もある。
Therefore, it is desirable that the code size of the machine language program be small from the viewpoint of cost. In the field of microcomputers for use in home electric appliances, the cost of RAM is higher than the cost of ROM.
In some cases, the cost may be more than four times M.

【0018】従って、可能な限り多くのデータを、RA
M領域ではなく、ROM領域に配置されるべき属性にす
ることは、コスト削減につながる。そこで、機械語プロ
グラムのコードサイズを削減し、又は、RAM領域に配
置されるべき属性のデータを削減することにより、オブ
ジェクト指向言語で記述されたソースプログラムを実行
コストの低い機械語プログラムに変換するプログラム変
換装置の実現が望まれている。
Therefore, as much data as possible is stored in RA
Making the attribute to be located in the ROM area instead of the M area leads to cost reduction. Therefore, a source program described in an object-oriented language is converted into a low-cost machine language program by reducing the code size of the machine language program or reducing attribute data to be arranged in the RAM area. Realization of a program conversion device is desired.

【0019】ところで、ソースプログラムを実行コスト
の低い機械語プログラムに変換するプログラム変換装置
に関する技術として、特開2000−40005号公報
に開示されている技術がある。この特開2000−40
005号公報に開示されている技術は、オブジェクト生
成文を翻訳する場合において、オブジェクト生成関数呼
び出し後のメンバ変数値を翻訳段階で計算しメンバ変数
値が定数となると判明したときにはその定数をメンバ変
数の内容としたオブジェクトを生成するとともにオブジ
ェクト生成関数の呼び出しを削除することによりコード
サイズを削減し、更に、そのメンバ変数値が定数となる
と判明したときに、オブジェクト生成文においてオブジ
ェクトの値が変化しないと宣言されていればオブジェク
トをROM領域に配置することにより、使用するRAM
領域を削減する技術である。
As a technique relating to a program conversion device for converting a source program into a machine language program having a low execution cost, there is a technique disclosed in Japanese Patent Application Laid-Open No. 2000-40005. This JP-A-2000-40
In the technique disclosed in Japanese Patent Application Publication No. 005, when an object generation statement is translated, a member variable value after calling an object generation function is calculated at a translation stage, and when it is determined that the member variable value becomes a constant, the constant is converted to a member variable. The object size is reduced and the code size is reduced by removing the call to the object generation function. Furthermore, when the member variable value is found to be a constant, the object value does not change in the object generation statement. If the object is declared, the RAM used by placing the object in the ROM area
This is a technology to reduce the area.

【0020】[0020]

【発明が解決しようとする課題】しかしながら、上述の
公報に開示されている技術は、オブジェクト生成関数呼
び出し直後におけるメンバ変数値が翻訳段階で計算でき
る場合にしか有効でないため、オブジェクト生成関数の
中に動的領域確保文が含まれていた場合には有効とはな
らない。なぜなら、動的領域確保文が含まれていれば、
動的領域確保文の実行によって確保されるメモリ領域の
先頭アドレスがメンバ変数値に代入されることになる
が、翻訳段階ではそのアドレス値を特定できないからで
ある。
However, the technique disclosed in the above publication is effective only when the member variable value immediately after the call to the object generation function can be calculated at the translation stage. It is not valid if a dynamic area allocation statement is included. Because, if the dynamic area allocation statement is included,
This is because the start address of the memory area secured by the execution of the dynamic area securing statement is substituted for the member variable value, but the address value cannot be specified at the translation stage.

【0021】そこで、本発明はかかる問題点に鑑みなさ
れたものであり、動的領域確保文を含むオブジェクト生
成関数が記述されたソースプログラムを、実行コストの
低い機械語プログラムに変換するプログラム変換装置を
提供することを目的とする。また、一般にプログラム変
換装置には実行速度の高い機械語プログラムの生成が求
められるため、本発明は、上記目的の他に、動的領域確
保文を含むオブジェクト生成関数が記述されたソースプ
ログラムを、実行速度の高い機械語プログラムに変換す
るプログラム変換装置を提供することを目的とする。
Therefore, the present invention has been made in view of such a problem, and a program conversion apparatus for converting a source program in which an object generation function including a dynamic area reservation statement is described into a machine language program with low execution cost. The purpose is to provide. In general, since a program conversion device is required to generate a high-speed machine language program, the present invention provides, in addition to the above objects, a source program in which an object generation function including a dynamic area reservation statement is described. It is an object of the present invention to provide a program conversion device for converting a program into a machine language program with a high execution speed.

【0022】[0022]

【課題を解決するための手段】上記目的を達成するため
に、本発明に係るプログラム変換装置は、動的に領域を
確保して当該領域の先頭アドレスをポインタ型変数に代
入する動的領域確保文を含むオブジェクト生成関数を呼
び出すことによりオブジェクトを生成するオブジェクト
生成文が記述されたソースプログラムを、機械語プログ
ラムに変換するプログラム変換装置であって、前記オブ
ジェクト生成文により前記オブジェクト生成関数が呼び
出されたと仮定した場合において前記動的領域確保文に
よって確保される領域のサイズを計算する計算手段と、
前記計算手段により計算された前記領域のサイズが定数
値である場合には、前記動的領域確保文を、当該サイズ
の第1データと、当該第1データの先頭アドレスを前記
ポインタ型変数に代入するための中間表現とに変換する
第1変換手段と、前記第1変換手段により動的領域確保
文が変換された後のオブジェクト生成関数を、前記オブ
ジェクト生成文が呼び出すものとして、前記オブジェク
ト生成文を機械語命令に変換する第2変換手段とを備え
ることを特徴とする。
In order to achieve the above object, a program conversion device according to the present invention secures a dynamic area and dynamically assigns a start address of the area to a pointer type variable. A program conversion device for converting a source program in which an object generation statement that generates an object by calling an object generation function including a statement into a machine language program, wherein the object generation function is called by the object generation statement Calculating means for calculating the size of the area secured by the dynamic area securing statement when assuming that
When the size of the area calculated by the calculation means is a constant value, the dynamic area securing statement is substituted for the first data of the size and the start address of the first data for the pointer type variable. A first conversion means for converting the object generation statement into an intermediate expression for performing the conversion, and an object generation function after the dynamic area reservation statement is converted by the first conversion means. And a second conversion unit for converting the に into a machine language instruction.

【0023】上記構成により、動的領域確保文により確
保されることが予定されていた領域は機械語プログラム
中においてデータとして置かれることになるため、動的
領域確保関数のサブルーチンコールを行わないことによ
りプログラム実行速度が向上する。なお、ここでいうデ
ータ(第1データ)は、機械語プログラムが実行される
までにOSによってメモリ中の領域が確保され、そのデ
ータのメモリアドレスが決定される意味の属性を持った
ものであり、OSはこの属性に従って動作するため第1
データの先頭アドレスには確保したメモリ領域のメモリ
アドレスが設定されることになる。また、第2変換手段
を特開2000−40005号公報に開示されている従
来技術を用いて具体化したならば、コードサイズの削減
等が図れる。
According to the above configuration, since the area to be secured by the dynamic area securing statement is placed as data in the machine language program, the subroutine call of the dynamic area securing function should not be performed. As a result, the program execution speed is improved. The data (first data) has an attribute that means that an area in the memory is secured by the OS before the machine language program is executed and the memory address of the data is determined. , The OS operates according to this attribute.
The memory address of the secured memory area is set as the head address of the data. Also, if the second conversion means is embodied using the conventional technique disclosed in Japanese Patent Application Laid-Open No. 2000-40005, the code size can be reduced.

【0024】また、本発明に係るプログラム変換装置
は、動的に領域を確保して当該領域の先頭アドレスをポ
インタ型変数に代入する動的領域確保文を複数含むソー
スプログラムを、機械語プログラムに変換するプログラ
ム変換装置であって、前記複数の動的領域確保文それぞ
れにより確保されるべき領域のサイズを計算するサイズ
計算手段と、引数としてサイズを受け取り当該サイズの
領域を動的に確保して当該領域の先頭アドレスを返却す
るサブルーチンである動的領域確保ルーチンを、前記複
数の動的領域確保文それぞれにより確保されるべき領域
のサイズの合計値を引数として呼び出すことにより、前
記複数の動的領域確保文により確保されるべき全ての領
域を一括して確保するためのサブルーチンコール命令を
生成する動的領域確保ルーチン呼出命令生成手段と、前
記サブルーチンコール命令の実行により返却されるアド
レスと前記サイズ計算手段により計算された前記各領域
のサイズとに基づき、前記動的領域確保ルーチンにより
確保される領域のうち前記複数の動的領域確保文それぞ
れの分に相当する各領域の先頭アドレスを算出する先頭
アドレス算出手段と、前記複数の動的領域確保文それぞ
れを、当該動的領域確保文に対応して前記先頭アドレス
算出手段により算出された領域の先頭アドレスを該当す
るポインタ型変数に代入する命令に変換する変換手段と
を備えることを特徴とする。
Further, the program conversion device according to the present invention converts a source program including a plurality of dynamic area securing statements for dynamically securing an area and assigning the start address of the area to a pointer type variable into a machine language program. A program conversion device for performing conversion, comprising: size calculation means for calculating a size of an area to be secured by each of the plurality of dynamic area securing statements; and receiving a size as an argument and dynamically securing an area of the size. The dynamic area allocation routine, which is a subroutine for returning the start address of the area, is called by using the total value of the size of the area to be allocated by each of the dynamic area allocation statements as an argument. A dynamic area check that generates a subroutine call instruction to collectively secure all areas to be secured by the area securement statement A routine call instruction generating unit, and based on an address returned by execution of the subroutine call instruction and a size of each of the regions calculated by the size calculating unit, A start address calculating means for calculating a start address of each area corresponding to each of the plurality of dynamic area reservation statements; and A conversion unit for converting the start address of the area calculated by the address calculation unit into an instruction for substituting the start address into a corresponding pointer type variable.

【0025】上記構成により、一般に比較的実行時間の
長い動的領域確保ルーチンを呼び出す回数を削減できる
ため、変換結果のプログラムの実行速度が向上するよう
になる。
According to the above configuration, the number of calls to the dynamic area securing routine, which generally has a relatively long execution time, can be reduced, so that the execution speed of the program resulting from the conversion is improved.

【0026】[0026]

【発明の実施の形態】以下、本発明の実施の形態に係る
プログラム変換装置について、図面を用いて詳細に説明
する。 <構成>図1は、本発明の実施の形態に係るプログラム
変換装置100の機能構成図である。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, a program conversion device according to an embodiment of the present invention will be described in detail with reference to the drawings. <Configuration> FIG. 1 is a functional configuration diagram of a program conversion device 100 according to an embodiment of the present invention.

【0027】プログラム変換装置100は、コンピュー
タに備えられたメモリに格納されたプログラムがCPU
により実行されることで、ソースプログラムを機械語プ
ログラムに翻訳(変換)する動作を行ういわゆるコンパ
イラであり、機能的には、制御部102、オブジェクト
生成関数変換部103、動的領域確保文検出部104、
記憶部105、オブジェクト生成文変換部106、動的
確保領域計算部107、オブジェクト生成関数呼び出し
翻訳部108及び一般文翻訳部109から構成される。
The program conversion device 100 is configured to execute a program stored in a memory provided in a computer by using a CPU.
Is a so-called compiler that performs an operation of translating (converting) a source program into a machine language program by executing the program. Functionally, the control unit 102, the object generation function conversion unit 103, the dynamic area reservation statement detection unit 104,
It comprises a storage unit 105, an object generation sentence conversion unit 106, a dynamic reservation area calculation unit 107, an object generation function call translation unit 108, and a general sentence translation unit 109.

【0028】コンピュータに備えられたメモリに格納さ
れたプログラムにおいて、制御部102は、メインルー
チンに相当し、オブジェクト生成関数変換部103、動
的領域確保文検出部104、オブジェクト生成文変換部
106、動的確保領域計算部107、オブジェクト生成
関数呼び出し翻訳部108及び一般文翻訳部109はサ
ブルーチンに相当する。
In a program stored in a memory provided in the computer, the control unit 102 corresponds to a main routine, and includes an object generation function conversion unit 103, a dynamic area reservation sentence detection unit 104, an object generation sentence conversion unit 106, The dynamic reservation area calculation unit 107, the object generation function call translation unit 108, and the general sentence translation unit 109 correspond to a subroutine.

【0029】同図には、プログラム変換装置100の他
に入力ファイル101及び出力ファイル110も記載し
ている。ここで、入力ファイル101にはオブジェクト
指向言語で記述されたソースプログラムが格納されてい
る。また、出力ファイル110には、プログラム変換装
置100が入力ファイル101を翻訳した結果として生
成する機械語命令列が格納される。
FIG. 2 also shows an input file 101 and an output file 110 in addition to the program conversion device 100. Here, the input file 101 stores a source program described in an object-oriented language. The output file 110 stores a machine language instruction sequence generated as a result of the program conversion device 100 translating the input file 101.

【0030】制御部102は、入力ファイル101から
メモリにソースプログラムを読み込み、ソースプログラ
ム中の各文に逐次着目して、着目した文の種類により、
処理を振り分ける機能を有する。即ち、制御部102
は、着目した文の種類に応じて、オブジェクト生成関数
変換部103、オブジェクト生成文変換部106又は一
般文翻訳部109を起動する。ここで、着目とは、処理
対象とすること、即ち、処理をするためにポインタ等に
より所在を特定することをいう。
The control unit 102 reads the source program from the input file 101 into the memory, sequentially pays attention to each sentence in the source program, and according to the type of the focused statement,
It has a function to distribute processing. That is, the control unit 102
Activates the object generation function conversion unit 103, the object generation sentence conversion unit 106, or the general sentence translation unit 109 according to the type of sentence of interest. Here, the term “attention” refers to processing a target, that is, specifying a location by a pointer or the like for processing.

【0031】オブジェクト生成関数変換部103は、ソ
ースプログラム中のオブジェクト生成関数の定義が着目
されたときに制御部102に起動されるものであり、オ
ブジェクト生成関数の定義中に動的領域確保文が存在す
るか検出させるべく動的領域確保文検出部104を起動
し、動的領域確保文が検出された場合には、新たに静的
オブジェクト生成関数を生成しその静的オブジェクト生
成関数をその動的領域確保文と対にして記憶部105に
格納する機能を有する。
The object generation function conversion unit 103 is activated by the control unit 102 when the definition of the object generation function in the source program is focused on, and a dynamic area securing statement is included in the definition of the object generation function. The dynamic area reservation statement detection unit 104 is activated to detect whether or not the statement exists, and if a dynamic area reservation statement is detected, a new static object generation function is generated and the static object generation function is executed. It has a function of storing in the storage unit 105 a pair with a target area securing statement.

【0032】ここで、静的オブジェクト生成関数とは、
動的領域確保文を含んでいた元のオブジェクト生成関数
に基づき生成される関数であり、静的オブジェクト生成
関数の仮引数は、元のオブジェクト生成関数の仮引数に
ポインタ型の仮引数を追加したものであり、静的オブジ
ェクト生成関数の処理内容については、元のオブジェク
ト生成関数の動的領域確保文を、その動的領域確保文に
おける代入先のポインタ型のメンバ変数にその新しく追
加した仮引数の値を代入する代入文に置き換えたもので
ある。
Here, the static object generation function is
This is a function that is generated based on the original object creation function that included the dynamic area allocation statement. For the dummy argument of the static object creation function, a pointer-type dummy argument was added to the dummy argument of the original object creation function. For the processing contents of the static object creation function, the dynamic area allocation statement of the original object creation function is replaced by the newly added dummy argument in the pointer type member variable of the assignment destination in the dynamic area allocation statement. Is replaced by an assignment statement that assigns the value of

【0033】動的領域確保文検出部104は、オブジェ
クト生成関数の定義中に動的領域確保文が存在するか調
べて、存在する場合には動的領域確保文を呼び出し元で
あるオブジェクト生成関数変換部103に伝え、存在し
なければその旨を伝える機能を有する。記憶部105
は、メモリ中の特定の領域である。
The dynamic area reservation statement detection unit 104 checks whether or not a dynamic area reservation statement exists in the definition of the object generation function. It has a function of notifying the conversion unit 103 and notifying that it does not exist. Storage unit 105
Is a specific area in the memory.

【0034】オブジェクト生成文変換部106は、ソー
スプログラム中のオブジェクト生成文が着目されたとき
に制御部102に起動されるものであり、オブジェクト
生成文のオブジェクトのクラスに対応する静的オブジェ
クト生成関数が記憶部105に既に格納されているか否
かを判定し、格納されている場合には静的オブジェクト
生成関数と対となっている動的領域確保文を指定してそ
の動的領域確保文が確保する領域のサイズを計算させる
べく動的確保領域計算部107を起動しそのサイズが定
数値であった場合にはオブジェクト生成文を、その定数
値をサイズとし初期値指定なしのRAM領域に配置され
るべき属性のデータとそのRAM領域の先頭アドレスを
ポインタ型の実引数として呼び出す静的オブジェクト生
成関数呼び出しコードとに変換し、オブジェクト生成関
数呼び出し翻訳部108を起動する機能を有する。ま
た、オブジェクト生成文変換部106は、動的確保領域
計算部107の起動結果として、動的領域確保文が確保
する領域のサイズが定数値とならないと判明した場合に
は、オブジェクト生成文をオブジェクト生成関数呼び出
しコードに変換し、オブジェクト生成関数呼び出し翻訳
部108を起動する機能を有する。ここで、静的オブジ
ェクト生成関数呼び出しコードは、静的オブジェクト生
成関数を呼び出す意味の中間表現即ち内部処理用の形式
のコードであり、オブジェクト生成関数呼び出しコード
は、オブジェクト生成関数を呼び出す意味の中間表現で
ある。
The object generation statement conversion unit 106 is activated by the control unit 102 when an object generation statement in a source program is focused on, and includes a static object generation function corresponding to the object class of the object generation statement. It is determined whether or not is already stored in the storage unit 105, and if it is stored, a dynamic area securing statement that is paired with the static object creation function is specified, and the dynamic area securing statement is Activate the dynamically allocated area calculation unit 107 to calculate the size of the area to be allocated, and if the size is a constant value, place the object generation statement in the RAM area using the constant value as the size and without specifying the initial value. Static object generation function call code that calls the attribute data to be performed and the start address of the RAM area as a pointer-type actual argument It converted into a de has the ability to launch object generation function calls the translation unit 108. If the size of the area to be secured by the dynamic area securing statement is found not to be a constant value as a result of the activation of the dynamic It has a function of converting the generated function call code and activating the object generation function call translator 108. Here, the static object generation function call code is an intermediate expression having a meaning of calling the static object generation function, that is, a code in a format for internal processing, and the object generation function call code is an intermediate expression having a meaning of calling the object generation function. It is.

【0035】なお、RAM領域に配置されるべき属性の
データ或いはROM領域に配置されるべき属性のデータ
は、それらを含む機械語プログラムが特定のプロセッサ
上でOS等の制御下で実行される際において、実行前に
メモリに割り当てられることになり、これらのデータに
初期値指定があればその初期値がメモリに格納されるこ
とになる。
The data of the attribute to be arranged in the RAM area or the data of the attribute to be arranged in the ROM area are stored when a machine language program including them is executed on a specific processor under the control of an OS or the like. In this case, the data is allocated to the memory before execution, and if an initial value is specified for these data, the initial value is stored in the memory.

【0036】動的確保領域計算部107は、オブジェク
ト生成文変換部106から指定された動的領域確保文が
確保する領域のサイズを計算してオブジェクト生成文変
換部106にサイズを返し、サイズが定数値とならない
場合にはサイズの返却の代わりにサイズが定数値となら
ない旨の通知を返す。オブジェクト生成関数呼び出し翻
訳部108は、オブジェクト生成文変換部106により
起動され、オブジェクト生成文を参照しつつ、静的オブ
ジェクト生成関数呼び出しコード又はオブジェクト生成
関数呼び出しコードを翻訳する機能を有する。即ち、こ
れらの関数呼び出しコードにより生成されるオブジェク
トの各メンバ変数の初期値を計算し、いずれのメンバ変
数の初期値も定数であった場合には、そのオブジェクト
がconstオブジェクトであれば、その関数呼び出し
コードをその定数を初期値とするROM領域に配置され
るべき属性のデータに翻訳し、constオブジェクト
でなければ、その関数呼び出しコードを、その定数を初
期値とするRAM領域に配置されるべき属性のデータに
翻訳する。関数呼び出しコードにより生成されるオブジ
ェクトの初期値の計算結果が定数以外の場合は、オブジ
ェクトのサイズであり初期値指定なしのRAM領域に配
置されるべき属性のデータと、静的オブジェクト生成関
数又はオブジェクト生成関数に相当するサブルーチンの
サブルーチンコール命令列に翻訳する。
The dynamic reservation area calculation unit 107 calculates the size of the area secured by the dynamic area reservation statement specified by the object generation statement conversion unit 106, and returns the size to the object generation statement conversion unit 106. If the value does not become a constant value, a notification that the size does not become a constant value is returned instead of returning the size. The object generation function call translation unit 108 is activated by the object generation statement conversion unit 106 and has a function of translating a static object generation function call code or an object generation function call code while referring to the object generation statement. That is, the initial value of each member variable of the object generated by these function call codes is calculated, and if the initial value of any member variable is a constant, if the object is a const object, the function The call code is translated into attribute data to be placed in a ROM area with the constant as an initial value, and if not a const object, the function call code should be placed in a RAM area with the constant as an initial value. Translate to attribute data. If the calculation result of the initial value of the object generated by the function call code is other than a constant, the data of the attribute which is the size of the object and should be arranged in the RAM area where the initial value is not specified, and the static object generation function or the It is translated into a subroutine call instruction sequence of a subroutine corresponding to the generation function.

【0037】また、サブルーチンコールで呼び出される
サブルーチンに相当する関数の定義が翻訳されていなけ
れば、関数の定義を翻訳する。なお、オブジェクト生成
関数呼び出し翻訳部108は翻訳結果を出力ファイル1
10に出力する。一般文翻訳部109は、制御部102
により起動され、オブジェクト生成文以外の文を機械語
命令列に翻訳し、出力ファイル110に出力する一般文
翻訳処理を行う機能を有する。この一般文翻訳処理は、
一般的なプログラム変換装置で用いられている通常の翻
訳処理である。 <データ>図2は、オブジェクト生成関数変換部103
が記憶部105に格納するデータの内容例を示す図であ
る。
If the definition of the function corresponding to the subroutine called by the subroutine call has not been translated, the function definition is translated. The object generation function call translating unit 108 outputs the translation result to the output file 1
Output to 10 The general sentence translator 109 includes the controller 102
, Which translates a sentence other than the object generation sentence into a machine language instruction sequence and outputs the output sentence to the output file 110. This general sentence translation process
This is a normal translation process used in a general program conversion device. <Data> FIG.
FIG. 3 is a diagram showing an example of data stored in a storage unit 105.

【0038】同図に示すように、記憶部105には動的
領域確保文と静的オブジェクト生成関数の定義との組が
格納される。なお、同図にはわかりやすくするため動的
領域確保文や静的オブジェクト生成関数の定義等をC+
+言語で記述して示したが、実際にはプログラム変換装
置100は、一般のプログラム変換装置と同様に、入力
ファイル101からソースプログラムをメモリに読み込
んだ後に中間表現に変換して翻訳処理を行うものであ
り、これに合わせて静的オブジェクト生成関数の定義も
中間表現の形式で生成する。
As shown in the figure, the storage unit 105 stores a set of a dynamic area securing statement and a definition of a static object generation function. Note that, for the sake of simplicity, the definition of the dynamic area allocation statement and the definition of the static object generation function are shown in FIG.
Although described in the + language, the program converter 100 actually reads the source program from the input file 101 into the memory, converts it into an intermediate representation, and performs a translation process, like a general program converter. According to this, the definition of the static object generation function is also generated in the form of an intermediate representation.

【0039】同図の例に示す「_IntArray_s
tatic」という静的オブジェクト生成関数は、図1
2に示した「memp=new int[siz
e];」という動的領域確保文に対応して、その動的領
域確保文を含む「IntArray」というオブジェク
ト生成関数に基づいてオブジェクト生成関数変換部10
3により生成されたものである。
"_IntArray_s" shown in the example of FIG.
static ", the static object generation function
“Mem = new int [siz] shown in FIG.
e]; ”, the object generation function conversion unit 10 based on the object generation function“ IntArray ”including the dynamic area reservation statement.
3 is generated.

【0040】この「_IntArray_stati
c」という静的オブジェクト生成関数の仮引数は、「I
ntArray」の仮引数である「int size」
と、新たに追加された「void *area」とであ
る。また、静的オブジェクト生成関数中の「memp=
area;」という文は、「IntArray」中の動
的領域確保文における「new int[size]」
を仮引数の内容である「area」に置き換えたもので
ある。 <動作>以下、上述した構成を備えるプログラム変換装
置100の動作について説明する。
This "_IntArray_stati"
The formal parameter of the static object generation function “c” is “I
"int size" which is a dummy argument of "ntArray"
And a newly added “void * area”. Also, “mep =” in the static object generation function
The statement “area;” is “new int [size]” in the dynamic area reservation statement in “IntArray”.
Is replaced with “area” which is the content of the dummy argument. <Operation> The operation of the program conversion device 100 having the above-described configuration will be described below.

【0041】ここでは、入力ファイル101に図12に
示したC++言語のソースプログラムが格納されている
こととし、プログラム変換装置100がそのソースプロ
グラムを変換する場合を例にして説明する。図3は、プ
ログラム変換装置100の全体的な動作を示すフローチ
ャートである。
Here, it is assumed that the C ++ language source program shown in FIG. 12 is stored in the input file 101, and an example in which the program conversion apparatus 100 converts the source program will be described. FIG. 3 is a flowchart showing the overall operation of the program conversion device 100.

【0042】まず、プログラム変換装置100の制御部
102は入力ファイル101に格納されているソースプ
ログラムを読み込み、そのプログラム中の一文に着目す
る(ステップS301)。なお、一文にはオブジェクト
生成関数の定義も含まれるものとする。続いて制御部1
02は、着目した文がオブジェクト生成関数の定義であ
るか否かを判定し(ステップS302)、オブジェクト
生成関数の定義であった場合には、オブジェクト生成関
数の定義を入力としてオブジェクト生成関数変換部10
3を起動することにより、オブジェクト生成関数変換処
理を行わせる(ステップS303)。オブジェクト生成
関数変換処理は、一定条件下で静的オブジェクト生成関
数を生成する処理であり、その詳しい内容については後
述する。
First, the control unit 102 of the program conversion apparatus 100 reads a source program stored in the input file 101, and focuses on one sentence in the program (step S301). Note that one sentence includes the definition of the object generation function. Subsequently, the control unit 1
02 determines whether or not the sentence of interest is the definition of an object generation function (step S302). If the statement is an object generation function definition, the object generation function conversion unit receives the object generation function definition as an input. 10
3 is started to perform an object generation function conversion process (step S303). The object generation function conversion process is a process of generating a static object generation function under certain conditions, and the details will be described later.

【0043】ここでは、着目した文がクラスIntAr
rayのオブジェクト生成関数「IntArray(i
nt size)」の定義であれば、オブジェクト生成
関数変換処理が行われることになる。着目した文がオブ
ジェクト生成関数の定義でない場合には、制御部102
は、着目した文がオブジェクト生成文であるか否かを判
定し(ステップS305)、オブジェクト生成文であっ
たときには、オブジェクト生成文を入力としてオブジェ
クト生成文変換部106を起動することにより、オブジ
ェクト生成文変換処理を行わせる(ステップS30
6)。オブジェクト生成文変換処理は、オブジェクト生
成文を一旦、静的オブジェクト生成関数呼び出しコード
又はオブジェクト生成関数呼び出しコードに変換し、そ
の変換結果である関数呼び出しコードを翻訳する処理で
あり、その詳しい内容については後述する。
Here, the sentence of interest is class IntAr
object creation function “IntArray (i
nt size) ", an object generation function conversion process is performed. If the focused statement is not the definition of the object generation function, the control unit 102
Determines whether the focused statement is an object generation statement (step S305), and if the statement is an object generation statement, activates the object generation statement conversion unit 106 with the object generation statement as an input to generate an object generation statement. A sentence conversion process is performed (step S30)
6). The object generation statement conversion process is a process of temporarily converting an object generation statement into a static object generation function call code or an object generation function call code, and translating a function call code that is a result of the conversion. It will be described later.

【0044】ここでは、着目した文がクラスIntAr
rayのオブジェクト生成文「const IntAr
ray ArrayObj(10);」であれば、オブ
ジェクト生成文変換処理が行われることになる。また、
ステップS305において着目した文がオブジェクト生
成文でなかった場合には、その文を入力として、一般文
翻訳部109を起動して一般文翻訳処理を行わせる(ス
テップS307)。
Here, the sentence of interest is the class IntAr
ray object creation statement "const IntAr
If “ray ArrayObj (10);”, the object generation sentence conversion process is performed. Also,
If the sentence of interest in step S305 is not an object generation sentence, the sentence is input and the general sentence translating unit 109 is activated to perform a general sentence translation process (step S307).

【0045】オブジェクト生成関数変換処理(ステップ
S303)、オブジェクト生成文変換処理(ステップS
306)又は一般文翻訳処理(ステップS307)が終
了した後、制御部102は未だ着目していない文がある
か否かを判定し(ステップS304)、あればステップ
S301に戻って次の文に着目し、なければ動作を終了
する。
Object generation function conversion processing (step S303), object generation sentence conversion processing (step S303)
306) or after the general sentence translation process (step S307) ends, the control unit 102 determines whether or not there is a sentence that has not yet been focused on (step S304), and if so, returns to step S301 and returns to the next sentence. Attention is paid, and if not, the operation is terminated.

【0046】以下、オブジェクト生成関数変換処理につ
いて説明する。図4は、主にオブジェクト生成関数変換
部103により行われるオブジェクト生成関数変換処理
を示すフローチャートである。オブジェクト生成関数変
換部103は、オブジェクト生成関数の定義を入力とし
て制御部102に起動されると、動的領域確保文検出部
104にオブジェクト生成関数の定義に動的領域確保文
が含まれればこれを検出させる(ステップS401)。
Hereinafter, the object generation function conversion processing will be described. FIG. 4 is a flowchart illustrating an object generation function conversion process mainly performed by the object generation function conversion unit 103. When the object generation function conversion unit 103 is activated by the control unit 102 with the definition of the object generation function as an input, the dynamic area reservation statement detection unit 104 determines whether the dynamic area reservation statement is included in the definition of the object generation function. Is detected (step S401).

【0047】オブジェクト生成関数変換部103は、動
的領域確保文が存在しない旨の通知を動的領域確保文検
出部104から受けるとオブジェクト生成関数変換処理
を終了する(ステップS402)。動的領域確保文検出
部104により動的領域確保文が検出された場合にはオ
ブジェクト生成関数変換部103は、入力されたオブジ
ェクト生成関数の定義をコピーして名前だけを変更して
新たにオブジェクト生成関数の定義を生成する(ステッ
プS403)。名前の変更は予め定めた命名規則に従う
ものとする。この命名規則は例えば元のオブジェクト生
成関数の名前の前に「_」を付加し、後に「_stat
ic」を付加するものである。
When the object generation function conversion unit 103 receives a notification from the dynamic area reservation statement detection unit 104 that there is no dynamic area reservation statement, it ends the object generation function conversion process (step S402). When the dynamic area allocation statement is detected by the dynamic area allocation statement detection unit 104, the object generation function conversion unit 103 copies the definition of the input object generation function, changes only the name, and newly creates a new object. A definition of a generation function is generated (step S403). Name changes shall follow a predetermined naming rule. This naming convention is, for example, to add "_" before the name of the original object creation function and "_stat" after it.
ic ”.

【0048】図12に示した例では、「IntArra
y(int size)」の定義が入力され、この定義
中に「memp=new int[size];」とい
う動的領域確保文が存在するため、オブジェクト生成関
数変換部103は、「_IntArray_stati
c(int size)」の定義を生成する。ステップ
S403に続いて、オブジェクト生成関数変換部103
は生成したオブジェクト生成関数の仮引数としてポイン
タ型の仮引数を追加する(ステップS404)。仮引数
名は所定の規則に従って定めるものであり、例えば「a
rea」と定める。
In the example shown in FIG. 12, "IntArra
The definition of “y (int size)” is input, and a dynamic area reservation statement “mep = new int [size];” exists in this definition. Therefore, the object generation function conversion unit 103 sets “_IntArray_stati”.
c (int size) "is generated. Subsequent to step S403, the object generation function conversion unit 103
Adds a pointer-type dummy argument as a dummy argument of the generated object generation function (step S404). The dummy argument name is determined according to a predetermined rule.
rea ”.

【0049】ポインタ型の仮引数を追加した後、オブジ
ェクト生成関数変換部103は、新たに生成したオブジ
ェクト生成関数の定義に含まれる動的領域確保文の右辺
を、追加した仮引数に置き換える(ステップS40
5)。これにより静的オブジェクト生成関数の定義が生
成されることになる。ステップS405に続いて、オブ
ジェクト生成関数変換部103は、検出された動的領域
確保文と、生成した静的オブジェクト生成関数の定義と
を対にして記憶部105に記憶し、オブジェクト生成関
数変換処理を終了する(ステップS406)。
After adding the pointer-type dummy argument, the object generation function conversion unit 103 replaces the right side of the dynamic area reservation statement included in the definition of the newly generated object generation function with the added dummy argument (step S101). S40
5). As a result, the definition of the static object generation function is generated. Subsequent to step S405, the object generation function conversion unit 103 stores the detected dynamic area allocation statement and the generated definition of the static object generation function in the storage unit 105 as a pair, and performs the object generation function conversion processing. Is completed (step S406).

【0050】この結果、記憶部105には図2に示した
データが格納されることになる。以下、オブジェクト生
成文変換処理について説明する。図5は、オブジェクト
生成文変換処理を示すフローチャートである。オブジェ
クト生成文変換部106は、オブジェクト生成文を入力
として起動されると、そのオブジェクト生成文により呼
び出されるオブジェクト生成関数に対応する静的オブジ
ェクト生成関数の定義が既に生成され記憶部105に格
納されているか否かを判定する(ステップS501)。
オブジェクト生成文「const IntArray
ArrayObj(10);」が入力されると、オブジ
ェクト生成文変換部106はクラス名「IntArra
y」から所定の命名規則に従って対応する静的オブジェ
クト生成関数名が「_IntArray_stati
c」であることを導き、その関数名をキーとして記憶部
105から検索することになる。
As a result, the data shown in FIG. 2 is stored in the storage unit 105. Hereinafter, the object generation sentence conversion process will be described. FIG. 5 is a flowchart showing the object generation sentence conversion process. When the object generation statement conversion unit 106 is activated with the object generation statement as an input, the definition of the static object generation function corresponding to the object generation function called by the object generation statement has already been generated and stored in the storage unit 105. It is determined whether or not there is (step S501).
Object creation statement "const IntArray
When "ArrayObj (10);" is input, the object generation sentence conversion unit 106 sets the class name "IntArray
y ”and the corresponding static object generation function name is“ _IntArray_stati ”according to a predetermined naming rule.
c ", and the function name is used as a key to search the storage unit 105.

【0051】既に記憶部105にオブジェクト生成文に
対応する静的オブジェクト生成関数の定義が格納されて
いる場合には、オブジェクト生成文変換部106は、動
的確保領域計算部107を起動し、動的領域確保文で確
保される領域のサイズを計算させる(ステップS50
2)。動的確保領域計算部107は、動的領域確保文に
より確保される領域のサイズがオブジェクト生成関数へ
の仮引数で表されている場合にはその仮引数に対応する
オブジェクト生成文の実引数の値を用いて、そのサイズ
計算を行う。
If the definition of the static object generation function corresponding to the object generation statement has already been stored in the storage unit 105, the object generation statement conversion unit 106 activates the dynamic reservation area calculation unit 107, and (Step S50)
2). When the size of the area secured by the dynamic area securing statement is represented by a dummy argument to the object creation function, the dynamic secured area calculation unit 107 The size is calculated using the value.

【0052】ここでは、動的領域確保文の右辺の「ne
w int(size)」で確保される領域のサイズ
は、仮引数「size」に対応する実引数値が「10」
であるため、int型の4バイトと10とを乗ずること
により40と計算されることになる。オブジェクト生成
文変換部106は、ステップS502によるサイズの計
算結果が定数であるか否かを判定し(ステップS50
3)、定数である場合には、計算されたサイズの初期値
指定のないRAM領域に配置されるべき属性のデータを
生成し(ステップS504)、オブジェクト生成文を、
ステップS504で生成したデータの先頭アドレスを実
引数にした静的オブジェクト生成関数呼び出しコードに
変換する(ステップS505)。
Here, "ne" on the right side of the dynamic area allocation statement
The size of the area secured by “w int (size)” is such that the actual argument value corresponding to the dummy argument “size” is “10”.
Therefore, 40 is calculated by multiplying the int type 4 bytes by 10. The object generation sentence conversion unit 106 determines whether the size calculation result in step S502 is a constant (step S50).
3) If it is a constant, the data of the attribute to be arranged in the RAM area without the initial value of the calculated size is generated (step S504), and the object generation statement is
The head address of the data generated in step S504 is converted into a static object generation function call code in which an actual argument is used (step S505).

【0053】ここでは、図12に示すオブジェクト生成
文に対応して、ステップS504で「_area00」
という名前で識別可能な40バイトのRAM領域に配置
されるべき属性のデータが生成され、ステップS505
でその先頭アドレスを実引数に含む「_IntArra
y_static(10,&_area00);」とい
う静的オブジェクト生成関数呼び出しコードが生成され
ることになる。
Here, “_area00” is set in step S504 corresponding to the object generation statement shown in FIG.
Is generated, the attribute data to be arranged in the 40-byte RAM area that can be identified by the name
"_IntArra" including the start address in the actual argument
y_static (10, &_area00);"is generated.

【0054】なお、オブジェクト生成文変換部106
は、ステップS501においてオブジェクト生成文に対
応する静的オブジェクト生成関数の定義が生成済みでな
いと判定した場合、又はステップS503において動的
領域確保文により確保される領域のサイズが定数でない
と判定した場合には、オブジェクト生成文を単にオブジ
ェクト生成関数呼び出しコードに変換する(ステップS
506)。例えば、もしIntArrayが動的領域確
保文を含まないオブジェクト生成関数であったならば、
「IntArray(10);」というオブジェクト生
成関数呼び出しコードが生成されることになる。
The object generation sentence conversion unit 106
Is when it is determined in step S501 that the definition of the static object generation function corresponding to the object generation statement has not been generated, or when it is determined in step S503 that the size of the area allocated by the dynamic area allocation statement is not a constant. , The object generation statement is simply converted into an object generation function call code (step S
506). For example, if IntArray is an object creation function that does not include a dynamic area allocation statement,
An object generation function call code "IntArray (10);" is generated.

【0055】ステップS503において動的領域確保文
により確保される領域のサイズが定数でないと判定され
る場合としては、例えば、確保領域のサイズの算出基礎
となる変数が、ユーザからの入力値等のOSの提供する
入出力ルーチンの戻り値である場合等が挙げられる。オ
ブジェクト生成文変換部106は、ステップS505の
実行後には生成した静的オブジェクト生成関数呼び出し
コードを入力としオブジェクト生成関数呼び出し翻訳部
108を起動することにより、またステップS506の
実行後には生成したオブジェクト生成関数呼び出しコー
ドを入力としオブジェクト生成関数呼び出し翻訳部10
8を起動することにより、関数呼出しコード翻訳処理を
行わせ(ステップS507)、オブジェクト生成文変換
処理を終える。
If it is determined in step S503 that the size of the area to be secured by the dynamic area securing statement is not a constant, for example, the variable used as the basis for calculating the size of the secured area may be a value such as an input value from the user. The return value may be a return value of an input / output routine provided by the OS. The object generation sentence conversion unit 106 activates the object generation function call translation unit 108 with the generated static object generation function call code as an input after the execution of step S505, and generates the generated object after the execution of step S506. Object generation function call translator 10 with function call code as input
8 to activate the function call code translation process (step S507), and ends the object generation sentence conversion process.

【0056】以下、この関数呼び出しコード翻訳処理に
ついて説明する。図6は、オブジェクト生成関数呼び出
し翻訳部108によりなされる関数呼び出しコード翻訳
処理を示すフローチャートである。オブジェクト生成関
数呼び出し翻訳部108は、オブジェクト生成文変換部
106から静的オブジェクト生成関数呼び出しコード又
はオブジェクト生成関数呼び出しコードを入力として起
動されると、オブジェクト生成関数の定義とオブジェク
ト生成関数呼び出しコードにおける実引数とに基づい
て、そのオブジェクト生成関数に対応して生成されるこ
とになるオブジェクトの各メンバ変数の初期値を計算し
(ステップS601)、全てのメンバ変数の初期値が定
数であるか否かを判定する(ステップS602)。つま
り、実際にプログラムを動作させることなくコンパイル
時においてメンバ変数の値を算定することができるかを
判定する。なお、このステップS601、S602に示
す処理の実現には、特開2000−40005号公報に
開示されている従来技術を使用すればよい。
The function call code translation process will be described below. FIG. 6 is a flowchart showing a function call code translation process performed by the object generation function call translation unit 108. When the object generation function call translating unit 108 is activated by inputting the static object generation function call code or the object generation function call code from the object generation sentence conversion unit 106, the definition of the object generation function and the actual Based on the arguments, the initial value of each member variable of the object to be generated corresponding to the object generation function is calculated (step S601), and whether or not the initial values of all the member variables are constants Is determined (step S602). That is, it is determined whether the value of the member variable can be calculated at compile time without actually operating the program. In order to realize the processing shown in steps S601 and S602, a conventional technique disclosed in Japanese Patent Application Laid-Open No. 2000-40005 may be used.

【0057】ステップS602において定数であると判
定した場合には、オブジェクト生成関数呼び出し翻訳部
108は、そのオブジェクトは実行時にオブジェクトの
値が変化しないconstオブジェクトか否かを「co
nst」という修飾子の有無により判定し(ステップS
603)、constオブジェクトであれば入力された
関数呼び出しコードを、その定数を初期値としたROM
領域に配置されるべき属性のデータに翻訳し(ステップ
S604)、関数呼び出しコード翻訳処理を終える。ま
た、ステップS603においてconstオブジェクト
でないと判定した場合には、オブジェクト生成関数呼び
出し翻訳部108は入力された関数呼び出しコードを、
ステップS601で計算された初期値のRAM領域に配
置されるべき属性のデータに翻訳し(ステップS60
5)、関数呼び出しコード翻訳処理を終える。なお、翻
訳結果は出力ファイル110に出力されることになる。
If it is determined in step S602 that the object is a constant, the object generation function call translating unit 108 determines whether the object is a const object whose value does not change at execution time.
nst ”(step S
603) If the object is a const object, the input function call code is stored in the ROM using the constant as an initial value.
The data is translated into the data of the attribute to be arranged in the area (step S604), and the function call code translation process ends. If it is determined in step S603 that the object is not a const object, the object generation function call translator 108 converts the input function call code into
It is translated into attribute data to be arranged in the RAM area of the initial value calculated in step S601 (step S60).
5) End the function call code translation process. Note that the translation result is output to the output file 110.

【0058】また、ステップS602において少なくと
も1つのメンバ変数の初期値が定数でないと判断した場
合、即ち入力された関数呼び出しコードの実引数と、そ
の関数呼び出しコードにより呼び出されるオブジェクト
生成関数の定義とに基づいた計算によってもメンバ変数
が定数値として特定できない場合には、オブジェクト生
成関数呼び出し翻訳部108は全メンバ変数に相当する
サイズであって初期値指定なしのRAM領域に配置され
るべき属性のデータを生成し(ステップS606)、入
力された関数呼び出しをオブジェクト生成関数のサブル
ーチンコール命令列に翻訳し(ステップS607)、関
数呼び出しコード翻訳処理を終える。
If it is determined in step S602 that the initial value of at least one member variable is not a constant, that is, the actual argument of the input function call code and the definition of the object generation function called by the function call code If the member variable cannot be specified as a constant value by the calculation based on the attribute value, the object generation function call translating unit 108 stores the data of the attribute to be arranged in the RAM area having the size corresponding to all the member variables and not specifying the initial value. Is generated (step S606), the input function call is translated into a subroutine call instruction sequence of the object generation function (step S607), and the function call code translation process ends.

【0059】「_IntArray_static(1
0,&_area00);」という静的オブジェクト生
成関数呼び出しコードを入力されて呼び出された場合に
は、オブジェクト生成関数呼び出し翻訳部108は、図
12に示すオブジェクトのメンバ変数「length」
及び「memp」の初期値を、静的オブジェクト生成関
数の定義に含まれる「length=size;」及び
「memp=area;」という代入文と静的オブジェ
クト生成関数呼び出しコードの実引数「10」及び「&
_area00」とより、それぞれ「10」,「&_a
rea00」と計算し、「&_area00」は、プロ
グラム実行前にRAM領域のアドレス値として定まるも
のであるため、メンバ変数の初期値が定数であると判定
する。この場合、元のオブジェクト生成文は「cons
t」という修飾子を有するものであるため、ステップS
604が実行され翻訳結果として、ROM領域に配置さ
れるべき属性のオブジェクトデータが得られる。
"_IntArray_static (1
0, &_area00);", the object generation function call translator 108 converts the member variable“ length ”of the object shown in FIG.
And the initial values of “mem” are replaced with the assignment statements “length = size;” and “mem = area;” included in the definition of the static object generation function, the actual arguments “10” of the static object generation function call code, and "&
_Area00 ”and“ 10 ”,“ & _a ”respectively.
area00 ", and"& _area00 "is determined as the address value of the RAM area before the execution of the program. Therefore, it is determined that the initial value of the member variable is a constant. In this case, the original object creation statement is "cons
t ”, the step S
604 is executed, and as a translation result, object data of the attribute to be arranged in the ROM area is obtained.

【0060】こうして、図12に示したソースプログラ
ムは、プログラム変換装置100により、図7で示され
る機械語命令列に翻訳され、出力ファイル110に出力
される。<考察>図7は、プログラム変換装置100に
よる図12に示したソースプログラムの翻訳結果を示す
図である。
In this way, the source program shown in FIG. 12 is translated into the machine language instruction sequence shown in FIG. <Consideration> FIG. 7 is a diagram showing a translation result of the source program shown in FIG.

【0061】結果的に、ソースプログラム中のオブジェ
クト生成文が図7に示す機械語命令列に変換されたこと
になる。同図中、「.section RAMARE
A」から「.section END」に挟まれた部分
は、RAM領域に配置されるべき属性のデータを表し、
「_area00:40」は、_area00という名
前で識別されるデータ領域が40バイトのサイズである
ことを表している。
As a result, the object generation statement in the source program is converted into the machine language instruction sequence shown in FIG. In the figure, ".section RAMARE"
A section between “.A” and “.section END” indicates attribute data to be arranged in the RAM area,
“_Area00: 40” indicates that the data area identified by the name of _area00 is 40 bytes in size.

【0062】また、「.section ROMARE
A」から「.section END」に挟まれた部分
は、ROM領域に配置されるべき属性のデータを表し、
「ArrayObj 10:4,&_area00:
4」は、ArrayObjというオブジェクトの初期値
として4バイトの即値データ10及び4バイトの即値ア
ドレス&_area00がROM領域に格納されること
を表している。
In addition, ".section ROMARE"
A portion between “.A” and “.section END” indicates attribute data to be arranged in the ROM area,
"ArrayObj 10: 4, & _area00:
"4" indicates that 4-byte immediate data 10 and 4-byte immediate address & _area00 are stored in the ROM area as the initial values of the object ArrayObj.

【0063】この図7に示すプログラム変換装置100
による翻訳結果と、図13に示した従来のプログラム変
換装置による翻訳結果とを比較すると、プログラム変換
装置100によれば、オブジェクト生成関数に相当する
機械語命令列が生成されておらずこのためコードサイズ
が削減されていることが明らかであり、memory_
alloc_funcという動的領域確保関数を呼び出
すサブルーチンコール等も生成していないため、プログ
ラムの実行速度が向上する。
The program conversion device 100 shown in FIG.
13 is compared with the translation result obtained by the conventional program conversion device shown in FIG. 13, the program conversion device 100 does not generate a machine language instruction sequence corresponding to the object generation function, and thus the code It is clear that the size has been reduced and memory_
Since a subroutine call for calling a dynamic area securing function called "alloc_func" is not generated, the execution speed of the program is improved.

【0064】また、プログラム変換装置100によれ
ば、ArrayObjをRAM領域ではなく、ROM領
域に配置されるべき属性のデータとするため、生成され
たプログラムの実行に必要となるRAM領域も削減され
る。 <補足>以上、本発明に係るプログラム変換装置につい
て、実施の形態に基づいて説明したが、本発明はこの実
施の形態に限られないことは勿論である。即ち、 (1)本実施の形態では、プログラム変換装置は、C+
+言語で記述されたソースプログラムを翻訳対象とした
が、これに限定されることはなく、他のオブジェクト指
向言語で記述されたソースプログラムを翻訳対象とする
ものであってもよい。 (2)本実施の形態では、記憶部105には静的オブジ
ェクト生成関数の定義を動的領域確保文と対にして格納
することとしたが、静的オブジェクト生成関数の定義を
元のオブジェクト生成関数の定義と対応付けて格納する
こととしてもよい。
Further, according to the program conversion apparatus 100, the ArrayObj is not the RAM area but the data of the attribute to be arranged in the ROM area. Therefore, the RAM area necessary for executing the generated program is also reduced. . <Supplement> Although the program conversion apparatus according to the present invention has been described based on the embodiment, it is needless to say that the present invention is not limited to this embodiment. That is, (1) In the present embodiment, the program conversion device is C +
The source program described in the + language is a translation target, but the present invention is not limited to this. A source program written in another object-oriented language may be the translation target. (2) In the present embodiment, the definition of the static object generation function is stored in the storage unit 105 as a pair with the dynamic area reservation statement. It may be stored in association with the function definition.

【0065】また、プログラム変換装置の処理手順は、
フローチャートによって示した手順に限定されることは
ない。即ち、ソースプログラムのオブジェクト生成関数
の定義中に動的領域確保文が存在し、その動的領域確保
文によって確保される領域のサイズをソースプログラム
の内容に基づいてコンパイル時に固定値として算定する
ことができたならば、動的領域確保文を、その算定した
サイズのRAM領域に配置されるべき属性のデータと、
そのデータの先頭アドレスを動的領域確保文によりアド
レスが代入されることになっていたメンバ変数に代入す
る中間表現とに変換する手順であればよい。これにより
比較的に実行時間の長いところの動的領域確保関数のサ
ブルーチンコールが不要となるため、プログラムの実行
速度の向上を図ることができる。更に、その結果として
オブジェクトの全メンバ変数がコンパイル時に固定値と
して算定することができるものになったならば、オブジ
ェクト生成関数のサブルーチンコール等のコードを生成
することなく、その全メンバ変数の値である固定値を初
期値としてもつRAM領域或いはROM領域に配置され
るべき属性のデータをオブジェクト生成文の翻訳結果と
する手順であればよい。これにより実行速度はさらに向
上し、コードサイズも削減される。なお、中間表現は、
ソースプログラムレベルの記述形式であっても差し支え
ない。 (3)本実施の形態で示したプログラム変換装置100
は、動的領域確保文によって確保される領域のサイズが
コンパイル時に固定値として算定することができなかっ
た場合には、従来のプログラム変化装置と同様の動作を
行うことになり、翻訳結果のプログラムは、オブジェク
ト生成関数に相当する機械語サブルーチン内で_mem
ory_alloc_funcという動的領域確保関数
を呼び出すものとなる。しかし、動的領域確保文によっ
て確保される領域のサイズがコンパイル時には固定値と
して算定できなくても、オブジェクト生成文に相当する
機械語命令列の実行前に固定値として算定することがで
きれば、実施の形態において示したような確保領域の先
頭アドレスをオブジェクト生成関数に相当する機械語サ
ブルーチンに引数として与える方式を利用することによ
り、オブジェクト生成関数に相当する機械語サブルーチ
ンから動的領域確保関数の呼び出しを削除することが可
能になる。この方法により、ソースプログラムに同一ク
ラスのオブジェクト生成文が複数記述されているような
場合において動的領域確保関数の呼び出し回数を削減
し、実行時間の短縮を図ることが可能になる。以下に、
この方法について説明する。
The processing procedure of the program conversion device is as follows.
The present invention is not limited to the procedure shown in the flowchart. That is, a dynamic area allocation statement exists in the definition of the object generation function of the source program, and the size of the area allocated by the dynamic area allocation statement is calculated as a fixed value at compilation based on the contents of the source program. Is completed, the dynamic area allocation statement is converted into attribute data to be allocated in the RAM area of the calculated size,
Any procedure may be used as long as the head address of the data is converted into an intermediate expression to be assigned to a member variable whose address is to be assigned by the dynamic area reservation statement. This eliminates the need for a subroutine call of the dynamic area securing function where the execution time is relatively long, so that the execution speed of the program can be improved. Furthermore, as a result, if all the member variables of the object can be calculated as fixed values at the time of compilation, the values of all the member variables can be calculated without generating a code such as a subroutine call of the object generation function. Any procedure can be used as long as the attribute data to be arranged in the RAM area or the ROM area having a certain fixed value as an initial value is the translation result of the object generation sentence. This further improves execution speed and reduces code size. The intermediate expression is
The description format at the source program level may be used. (3) Program conversion device 100 described in the present embodiment
If the size of the area allocated by the dynamic area allocation statement cannot be calculated as a fixed value at compile time, the same operation as the conventional program change device will be performed, and the translated program Is _mem in the machine language subroutine corresponding to the object creation function.
This calls a dynamic area securing function called ory_alloc_func. However, even if the size of the area secured by the dynamic area securing statement cannot be calculated as a fixed value at compile time, if it can be calculated as a fixed value before executing the machine language instruction sequence corresponding to the object creation statement, Calling the dynamic area allocation function from the machine language subroutine corresponding to the object generation function by using the method of giving the head address of the allocation area as an argument to the machine language subroutine corresponding to the object generation function as shown in the embodiment Can be deleted. With this method, it is possible to reduce the number of calls to the dynamic area securing function and shorten the execution time when a plurality of object generation statements of the same class are described in the source program. less than,
This method will be described.

【0066】図8は、図12に示したものと同じクラス
IntArrayの定義と、新たにクラスIntArr
ayのオブジェクトを生成する2つのオブジェクト生成
文とを含むC++言語のソースプログラムの一部を示す
図である。図8中、getsizeは、引数として渡し
た番号に応じてプログラム実行環境中の特定の要素に関
するサイズを取得する関数である。
FIG. 8 shows the definition of the same class IntArray as that shown in FIG.
FIG. 11 is a diagram illustrating a part of a source program in the C ++ language including two object generation statements for generating an object of ay. In FIG. 8, getsize is a function for acquiring the size of a specific element in the program execution environment according to the number passed as an argument.

【0067】従って、ArrayObj1というオブジ
ェクトについてのメンバ変数lengthの初期値は、
getsize(1)の実行結果として取得したサイズ
となり、メンバ変数mempの初期値は、そのleng
thで示されるサイズの確保された領域についての先頭
アドレスとなる。また、ArrayObj2というオブ
ジェクトについてのメンバ変数lengthの初期値
は、getsize(2)の実行結果として取得したサ
イズとなり、メンバ変数mempの初期値は、そのle
ngthで示されるサイズの確保された領域についての
先頭アドレスとなる。
Therefore, the initial value of the member variable length for the object ArrayObj1 is
The size obtained as the execution result of getsize (1) is the size, and the initial value of the member variable memp is
This is the start address of the area with the size indicated by th. The initial value of the member variable length for the object ArrayObj2 is the size acquired as a result of executing getsize (2), and the initial value of the member variable memp is
This is the start address of the area where the size indicated by ngth is secured.

【0068】図9は、従来のプログラム変換装置が図8
に示したオブジェクト生成文を翻訳した結果である機械
語命令列を示す図である。図9に示す機械語命令列で
は、_InitObj中においてArrayObj1と
ArrayObj2という2つのオブジェクトを生成す
るためにオブジェクト生成関数に相当するサブルーチン
であるIntArrayが2度呼び出されており、その
IntArray中では_memory_alloc_
funcが呼び出されている。従って、このプログラム
が実行されると、_memory_alloc_fun
cという動的領域確保関数が2度実行されることにな
る。
FIG. 9 is a diagram showing a conventional program conversion apparatus according to FIG.
FIG. 13 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. In the machine language instruction sequence shown in FIG. 9, IntArray, which is a subroutine corresponding to an object generation function, is called twice in order to generate two objects, ArrayObj1 and ArrayObj2, in _InitObj, and _memory_alloc_
func has been called. Therefore, when this program is executed, _memory_alloc_fun
The dynamic area securing function c is executed twice.

【0069】これに対し、確保した領域の先頭アドレス
をオブジェクト生成関数に相当する機械語サブルーチン
に引数として与える方式を用いる本発明に係るプログラ
ム変換装置による翻訳結果を次に示す。図10は、本発
明の方式を用いて図8に示したオブジェクト生成文を翻
訳した結果である機械語命令列を示す図である。
On the other hand, a translation result by the program conversion apparatus according to the present invention using the method of giving the head address of the secured area as an argument to the machine language subroutine corresponding to the object generation function is shown below. FIG. 10 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. 8 using the method of the present invention.

【0070】図10に示す機械語命令列では、オブジェ
クト生成関数に相当するサブルーチンとして、上述の実
施の形態に静的オブジェクト生成関数として示したもの
と同様に、通常のIntArrayに対してポインタ型
の引数を追加しその引数をメンバ変数に代入するもので
ある_IntArray_staticが存在する。ま
た、_InitObj中において_memory_al
loc_funcが1度呼び出され、_IntArra
y_staticが2度呼び出されている。
In the machine language instruction sequence shown in FIG. 10, as a subroutine corresponding to an object generation function, a pointer type pointer to a normal IntArray is used in the same manner as the static object generation function in the above embodiment. There is _IntArray_static, which adds an argument and substitutes the argument for a member variable. Also, in _InitObj, _memory_al
loc_func is called once, _IntArra
y_static has been called twice.

【0071】この図10に示す機械語命令列の内容を図
11に高級言語レベルの表記を用いて簡単に示す。以
下、図11に基づいて説明する。「s1=getsiz
e(1);」、「s2=getsize(2);」は、
図8に示した2つのオブジェクト生成文それぞれの実引
数として記述されたgetsizeに基づいて生成され
る。これらが実行されると、getsizeによって得
られたそれぞれのサイズがs1、s2に代入されること
になる。
The contents of the machine language instruction sequence shown in FIG. 10 are simply shown in FIG. 11 using a high-level language notation. Hereinafter, description will be made with reference to FIG. "S1 = getsiz
e (1); "and" s2 = getsize (2); "
It is generated based on the getsize described as the actual argument of each of the two object generation statements shown in FIG. When these are executed, the respective sizes obtained by getsize are substituted for s1 and s2.

【0072】「areatop=_memory_al
loc_func((s1+s2)*4);」は、s1
で示されるサイズとs2で示されるサイズの合計分だけ
のint型の領域を確保して、その先頭アドレスをar
eatopに代入するものである。従来のように領域確
保を2度行うのではなく、2度分の合計サイズの領域を
1度で確保することになる。
"Areatop = _memory_al
loc_func ((s1 + s2) * 4); "is s1
And an int type area corresponding to the sum of the size indicated by s2 and the size indicated by s2,
This is to be assigned to "etop". Rather than securing the area twice as in the related art, the area having the total size of twice is secured once.

【0073】「_IntArray_static(&
ArrayObj1,s1,areatop);」は、
ArrayObj1オブジェクトのメンバ変数に設定す
るため、サイズを示すs1と確保された領域の先頭アド
レスであるareatopとをオブジェクト生成関数に
相当するサブルーチンに渡すものである。「_IntA
rray_static(&ArrayObj2,s
2,areatop+(s1*4));」は、Arra
yObj2オブジェクトのメンバ変数に設定するため、
サイズを示すs2と、まとめて1度で確保された領域の
うちArrayObj2用の領域の先頭アドレスである
areatop+(s1*4)とをオブジェクト生成関
数に相当するサブルーチンに渡すものである。
"_IntArray_static (&
ArrayObj1, s1, areatop);
In order to set the member variables of the ArrayObj1 object, s1 indicating the size and areatop, which is the start address of the reserved area, are passed to a subroutine corresponding to an object generation function. "_IntA
array_static (& ArrayObj2, s
2, areatop + (s1 * 4));
To set a member variable of the yObj2 object,
The size s2 and the top address of the ArrayObj2 area, areatop + (s1 * 4), of the area secured once are passed to the subroutine corresponding to the object generation function.

【0074】このように、複数の動的領域確保文を1つ
にまとめることにより、動的に領域を確保するライブラ
リ関数又はシステムコールの呼び出しを1度に削減する
ことができ、実行時間の短縮が図れる。 (4)本実施の形態では、動的領域確保文によって確保
される領域の初期値は計算せずに、動的領域確保文に対
応してRAM領域に配置されるべき属性のデータを生成
する方法を用いたが、動的領域確保文によって確保され
た領域についても、オブジェクトのメンバ変数の初期値
の計算と同様の方法で初期値を計算し定数であるか否か
を判定し、初期値が定数であってその領域の内容が実行
時に変更されないと判明している場合はROM領域に配
置されるべき属性のデータに翻訳することとしてもよ
い。これにより、動的領域確保文によって確保される領
域に格納されるデータもROM領域に予め置くことが可
能となるため、プログラムの実行に必要なRAM領域を
更に削減できるようになる。 (5)本実施の形態では、動的領域確保文が1つの場合
について説明したが、動的領域確保文が複数であって
も、ポインタ型の仮引数を動的領域確保文の数だけ増や
し、動的領域確保文を、メンバ変数にポインタ型の仮引
数を代入する文に置換することとして静的オブジェクト
生成関数を生成し、また各動的領域確保文により確保さ
れるサイズの領域についての各先頭アドレスを実引数と
してその静的オブジェクト生成関数を呼び出すようにす
ればよい。 (6)本実施の形態では特に示さなかったが、動的領域
確保文により確保される領域とオブジェクトのメンバ変
数を格納するための領域が共にROM領域に配置される
べき属性のデータとなった場合又は共にRAM領域に配
置されるべき属性のデータとなった場合には、これらの
データを隣接するメモリ領域に割り当てられるような属
性のものとしてもよい。即ち、各データの相対アドレス
を指定して連続したアドレスに位置されるように設定す
ることとしてもよい。このようにするとオブジェクトの
メンバ関数によってアクセスされる領域が隣接している
ことになるため、ハードウェアアーキテクチャやOSの
仕様によっては、2つの領域が離れているのに比べて高
速に参照が可能となり、プログラム実行速度が向上す
る。 (7)本実施の形態では動的領域確保文に対応して生成
されたデータは、初期値指定のないRAM領域に配置さ
れるべき属性のデータであるとしたが、任意の初期値を
指定するものとしても差し支えない。 (8)実施の形態において図3〜図6を用いて示したプ
ログラム変換装置の処理手順を汎用のコンピュータに実
行させるためのコンピュータプログラムを、記録媒体に
記録し又は各種通信路等を介して、流通させ頒布するこ
ともできる。
As described above, by combining a plurality of dynamic area allocation statements into one, it is possible to reduce the number of calls to library functions or system calls for dynamically allocating an area at once, and to reduce the execution time. Can be achieved. (4) In the present embodiment, the data of the attribute to be allocated in the RAM area corresponding to the dynamic area allocation statement is generated without calculating the initial value of the area allocated by the dynamic area allocation statement. Although the method was used, the initial value of the area allocated by the dynamic area allocation statement is calculated in the same way as the calculation of the initial value of the member variable of the object, and it is determined whether the area is a constant. Is a constant and it is known that the contents of the area are not changed at the time of execution, the data may be translated into attribute data to be arranged in the ROM area. As a result, data stored in the area secured by the dynamic area securing statement can also be previously stored in the ROM area, so that the RAM area required for executing the program can be further reduced. (5) In the present embodiment, the case where there is one dynamic area reservation statement has been described. However, even if there are a plurality of dynamic area reservation statements, the number of pointer-type dummy arguments is increased by the number of dynamic area reservation statements. , Generate a static object generation function by replacing the dynamic area allocation statement with a statement that assigns a pointer-type dummy argument to a member variable. What is necessary is just to call the static object generation function using each head address as an actual argument. (6) Although not specifically shown in the present embodiment, the area secured by the dynamic area securing statement and the area for storing the member variables of the object are both attribute data to be arranged in the ROM area. In such a case, or when both of them become attribute data to be arranged in the RAM area, these data may be attributed to be allocated to the adjacent memory area. That is, the relative address of each data may be designated and set so as to be located at a continuous address. In this case, the areas accessed by the member functions of the object are adjacent to each other, and depending on the hardware architecture and the specifications of the OS, the reference can be performed at a higher speed than when the two areas are separated from each other. As a result, the program execution speed is improved. (7) In the present embodiment, the data generated corresponding to the dynamic area reservation statement is data of the attribute to be arranged in the RAM area where no initial value is specified, but an arbitrary initial value is specified. You can do it. (8) In the embodiment, a computer program for causing a general-purpose computer to execute the processing procedure of the program conversion device shown in FIGS. 3 to 6 is recorded on a recording medium or through various communication paths and the like. They can also be distributed and distributed.

【0075】かかる記録媒体には、ICカード、光ディ
スク、フレキシブルディスク、ROM等がある。流通、
頒布されたコンピュータプログラムは、汎用のコンピュ
ータにインストール等されることにより利用に供され、
汎用のコンピュータは、当該コンピュータプログラムを
実行して、本実施の形態に示したようなプログラム変換
装置を実現する。
Such recording media includes an IC card, an optical disk, a flexible disk, a ROM, and the like. Distribution,
The distributed computer program is used by being installed on a general-purpose computer or the like,
The general-purpose computer executes the computer program to realize the program conversion device as described in the present embodiment.

【0076】[0076]

【発明の効果】以上の説明から明らかなように本発明に
係るプログラム変換装置は、動的に領域を確保して当該
領域の先頭アドレスをポインタ型変数に代入する動的領
域確保文を含むオブジェクト生成関数を呼び出すことに
よりオブジェクトを生成するオブジェクト生成文が記述
されたソースプログラムを、機械語プログラムに変換す
るプログラム変換装置であって、前記オブジェクト生成
文により前記オブジェクト生成関数が呼び出されたと仮
定した場合において前記動的領域確保文によって確保さ
れる領域のサイズを計算する計算手段と、前記計算手段
により計算された前記領域のサイズが定数値である場合
には、前記動的領域確保文を、当該サイズの第1データ
と、当該第1データの先頭アドレスを前記ポインタ型変
数に代入するための中間表現とに変換する第1変換手段
と、前記第1変換手段により動的領域確保文が変換され
た後のオブジェクト生成関数を、前記オブジェクト生成
文が呼び出すものとして、前記オブジェクト生成文を機
械語命令に変換する第2変換手段とを備えることを特徴
とする。
As is apparent from the above description, the program conversion apparatus according to the present invention provides an object including a dynamic area securing statement for dynamically securing an area and assigning the start address of the area to a pointer type variable. A program conversion device that converts a source program in which an object generation statement for generating an object by calling a generation function is described into a machine language program, assuming that the object generation function is called by the object generation statement Calculating means for calculating the size of the area secured by the dynamic area securing statement, and, if the size of the area calculated by the calculating means is a constant value, To assign the first data of the size and the start address of the first data to the pointer type variable A first conversion unit for converting the object generation statement into an intermediate representation; and an object generation function obtained by converting the dynamic area securing statement by the first conversion unit. And a second conversion unit that converts the instruction into an instruction.

【0077】これにより、動的領域確保文により確保さ
れることが予定されていた領域は機械語プログラム中に
おいてデータとして置かれることになるため、動的領域
確保関数のサブルーチンコールを行わないことによりプ
ログラム実行速度が向上する。また、第2変換手段を特
開2000−40005号公報に開示されている従来技
術を用いて具体化したならば、コードサイズの削減等が
図れる。
As a result, the area to be secured by the dynamic area securing statement is placed as data in the machine language program. Program execution speed is improved. Also, if the second conversion means is embodied using the conventional technique disclosed in Japanese Patent Application Laid-Open No. 2000-40005, the code size can be reduced.

【0078】また、前記第2変換手段は、前記第1変換
手段による変換後の前記オブジェクト生成関数が前記オ
ブジェクト生成文により呼び出されたと仮定した場合に
おける当該呼出によって前記オブジェクトのメンバ変数
に対し設定される値が定数値であるときに、前記オブジ
ェクト生成文を、前記メンバ変数に設定されるアドレス
値又は定数値をもつデータであってオブジェクトのメン
バ変数と同じサイズの第2データに変換し、さらに前記
オブジェクト生成文により生成されるオブジェクトが値
の変化しないオブジェクトであれば当該第2データをR
OM領域に配置されるべき属性のデータにするものとし
てもよい。
Further, the second conversion means sets the member variables of the object by the call when the object generation function after conversion by the first conversion means is called by the object generation statement. When the value is a constant value, the object generation statement is converted to second data having the same size as the object member variable, which is data having an address value or a constant value set in the member variable, If the object generated by the object generation statement is an object whose value does not change, the second data
The data may be attribute data to be arranged in the OM area.

【0079】これにより、オブジェクト生成文を、オブ
ジェクト生成関数を呼び出した後になるであろう状態の
オブジェクトデータ(即ち第2データ)に翻訳し、また
オブジェクト生成文がconst修飾子を持つものであ
ればそのオブジェクトデータにROM領域に配置される
べき属性を与えるため、オブジェクト生成関数に相当す
るコードが削減でき、実行時に必要なRAM領域を削減
し得るようになる。組み込み用途のマイクロコンピュー
タにおいては一般にRAMはROMよりコストが高いた
め、これによりコスト削減が図れる。
Thus, the object generation statement is translated into object data (that is, the second data) in a state that will be after calling the object generation function, and if the object generation statement has a const qualifier, Since an attribute to be arranged in the ROM area is given to the object data, the code corresponding to the object generation function can be reduced, and the RAM area required at the time of execution can be reduced. In a microcomputer for embedded use, a RAM is generally higher in cost than a ROM, so that the cost can be reduced.

【0080】また、前記第2変換手段は、前記第1変換
手段による変換後の前記オブジェクト生成関数が前記オ
ブジェクト生成文により呼び出されたと仮定した場合に
おける当該呼出によって前記第1データに対し設定され
る値が定数値であるときに、当該定数値を前記第1デー
タの初期値とし、さらに前記第1データが初期値から変
化しないものであれば前記第1データをROM領域に配
置されるべき属性のデータにするものとしてもよい。
Further, the second conversion means is set for the first data by the call when it is assumed that the object generation function converted by the first conversion means is called by the object generation statement. When the value is a constant value, the constant value is set as an initial value of the first data, and if the first data does not change from the initial value, the first data is an attribute to be arranged in the ROM area. May be used.

【0081】これにより、動的領域確保文により確保さ
れることが予定されていた領域を、一定条件下でROM
領域に配置されるべき属性のデータとして機械語プログ
ラム中に置くことになるため、コスト削減が図れる。ま
た、前記第1変換手段は、前記動的領域確保文を含むオ
ブジェクト生成関数を基礎として、ポインタ型の仮引数
を追加しさらに前記動的領域確保文を、前記ポインタ型
変数に前記仮引数を代入する代入文に置き換えた中間表
現である静的オブジェクト生成関数を生成するものであ
り、前記第2変換手段は、前記オブジェクト生成文を、
前記第1データの先頭アドレスを前記ポインタ型の仮引
数として用いることができるように渡して前記第1変換
手段により生成された前記静的オブジェクト生成関数を
呼び出す中間表現に変換し、当該中間表現に応じた機械
語命令を生成するものとしてもよい。
As a result, the area to be reserved by the dynamic area reservation statement can be
Since the data of the attribute to be arranged in the area is stored in the machine language program, the cost can be reduced. Further, the first conversion means adds a pointer-type dummy argument based on the object generation function including the dynamic area allocation statement, further stores the dynamic area allocation statement in the pointer type variable, and Generating a static object generation function which is an intermediate expression replaced with an assignment statement to be substituted, wherein the second conversion means converts the object generation statement into
The head address of the first data is passed so that it can be used as the formal parameter of the pointer type, and is converted into an intermediate expression for calling the static object generation function generated by the first conversion means. A corresponding machine language instruction may be generated.

【0082】これにより、動的領域確保文をオブジェク
ト生成関数から除去するためのプログラム変換装置の処
理構造を比較的簡単なものにすることができる。また、
前記第1データと、前記オブジェクトのメンバ変数に対
応するデータとを隣接するメモリ領域に割り当てられる
属性のデータにすることとしてもよい。これにより、機
械語プログラムの動作環境となるハードウェアアーキテ
クチャやOSの仕様によってはプログラム実行速度が向
上する。
Thus, the processing structure of the program conversion device for removing the dynamic area reservation statement from the object generation function can be made relatively simple. Also,
The first data and data corresponding to a member variable of the object may be data of an attribute assigned to an adjacent memory area. As a result, the program execution speed is improved depending on the hardware architecture or the OS specifications that are the operating environment of the machine language program.

【0083】また、本発明に係るプログラム変換装置
は、動的に領域を確保して当該領域の先頭アドレスをポ
インタ型変数に代入する動的領域確保文を複数含むソー
スプログラムを、機械語プログラムに変換するプログラ
ム変換装置であって、前記複数の動的領域確保文それぞ
れにより確保されるべき領域のサイズを計算するサイズ
計算手段と、引数としてサイズを受け取り当該サイズの
領域を動的に確保して当該領域の先頭アドレスを返却す
るサブルーチンである動的領域確保ルーチンを、前記複
数の動的領域確保文それぞれにより確保されるべき領域
のサイズの合計値を引数として呼び出すことにより、前
記複数の動的領域確保文により確保されるべき全ての領
域を一括して確保するためのサブルーチンコール命令を
生成する動的領域確保ルーチン呼出命令生成手段と、前
記サブルーチンコール命令の実行により返却されるアド
レスと前記サイズ計算手段により計算された前記各領域
のサイズとに基づき、前記動的領域確保ルーチンにより
確保される領域のうち前記複数の動的領域確保文それぞ
れの分に相当する各領域の先頭アドレスを算出する先頭
アドレス算出手段と、前記複数の動的領域確保文それぞ
れを、当該動的領域確保文に対応して前記先頭アドレス
算出手段により算出された領域の先頭アドレスを該当す
るポインタ型変数に代入する命令に変換する変換手段と
を備えることを特徴とする。
Further, the program conversion device according to the present invention converts a source program including a plurality of dynamic area securing statements for dynamically securing an area and substituting the start address of the area into a pointer type variable into a machine language program. A program conversion device for performing conversion, comprising: size calculation means for calculating a size of an area to be secured by each of the plurality of dynamic area securing statements; and receiving a size as an argument and dynamically securing an area of the size. The dynamic area allocation routine, which is a subroutine for returning the start address of the area, is called by using the total value of the size of the area to be allocated by each of the dynamic area allocation statements as an argument. A dynamic area check that generates a subroutine call instruction to collectively secure all areas to be secured by the area securement statement A routine call instruction generating unit, and based on an address returned by execution of the subroutine call instruction and a size of each of the regions calculated by the size calculating unit, A start address calculating means for calculating a start address of each area corresponding to each of the plurality of dynamic area reservation statements; and A conversion unit for converting the start address of the area calculated by the address calculation unit into an instruction for substituting the start address into a corresponding pointer type variable.

【0084】これにより、一般に比較的実行時間の長い
動的領域確保ルーチンを呼び出す回数を削減できるた
め、変換結果のプログラムの実行速度が向上するように
なる。
As a result, the number of times of calling the dynamic area securing routine, which generally has a relatively long execution time, can be reduced, so that the execution speed of the program resulting from the conversion is improved.

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

【図1】本発明の実施の形態に係るプログラム変換装置
100の機能構成図である。
FIG. 1 is a functional configuration diagram of a program conversion device 100 according to an embodiment of the present invention.

【図2】オブジェクト生成関数変換部103が記憶部1
05に格納するデータの内容例を示す図である。
FIG. 2 shows a storage unit 1 in which an object generation function conversion unit 103 is used.
FIG. 5 is a diagram showing an example of the content of data stored in a storage unit 05.

【図3】プログラム変換装置100の全体的な動作を示
すフローチャートである。
FIG. 3 is a flowchart showing an overall operation of the program conversion device 100.

【図4】主にオブジェクト生成関数変換部103により
行われるオブジェクト生成関数変換処理を示すフローチ
ャートである。
FIG. 4 is a flowchart illustrating an object generation function conversion process mainly performed by an object generation function conversion unit 103;

【図5】オブジェクト生成文変換処理を示すフローチャ
ートである。
FIG. 5 is a flowchart illustrating an object generation sentence conversion process.

【図6】オブジェクト生成関数呼び出し翻訳部108に
よりなされる関数呼び出しコード翻訳処理を示すフロー
チャートである。
FIG. 6 is a flowchart showing a function call code translation process performed by an object generation function call translation unit 108;

【図7】プログラム変換装置100による図12に示す
ソースプログラムの翻訳結果を示す図である。
7 is a diagram showing a translation result of the source program shown in FIG. 12 by the program conversion device 100. FIG.

【図8】図12に示すものと同じクラスIntArra
yの定義と、新たにクラスIntArrayのオブジェ
クトを生成する2つのオブジェクト生成文とを含むC+
+言語のソースプログラムの一部を示す図である。
FIG. 8 shows the same class IntArra as shown in FIG.
C + containing the definition of y and two object creation statements that create new objects of class IntArray
FIG. 9 is a diagram showing a part of a + language source program.

【図9】従来のプログラム変換装置が図8に示すオブジ
ェクト生成文を翻訳した結果である機械語命令列を示す
図である。
9 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. 8 by the conventional program conversion device.

【図10】本発明の方式を用いて図8に示すオブジェク
ト生成文を翻訳した結果である機械語命令列を示す図で
ある。
FIG. 10 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. 8 using the method of the present invention.

【図11】図10に示す機械語命令列の内容を高級言語
レベルの表記を用いて簡単に示した図である。
11 is a diagram simply showing the contents of the machine language instruction sequence shown in FIG. 10 using a notation at a high-level language level.

【図12】オブジェクト生成関数を含むクラスIntA
rrayの定義と、クラスIntArrayのオブジェ
クトを生成するオブジェクト生成文とを含むC++言語
のソースプログラムの一部を示す図である。
FIG. 12 shows a class IntA including an object generation function.
FIG. 14 is a diagram illustrating a part of a source program in the C ++ language including a definition of “rray” and an object generation statement for generating an object of class IntArray.

【図13】従来のプログラム変換装置が図12に示すオ
ブジェクト生成文を翻訳した結果である機械語命令列を
示す図である。
13 is a diagram showing a machine language instruction sequence as a result of translating the object generation sentence shown in FIG. 12 by the conventional program conversion device.

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

100 プログラム変換装置 101 入力ファイル 102 制御部 103 オブジェクト生成関数変換部 104 動的領域確保文検出部 105 記憶部 106 オブジェクト生成文変換部 107 動的確保領域計算部 108 オブジェクト生成関数呼び出し翻訳部 109 一般文翻訳部 110 出力ファイル REFERENCE SIGNS LIST 100 program conversion device 101 input file 102 control unit 103 object generation function conversion unit 104 dynamic area reservation sentence detection unit 105 storage unit 106 object generation statement conversion unit 107 dynamic reservation area calculation unit 108 object generation function call translation unit 109 general sentence Translator 110 output file

Claims (8)

【特許請求の範囲】[Claims] 【請求項1】 動的に領域を確保して当該領域の先頭ア
ドレスをポインタ型変数に代入する動的領域確保文を含
むオブジェクト生成関数を呼び出すことによりオブジェ
クトを生成するオブジェクト生成文が記述されたソース
プログラムを、機械語プログラムに変換するプログラム
変換装置であって、 前記オブジェクト生成文により前記オブジェクト生成関
数が呼び出されたと仮定した場合において前記動的領域
確保文によって確保される領域のサイズを計算する計算
手段と、 前記計算手段により計算された前記領域のサイズが定数
値である場合には、前記動的領域確保文を、当該サイズ
の第1データと、当該第1データの先頭アドレスを前記
ポインタ型変数に代入するための中間表現とに変換する
第1変換手段と、 前記第1変換手段により動的領域確保文が変換された後
のオブジェクト生成関数を、前記オブジェクト生成文が
呼び出すものとして、前記オブジェクト生成文を機械語
命令に変換する第2変換手段とを備えることを特徴とす
るプログラム変換装置。
1. An object generation statement for generating an object by calling an object generation function including a dynamic area reservation statement for dynamically allocating an area and assigning the start address of the area to a pointer variable. A program conversion device for converting a source program into a machine language program, wherein the size of an area secured by the dynamic area securing statement is calculated when it is assumed that the object creation function is called by the object creation statement. Calculating means, when the size of the area calculated by the calculating means is a constant value, the dynamic area securing statement is set to the first data of the size and the start address of the first data to the pointer. First conversion means for converting the data into an intermediate representation for substituting into a type variable; And a second conversion unit for converting the object generation statement into a machine language instruction as a function to be called by the object generation statement after the object area securing statement has been converted. .
【請求項2】 前記第2変換手段は、前記第1変換手段
による変換後の前記オブジェクト生成関数が前記オブジ
ェクト生成文により呼び出されたと仮定した場合におけ
る当該呼出によって前記オブジェクトのメンバ変数に対
し設定される値が定数値であるときに、前記オブジェク
ト生成文を、前記メンバ変数に設定されるアドレス値又
は定数値をもつデータであってオブジェクトのメンバ変
数と同じサイズの第2データに変換し、さらに前記オブ
ジェクト生成文により生成されるオブジェクトが値の変
化しないオブジェクトであれば当該第2データをROM
領域に配置されるべき属性のデータにすることを特徴と
する請求項1記載のプログラム変換装置。
2. The method according to claim 1, wherein the second conversion unit is configured to set a member variable of the object by the call when the object generation function after conversion by the first conversion unit is called by the object generation statement. When the value is a constant value, the object generation statement is converted to second data having the same size as the object member variable, which is data having an address value or a constant value set in the member variable, If the object generated by the object generation statement is an object whose value does not change, the second data is stored in the ROM.
2. The program conversion device according to claim 1, wherein the data is attribute data to be arranged in the area.
【請求項3】 前記第2変換手段は、前記第1変換手段
による変換後の前記オブジェクト生成関数が前記オブジ
ェクト生成文により呼び出されたと仮定した場合におけ
る当該呼出によって前記第1データに対し設定される値
が定数値であるときに、当該定数値を前記第1データの
初期値とし、さらに前記第1データが初期値から変化し
ないものであれば前記第1データをROM領域に配置さ
れるべき属性のデータにすることを特徴とする請求項1
又は2記載のプログラム変換装置。
3. The second conversion means is set for the first data by the call when it is assumed that the object generation function converted by the first conversion means is called by the object generation statement. When the value is a constant value, the constant value is set as an initial value of the first data, and if the first data does not change from the initial value, the first data is an attribute to be arranged in the ROM area. 2. The data of claim 1,
Or the program conversion device according to 2.
【請求項4】 前記第1変換手段は、前記動的領域確保
文を含むオブジェクト生成関数を基礎として、ポインタ
型の仮引数を追加しさらに前記動的領域確保文を、前記
ポインタ型変数に前記仮引数を代入する代入文に置き換
えた中間表現である静的オブジェクト生成関数を生成す
るものであり、 前記第2変換手段は、前記オブジェクト生成文を、前記
第1データの先頭アドレスを前記ポインタ型の仮引数と
して用いることができるように渡して前記第1変換手段
により生成された前記静的オブジェクト生成関数を呼び
出す中間表現に変換し、当該中間表現に応じた機械語命
令を生成することを特徴とする請求項1〜3のいずれか
1項に記載のプログラム変換装置。
4. The first conversion means adds a pointer-type dummy argument based on an object generation function including the dynamic area reservation statement, and further adds the dynamic area reservation statement to the pointer type variable. Generating a static object generation function which is an intermediate expression replaced with an assignment statement for substituting a dummy argument, wherein the second conversion means converts the object generation statement into a pointer type of a first address of the first data. The static object generation function generated by the first conversion means is converted into an intermediate expression for calling the static object generation function, and a machine language instruction corresponding to the intermediate expression is generated. The program conversion device according to claim 1.
【請求項5】 前記第1データと、前記オブジェクトの
メンバ変数に対応するデータとを隣接するメモリ領域に
割り当てられる属性のデータにすることを特徴とする請
求項1〜4のいずれか1項に記載のプログラム変換装
置。
5. The method according to claim 1, wherein the first data and data corresponding to a member variable of the object are data of an attribute assigned to an adjacent memory area. The program conversion device according to the above.
【請求項6】 動的に領域を確保して当該領域の先頭ア
ドレスをポインタ型変数に代入する動的領域確保文を複
数含むソースプログラムを、機械語プログラムに変換す
るプログラム変換装置であって、 前記複数の動的領域確保文それぞれにより確保されるべ
き領域のサイズを計算するサイズ計算手段と、 引数としてサイズを受け取り当該サイズの領域を動的に
確保して当該領域の先頭アドレスを返却するサブルーチ
ンである動的領域確保ルーチンを、前記複数の動的領域
確保文それぞれにより確保されるべき領域のサイズの合
計値を引数として呼び出すことにより、前記複数の動的
領域確保文により確保されるべき全ての領域を一括して
確保するためのサブルーチンコール命令を生成する動的
領域確保ルーチン呼出命令生成手段と、 前記サブルーチンコール命令の実行により返却されるア
ドレスと前記サイズ計算手段により計算された前記各領
域のサイズとに基づき、前記動的領域確保ルーチンによ
り確保される領域のうち前記複数の動的領域確保文それ
ぞれの分に相当する各領域の先頭アドレスを算出する先
頭アドレス算出手段と、 前記複数の動的領域確保文それぞれを、当該動的領域確
保文に対応して前記先頭アドレス算出手段により算出さ
れた領域の先頭アドレスを該当するポインタ型変数に代
入する命令に変換する変換手段とを備えることを特徴と
するプログラム変換装置。
6. A program conversion apparatus for converting a source program including a plurality of dynamic area securing statements for dynamically securing an area and assigning a start address of the area to a pointer type variable into a machine language program, Size calculating means for calculating the size of an area to be secured by each of the plurality of dynamic area securing statements, and a subroutine for receiving a size as an argument, dynamically securing an area of the size, and returning a start address of the area Is called as an argument with the total size of the areas to be secured by each of the plurality of dynamic area securing statements, so that all the A dynamic area securing routine call instruction generating means for generating a subroutine call instruction for collectively securing the area of Based on the address returned by the execution of the routine call instruction and the size of each of the areas calculated by the size calculation means, each of the plurality of dynamic area allocation statements among the areas allocated by the dynamic area allocation routine A start address calculating means for calculating a start address of each area corresponding to the above-mentioned area; and an area calculated by the start address calculating means corresponding to each of the plurality of dynamic area securing statements corresponding to the dynamic area securing statement. Converting means for converting the start address of the instruction into an instruction for substituting the pointer address into a corresponding pointer type variable.
【請求項7】 動的に領域を確保して当該領域の先頭ア
ドレスをポインタ型変数に代入する動的領域確保文を含
むオブジェクト生成関数を呼び出すことによりオブジェ
クトを生成するオブジェクト生成文が記述されたソース
プログラムを機械語プログラムに変換するプログラム変
換処理を、コンピュータに実行させるための制御プログ
ラムを記録した記録媒体であって、 前記プログラム変換処理は、 前記オブジェクト生成文により前記オブジェクト生成関
数が呼び出されたと仮定した場合において前記動的領域
確保文によって確保される領域のサイズを計算する計算
ステップと、 前記計算ステップにより計算された前記領域のサイズが
定数値である場合には、前記動的領域確保文を、当該サ
イズのデータと、当該データの先頭アドレスを前記ポイ
ンタ型変数に代入するための中間表現とに変換する第1
変換ステップと、 前記第1変換ステップにより動的領域確保文が変換され
た後のオブジェクト生成関数を、前記オブジェクト生成
文が呼び出すものとして、前記オブジェクト生成文を機
械語命令に変換する第2変換ステップとを含むことを特
徴とする記録媒体。
7. An object generation statement for generating an object by calling an object generation function including a dynamic area reservation statement for dynamically allocating an area and assigning the start address of the area to a pointer type variable. A recording medium storing a control program for causing a computer to execute a program conversion process of converting a source program into a machine language program, wherein the program conversion process includes a step of calling the object generation function by the object generation statement. A calculating step of calculating a size of an area secured by the dynamic area securing statement in a case where it is assumed; and a dynamic area securing statement when the size of the area calculated by the calculating step is a constant value. With the data of the size and the start address of the data. First conversion to intermediate representation for assignment to pointer type variable
A conversion step; and a second conversion step of converting the object generation statement into a machine language instruction, assuming that the object generation function calls the object generation function after the dynamic area securing statement has been converted by the first conversion step. And a recording medium comprising:
【請求項8】 動的に領域を確保して当該領域の先頭ア
ドレスをポインタ型変数に代入する動的領域確保文を複
数含むソースプログラムを、機械語プログラムに変換す
るプログラム変換処理を、コンピュータに実行させるた
めの制御プログラムを記録した記録媒体であって、 前記プログラム変換処理は、 前記複数の動的領域確保文それぞれにより確保されるべ
き領域のサイズを計算するサイズ計算ステップと、 引数としてサイズを受け取り当該サイズの領域を動的に
確保して当該領域の先頭アドレスを返却するサブルーチ
ンである動的領域確保ルーチンを、前記複数の動的領域
確保文それぞれにより確保されるべき領域のサイズの合
計値を引数として呼び出すことにより、前記複数の動的
領域確保文により確保されるべき全ての領域を一括して
確保するためのサブルーチンコール命令を生成する動的
領域確保ルーチン呼出命令生成ステップと、 前記サブルーチンコール命令の実行により返却されるア
ドレスと前記サイズ計算ステップにより計算された前記
各領域のサイズとに基づき、前記動的領域確保ルーチン
により確保される領域のうち前記複数の動的領域確保文
それぞれの分に相当する各領域の先頭アドレスを算出す
る先頭アドレス算出ステップと、 前記複数の動的領域確保文それぞれを、当該動的領域確
保文に対応して前記先頭アドレス算出ステップにより算
出された領域の先頭アドレスを該当するポインタ型変数
に代入する命令に変換する変換ステップとを含むことを
特徴とする記録媒体。
8. A program conversion process for converting a source program including a plurality of dynamic area allocation statements for dynamically allocating an area and assigning the start address of the area to a pointer type variable into a machine language program, by a computer. A recording medium on which a control program to be executed is recorded, wherein the program conversion processing includes: a size calculating step of calculating a size of an area to be secured by each of the plurality of dynamic area securing statements; The dynamic area allocation routine, which is a subroutine for dynamically allocating an area of the size and returning the start address of the area, is executed by summing the size of the area to be allocated by each of the plurality of dynamic area allocation statements. By calling all the areas to be secured by the dynamic area securing statements. Generating a subroutine call instruction for generating a subroutine call instruction for securing the subroutine call instruction, based on an address returned by execution of the subroutine call instruction and the size of each area calculated in the size calculation step. A start address calculating step of calculating a start address of each area corresponding to each of the plurality of dynamic area securing statements among the areas secured by the dynamic area securing routine; A conversion step of converting each of them into an instruction for assigning the start address of the area calculated in the start address calculation step to the corresponding pointer type variable in accordance with the dynamic area reservation statement. Medium.
JP2000304148A 2000-10-03 2000-10-03 Program converter Pending JP2002108628A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000304148A JP2002108628A (en) 2000-10-03 2000-10-03 Program converter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000304148A JP2002108628A (en) 2000-10-03 2000-10-03 Program converter

Publications (1)

Publication Number Publication Date
JP2002108628A true JP2002108628A (en) 2002-04-12

Family

ID=18785235

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000304148A Pending JP2002108628A (en) 2000-10-03 2000-10-03 Program converter

Country Status (1)

Country Link
JP (1) JP2002108628A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006185353A (en) * 2004-12-28 2006-07-13 Denso Corp Constant attribute/variable attribute encapsulation method, microcomputer and data structure

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006185353A (en) * 2004-12-28 2006-07-13 Denso Corp Constant attribute/variable attribute encapsulation method, microcomputer and data structure

Similar Documents

Publication Publication Date Title
US7421686B2 (en) Program code conversion
Krall Efficient JavaVM just-in-time compilation
JP4130713B2 (en) Program converter
US6760905B1 (en) Lazy compilation of template-generated classes in dynamic compilation execution environments
US20050160415A1 (en) Method and system for improving performance of Java virtual machine
CA2434280A1 (en) Method and apparatus to guarantee type and initialization safety in multihreaded programs
JP4026940B2 (en) Program converter
JP2000353097A (en) Method and device for generating low density interference graph
JP2002108628A (en) Program converter
JP3051438B2 (en) How to give enhanced graphics capabilities
JP3264901B2 (en) Compiling device and compiling method
JP3327674B2 (en) Program translation apparatus and method
JP2002182927A (en) Allocating method of register in different execution environment, software developing method in different execution environment and lsi in which program to execute the same is incorporated
WO2006131695A1 (en) Method and apparatus for combined execution of native code and target code during program code conversion
US6029003A (en) Method of assigning external variables to memories when compiling source program
JP2001142719A (en) Compiler device and recording medium with recorded compiler program
JP2001350647A (en) Debug system and debug method
JP2001014172A (en) Program converting device
JP2002182925A (en) Compiling method and computer readable recording medium
JP2001273150A (en) Device for converting program
JPH07129408A (en) Executing system for language processing program
Tse Typed Intermediate Languages
JP2000339171A (en) Compile device, its method and recording medium
JP2000339173A (en) Language processor
JPH1185531A (en) Language processor and storage medium recording program realizing language processor