Data processing: software development – installation – and managem – Software program development tool – Translation of code
Reexamination Certificate
1999-07-16
2001-09-18
Dam, Tuan Q. (Department: 2122)
Data processing: software development, installation, and managem
Software program development tool
Translation of code
C717S152000
Reexamination Certificate
active
06292937
ABSTRACT:
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates to a program conversion device that translates a source program into a machine language program and more specifically to a program conversion device for translating a source program that is written in an object-oriented language and contains object generation statements.
2. Description of the Prior Art
In object-oriented languages (OOL), objects (also called instances) need to be generated prior to use. This is achieved by object generation statements. When an object is generated using an object generation statement, an object generation function, which is one of member functions of the object, is invoked. In this way, an object generation statement invokes an object generation function to generate an object.
Usually, an object generation function is designed to initialize member variables of an object.
The following describes a conventional program conversion device that translates a source program written in C++, which is an OOL, into a machine language program.
FIG. 1
shows a part of a source program written in C++ that is made up of a definition of class X and an object generation statement used to generate an object of class X. The definition of class X contains an object generation function.
In C++, an object generation function is called a constructor and contains the name of its class. In the figure, “X (int a, int b)” represents an object generation function of class X. An object generation statement is written as a declaration statement for an object. In the figure, the object generation statement represented by “const X obj (2, 3);” is the declaration statement to generate object “obj” of class X. “(2, 3)” in “const X obj (2, 3);” denotes two actual parameters to be passed to the object generation function, and “const” denotes a qualifier showing that the values of object “obj” do not change after the object is generated. Hereafter, such an object whose values are invariable is called a “const object”.
Here, note that object “obj” is a global object to which functions and other objects can refer and therefore should be placed in a memory during execution of the machine code that results from the translation of the source code.
The program conversion device, i.e., compiler, which translates a source program into a machine language program, generates a machine language program executable by a certain type of a processor.
In translating a source program into a machine language program for a microcomputer built into a household electrical appliance, a program conversion device translates data and procedures written in the source program respectively into data and codes, the resulting data being assigned a storage location attribute indicating either a ROM area or a RAM area, and the codes being assigned a storage location attribute indicating a ROM area. The RAM area refers to a memory area from which and into which data can be read and written, while the ROM area refers to a memory area from which data can be read only. Here, a storage location attribute indicating that data is to be placed into a ROM area is hereafter called a ROM attribute, and a storage location attribute indicating a RAM area is called a RAM attribute.
The machine language program outputted from the program conversion device is executed by a certain type of a processor under the control of an operating system (OS) or the like. The data and codes in the machine language program are placed in either a ROM or RAM area according to the storage location attributes assigned to the data and codes.
Conventional program conversion devices translate an object generation statement like that shown in
FIG. 1
into object data and a code sequence including a subroutine call instruction that invokes an object generation function. Here, the object data refers to a group of the member variables of the object, and the code sequence including a subroutine call instruction to invoke an object generation function is hereafter called a subroutine call code sequence.
The conventional program conversion device always assigns the RAM attribute to the object data, and the ROM attribute to the subroutine call code sequence. This is because values can be dynamically set in member variables of an object during the execution of the object generation function invoked when the object is generated. This is the same even when a const object is generated.
FIG. 2
shows machine code that has been generated by a conventional program conversion device as a result of the translation of the object generation statement in the source program shown in FIG.
1
. This machine code therefore is a part of a machine language program generated as a result of the translation of the source program. For ease of explanation, the machine language is represented by mnemonic code in the figure, and translation result of the object generation function shown in
FIG. 1
is omitted in FIG.
2
. The machine code between “.section RAMAREA” and the first “.section END” indicates data assigned the RAM attribute, and “obj:12” indicates that object “obj” is 12 bytes. Accordingly, a 12-byte RAM area is reserved for the execution of the machine language program.
The code sequence between “.section TEXT” and the second “.section END” in the figure is a subroutine call code sequence assigned the ROM attribute. In this subroutine call code sequence, “mov &obj, R0” represents an instruction to place the address of object “obj” into register R0, and “mov #2, R1” and “mov #3, R2” represent instructions to place parameters “2” and “3” into registers R1 and R2. “call X” indicates a subroutine call instruction to invoke the object generation function.
In this way, the conventional program conversion device translates an object generation statement in a source program into a subroutine call code sequence that unconditionally invokes the object generation function, and object data assigned the RAM attribute.
Generally, a machine language program of a larger code size requires a large memory for its execution, which raises execution cost. Accordingly, the code size of the machine language program should be minimized to lower the execution cost.
Also, in microcomputers to be built into household electrical appliances, the cost of RAM can be up to four times the cost of ROM. Accordingly, it is preferable for a program conversion device to assign the ROM attribute rather than the RAM attribute to as much data as possible.
SUMMARY OF THE INVENTION
In view of the above problems, the present invention aims to provide a program conversion device that translates a source program written in an OOL into a machine language program that involves a low execution cost by reducing a code size of the machine language program to be generated and/or a quantity of translated data that has the RAM attribute.
Points to be Focused for Improvements
In order to achieve the above aims, it is focused in the present invention that under certain circumstances execution results of object generation functions can be determined during translation from a source program into a machine language program, not during execution of the machine language program.
When translating an object generation statement that generates a global object and that invokes an object generation function that does not perform processing other than setting constant values in member variables of the object, it is possible to calculate the object data, which is the execution result of the object generation function in the conventional technique, as the translation result of the object generation statement.
Accordingly, if such an object generation function is to be invoked by an object generation statement, the program conversion device of the present invention translates the global object generation statement into object data only. In this way, unlike a conventional program conversion device that unconditionally translates such an object generation statement into object data and a subroutine call code sequence to
Sakata Toshiyuki
Tanaka Hirohisa
Urushibara Seiichi
Yamanaka Kiyokazu
Dam Tuan Q.
Matsushita Electric - Industrial Co., Ltd.
Price and Gess
LandOfFree
Program conversion device for translating an object-oriented... does not yet have a rating. At this time, there are no reviews or comments for this patent.
If you have personal experience with Program conversion device for translating an object-oriented..., we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Program conversion device for translating an object-oriented... will most certainly appreciate the feedback.
Profile ID: LFUS-PAI-O-2443501