JP4033952B2 - Symbol name replacement device - Google Patents
Symbol name replacement device Download PDFInfo
- Publication number
- JP4033952B2 JP4033952B2 JP28956297A JP28956297A JP4033952B2 JP 4033952 B2 JP4033952 B2 JP 4033952B2 JP 28956297 A JP28956297 A JP 28956297A JP 28956297 A JP28956297 A JP 28956297A JP 4033952 B2 JP4033952 B2 JP 4033952B2
- Authority
- JP
- Japan
- Prior art keywords
- language
- symbol name
- symbol
- type information
- name
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Description
【0001】
【発明の属する技術分野】
本発明は、C言語のシンボル名をC++言語のシンボル名に置き換えるシンボル名置き換え装置に関する。
【0002】
【発明の背景】
C(C言語)はシステム記述用の言語としてUNIXと共に発展してきた言語であり、豊富な演算子とデータ型及び構造化プログラミングに適した制御構造を持つ特徴から、様々な分野で多くのプログラム開発に利用されてきた。一方、C++(C++言語)は、C言語をオブジェクト指向対応に改良した新しい言語であり、多くの点でC言語と共通するが完全互換ではない。例えば、演算子やデータ型などの基本構造は保たれているものの、コンパイル後のシンボル(変数、定数又は関数を示すユーザ定義名)に違いがある。
【0003】
今、整数型(int)の変数aをC言語とC++言語でソースリストに記述したとすると、どちらも、
int a ………(1)
と表記(初期値は省略)されるが、これをCコンパイラでコンパイルすると、
_a ………(2)
となり、C++コンパイラでコンパイルすると、
_△_a ………(3)
となる。ここで、_(アンダーバー)aはシンボル、_△は整数型を表わす記号である(但し△は便宜的な記号)。(2)と(3)の違いは型情報の有無にある。型情報はオブジェクト指向における属性(プロパティ)の一つであり、かかる属性の引き継ぎはオブジェクト指向の基本原則である。したがって、(2)と(3)の違い(型情報の有無)は専らオブジェクト指向対応であるか否かによるものである。
【0004】
【従来の技術】
C++言語でシステムを開発する場合、すべてのモジュールを新たに作るのは無駄である。C言語で作られた評価済の膨大なモジュールがすでに存在しているからである。
図2は、C言語で作られたプログラムをC++言語のプログラムにリンクする場合の簡単な例である。図において、「int a」は整数型のaというシンボルを表わしている。このシンボルをリンクするには、C++側に特別な仕様を適用しなければならない。図中の「extern “C”」という表記がそれである。C++言語のプログラムにこの表記を書き込めば、C言語で作られた評価済の膨大なモジュールを利用でき、開発効率を大幅に改善できる。
【0005】
【発明が解決しようとする課題】
しかしながら、かかる従来の方法にあっては、C++側にいちいち特別な表記を書き込む必要があり、面倒であるばかりか、記入忘れなどのケアレスミスを避けられず、開発効率を改善できるものの、システムの信頼性を向上できないという問題点があった。
【0006】
そこで、本発明は、C++側にいちいち特別な表記を書き込む必要がなく、システムの信頼性向上に寄与する技術の提供を目的とする。
【0007】
【課題を解決するための手段】
本発明は、C言語のシンボル名をC++言語のシンボル名に置き換える装置であって、C言語のシンボル名から型情報を抽出する抽出手段と、抽出された型情報をC++言語の型情報の記号に変換する変換手段と、変換されたC++言語の型情報の記号と前記C言語のシンボル名とを組み合わせてC++言語のシンボル名を生成する生成手段と、生成されたC++言語のシンボル名を前記C言語のシンボル名に置換する置換手段と、を備えたことを特徴とする。
【0008】
本発明では、C言語のシンボル名を与えると、そのシンボル名から型情報が抽出され、その型情報がC++言語の型情報の記号に変換されると共に、その記号と前記C言語のシンボル名とが組み合わされてC++言語のシンボル名が生成された後、生成されたC++言語のシンボル名が前記C言語のシンボル名に置き換えられる。したがって、C言語のシンボル名がC++言語のシンボル名に置換されるため、C++側にいちいち特別な表記を書き込むことなく、C言語のシンボルをリンクできるので、システムの信頼性向上を図ることができる。
【0009】
【発明の実施の形態】
以下、本発明の実施例を図面に基づいて説明する。
図1は本発明に係るシンボル名置き換え装置の一実施例を示す図である。
図1において、1はC言語で記述されたソースリストであり、リスト内には便宜例として整数型(int)の変数aが初期値0で宣言されている。2はリスト1をコンパイルして生成されたモジュールの一部であり、Cコンパイラ3では既述のとおりシンボル名(この例では変数a)の頭にアンダースコア(_)を付して表記される。
【0010】
4はシンボル名の型情報を抽出する型情報抽出手段(抽出手段)である。この型情報抽出手段4は、例えば、Cコンパイラ3のデバッグオプションを使用することができる。公知のCコンパイラ(例えばfcc911:富士通(株)製FRファミリ用最適化Cコンパイラのコマンド名)のデバッグオプションには、図示のように、コンパイルされたシンボル名(_a)、元のシンボル名(a)及び型情報(int)などを収集できる機能が備えられているからである。5は型情報を含むデバックテーブルであり、型情報抽出手段4によって生成されたものである。なお、6はワーキングレジスタ(生成手段、置換手段)、7は変換テーブル(変換手段)であり、前者はC++言語のシンボル名を生成するための一時的な作業領域、後者は、C++言語のすべての型情報と各型情報に対応した記号とをテーブルマップ化したものである。
【0011】
このような構成において、まず、ソースリスト1内のシンボルは、Cコンパイラ3によってコンパイルされ、さらに、型情報抽出手段4によってその型情報(int)が取り出される。そして、▲1▼デバッグテーブル5内の型情報を用いて変換テーブル7が検索され、▲2▼その型情報に一致するC++言語の記号(_Vo)が取り出されてワーキングレジスタ6の所定位置(中央)にセットされる。次いで、▲3▼▲4▼ワーキングレジスタ6の先頭と後尾に、コンパイルされたシンボル名(_a)がセットされた後、▲5▼先頭のシンボル名を用いてモジュール2が検索され、モジュール2内の一致するシンボル名が、ワーキングレジスタ6の中央と後尾の記号を連結したもの(_Vo_a)で置き換えられる。
【0012】
したがって、この構成によれば、Cコンパイラ3によって生成されたモジュール2内のシンボル(C言語のシンボル)が、C++言語のシンボルに置き換えられるから、例えば、C言語で作られた評価済の膨大なモジュールにこの装置を適用すれば、コンパイル済のすべてのシンボルに型情報を持たせることができ、C++プログラムとの互換性を確保できる。その結果、C++言語のプログラム側に特別な仕様を施すことなく、既存のC言語資産を有効に活用することができ、開発効率の改善と信頼性の向上を共に達成することができる。
【0013】
なお、本実施例のシンボル名置き換え装置は単体であってもよく、又はリンケージエディタやアセンブラ若しくはCコンパイラに組み込まれたものであってもよい。また、リンケージエディタやアセンブラ若しくはCコンパイラなどは、記憶媒体に収められたプログラムの形で配布されるから、本実施例のシンボル名置き換え装置も、単体又はこれらのプログラムと一緒に、フロッピィディスク、MO、CD−ROM、メモリカード、ROMチップ、固定記憶装置(ハードディスク)などの記憶媒体に収められたものであってもよい。
【0014】
【発明の効果】
本発明によれば、C言語のシンボル名がC++言語のシンボル名に置換されるため、C++側にいちいち特別な表記を書き込むことなく、C言語のシンボルをリンクでき、システムの開発効率と信頼性を共に向上できる。
【図面の簡単な説明】
【図1】一実施例の概念図である。
【図2】従来例の概念図である。
【符号の説明】
4:型情報抽出手段(抽出手段)
6:ワーキングレジスタ(生成手段、置換手段)
7:変換テーブル(変換手段)[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a symbol name replacement device that replaces a C language symbol name with a C ++ language symbol name.
[0002]
BACKGROUND OF THE INVENTION
C (C language) is a language that has been developed with UNIX as a system description language, and has many operators, data types, and features that have control structures suitable for structured programming. Has been used. On the other hand, C ++ (C ++ language) is a new language obtained by improving the C language to be object-oriented, and is common to the C language in many respects but is not completely compatible. For example, although basic structures such as operators and data types are maintained, symbols after compilation (user-defined names indicating variables, constants, or functions) are different.
[0003]
Now, assuming that an integer type (int) variable a is described in the source list in C language and C ++ language,
int a (1)
(Initial value is omitted), but when this is compiled with a C compiler,
_A (2)
Then, when compiling with C ++ compiler,
_ △ _a (3)
It becomes. Here, _ (underbar) a is a symbol, and _Δ is a symbol representing an integer type (where Δ is a convenient symbol). The difference between (2) and (3) is the presence or absence of type information. Type information is one of the attributes (properties) in object orientation, and the inheritance of such attributes is a basic principle of object orientation. Therefore, the difference between (2) and (3) (the presence or absence of type information) depends solely on whether or not it is object-oriented.
[0004]
[Prior art]
When developing a system in the C ++ language, it is useless to make all the modules newly. This is because a large number of evaluated modules already created in C language already exist.
FIG. 2 is a simple example of linking a program created in C language to a program in C ++ language. In the figure, “int a” represents an integer type symbol a. In order to link this symbol, a special specification must be applied to the C ++ side. This is the notation “extern“ C ”” in the figure. If this notation is written in a C ++ language program, a large number of evaluated modules created in the C language can be used, and development efficiency can be greatly improved.
[0005]
[Problems to be solved by the invention]
However, in this conventional method, it is necessary to write a special notation on the C ++ side, which is troublesome and careless mistakes such as forgetting to enter cannot be avoided. There was a problem that reliability could not be improved.
[0006]
Therefore, the present invention aims to provide a technique that contributes to improving the reliability of the system without having to write special notation on the C ++ side.
[0007]
[Means for Solving the Problems]
The present invention is an apparatus for replacing a C language symbol name with a C ++ language symbol name, an extraction means for extracting type information from the C language symbol name, and the extracted type information as a symbol of C ++ language type information. A conversion means for converting to C ++ language, a generation means for generating a C ++ language symbol name by combining the converted C ++ language type information symbol and the C language symbol name, and the generated C ++ language symbol name Replacing means for replacing with a C language symbol name.
[0008]
In the present invention, when a C language symbol name is given, type information is extracted from the symbol name, the type information is converted into a C ++ language type information symbol, and the symbol, the C language symbol name, Are combined to generate a C ++ language symbol name, and the generated C ++ language symbol name is replaced with the C language symbol name. Therefore, since the C language symbol name is replaced with the C ++ language symbol name, the C language symbol can be linked without writing a special notation on the C ++ side, so that the reliability of the system can be improved. .
[0009]
DETAILED DESCRIPTION OF THE INVENTION
Embodiments of the present invention will be described below with reference to the drawings.
FIG. 1 is a diagram showing an embodiment of a symbol name replacement apparatus according to the present invention.
In FIG. 1, 1 is a source list written in C language, and an integer type (int) variable a is declared with an
[0010]
[0011]
In such a configuration, first, the symbols in the
[0012]
Therefore, according to this configuration, since the symbols (C language symbols) in the
[0013]
The symbol name replacement device of this embodiment may be a single device, or may be incorporated in a linkage editor, assembler, or C compiler. Also, since the linkage editor, assembler, C compiler, etc. are distributed in the form of a program stored in a storage medium, the symbol name replacement device of the present embodiment is a single unit or together with these programs, a floppy disk, MO It may be stored in a storage medium such as a CD-ROM, memory card, ROM chip, fixed storage device (hard disk).
[0014]
【The invention's effect】
According to the present invention, since the C language symbol name is replaced with the C ++ language symbol name, the C language symbol can be linked without writing special notation on the C ++ side, and the development efficiency and reliability of the system Can be improved together.
[Brief description of the drawings]
FIG. 1 is a conceptual diagram of an embodiment.
FIG. 2 is a conceptual diagram of a conventional example.
[Explanation of symbols]
4: Type information extraction means (extraction means)
6: Working register (generation means, replacement means)
7: Conversion table (conversion means)
Claims (2)
前記第1のシンボル名と該第1のシンボル名の型情報とを対応付けて記憶する記憶手段と、
前記第1のシンボル名に基づき前記記憶手段を検索して前記型情報を前記記憶手段から抽出する抽出手段と、
抽出された前記型情報をC++言語の型情報を示す記号に変換する変換手段と、
変換されたC++言語の型情報を示す記号と前記第1のシンボル名とを組み合わせて第2のシンボル名を生成する生成手段と、
前記第2のシンボル名で前記第1のシンボル名を置換する置換手段と、
を備えたことを特徴とするシンボル名置き換え装置。 The first object obtained by compiling the first source code described in the C language can be linked to the second object obtained by compiling the second source code written in the C ++ language. In order to achieve the above, a symbol name replacement device that replaces a first symbol name included in the first object ,
Storage means for storing the first symbol name and the type information of the first symbol name in association with each other;
Extracting means for searching the storage means based on the first symbol name and extracting the type information from the storage means ;
Conversion means for converting the extracted the type information in a symbol indicating the type information of the C ++ language,
Generating means for generating a second symbol name by combining the symbol indicating the converted C ++ language type information and the first symbol name;
Replacing means for replacing the first symbol name with the second symbol name;
A symbol name replacement device characterized by comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP28956297A JP4033952B2 (en) | 1997-10-22 | 1997-10-22 | Symbol name replacement device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP28956297A JP4033952B2 (en) | 1997-10-22 | 1997-10-22 | Symbol name replacement device |
Publications (2)
Publication Number | Publication Date |
---|---|
JPH11126164A JPH11126164A (en) | 1999-05-11 |
JP4033952B2 true JP4033952B2 (en) | 2008-01-16 |
Family
ID=17744846
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP28956297A Expired - Fee Related JP4033952B2 (en) | 1997-10-22 | 1997-10-22 | Symbol name replacement device |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4033952B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2007304840A (en) * | 2006-05-11 | 2007-11-22 | Matsushita Electric Ind Co Ltd | Compilation method, debugging method, compilation program, and debugging program |
-
1997
- 1997-10-22 JP JP28956297A patent/JP4033952B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JPH11126164A (en) | 1999-05-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Johnson | A portable compiler: Theory and practice | |
US6934940B2 (en) | Source code transformation-temporary object reduction | |
CN104714788A (en) | Method and device for automatically generating software installation package | |
van den Brand et al. | Compilation and memory management for ASF+ SDF | |
US6665688B1 (en) | Method and system for automatically regenerating data on-demand | |
Marlow et al. | Deforestation for higher-order functions | |
JPH09212356A (en) | System for protecting computer software described in interpreter language | |
US5889995A (en) | Using constant selectors for method identification | |
Strumpen | Compiler technology for portable checkpoints | |
JP4033952B2 (en) | Symbol name replacement device | |
Hall et al. | The Glasgow Haskell compiler: a retrospective | |
US7080370B1 (en) | Method and apparatus for compiling source programs using one or more libraries | |
Doh et al. | Action semantics-directed prototyping | |
Gaul et al. | Construction of verified software systems with program-checking: An application to compiler back-ends | |
CN111666095A (en) | Method, system, equipment and storage medium for realizing Java decompilation | |
Dewhurst | Object representation of scope during translation | |
JP3192177B2 (en) | Object processing device | |
Tarhio | A compiler generator for attribute evaluation during LR parsing | |
Coutant et al. | A Tour Through the C Implementation of Icon, Version 4 | |
Griswold et al. | The C Implementation of Icon: A Tour Through Version 5 | |
Lee | Postfix transformations for action notation | |
Crawford et al. | Engineering a program optimizer | |
Griswold et al. | A Tour Through the C Implementation of Icon; Version 5.9 | |
Collins et al. | The Mystro System: a comprehensive translator toolkit | |
Broadbent | The implementation of a generalized table driven back end processor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20040419 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20070508 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20070709 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20070807 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20070927 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20071023 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20071024 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20101102 Year of fee payment: 3 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
S111 | Request for change of ownership or part of ownership |
Free format text: JAPANESE INTERMEDIATE CODE: R313111 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20101102 Year of fee payment: 3 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
LAPS | Cancellation because of no payment of annual fees |