www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD Source Hot Spot for Expression Type Deduction

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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


or is there a hot spot where I can insert a callback to print 
such information?
Apr 08 2014
parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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 +

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.
Apr 08 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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 
Apr 08 2014