mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
wgsl parser: use new TypesBuilder factory functions, and set Source for ast::Type nodes
* ProgramBuilder: added a bunch of overloads that take Source * Added MultiTokenSource RAII helper to build source ranges for multi-token types * Added comparison operators to Source::Range and Source::Location to make it easier to write tests to compare Source ranges * Moved CombineSourceRange from resolver.cc to a static function in Source named Source::Combine() * Added Source tests for all ast type nodes returned by the wgsl parser Bug: tint:724 Change-Id: I6fb6211a3c42c14693df8746af6a30f5aa56f2af Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48963 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
a810d71df5
commit
4b16a160d5
@@ -84,13 +84,6 @@ class ScopedAssignment {
|
||||
T old_value_;
|
||||
};
|
||||
|
||||
// Helper function that returns the range union of two source locations. The
|
||||
// `start` and `end` locations are assumed to refer to the same source file.
|
||||
Source CombineSourceRange(const Source& start, const Source& end) {
|
||||
return Source(Source::Range(start.range.begin, end.range.end),
|
||||
start.file_path, start.file_content);
|
||||
}
|
||||
|
||||
bool IsValidStorageTextureDimension(ast::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
@@ -1392,7 +1385,7 @@ bool Resolver::ValidateVectorConstructor(const sem::Vector* vec_type,
|
||||
"attempted to construct '" +
|
||||
vec_type->FriendlyName(builder_->Symbols()) + "' with " +
|
||||
std::to_string(value_cardinality_sum) + " component(s)",
|
||||
CombineSourceRange(values_start, values_end));
|
||||
Source::Combine(values_start, values_end));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1414,7 +1407,7 @@ bool Resolver::ValidateMatrixConstructor(const sem::Matrix* matrix_type,
|
||||
VectorPretty(matrix_type->rows(), elem_type) + "' arguments in '" +
|
||||
matrix_type->FriendlyName(builder_->Symbols()) +
|
||||
"' constructor, found " + std::to_string(values.size()),
|
||||
CombineSourceRange(values_start, values_end));
|
||||
Source::Combine(values_start, values_end));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user