[Issue 10979] Add trait for function callgraph extraction, to allow "builtin attribute"-style UDA semantic checks

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 8 16:10:34 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10979



--- Comment #5 from Adam D. Ruppe <destructionator at gmail.com> 2013-10-08 16:10:32 PDT ---
I just wrote this on the newsgroup and want it to be here too:

Though, my proposed __traits could perhaps be improved to just 
offer two things:

__traits(getFunctionsCalled, function)

returns a tuple of all functions called. These would ideally be 
in the form of symbols.

__traits(functionBodyAvailable, function)

true if the source was available to the compiler.


And that's it: the rest is done in the library using existing 
language features. Then we can decide in library code if a 
missing attribute is a problem based on if the body was available 
or not.

Note that this isn't specific to the gc: it would provide the 
necessary foundation for all kinds of library extensions in the 
same vein as @safe, with the possibility of automatic inference 
from the prototype + presence of body.


 * * *


To get the entire call graph, your helper library function would do
getFunctionsCalled recursively. It would be a pain to actually build a big
return tuple since you can't ~= a symbol.... but you could easily enough pass a
visitor template to the helper function which is instantiated with each thingy.

But anyway, recursive templates are a solved problem, so however we decide to
do it, we can keep the compiler simple.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list