Start cleaning up tests (2/N)

Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: Ia29fe615ac8975252a34f1252c363109ee382d72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35508
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-14 22:27:37 +00:00
committed by Commit Bot service account
parent 7eaf4b57ae
commit 5180e16386
28 changed files with 389 additions and 678 deletions

View File

@@ -144,7 +144,7 @@ class TypesBuilder {
}
/// @param subtype the array element type
/// @param n the array size. 0 represents unbounded
/// @param n the array size. 0 represents a runtime-array.
/// @return the tint AST type for a array of size `n` of type `T`
type::Array* array(type::Type* subtype, uint32_t n) const {
return mod_->create<type::Array>(subtype, n, ArrayDecorationList{});
@@ -422,7 +422,7 @@ class Builder {
}
/// @param args the arguments for the array constructor
/// @return an `TypeConstructorExpression` of a 4x4 matrix of type
/// @return an `TypeConstructorExpression` of an array with element type
/// `T`, constructed with the values `args`.
template <typename T, int N = 0, typename... ARGS>
TypeConstructorExpression* array(ARGS&&... args) {
@@ -430,6 +430,19 @@ class Builder {
Source{}, ty.array<T, N>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array.
/// @param args the arguments for the array constructor
/// @return an `TypeConstructorExpression` of an array with element type
/// `subtype`, constructed with the values `args`.
template <typename... ARGS>
TypeConstructorExpression* array(type::Type* subtype,
uint32_t n,
ARGS&&... args) {
return create<TypeConstructorExpression>(
Source{}, ty.array(subtype, n), ExprList(std::forward<ARGS>(args)...));
}
/// @param name the variable name
/// @param storage the variable storage class
/// @param type the variable type