Skip to content

Commit 42cff3a

Browse files
committed
[SourceLocation] Extract and rework line tables
* `computeLines` now produces newly introducded 'SourceLineTable'. * `SourceLineTable` is factored out line tables and `#sourceLocation` directive info, extracted from `SourceLocationConverter`. * `forEachLineLength` is now `forEachEndOfLine` which emits the absolute position of each end-of-line, instead of the line length, because the caller can easily derive the start-of-line position (i.e. the last end-of-line). * `#sourceLocation` info are now handled differently. Specifically, while traversing the syntax tree, it only collects the raw syntax, then post-process those info to produce the newly introduced `VirtualFile`. `VirtualFile` is a type that have enough infomation for `swift::SourceMamanger` in the compiler. Post-processing is needed because we want the start position of the _next_ line of the end of `#sourceLocation` directive, which might still not available when the first pass sees the directive. * In the future, the compiler shoud only use `SourceLineTable` instead of `SourceLocationConverter` as `swift::SourceManager` already know the file name and the whole source buffer.
1 parent 7aed63b commit 42cff3a

File tree

1 file changed

+406
-246
lines changed

1 file changed

+406
-246
lines changed

0 commit comments

Comments
 (0)