www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Where can I find how string == is performed in dmd2 source?

reply spir <denis.spir gmail.com> writes:
Hello,


Nearly all is in title.
I found dmd2/src/phobos/std/string.cmp in string.d. But this performs strin=
g comp with positive/negative/zero result, not equality test with boolean r=
esult.


denis
-- -- -- -- -- -- --
vit esse estrany =E2=98=A3

spir.wikidot.com
Dec 06 2010
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 06 Dec 2010 09:44:10 -0500, spir <denis.spir gmail.com> wrote:

 Hello,


 Nearly all is in title.
 I found dmd2/src/phobos/std/string.cmp in string.d. But this performs  
 string comp with positive/negative/zero result, not equality test with  
 boolean result.

It's in druntime. Easy way to find out what druntime function is used by the compiler void main() { auto str1 = "hello"; auto str2 = "world"; auto iseq = (str1 == str2); } compile using -c, then use obj2asm, result of main function: .text._Dmain segment assume CS:.text._Dmain _Dmain: push EBP mov EBP,ESP push EBX push ESI mov EDX,_TMP0 SYM32[0Bh] mov EAX,_TMP0 SYM32[0Ch] mov ECX,_TMP1 SYM32[016h] mov EBX,_TMP1 SYM32[018h] mov ESI,offset FLAT:_D11TypeInfo_Aa6__initZ SYM32 push ESI push ECX push EBX push EDX push EAX ******** call _adEq2 PC32 xor EAX,EAX add ESP,014h pop ESI pop EBX pop EBP ret .text._Dmain ends So it looks like adEq2 is the function called (I marked with ******** above). Searching druntime, it looks like it's here: http://www.dsource.org/projects/druntime/browser/trunk/src/rt/adi.d#L353 This is an essential exercise for D runtime hacking ;) -Steve
Dec 06 2010