x/debug: add expression types &x and *x.
Support for the address operator uses two new value types.
The result struct produced for an expression &x contains the DWARF type
of x, and a value of type pointerToValue containing the address of x.
We don't use the DWARF type of &x, because the program's DWARF
information may not contain that type if it's not used in the program.
When evaluating the operand of an address expression, we don't want to
return the value of the operand, since we need the address. So we add
a parameter getAddress to evalNode and resultFrom, and when getAddress
is true and the result of the expression is an addressable value, we
return a value of type addressableValue containg the address. Then when
evaluating the node for &x, we convert the addressableValue to a
pointerToValue, or return an error if x was not addressable.
Reviewed-by: Dave Day <firstname.lastname@example.org>
3 files changed