www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Callout to DMD hackers

reply "Andrej Mitrovic" <andrej.mitrovich gmail.com> writes:
Recently Vladimir Panteleev has ported the DMD Source Guide from 
the old wiki to the new one[1], and updated it with up-to-date 
information. I've added a "DMD Hacking Tips & Tricks" section[2], 
which should help people new to the codebase to start hacking on 
DMD-FE. I've only added a few tips that I know of.

If you regularly hack on DMD and know some good tips for new DMD 
developers, please either post those tips in this thread and 
we'll add them to the wiki, or you can directly add them to the 
wiki. Everybody benefits from sharing knowledge about compiler 
internals. For example, GCC has pretty extensive documentation 
about its internals[3].

[1] : http://wiki.dlang.org/DMD_Source_Guide
[2] : 
http://wiki.dlang.org/DMD_Source_Guide#DMD_Hacking_Tips_.26_Tricks
[3] : http://gcc.gnu.org/onlinedocs/gccint/
Mar 08 2014
next sibling parent "Dicebot" <public dicebot.lv> writes:
Thanks both to you and Vladimir for your effort! Some of those 
tips could have saved me a lot of time if read earlier :)
Mar 08 2014
prev sibling next sibling parent reply "Suliman" <evermind live.ru> writes:
Few years ago I had read that Walter had add some print 
instruction to Phobos, that allow to do print without importing 
std.stdio; It was needed to debugging phobos.

Maybe it's not proper thread, but maybe someone of D hackers 
remember it, because I can't remember how it was done.
Mar 08 2014
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/8/14, Suliman <evermind live.ru> wrote:
 Few years ago I had read that Walter had add some print
 instruction to Phobos, that allow to do print without importing
 std.stdio; It was needed to debugging phobos.

 Maybe it's not proper thread, but maybe someone of D hackers
 remember it, because I can't remember how it was done.
Not sure, but you can always do the following to e.g. avoid doing any imports: ----- extern(C) int printf(in char* format, ...); void main() { printf("hello\n"); } -----
Mar 08 2014
prev sibling parent Mike Parker <aldacron gmail.com> writes:
On 3/8/2014 11:21 PM, Suliman wrote:
 Few years ago I had read that Walter had add some print instruction to
 Phobos, that allow to do print without importing std.stdio; It was
 needed to debugging phobos.

 Maybe it's not proper thread, but maybe someone of D hackers remember
 it, because I can't remember how it was done.
IIRC C's printf was declared in object.d. But that was back in the early D1 days.
Mar 08 2014
prev sibling next sibling parent "Phillip Larkson" <phillip philliplarkson.com> writes:
Thanks for the information! I plan on playing around with the 
compiler soon, and the more information the merrier.
Mar 08 2014
prev sibling next sibling parent reply "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 13:25:32 UTC, Andrej Mitrovic wrote:
 Recently Vladimir Panteleev has ported the DMD Source Guide 
 from the old wiki to the new one[1], and updated it with 
 up-to-date information. I've added a "DMD Hacking Tips & 
 Tricks" section[2], which should help people new to the 
 codebase to start hacking on DMD-FE. I've only added a few tips 
 that I know of.

 If you regularly hack on DMD and know some good tips for new 
 DMD developers, please either post those tips in this thread 
 and we'll add them to the wiki, or you can directly add them to 
 the wiki. Everybody benefits from sharing knowledge about 
 compiler internals. For example, GCC has pretty extensive 
 documentation about its internals[3].

 [1] : http://wiki.dlang.org/DMD_Source_Guide
 [2] : 
 http://wiki.dlang.org/DMD_Source_Guide#DMD_Hacking_Tips_.26_Tricks
 [3] : http://gcc.gnu.org/onlinedocs/gccint/
Awesome! Thanks for the information. This part of article[1] was funny to add Walter as one of the people seem to have understood the DMD IR. Was not DMD IR implemented by Walter? also, me too. I don't got how DMD IR actually works or what is like. I don't understand this part "converted to UTF-8 when necessary" in [2]. What does it mean? I don't know much about UTF-8, just basics, unlike as should do, but shouldn't convert everything to UTF-8 and just handle the source code as UTF-8? [1]: I've been looking at trying to hook the DMD frontend up to LLVM (www.llvm.org), but I've been having some trouble. The LLVM IR (Intermediate Representation) is very well documented, but I'm having a rough time figuring out how DMD holds its IR. Since at least three people (David, Ben, and Walter) seem to have understand, I thought I'd ask for guidance.
Mar 08 2014
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 [1]: I've been looking at trying to hook the DMD frontend up to
 LLVM (www.llvm.org)
