Re: Language translation

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Wed, 05 Mar 2014 16:42:41 +0100

          From comp.compilers

Related articles
Language translation awgold70@gmail.com (Anthony Williams) (2014-03-05)
Re: Language translation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-03-05)
Re: Language translation kaz@kylheku.com (Kaz Kylheku) (2014-03-05)
Re: Language translation jkallup@web.de (Jens Kallup) (2014-03-06)
Re: Language translation norjaidi.tuah@ubd.edu.bn (Nor Jaidi Tuah) (2014-03-10)
Re: Language translation awgold70@gmail.com (Anthony Williams) (2014-03-10)
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Wed, 05 Mar 2014 16:42:41 +0100
Organization: Compilers Central
References: 14-03-009
Keywords: OOP, translator, comment
Posted-Date: 05 Mar 2014 11:06:36 EST

Anthony Williams schrieb:
> Dear Group,
>
> I'm facing the problem to translate language A into language B. The
> problem is, that A is an object oriented language (it supports
> classes, attributes of classes ...). But B is much simpler. It hasn't
> support for classes. There is only variables, functions. And my
> Question: How Could I Implement Classes in B. (At first it would be
> sufficient, if i could "emulate" simple classes, that don't support
> inheritance, function hiding, polymorphy ...)


Just rephrasing what John said, in my own words and view:


An emulation typically adds an this/self instance reference to the
parameter list of every method. "Real" OO languages simply hide this
parameter in the source code, i.e. the compiler changes the parameter
list and calls accordingly. That's what your translator should add to
the translated source code. That's all about basic (static) methods.


Instance data is a record (struct...), containing all data fields of the
class.


BTW the first C++ compiler was such a translator, from C++ to C. I don't
remember its name, but it should be available in the museum - John?


DoDi
[cfront which you can find at http://www.softwarepreservation.org/projects/c_plus_plus
-John]


Post a followup to this message

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