digitalmars.D - Automated translation from C++ to D
- Georg Wrede (10/14) Feb 21 2006 Hardly anybody would disagree there!
- Sean Kelly (10/26) Feb 21 2006 I think templates would likely cause some problems. And the
- Walter Bright (3/5) Feb 21 2006 It would be nearly useless, because one has to adopt different algorithm...
- Aarti (14/24) Feb 21 2006 ...but what about GCC intermediate languages? Documentation on:
- Walter Bright (11/22) Feb 23 2006 Let me illustrate by example. I could write an assembler to D translator...
- Hasan Aljudy (10/20) Feb 25 2006 Why? Aren't the constructs pretty much the same?
- bobef (6/32) Feb 26 2006 Everything is the same. It is just bits in the memory, which is
- James Dunne (7/46) Feb 26 2006 My thinking exactly. If your brain can do it, a computer can too. The
On Feb 3, in this newsgroup, Walter wrote:1) It's written in Java, which is the easiest code to translate to D besides C, perhaps even easier (no macros <g>). Furthermore, Kris has written a tool to automate some of the translation. Automated translation from C++ is essentially impossible.Hardly anybody would disagree there! But, (hey, it's me talking, what can you expect? ;-) ) since you have both a C++ compiler and a D compiler, would the following tack cut it: Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code? Mind you, I'm not suggesting you'd do this for real, heck you've got other things to do. This is mostly academic. Would there be any very different issues if this is done using Digital Mars compilers versus GCC?
Feb 21 2006
Georg Wrede wrote:On Feb 3, in this newsgroup, Walter wrote:I think templates would likely cause some problems. And the preprocessor code shouldn't be processed completely. And then there's copy semantics and all the operator overloads D doesn't support. I can't claim to have nearly as much experience as Walter, but this sounds like a nightmare. C to D sounds much more achievable, but even that required a modified C preprocessor to accomplish.1) It's written in Java, which is the easiest code to translate to D besides C, perhaps even easier (no macros <g>). Furthermore, Kris has written a tool to automate some of the translation. Automated translation from C++ is essentially impossible.Hardly anybody would disagree there! But, (hey, it's me talking, what can you expect? ;-) ) since you have both a C++ compiler and a D compiler, would the following tack cut it: Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code?Would there be any very different issues if this is done using Digital Mars compilers versus GCC?Probably not. The language spec doesn't vary from platform to platform, only the compiler implementation. Sean
Feb 21 2006
"Georg Wrede" <georg.wrede nospam.org> wrote in message news:43FB4E35.5080606 nospam.org...Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code?It would be nearly useless, because one has to adopt different algorithms.
Feb 21 2006
Walter Bright napisał(a):"Georg Wrede" <georg.wrede nospam.org> wrote in message news:43FB4E35.5080606 nospam.org......but what about GCC intermediate languages? Documentation on: http://gcc.gnu.org/onlinedocs/gccint/Tree-SSA.html#Tree-SSA says: "GCC uses three main intermediate languages to represent the program during compilation: GENERIC, GIMPLE and RTL. GENERIC is a language-independent representation generated by each front end. It is used to serve as an interface between the parser and optimizer. GENERIC is a common representation that is able to represent programs written in all the languages supported by GCC." Is GENERIC too low-level language to make it possible to convert it in a sensible way to D? Regards Marcin KuszczakCompile the C++ "half-way" (your choice of which passes), and then translate that to D source code?It would be nearly useless, because one has to adopt different algorithms.
Feb 21 2006
"Aarti" <aarti interia.pl> wrote in message news:dtfs08$2iqg$1 digitaldaemon.com......but what about GCC intermediate languages? Documentation on: http://gcc.gnu.org/onlinedocs/gccint/Tree-SSA.html#Tree-SSA says: "GCC uses three main intermediate languages to represent the program during compilation: GENERIC, GIMPLE and RTL. GENERIC is a language-independent representation generated by each front end. It is used to serve as an interface between the parser and optimizer. GENERIC is a common representation that is able to represent programs written in all the languages supported by GCC." Is GENERIC too low-level language to make it possible to convert it in a sensible way to D?Let me illustrate by example. I could write an assembler to D translator, but the D code emitted would look like: add(&flags, &EAX, 6); cmp(&flags, EAX, EBX); if (jne(&flags)) goto L1A0; etc. It would bear no reasonable relation to whatever source code produced it. I haven't looked at the gcc intermediate code, but it's more than likely too low level.
Feb 23 2006
Walter Bright wrote:"Georg Wrede" <georg.wrede nospam.org> wrote in message news:43FB4E35.5080606 nospam.org...Why? Aren't the constructs pretty much the same? C++ classes maybe a hell to parse, but it's possible (obviously has been done), and they must be translatable to D classes! Templates can be translated to templates (I assume ..) variables to variables .. functions to functions .. One thing that comes to mind is passing objects *by-value* but I think it can be simulated with D structs? (D structs can be passed by value, am I not correct?)Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code?It would be nearly useless, because one has to adopt different algorithms.
Feb 25 2006
Hasan Aljudy wrote:Walter Bright wrote:Everything is the same. It is just bits in the memory, which is electricity, which is energy, which is everything..."Georg Wrede" <georg.wrede nospam.org> wrote in message news:43FB4E35.5080606 nospam.org...Why? Aren't the constructs pretty much the same?Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code?It would be nearly useless, because one has to adopt different algorithms.C++ classes maybe a hell to parse, but it's possible (obviously has been done), and they must be translatable to D classes! Templates can be translated to templates (I assume ..) variables to variables .. functions to functions .. One thing that comes to mind is passing objects *by-value* but I think it can be simulated with D structs? (D structs can be passed by value, am I not correct?)I think the question is not is it possible. Of course it is, if your brain can do you, the computer can do it too. The question is does it worth the effort, and I believe the answer has been already given...
Feb 26 2006
bobef wrote:Hasan Aljudy wrote:My thinking exactly. If your brain can do it, a computer can too. The effort involved out of the brain in order to coax the computer into doing it is the question. =) -- Regards, James DunneWalter Bright wrote:Everything is the same. It is just bits in the memory, which is electricity, which is energy, which is everything..."Georg Wrede" <georg.wrede nospam.org> wrote in message news:43FB4E35.5080606 nospam.org...Why? Aren't the constructs pretty much the same?Compile the C++ "half-way" (your choice of which passes), and then translate that to D source code?It would be nearly useless, because one has to adopt different algorithms.C++ classes maybe a hell to parse, but it's possible (obviously has been done), and they must be translatable to D classes! Templates can be translated to templates (I assume ..) variables to variables .. functions to functions .. One thing that comes to mind is passing objects *by-value* but I think it can be simulated with D structs? (D structs can be passed by value, am I not correct?)I think the question is not is it possible. Of course it is, if your brain can do you, the computer can do it too. The question is does it worth the effort, and I believe the answer has been already given...
Feb 26 2006