Source location information
Paul Sandoz
paul.sandoz at oracle.com
Tue Apr 9 16:54:34 UTC 2024
> On Apr 9, 2024, at 1:11 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
> Curious: why not making the location sticky?
>
I figured its better to have no location information rather than incorrect location information (which might happen if builder’s location is not explicitly reset), but it should be easy to try both approaches.
Paul.
> Maurizio
>
> On 08/04/2024 23:13, Paul Sandoz wrote:
>> Based on comments and feedback here is a sketch of a proposed approach.
>>
>> Location information is optionally present on any operation as a general attribute. Such information is added to an op indirectly by adding it to a block builder, and the next operation that is appending to the block builder is assigned the location information. Any subsequent operations added are not assigned the same location information e.g.,
>>
>> Block.Builder b = …
>> SourceLocation l = …
>> b.setSourceLocation(l);
>> Op op = ...
>> b.op(op); // op is bound to block and is assigned l
>> assert op.sourceLocation().equals(l);
>> Op op2 = ...
>> b.op(op2); // op is bound to block and is not assigned any location information
>>
>>
>> SourceLocation could be a record comprising source, line, and column (we could also provide start and end positions of line/column to give a “block", javac has that information for some nodes).
>>
>> When transforming an operation it’s source location, if present, could be added to the associated block builder prior to it being transformed.
>>
>> Paul.
>>
>>> On Mar 29, 2024, at 1:29 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>>>
>>> Hi,
>>>
>>> Attached is a document discussing support for source location in code models. It briefly presents some possible approaches and requirements, and does not (yet) choose a specific approach and describe in more detail (because I don’t know what that should be).
>>>
>>> Paul.
>>>
>>> <source-location.md>
More information about the babylon-dev
mailing list