digitalmars.D - Does the D front-end write C code?
- Garett Bass (5/5) Nov 29 2005 Does the D front-end just write C code? I'm curious because I'm current...
- Walter Bright (3/4) Nov 30 2005 No. It's output is an intermediate form represented by a data structure.
- Munchgreeble (18/26) Nov 30 2005 This would be an obvious way to us a "third" compiler. I'm definitely a
- JT (10/36) Nov 30 2005 Ive got a D port of the DMD front end that currenty can reproduce D code...
- Chris (12/22) Nov 30 2005 I read this as:
- JT (12/36) Nov 30 2005 no no, its not a decompiler. It takes a D program - parses it and produc...
- Munchgreeble (1/15) Dec 01 2005
- Oskar Linde (11/20) Dec 02 2005 Very nice! The dmd front end coding style maps very well onto D. I've ac...
- JT (5/27) Dec 02 2005 THANK YOU! I think you just found one of the bugs Ive been putting off :...
Does the D front-end just write C code? I'm curious because I'm currently writing an object-oriented C project for my languages class, and it seems possible that D is implemented similarly. Thanks, Garett
Nov 29 2005
"Garett Bass" <garettbass studiotekne.com> wrote in message news:dmjlkm$17c$1 digitaldaemon.com...Does the D front-end just write C code?No. It's output is an intermediate form represented by a data structure.
Nov 30 2005
This would be an obvious way to us a "third" compiler. I'm definitely a fan of multiple compilers - I can't imagine persuading people to use a language for which GNU was the only implementation, even if we ended up using the GNU compiler on the project. With D being similar to C, C may well make a good intermediate language. I'm pretty new here mind you so others may be able to point to reasons why C would not make a good intermediate language. Assuming it would however, we'd then be able to use our favourite C compiler. The Intel C compiler for example produces some very efficient object code on the x86 platform, because it does some very x86 specific optimisations. It may just be that being able to bolt on those optimisations would give the fastest object code for at least some D programs. Far more importantly, if you can compile down to ANSI C, then D becomes available on virtually any platform/OS you care to think of =) I suspect this has been discussed before though? Cheers Munch Garett Bass wrote:Does the D front-end just write C code? I'm curious because I'm currently writing an object-oriented C project for my languages class, and it seems possible that D is implemented similarly. Thanks, Garett
Nov 30 2005
In article <dmjpvu$4n5$1 digitaldaemon.com>, Munchgreeble says...This would be an obvious way to us a "third" compiler. I'm definitely a fan of multiple compilers - I can't imagine persuading people to use a language for which GNU was the only implementation, even if we ended up using the GNU compiler on the project. With D being similar to C, C may well make a good intermediate language. I'm pretty new here mind you so others may be able to point to reasons why C would not make a good intermediate language. Assuming it would however, we'd then be able to use our favourite C compiler. The Intel C compiler for example produces some very efficient object code on the x86 platform, because it does some very x86 specific optimisations. It may just be that being able to bolt on those optimisations would give the fastest object code for at least some D programs. Far more importantly, if you can compile down to ANSI C, then D becomes available on virtually any platform/OS you care to think of =) I suspect this has been discussed before though? Cheers Munch Garett Bass wrote:Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program - I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparser fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.Does the D front-end just write C code? I'm curious because I'm currently writing an object-oriented C project for my languages class, and it seems possible that D is implemented similarly. Thanks, Garett
Nov 30 2005
On Wed, 30 Nov 2005 10:04:16 +0000 (UTC), JT <JT_member pathlink.com> wrote:Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program -I read this as: "I made D decompiler" that can't be right... can it? I thought the front end is just a parser.I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparser fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.I've been following the progress on dbug for a while.. updating from the repository every few days. TBH I'm not sure exactly what you've been doing with the directory structure lately. But in any case, DBug is full of really neat code. I encourage everyone to check it out. btw, there's an unanswered post on the forums ;) Chris
Nov 30 2005
In article <e2kro15jefvv6tfc9em4knf0sph89e1oe1 4ax.com>, Chris says...On Wed, 30 Nov 2005 10:04:16 +0000 (UTC), JT <JT_member pathlink.com> wrote:no no, its not a decompiler. It takes a D program - parses it and produces a symbol tree - this is normally sent to the back end, and right now I have it simply reproducing itself back into D. Mostly for debugging - as what goes in should come back out. Yeah ive been re-organizeing the dir structure a little bit. The focus of the project has shifted a little bit as Im now making a D IDE called Cydonia. Im slowly moving the actual low level debugging library from "dmddebug" to "dbug" and DBug will become the debugging lib. And im moving some of the sub projects like the disassembler into the debugging library etc. Just trying to clean it up a little bit, as it was mostly a bunch of prototype stuff that im slowly trying to work into a release. I hope to have a version .001 or something very soon I just want to tie up a lot of loose ends first.Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program -I read this as: "I made D decompiler" that can't be right... can it? I thought the front end is just a parser.I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparser fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.I've been following the progress on dbug for a while.. updating from the repository every few days. TBH I'm not sure exactly what you've been doing with the directory structure lately. But in any case, DBug is full of really neat code. I encourage everyone to check it out. btw, there's an unanswered post on the forums ;) Chris
Nov 30 2005
Great! =)Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program - I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparser fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.
Dec 01 2005
In article <dmjtf0$9ev$1 digitaldaemon.com>, JT says...Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program - I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparserVery nice! The dmd front end coding style maps very well onto D. I've actually been toying with converting the front end too, but since you have gotten much further, I've just scrapped my code. :)fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.Yes, seems to work fairly well. A bug I stumbled upon: aggregate.d:1045 if( (tc.sym.symtab !is null) || (tc.sym.scope is null) ) the conditions are inverted, should be: if( (tc.sym.symtab is null) || (tc.sym.scope !is null) ) Cheers, Oskar
Dec 02 2005
In article <dmpmui$1l6l$1 digitaldaemon.com>, Oskar Linde says...In article <dmjtf0$9ev$1 digitaldaemon.com>, JT says...THANK YOU! I think you just found one of the bugs Ive been putting off :D Yeah this is one of those late night "from struct ptr to class reference" bugs that crept in. Ive been planning on going over all these type expressions with a fine tooth comb and you just saved some time.Ive got a D port of the DMD front end that currenty can reproduce D code from a compiled program - I really want to get it to output C or C++ but thats way down on my list. I think thats a very interesting solution for some cases. But it can be done relatively easy using the front end. In fact walter already has it generating a little bit of C code for symbols or someting Im not quite sure. http://trac.dsource.org/projects/dbug/browser/trunk/src/dparserVery nice! The dmd front end coding style maps very well onto D. I've actually been toying with converting the front end too, but since you have gotten much further, I've just scrapped my code. :)fyi its got a few places I need to cleanup yet like complex numbers and a small bug in the second semantic pass where a variable isnt getting set, but I believe lexical analysis and semantic 1 should work.Yes, seems to work fairly well. A bug I stumbled upon: aggregate.d:1045 if( (tc.sym.symtab !is null) || (tc.sym.scope is null) ) the conditions are inverted, should be: if( (tc.sym.symtab is null) || (tc.sym.scope !is null) ) Cheers, Oskar
Dec 02 2005