Thread overview
DMD Source Hot Spot for Expression Type Deduction
Apr 08, 2014
Nordlöw
Continued: DMD Source Hot Spot for Expression Type Deduction
Apr 08, 2014
Nordlöw
Apr 08, 2014
Nordlöw
April 08, 2014
I'm looking for hot spots in the DMD source where deduction of types of expressions are performed.

I want to use this to extract information about the type of an expression before/after point.

Is this logic spread all over

.*Exp::semantic
.*Exp::semantic2
.*Exp::semantic3

or is there a hot spot where I can insert a callback to print such information?
April 08, 2014
So far I figured that what I typically want to do is

printf("Type: %s", e->type->toChars());

whenever I find a type-deduced expression e that fulfils

(e->loc->linnum == QUERY_LINE &&
 e->loc->charnum <= QUERY_COLUMN &&
 QUERY_COLUMN < (e->loc->charnum +
                 e->length_of_expression_in_code))

Can I somehow query the source code range (start end begin offset/row-column) of an expression?

This of course has to handle sub-expression types which is a complication I haven't covered here.

So maybe a better feature would be to query for type of expression before or after point.
April 08, 2014
I just realized that maybe the best way is to recurse down the AST until I find node(s) whose token range cover my query point right?