kuilpd wrote:

> We can definitely add functions to covert (directly) between Scalars and 
> ValueObjects (in fact, I think the only reason that the APInt overloads 
> currently exists is because of the initial attempt to upstream the DIL 
> implementation). 

Ah, I didn't know that, I think I joined the upstream implementation right 
after that.

> However, I'm still not sure if it's necessary to ValueObjects for values 
> internal to the expression. I don't think the different result type should be 
> a problem since the result type for a given ast node kind should be always 
> the same. Scalar nodes and all arithmetic operation should return a scalar, 
> while other operations return a value object. If you need to use a value 
> object in a scalar context (e.g. in `a[b]` where `b` is a variable) you add 
> new node type (`LValueToRValueConversionNode` ?), which performs the 
> extraction.

I did an internal value for a subscript node to make the switch to DIL faster, 
but in the full implementation none of the nodes really have any internal 
values (if I understood correctly what you are proposing). We just have 
incoming AST nodes for arguments, and there is a single interface to traverse 
the AST tree: `Evaluate(node)` that returns a `ValueObject` of the entire 
subtree of that node. So when evaluating `b` in `a[b]` we don't know what `b` 
is until we evaluate it: a literal, variable, or a whole another expression. We 
specifically moved away from analyzing types of nodes during parsing, the way 
it was done in `lldb-eval`.

> > Also, it looks like bit size of APInt that comes from a ValueObject is not 
> > reliable, since even a variable of type char has an APInt with 32 bit size.
> 
> That might be something we can fix. What's the API you're using and what 
> happens if you change it to do what you need?

I looked at this again, and realized that `APInt` having 32 bit width by 
default is actually okay, since according to C99 whenever we use a lower width 
variable in any arithmetic operation it gets promoted to `int` anyway. Although 
my question now is how exactly and where is that 32 bit size picked: is it some 
default value or is it based on a target machine? I'm not sure at which point 
is an instance of `APInt` created for a variable, I'll look into it further.

https://github.com/llvm/llvm-project/pull/147064
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to