digitalmars.D - pragma(mangle)
- Daniel Murphy (9/9) Jun 11 2011 Stealing the idea from http://d.puremagic.com/issues/show_bug.cgi?id=269...
- Sean Kelly (8/23) Jun 11 2011 I'd use it. And any characters usable as a jump label in ask should be a...
- Nick Sabalausky (10/20) Jun 11 2011 It sounds like it may have great potential for working around hashed
- Daniel Murphy (18/26) Jun 11 2011 You could use it, for example, to provide a function with C++ linkage ta...
- Andrej Mitrovic (6/8) Jun 11 2011 I assumed I must have been doing something wrong when I filed this:
- Nick Sabalausky (5/15) Jun 11 2011 Are you working on updating DDMD to a newer DMD, or just simply trying t...
- Andrej Mitrovic (11/14) Jun 11 2011 I'd like to really work on it properly (it would seem like an exciting
- Nick Sabalausky (7/21) Jun 12 2011 Actually, what I meant was this: DDMD is currently based on DMD 2.040. I...
- Andrei Alexandrescu (4/22) Jun 12 2011 I've always wondered what's the methodology of changing ddmd from diffs
- Nick Sabalausky (8/33) Jun 12 2011 I've recently asked about that on the DDMD forum. No response yet, but i...
- Andrej Mitrovic (7/43) Jun 12 2011 If you take a diff of DMD's parse.c and DDMD's parser.d, you'll see
- Nick Sabalausky (11/38) Jun 12 2011 The AST is different though. I haven't compared the contents of the file...
- David Nadlinger (7/13) Jun 12 2011 ddmd is obviously a different story, but just merging the commits
- Robert Clipsham (7/15) Jun 11 2011 When I was working on ddmd this was worked around with a wrapper C file
- Nick Sabalausky (6/21) Jun 11 2011 Yea, it's still there: "bridge/bridge.cpp"
- Andrej Mitrovic (6/24) Jun 11 2011 I did have to update some definitions in the bridge file, and now I've
Stealing the idea from http://d.puremagic.com/issues/show_bug.cgi?id=2698, I've implemented pragma(mangle). Basically, pragma(mangle, "_mangled__name_") void myfunction() {} Will cause the compiler to use "_mangled__name_" as the function's mangle string. Would many people find this a useful thing to have in the compiler? Also, does anybody know what set of characters to accept in a mangle string?
Jun 11 2011
I'd use it. And any characters usable as a jump label in ask should be accep= ted. OSX does some weird macro mangling of some posix functions and short of= a C or asm trampoline these can't be called in D. Sent from my iPhone On Jun 11, 2011, at 1:47 PM, "Daniel Murphy" <yebblies nospamgmail.com> wrot= e:Stealing the idea from http://d.puremagic.com/issues/show_bug.cgi?id=3D269=8,=20I've implemented pragma(mangle). =20 Basically, pragma(mangle, "_mangled__name_") void myfunction() {} =20 Will cause the compiler to use "_mangled__name_" as the function's mangle=20=string. =20 Would many people find this a useful thing to have in the compiler? =20 Also, does anybody know what set of characters to accept in a mangle strin=g?=20=20 =20
Jun 11 2011
"Daniel Murphy" <yebblies nospamgmail.com> wrote in message news:it0kh7$2v1r$1 digitalmars.com...Stealing the idea from http://d.puremagic.com/issues/show_bug.cgi?id=2698, I've implemented pragma(mangle). Basically, pragma(mangle, "_mangled__name_") void myfunction() {} Will cause the compiler to use "_mangled__name_" as the function's mangle string. Would many people find this a useful thing to have in the compiler? Also, does anybody know what set of characters to accept in a mangle string?It sounds like it may have great potential for working around hashed mangles. And maybe for exposing an API to another link-compatible language like C (or not, I don't know, maybe extern(C) is always good enough for that?). Two possible problems I can see: 1. Can it be reliably demangled? If not, I think that would severely hinder its usefulness. 2. What if "myfunction" is templated?
Jun 11 2011
"Nick Sabalausky" <a a.a> wrote in message news:it0m05$6t7$1 digitalmars.com...It sounds like it may have great potential for working around hashed mangles. And maybe for exposing an API to another link-compatible language like C (or not, I don't know, maybe extern(C) is always good enough for that?).You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D. D also can't provide C functions with names that are D reserved identifiers. extern(C) pragma(mangle, "_pure") void cpure() {}Two possible problems I can see: 1. Can it be reliably demangled? If not, I think that would severely hinder its usefulness.The idea is that you can support name mangling that the compiler can't understand. I'd imagine you'd have to follow D name mangling if you wanted it demangled.2. What if "myfunction" is templated?Currently it attaches to one declaration and alters it's mangle, that's it. I'm not sure what should happen in more complicated situations. I do think this should be possible: template(name, T, U) { extern pragma(mangle, genMangle!(name, T, U) void myfun(name, T, U); }
Jun 11 2011
On 6/11/11, Daniel Murphy <yebblies nospamgmail.com> wrote:You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D.I assumed I must have been doing something wrong when I filed this: http://d.puremagic.com/issues/show_bug.cgi?id=6121 . But I guess not. I can't link DDMD with the DMD 2.053 backend because of this. I'd have to change DMD's long types to int, which might not be a big issue but I'd rather avoid having to patch every release..
Jun 11 2011
"Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote in message news:mailman.825.1307830585.14074.digitalmars-d puremagic.com...On 6/11/11, Daniel Murphy <yebblies nospamgmail.com> wrote:Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D.I assumed I must have been doing something wrong when I filed this: http://d.puremagic.com/issues/show_bug.cgi?id=6121 . But I guess not. I can't link DDMD with the DMD 2.053 backend because of this. I'd have to change DMD's long types to int, which might not be a big issue but I'd rather avoid having to patch every release..
Jun 11 2011
On 6/12/11, Nick Sabalausky <a a.a> wrote:Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.I'd like to really work on it properly (it would seem like an exciting project to work on!), and update DDMD to be more D2-like, e.g. that entire main.d module seems to re-implement argument passing via C APIs just like DMD's C++ code, but this seems unnecessary to me? Replacing that with getopt() would cut that module down to a tiny fragment of its original size. What I'm really interested in doing is building interfaces to DDMD via various functions so it can be used by tools on demand. If I get something rolling I might put it up on github or somewhere, will let you know..
Jun 11 2011
"Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote in message news:mailman.828.1307833235.14074.digitalmars-d puremagic.com...On 6/12/11, Nick Sabalausky <a a.a> wrote:Actually, what I meant was this: DDMD is currently based on DMD 2.040. Ie, ATM, it's DMD 2.040 ported to D. You said you were trying to use the 2.053 backend with DDMD, so I was just wondering if you were also updating DDMD frontend to be a D port of something newer than 2.040.Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.I'd like to really work on it properly (it would seem like an exciting project to work on!), and update DDMD to be more D2-like, e.g. that entire main.d module seems to re-implement argument passing via C APIs just like DMD's C++ code, but this seems unnecessary to me? Replacing that with getopt() would cut that module down to a tiny fragment of its original size.What I'm really interested in doing is building interfaces to DDMD via various functions so it can be used by tools on demand. If I get something rolling I might put it up on github or somewhere, will let you know..That does sounds cool, too :)
Jun 12 2011
On 6/12/11 4:23 AM, Nick Sabalausky wrote:"Andrej Mitrovic"<andrej.mitrovich gmail.com> wrote in message news:mailman.828.1307833235.14074.digitalmars-d puremagic.com...I've always wondered what's the methodology of changing ddmd from diffs in dmd. I can only imagine it as a difficult manual process. AndreiOn 6/12/11, Nick Sabalausky<a a.a> wrote:Actually, what I meant was this: DDMD is currently based on DMD 2.040. Ie, ATM, it's DMD 2.040 ported to D. You said you were trying to use the 2.053 backend with DDMD, so I was just wondering if you were also updating DDMD frontend to be a D port of something newer than 2.040.Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.I'd like to really work on it properly (it would seem like an exciting project to work on!), and update DDMD to be more D2-like, e.g. that entire main.d module seems to re-implement argument passing via C APIs just like DMD's C++ code, but this seems unnecessary to me? Replacing that with getopt() would cut that module down to a tiny fragment of its original size.
Jun 12 2011
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:it2l1n$1alh$2 digitalmars.com...On 6/12/11 4:23 AM, Nick Sabalausky wrote:I've recently asked about that on the DDMD forum. No response yet, but it's not really a high-traffic forum anyway: http://www.dsource.org/forums/viewtopic.php?t=5946&sid=4ece5dbd7a2352d5de1f61b14452733f As I said there: "I would guess that right strategy would be to compare two versions of DMD (ie, the one DDMD is currently based on, and the one you're trying to update to), and then recreate the changes in DDMD.""Andrej Mitrovic"<andrej.mitrovich gmail.com> wrote in message news:mailman.828.1307833235.14074.digitalmars-d puremagic.com...I've always wondered what's the methodology of changing ddmd from diffs in dmd. I can only imagine it as a difficult manual process.On 6/12/11, Nick Sabalausky<a a.a> wrote:Actually, what I meant was this: DDMD is currently based on DMD 2.040. Ie, ATM, it's DMD 2.040 ported to D. You said you were trying to use the 2.053 backend with DDMD, so I was just wondering if you were also updating DDMD frontend to be a D port of something newer than 2.040.Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.I'd like to really work on it properly (it would seem like an exciting project to work on!), and update DDMD to be more D2-like, e.g. that entire main.d module seems to re-implement argument passing via C APIs just like DMD's C++ code, but this seems unnecessary to me? Replacing that with getopt() would cut that module down to a tiny fragment of its original size.
Jun 12 2011
On 6/12/11, Nick Sabalausky <a a.a> wrote:"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:it2l1n$1alh$2 digitalmars.com...If you take a diff of DMD's parse.c and DDMD's parser.d, you'll see that they're almost identical. So yeah, I think what DDMD devs probably do is take a diff of two DMD versions and then manually upgrade DDMD's frontend to match. I don't think it's way too much work (I'm just assuming though), simple C++ code tends to translate nicely into D and I think DMD's C++ sources are nice and readable.On 6/12/11 4:23 AM, Nick Sabalausky wrote:I've recently asked about that on the DDMD forum. No response yet, but it's not really a high-traffic forum anyway: http://www.dsource.org/forums/viewtopic.php?t=5946&sid=4ece5dbd7a2352d5de1f61b14452733f As I said there: "I would guess that right strategy would be to compare two versions of DMD (ie, the one DDMD is currently based on, and the one you're trying to update to), and then recreate the changes in DDMD.""Andrej Mitrovic"<andrej.mitrovich gmail.com> wrote in message news:mailman.828.1307833235.14074.digitalmars-d puremagic.com...I've always wondered what's the methodology of changing ddmd from diffs in dmd. I can only imagine it as a difficult manual process.On 6/12/11, Nick Sabalausky<a a.a> wrote:Actually, what I meant was this: DDMD is currently based on DMD 2.040. Ie, ATM, it's DMD 2.040 ported to D. You said you were trying to use the 2.053 backend with DDMD, so I was just wondering if you were also updating DDMD frontend to be a D port of something newer than 2.040.Are you working on updating DDMD to a newer DMD, or just simply trying to use the newer backend? If the former, then that's fantastic and I look forward to it.I'd like to really work on it properly (it would seem like an exciting project to work on!), and update DDMD to be more D2-like, e.g. that entire main.d module seems to re-implement argument passing via C APIs just like DMD's C++ code, but this seems unnecessary to me? Replacing that with getopt() would cut that module down to a tiny fragment of its original size.
Jun 12 2011
"Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote in message news:mailman.849.1307906475.14074.digitalmars-d puremagic.com...On 6/12/11, Nick Sabalausky <a a.a> wrote:The AST is different though. I haven't compared the contents of the files, but a quick comparison of the directory contents suggests that DMD has many different AST classes in a single .h/.c combo (with a separate .h/.c combo for each "category" of AST class types), wheras DDMD splits all the AST types into their own separate .d files. Also, since C++ and D syntax is naturally different, a file compare between a .c and .d would come up with a lot of "changes" that are just syntax differences and not real changes at all. I'd imagine there'd be a lot of that to sort through."Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:it2l1n$1alh$2 digitalmars.com...If you take a diff of DMD's parse.c and DDMD's parser.d, you'll see that they're almost identical. So yeah, I think what DDMD devs probably do is take a diff of two DMD versions and then manually upgrade DDMD's frontend to match. I don't think it's way too much work (I'm just assuming though), simple C++ code tends to translate nicely into D and I think DMD's C++ sources are nice and readable.I've always wondered what's the methodology of changing ddmd from diffs in dmd. I can only imagine it as a difficult manual process.I've recently asked about that on the DDMD forum. No response yet, but it's not really a high-traffic forum anyway: http://www.dsource.org/forums/viewtopic.php?t=5946&sid=4ece5dbd7a2352d5de1f61b14452733f As I said there: "I would guess that right strategy would be to compare two versions of DMD (ie, the one DDMD is currently based on, and the one you're trying to update to), and then recreate the changes in DDMD."
Jun 12 2011
On 6/12/11 9:21 PM, Andrej Mitrovic wrote:If you take a diff of DMD's parse.c and DDMD's parser.d, you'll see that they're almost identical. So yeah, I think what DDMD devs probably do is take a diff of two DMD versions and then manually upgrade DDMD's frontend to match. I don't think it's way too much work (I'm just assuming though), simple C++ code tends to translate nicely into D and I think DMD's C++ sources are nice and readable.ddmd is obviously a different story, but just merging the commits one-by-one manually has worked quite well for me when doing LDC frontend updates. Merging a whole release worth of changes at once might be more efficient, but I found it a lot more difficult to reason about the changes that way. David
Jun 12 2011
On 11/06/2011 23:15, Andrej Mitrovic wrote:On 6/11/11, Daniel Murphy<yebblies nospamgmail.com> wrote:When I was working on ddmd this was worked around with a wrapper C file that wrapped the functions with long parameters in functions D accepted. Is that file no longer there? -- Robert http://octarineparrot.com/You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D.I assumed I must have been doing something wrong when I filed this: http://d.puremagic.com/issues/show_bug.cgi?id=6121 . But I guess not. I can't link DDMD with the DMD 2.053 backend because of this. I'd have to change DMD's long types to int, which might not be a big issue but I'd rather avoid having to patch every release..
Jun 11 2011
"Robert Clipsham" <robert octarineparrot.com> wrote in message news:it0rec$mii$1 digitalmars.com...On 11/06/2011 23:15, Andrej Mitrovic wrote:Yea, it's still there: "bridge/bridge.cpp" I had wondered what exactly that was for. In retrospect, it probably would have been obvious if I had ever actually paid any attention to anything inside that file ;)On 6/11/11, Daniel Murphy<yebblies nospamgmail.com> wrote:When I was working on ddmd this was worked around with a wrapper C file that wrapped the functions with long parameters in functions D accepted. Is that file no longer there?You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D.I assumed I must have been doing something wrong when I filed this: http://d.puremagic.com/issues/show_bug.cgi?id=6121 . But I guess not. I can't link DDMD with the DMD 2.053 backend because of this. I'd have to change DMD's long types to int, which might not be a big issue but I'd rather avoid having to patch every release..
Jun 11 2011
On 6/12/11, Robert Clipsham <robert octarineparrot.com> wrote:On 11/06/2011 23:15, Andrej Mitrovic wrote:I did have to update some definitions in the bridge file, and now I've just noticed that I've accidentally killed one prototype in the bridge file. So that fixes that issue. I'm left with one nagging symbol, "Symbol Undefined ?fatal YAXXZ (void cdecl fatal(void ))". I'll figure this out later.On 6/11/11, Daniel Murphy<yebblies nospamgmail.com> wrote:When I was working on ddmd this was worked around with a wrapper C file that wrapped the functions with long parameters in functions D accepted. Is that file no longer there? -- Robert http://octarineparrot.com/You could use it, for example, to provide a function with C++ linkage taking a C++ long parameter, something which I think is currently impossible in D.I assumed I must have been doing something wrong when I filed this: http://d.puremagic.com/issues/show_bug.cgi?id=6121 . But I guess not. I can't link DDMD with the DMD 2.053 backend because of this. I'd have to change DMD's long types to int, which might not be a big issue but I'd rather avoid having to patch every release..
Jun 11 2011