Uhm, haven't you heard of the LDC project? http://wiki.dlang.org/LDC
Mar 08 2014
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Saturday, 8 March 2014 at 21:07:52 UTC, Andrej Mitrovic wrote:
 On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 [1]: I've been looking at trying to hook the DMD frontend up to
 LLVM (www.llvm.org)
Uhm, haven't you heard of the LDC project? http://wiki.dlang.org/LDC
He was quoting an ancient bit of the article :P
Mar 08 2014
prev sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 I don't understand this part "converted to UTF-8 when necessary"
 in [1].
See Module::parse() in module.c, it converts all non-UTF-8 formats to UTF-8 when reading a file. Actually thinking about this, this has to be extremely inefficient. Hopefully once the compiler is ported to D we won't have to do this sort of conversion.
Mar 08 2014
next sibling parent "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 21:16:30 UTC, Andrej Mitrovic wrote:
 On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 I don't understand this part "converted to UTF-8 when 
 necessary"
 in [1].
See Module::parse() in module.c, it converts all non-UTF-8 formats to UTF-8 when reading a file. Actually thinking about this, this has to be extremely inefficient. Hopefully once the compiler is ported to D we won't have to do this sort of conversion.
Umm, why exactly? what approach will you be using instead of? I'm learning a bit more about compilers/programming languages at my free time. And if when the dmd in D port starts and I know at least enough about to be able to get involved with the project sure I will do. Of course I hope my poor english don't scare everybody in there but it's something I'm going to change
Mar 08 2014
prev sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 03/08/2014 10:16 PM, Andrej Mitrovic wrote:
 On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 I don't understand this part "converted to UTF-8 when necessary"
 in [1].
See Module::parse() in module.c, it converts all non-UTF-8 formats to UTF-8 when reading a file. Actually thinking about this, this has to be extremely inefficient. Hopefully once the compiler is ported to D we won't have to do this sort of conversion.
How many actual D source files are not UTF-8?
Mar 08 2014
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/8/14, Timon Gehr <timon.gehr gmx.ch> wrote:
 How many actual D source files are not UTF-8?
No idea. Maybe some Windows tools use UTF-16, although I can't think of any. VS uses UTF-8 right?
Mar 08 2014
next sibling parent reply "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 22:20:50 UTC, Andrej Mitrovic wrote:
 On 3/8/14, Timon Gehr <timon.gehr gmx.ch> wrote:
 How many actual D source files are not UTF-8?
No idea. Maybe some Windows tools use UTF-16, although I can't think of any. VS uses UTF-8 right?
VS do use UTF-16, IIRC.
Mar 11 2014
parent reply "Brad Anderson" <eco gnuk.net> writes:
On Wednesday, 12 March 2014 at 01:17:23 UTC, Asman01 wrote:
 On Saturday, 8 March 2014 at 22:20:50 UTC, Andrej Mitrovic 
 wrote:
 On 3/8/14, Timon Gehr <timon.gehr gmx.ch> wrote:
 How many actual D source files are not UTF-8?
