Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Language translation Date: Wed, 05 Mar 2014 16:42:41 +0100 Organization: Compilers Central Lines: 28 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-03-010@comp.compilers> References: <14-03-009@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: miucha.iecc.com 1394035596 84999 64.57.183.58 (5 Mar 2014 16:06:36 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Wed, 5 Mar 2014 16:06:36 +0000 (UTC) Keywords: OOP, translator, comment Posted-Date: 05 Mar 2014 11:06:36 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1132 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]