Source: Restructure Source::File

Add Source::FileContent to hold the file source content and per-line data.

Have Source hold an optional pointer to a FileContent, and add a file_path field.

This allows us to kill the `FreeInternalCompilerErrors()` filth as we're now able to construct Sources that hold a file path without file content.

Change-Id: I03556795d7d4161c3d34cef32cb685c45ad04a3d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42026
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-02-18 21:40:19 +00:00
committed by Commit Bot service account
parent 41e58d89ea
commit 1d98236770
13 changed files with 142 additions and 159 deletions

View File

@@ -30,9 +30,10 @@ std::vector<std::string> split_lines(const std::string& str) {
}
} // namespace
Source::File::File(const std::string& file_path,
const std::string& file_content)
: path(file_path), content(file_content), lines(split_lines(content)) {}
Source::FileContent::FileContent(const std::string& body)
: data(body), lines(split_lines(body)) {}
Source::FileContent::~FileContent() = default;
Source::File::~File() = default;