No idea. Maybe some Windows tools use UTF-16, although I can't think of any. VS uses UTF-8 right?
VS do use UTF-16, IIRC.
You can change the file encoding but the default is codepage 1252 for me (I assume it changes based on your locale but I don't know that for certain). It's definitely not UTF-16 encoded. I don't recall ever seeing Windows VS source code encoded with anything other than 1252/8859-1 or (rarely) UTF-8.
Mar 11 2014
parent Russel Winder <russel winder.org.uk> writes:
On Wed, 2014-03-12 at 02:14 +0000, Brad Anderson wrote:
[=E2=80=A6]
 You can change the file encoding but the default is codepage 1252
 for me (I assume it changes based on your locale but I don't know
 that for certain). It's definitely not UTF-16 encoded. I don't=20
 recall ever seeing Windows VS source code encoded with anything=20
 other than 1252/8859-1 or (rarely) UTF-8.
I would have thought UTF-8 was the only sensible encoding of Unicode for general purposes. Windows is the reason for UTF-16LE and UTF-16BE because Microsoft implemented things differently to the rest of the planet, and what the standard said. So the standard got retrofitted. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Mar 12 2014
prev sibling parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 08.03.2014 23:20, Andrej Mitrovic wrote:
 On 3/8/14, Timon Gehr <timon.gehr gmx.ch> wrote:
 How many actual D source files are not UTF-8?
No idea. Maybe some Windows tools use UTF-16, although I can't think of any. VS uses UTF-8 right?
Visual D sets the default encoding for D files to UTF8, otherwise they are Codepage 1252 "Western European" on my system, e.g. for C/C++ files.
Mar 12 2014
prev sibling next sibling parent reply "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 13:25:32 UTC, Andrej Mitrovic wrote:
 Recently Vladimir Panteleev has ported the DMD Source Guide 
 from the old wiki to the new one[1], and updated it with 
 up-to-date information. I've added a "DMD Hacking Tips & 
 Tricks" section[2], which should help people new to the 
 codebase to start hacking on DMD-FE. I've only added a few tips 
 that I know of.

 If you regularly hack on DMD and know some good tips for new 
 DMD developers, please either post those tips in this thread 
 and we'll add them to the wiki, or you can directly add them to 
 the wiki. Everybody benefits from sharing knowledge about 
 compiler internals. For example, GCC has pretty extensive 
 documentation about its internals[3].

 [1] : http://wiki.dlang.org/DMD_Source_Guide
 [2] : 
 http://wiki.dlang.org/DMD_Source_Guide#DMD_Hacking_Tips_.26_Tricks
 [3] : http://gcc.gnu.org/onlinedocs/gccint/
Also, where is root/async.c actually used?
Mar 08 2014
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 Also, where is root/async.c actually used?
In mars.c, take a look at the "#if ASYNCREAD" section.
Mar 08 2014
parent "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 21:09:14 UTC, Andrej Mitrovic wrote:
 On 3/8/14, Asman01 <jckj33 gmail.com> wrote:
 Also, where is root/async.c actually used?
In mars.c, take a look at the "#if ASYNCREAD" section.
Thanks. I will check out.
Mar 08 2014
prev sibling next sibling parent reply "Asman01" <jckj33 gmail.com> writes:
On Saturday, 8 March 2014 at 13:25:32 UTC, Andrej Mitrovic wrote:
 Recently Vladimir Panteleev has ported the DMD Source Guide 
 from the old wiki to the new one[1], and updated it with 
 up-to-date information. I've added a "DMD Hacking Tips & 
 Tricks" section[2], which should help people new to the 
 codebase to start hacking on DMD-FE. I've only added a few tips 
 that I know of.

 If you regularly hack on DMD and know some good tips for new 
 DMD developers, please either post those tips in this thread 
 and we'll add them to the wiki, or you can directly add them to 
 the wiki. Everybody benefits from sharing knowledge about 
 compiler internals. For example, GCC has pretty extensive 
 documentation about its internals[3].

 [1] : http://wiki.dlang.org/DMD_Source_Guide
 [2] : 
 http://wiki.dlang.org/DMD_Source_Guide#DMD_Hacking_Tips_.26_Tricks
 [3] : http://gcc.gnu.org/onlinedocs/gccint/
Just for clarification, the parsing method which dmd use is a recursive descent parser, right?
Mar 11 2014
parent Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On 3/11/2014 9:02 PM, Asman01 wrote:
 Just for clarification, the parsing method which dmd use is a recursive
 descent parser, right?
Yes.
Mar 11 2014
prev sibling parent Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On 3/8/2014 8:25 AM, Andrej Mitrovic wrote:
 Recently Vladimir Panteleev has ported the DMD Source Guide from the old
 wiki to the new one[1], and updated it with up-to-date information. I've
 added a "DMD Hacking Tips & Tricks" section[2], which should help people
 new to the codebase to start hacking on DMD-FE. I've only added a few
 tips that I know of.
Wow, that page is hugely improved since last time I looked (quite a while ago, TBH). Cheers to all who contributed! One thing I'm still unclear on though (maybe someone in-the-know could add this info?): Last I looked at DMD's semantic code, there was a lot of stuff about "deferred" semantics. What's all that stuff about? It sounds like some sort of inverse of what the Wiki describes about handling forward references, but I don't know anything about it.
Mar 11 2014