digitalmars.D.learn - Is there a way to "see" source code generated by templates after a
- WhatMeWorry (8/8) Jul 16 2016 I don't suppose there's a way to "see" source code generated by
- rikki cattermole (3/10) Jul 16 2016 Yup. But that is done by an external tool most of the time.
- Stefan Koch (4/12) Jul 17 2016 If you do use mixins I can craft you a patch.
- WhatMeWorry (4/21) Jul 17 2016 Wonderful! Nope, I can wait. I don't want to do anything that
- zabruk70 (3/5) Jul 17 2016 Wow! Is this really possible?! So long time several peoples asked
- Stefan Koch (4/9) Jul 17 2016 I am reasonably sure that I can do it :)
- Nicholas Wilson (2/12) Jul 18 2016 Just pipe it through dformat should do a good enough job.
- Stefan Koch (3/11) Jul 18 2016 I did it for function templates just now.
- Stefan Koch (17/19) Jul 18 2016 Okay here is the frist really hacky draft patch
- lobo (7/9) Jul 18 2016 Does this do what you want?
- WhatMeWorry (3/14) Jul 18 2016 i appreciate the reply but you're about 20 years too late :)
- WhatMeWorry (5/11) Jul 19 2016 I've just stumbled across this on dmd documentation. Haven't had
- ZombineDev (6/22) Jul 20 2016 This is not what you are looking for. This option makes dmd put
I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :) Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?
Jul 16 2016
On 17/07/2016 5:57 PM, WhatMeWorry wrote:I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :)There isn't and it has been asked for (I for one want it).Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?Yup. But that is done by an external tool most of the time.
Jul 16 2016
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :) Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?If you do use mixins I can craft you a patch. If you want to see template expansions you have to wait a little longer.
Jul 17 2016
On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:Wonderful! Nope, I can wait. I don't want to do anything that would slow you down. This will make learning and debugging code generation so much easier.I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :) Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?If you do use mixins I can craft you a patch. If you want to see template expansions you have to wait a little longer.
Jul 17 2016
On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:If you want to see template expansions you have to wait a little longer.Wow! Is this really possible?! So long time several peoples asked this...
Jul 17 2016
On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:I am reasonably sure that I can do it :) However don't expect anything pretty. The indentation will be long gone ...If you want to see template expansions you have to wait a little longer.Wow! Is this really possible?! So long time several peoples asked this...
Jul 17 2016
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote:On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:Just pipe it through dformat should do a good enough job.On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:I am reasonably sure that I can do it :) However don't expect anything pretty. The indentation will be long gone ...If you want to see template expansions you have to wait a little longer.Wow! Is this really possible?! So long time several peoples asked this...
Jul 18 2016
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote:On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:I did it for function templates just now. It will the instantiated bodys to std-out.On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:I am reasonably sure that I can do it :)If you want to see template expansions you have to wait a little longer.Wow! Is this really possible?! So long time several peoples asked this...
Jul 18 2016
On Monday, 18 July 2016 at 17:35:29 UTC, Stefan Koch wrote:I did it for function templates just now. It will the instantiated bodys to std-out.Okay here is the frist really hacky draft patch In dtemplate.d line 6691 right at the end of semantic3 insert the following code : if (auto a = toAlias2) { scope hgs = HdrGenState(); scope ob = OutBuffer(); scope ppv = new PrettyPrintVisitor(&ob, &hgs); if (auto fd = a.isFuncDeclaration()) { printf("FunctionTemplate: %s\n{", toChars); if (auto fb = fd.fbody) fb.accept(ppv); } printf("%.*s\n}\n", ob.size, cast(char*)ob.data); } } Without warranty of any kind of course :)
Jul 18 2016
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:[snip]Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?Does this do what you want? cl.exe /E gcc -E clang -E clang-cl /E
Jul 18 2016
On Monday, 18 July 2016 at 07:37:27 UTC, lobo wrote:On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:i appreciate the reply but you're about 20 years too late :) Thankfully, my c/c++ days are long gone. Long live D.[snip]Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?Does this do what you want? cl.exe /E gcc -E clang -E clang-cl /E
Jul 18 2016
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :)I've just stumbled across this on dmd documentation. Haven't had time to play with it yet. -allinst generate code for all template instantiations
Jul 19 2016
On Tuesday, 19 July 2016 at 20:19:53 UTC, WhatMeWorry wrote:On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:This is not what you are looking for. This option makes dmd put seemingly unused code in the binary. It does not output human-readable template instantations. It was meant to help workaround linking errors at the time when the lazy template instantiation mechanism was not so robust as nowadays.I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because if there were a way, I'd of come across it by now :)I've just stumbled across this on dmd documentation. Haven't had time to play with it yet. -allinst generate code for all template instantiations
Jul 20 2016