The present invention relates to an automatic software generating system, and in particular, to a software generating system for automatically generating software from an object-oriented specification which features an improved code efficiency.
A code generating system generates software from an object-oriented software statement. Generally, a specification described by an operator is entered via an input device, then the specification is analyzed, and a program code is generated and output.
However, when a code is generated simply on the basis of the specification described by the operator, there arises such a problem that a target code becomes enormously large, thereby requiring a large memory capacity therefor.
In order to solve this problem associated with the conventional art, JPA Laid-Open No. 6-266562 discloses a method for reducing the size of a target code. This method includes the steps of: comparing a class name to which its method belongs and an input file if they coincide with each other during semantic analysis processing of a class declaration in a context semantic analyzer provided for analyzing the specification written by the operator; generating in an output code an instance and declaration in a method address store table upon matching therebetween; and generating in the output code only the declaration in the method address store table upon non-matching therebetween.
However, the conventional code generation method as described above does not take into account whatsoever anything about an object-oriented function to use for generating an object-oriented program code.
That is, when generating a code from an object-oriented specification, unnecessary codes are also generated for unused functions of the object-oriented functions.
When this conventional code generation method is applied, in particular, to a software for an embedded control system, because a resulting output code becomes enormous, a large sized unit having a large memory capacity capable of implementing the enormous code will be required, thus there is such a problem that the cost of manufacture will increase substantially.
The present invention is contemplated to solve the problems associated with the prior art, and provide for a code generating system in which its code is optimized to suit for any particular target of application and to be applicable to any embedded control system without need of increasing its memory capacity.
The above-mentioned object of the invention can be accomplished by provision of a code generating system which is comprised of: a specification analyzer means which analyzes an object-oriented specification, for deriving specification information; a function removal means for removing unnecessary functions out of plural object-oriented functions according to a predetermined function removal rule on the basis of the specification information derived from the specification analyzer means, and producing a program information without using the unnecessary functions; and a code generation means for generating a code on the basis of the program information produced by the function removal means.
According to the invention, an unnecessary function in an object-oriented programming language is removed during the generation of a code from an object-oriented specification, thereby eliminating its mechanism itself required for realizing the unnecessary function. As a result, the code which can substantially reduce its memory capacity can be generated.
Other objects, features and advantages of the invention will be apparent from the following description taken in connection with the accompanying drawing wherein:
FIGS. 9(a) and (b) show results of respective code generations;
FIGS. 10(a) and (b) show results of respective execution codes generated;
FIGS. 11(a) and (b) show respective memory allocations in case a virtual function is executed or not;
FIGS. 17(a) and (b) show examples of displays, respectively.
Further, the processing unit 105 is comprised of: a specification analyzer section 106 for executing lexical and grammatical analyses of the software specification entered; an object-oriented function removal section 107 for removing unnecessary functions on the basis of the function select items entered; a code generator section 108 for generating a code on the basis of the software specification written with the unnecessary functions removed by the object-oriented function removal section 107 and undergone the lexical and grammatical analyses in the specification analysis section 106; an input display control section 109 for controlling the display screen of the display device 102 so as to enable the software specification and function select items to be input from the input device 101; and a total control section 110 for controlling respective sections. Still further, the input display control section 109 includes a class interface description section 111; a process detail description section 112; and a function select item description section 113. In addition, the code which is generated in the code generator section 108 is displayed on the display device 102, and/or stored in a portable memory device such as a floppy disk via the read/write device 103.
With reference to
Then, the process detail description section 112 within the input display control unit 109 is started to allows for the operator to accept the input of an operational diagram representing the pattern of the software specification, then this operational diagram is stored in the memory device 104.
Finally, the function select item description section 113 is started to allow for entry of a function select item which defines conditions for generating a code on the basis of the software specification entered, and to store the same in the memory device 104.
On the other hand, in case the code generation mode is selected by the operator, the total control section 110 allows to read a model diagram and operational diagram which is the software specification from the memory device 104, then starts the specification analyzer section 106 to execute lexical and grammatical analyses thereof. Then, the object-oriented function removal section 107 is started to determine which function is not needed in accordance with the function select items stored in the memory device 104. Then, the code generator section 108 is started to generate a code on the bases of the software specification subjected to the lexical and grammatical analyses in the specification analyzer section 106, and of an output code pattern determined in the object-oriented function removal section 107. Further, the code generated is displayed on the display device 102 upon request by the operator, and/or written into a floppy disk via the read/write unit 103.
Each processing described above will be set forth in detail using a method referred to as OOIE in the object-oriented analysis and design work in the following.
A case where the input mode is selected by the operator will be described. Upon selection of the input mode, the total control section 110 starts the class interface description section 111. Thereby, the operator is allowed to input a model pattern shown in
The model diagram indicated in
Static information is described in detail in this model diagram which includes three rows of lines. The first row 301 depicts a name and type of a variable corresponding to a class title, the second row 302 depicts a definition of its data structure, and the third row 303 depicts a title of processing to be executed and a type of argument, respectively.
According to the model diagram of
Then, the total control section 110 causes the process detail description section 112 to be started to allow for the operator to enter an operational diagram as shown in
Then, the total control section 110 starts the function select item description section 113 to display the function select input screen on the output device 102. The function select refers to a selection of operation whether to use or not to use an object-oriented function such as “dynamic generation of an instance”, “virtual function” and the like during its code generation.
The use-of-function select item 502 and the output code pattern 504 are entered in advance on this function select item screen. Therefore, the operator can easily choose whether to use or not to use its object-oriented function by entering data through the input pattern 501 and set-up option 503. The function select item determined by the operator is stored in the memory device 104.
In the input mode as described hereinabove, the software specification and the function select item are entered by the operator.
Then, a case where the operator chooses the code generation mode will be described in detail in the following.
Upon selection of the code generation mode by the operator, the total control section 110 starts the specification analyzer unit 106.
Lexical and context analyses are executed in the specification analyzer unit 106, then character strings derived from the software specification information having been entered as diagrammatic information and types of these character strings are output as shown in
For example, information on the software specification entered by the operator and checked as indicated in
Further, information on the software specification indicated in a rounded square in
Then, the total control unit 110 starts object-oriented function removal section 107.
The object-oriented function removal section 107 outputs a code pattern according to the function select items entered by the operator and stored in the memory device 104.
A flow chart of processing in the object-oriented unction removal section 107 is shown in FIG. 7.
In step 701, a result of grammatical analysis output from the specification analysis section 106 is entered. Then, in step 702, function select items which define a condition under which a code is to be generated are read from the memory device 104 according to the object name, method name derived from the result of the grammatical analysis, and the input pattern of the function select items.
In case a table cannot be read from the memory device 104 in step 702, a standard generation pattern information is output in step 704. In case the table could have been read from the memory device 104 in step 702, it is determined in step 705 whether to use or not to use any particular function according to the function select item having been read. When it is determined to use, a standard generation pattern information defined by the function select item is output in step 707. When judged not to use, a code generation pattern information defined by the function select item is output in step 706.
Then, the total control section 110 starts code generation section 108 to execute code generation.
A flow chart indicative of operation of the code generation section 108 is shown in FIG. 8.
In step, 801, the generation pattern information output from the object-oriented function removal unit 107 is entered. Then, in step 802, a code generation is executed on the basis of the aforementioned generation pattern information and the code generation pattern stored and read from the memory device 104.
By way of example, when the software specification from the specification analysis section 106, and the generation pattern information of “OBJENAME, METHODNAME( )” from the object-oriented function removal section 107 as shown in
Namely, the memory device 104 stores the following information as a code generation pattern.
When use of “dynamic generation of an instance” is not set up in the table, a code shown in FIG. 9(a) is generated. By compiling this resulting code, an execution code as shown in FIG. 10(a) is obtained. This execution code is output to the display device 102, and/or stored in a floppy disk via the read/write device 103.
By way of example, FIG. 9(b) and FIG. 10(b) show a code generated and its compiled execution code when use of “dynamic generation of an instance” is set up in the table.
In comparison of these two execution codes, when the dynamic generation function is used, an instance is explicitly expressed for an explicit designation of its instance in block 1001 in FIG. 10(b), and a code for storing an address of the instance in stack is generated.
In contrast, when the dynamic generation function is not used, there is no area corresponding to the block 1001 for designating the instance, and no code corresponding thereto is output. By removing the object-oriented function in the manner as described hereinabove, the code size can be reduced substantially.
Another case of using a different function as its object-oriented function will be described by way of example of a “virtual function”.
The virtual function sets forth a common interface in a parent class when a plurality of children classes are produced from the parent class using “inheritance”, and wherein implementation in each of the plurality of children classes differs from each other. By way of example, the “inheritance” refers to a method of producing a new class by succeeding all the attributes already in existence in some existing class, and describing a difference therebetween.
FIG. 11(a) shows a memory allocation for the code in an execution format, which is generated by the aforementioned method which is set up by choosing the “use of the virtual function” by the operator when the method to use the virtual function is designated. As shown in this drawing, code 1101 for function “FUNC. CHECK( )” is stored in a program code section, and a region 1102 for an internal variable, and a table 1103 for calling a virtual function “FUN. CHEKC( ) CALL_UP TABLE” are stored in a data section. Virtual function table 1101 set forth in the data section realizes a mechanism of the virtual function.
FIG. 11(b) shows a memory allocation of a code compiled in an execution format wherein the function of the virtual function is set “not to use”. In this case, because the virtual function is called up directly, a portion corresponding to the table 1103 indicated in FIG. 11(a) is eliminated.
As described above, by removing some of the object-oriented functions such as dynamic generations of instances and/or virtual functions, a corresponding mechanism which becomes unnecessary for realizing its object-oriented function can be removed from its inclusion. For such purpose, no particular knowledge on each object-oriented mechanism is required for the operator to have, thereby simply designating “use/not use” on the display, optimization of the system can be accomplished.
Another method of designating the function select items will be described in the following.
The function select item shown in
Then, with reference to a table generated, the object-oriented function removing section 107 reads out a code generation pattern corresponding thereto, and outputs the same to the code generation unit 108 whereby to execute the code generation.
Further example of designating another select item will be described in the following.
FIG. 17(a) shows an example of display on the analysis result display section 1501. Here, the optimization information including the number of instances, the virtual functions selected and the like derived in the optimization information deriving unit 1501 is displayed.
After this optimization information is displayed, the function select item description section 110 displays function select items as indicated in FIG. 17(b) to prompt the operator to enter “use” or “not use” of the corresponding function.
By allowing the operator to utilize the result of analysis obtained in the specification analysis section 106 as described above, a more effective set-up procedure becomes possible in setting up of the items by the user. For example, because the number of instances to be utilized in programming is a major factor in making decision whether to use the dynamic generation of instances or not, such information will help the operator set up more effectively.
Further, this embodiment of the invention is not limited in its applicability to any specific programming language, and can operate in the same way using statements described in C++ or Java.
Number | Date | Country | Kind |
---|---|---|---|
10-038329 | Feb 1998 | JP | national |
Number | Name | Date | Kind |
---|---|---|---|
5481708 | Kukol | Jan 1996 | A |
5488727 | Agrawal et al. | Jan 1996 | A |
5493680 | Danforth | Feb 1996 | A |
5535391 | Hejlsberg et al. | Jul 1996 | A |
5937189 | Branson et al. | Aug 1999 | A |
6041179 | Bacon et al. | Mar 2000 | A |
6101326 | Mattson, Jr. | Aug 2000 | A |
6129460 | Baisley | Oct 2000 | A |
6173444 | Archambault | Jan 2001 | B1 |
6202204 | Wu et al. | Mar 2001 | B1 |
6230314 | Sweeney et al. | May 2001 | B1 |
6513152 | Branson et al. | Jan 2003 | B1 |
6581203 | Nguyen et al. | Jun 2003 | B1 |
Number | Date | Country |
---|---|---|
06266562 | Sep 1994 | JP |
07119537 | May 1995 | JP |
07122158 | May 1995 | JP |
07241319 | Sep 1995 | JP |
07266794 | Oct 1995 | JP |
09198485 | Jul 1997 | JP |
10038329 | Feb 1998 | JP |