Re: Translating OO program to procedural program

Hans-Peter Diettrich <DrDiettrich1@aol.com>
11 Oct 2006 23:21:13 -0400

          From comp.compilers

Related articles
Translating OO program to procedural program samhng@gmail.com (=?iso-8859-1?B?bW9vcJk=?=) (2006-10-10)
Re: Translating OO program to procedural program pjb@informatimago.com (Pascal Bourguignon) (2006-10-11)
Re: Translating OO program to procedural program oliverhunt@gmail.com (oliverhunt@gmail.com) (2006-10-11)
Re: Translating OO program to procedural program napi@axiomsol.com (napi) (2006-10-11)
Re: Translating OO program to procedural program mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-10-11)
Re: Translating OO program to procedural program torbenm@app-6.diku.dk (2006-10-11)
Re: Translating OO program to procedural program englere_geo@yahoo.com (Eric) (2006-10-11)
Re: Translating OO program to procedural program DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-10-11)
Re: Translating OO program to procedural program int2k@gmx.net (Wolfram Fenske) (2006-10-11)
Re: Translating OO program to procedural program tommy.thorn@gmail.com (Tommy Thorn) (2006-10-11)
Re: Translating OO program to procedural program JoachimPimiskern@web.de (Joachim Pimiskern) (2006-10-12)
Re: Translating OO program to procedural program gnorik@gmail.com (2006-10-24)
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: 11 Oct 2006 23:21:13 -0400
Organization: Compilers Central
References: 06-10-039
Keywords: OOP, C++, comment

moop wrote:


> I am working on a project translates OO programs to procedural
> programs, such as translating C++ to C and the like. I hope this
> effort can be spreaded out to other langs, so I am working on to
> abstract the common issues of doing so. I know there is a pinoneer
> attempt is C Front which produce C++ programs via a C compiler, I want
> to have a look on that, but still cannot find it now, anyone can
> suggest this to me?


If an old Cfront version really is unavailable (John?), I'd suggest
that you look into open source OO compilers or systems, to get an idea
how objects and methods are implemented there.


IMO two general object models exist, one with fixed class types (e.g.
C++), and one with objects that exchange messages (e.g. Smalltalk?).


> My approach is just to rename the methods with the instance name so
> that they can be placed in a single source file and then be compiled
> later by the procedural lang compiler.


In C++ type languages the actual instance typically is passed to a
method as a (hidden) argument. What you'll have to do is mangling the
*class* name and the method name. In other languages an object might
be implemented by a list of methods, and a general Dispatch function
for every object. Perhaps a study of the CORBA or ActiveX
documentation will shed some light on possible implementations of such
objects.


DoDi
[I have never seen a legal copy of cfront for free. But as others have
noted, the cfront language is quite different from modern C++. -John


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.