Migrate tint to use new parser constructor

The `tint::reader::wgsl::Parser` constructor is being migrated to taking a `tint::Source::File` pointer instead of a string. This help improve error messages by letting them refer to the source file locations.

Bug: tint:282
Change-Id: Ib21351f77fbaa10a07d096b38e51373be68ba424
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31562
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-11-02 14:17:14 +00:00 committed by Commit Bot service account
parent 0a374dce66
commit 6007963593
1 changed files with 6 additions and 3 deletions

View File

@ -164,7 +164,8 @@ namespace dawn_native {
errorStream << "Tint WGSL failure:" << std::endl; errorStream << "Tint WGSL failure:" << std::endl;
tint::Context context; tint::Context context;
tint::reader::wgsl::Parser parser(&context, source); tint::Source::File file("", source);
tint::reader::wgsl::Parser parser(&context, &file);
if (!parser.Parse()) { if (!parser.Parse()) {
errorStream << "Parser: " << parser.error() << std::endl; errorStream << "Parser: " << parser.error() << std::endl;
@ -197,7 +198,8 @@ namespace dawn_native {
errorStream << "Tint WGSL->SPIR-V failure:" << std::endl; errorStream << "Tint WGSL->SPIR-V failure:" << std::endl;
tint::Context context; tint::Context context;
tint::reader::wgsl::Parser parser(&context, source); tint::Source::File file("", source);
tint::reader::wgsl::Parser parser(&context, &file);
// TODO: This is a duplicate parse with ValidateWGSL, need to store // TODO: This is a duplicate parse with ValidateWGSL, need to store
// state between calls to avoid this. // state between calls to avoid this.
@ -240,7 +242,8 @@ namespace dawn_native {
errorStream << "Tint WGSL->SPIR-V failure:" << std::endl; errorStream << "Tint WGSL->SPIR-V failure:" << std::endl;
tint::Context context; tint::Context context;
tint::reader::wgsl::Parser parser(&context, source); tint::Source::File file("", source);
tint::reader::wgsl::Parser parser(&context, &file);
// TODO: This is a duplicate parse with ValidateWGSL, need to store // TODO: This is a duplicate parse with ValidateWGSL, need to store
// state between calls to avoid this. // state between calls to avoid this.