mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 05:27:49 +00:00
tests: Use ProgramBuilder helpers where we can
A general code cleanup Change-Id: Ib251ca2d4b71f75736bdba8b4255965593a76c31 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48680 Auto-Submit: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
261642e4e3
commit
43073d8aa3
@@ -1203,10 +1203,26 @@ class ProgramBuilder {
|
||||
return func;
|
||||
}
|
||||
|
||||
/// Creates an ast::ReturnStatement with no return value
|
||||
/// @param source the source information
|
||||
/// @returns the return statement pointer
|
||||
ast::ReturnStatement* Return(const Source& source) {
|
||||
return create<ast::ReturnStatement>(source);
|
||||
}
|
||||
|
||||
/// Creates an ast::ReturnStatement with no return value
|
||||
/// @returns the return statement pointer
|
||||
ast::ReturnStatement* Return() { return create<ast::ReturnStatement>(); }
|
||||
|
||||
/// Creates an ast::ReturnStatement with the given return value
|
||||
/// @param source the source information
|
||||
/// @param val the return value
|
||||
/// @returns the return statement pointer
|
||||
template <typename EXPR>
|
||||
ast::ReturnStatement* Return(const Source& source, EXPR&& val) {
|
||||
return create<ast::ReturnStatement>(source, Expr(std::forward<EXPR>(val)));
|
||||
}
|
||||
|
||||
/// Creates an ast::ReturnStatement with the given return value
|
||||
/// @param val the return value
|
||||
/// @returns the return statement pointer
|
||||
@@ -1330,6 +1346,20 @@ class ProgramBuilder {
|
||||
std::forward<ELSE_STATEMENTS>(elseStatements)...});
|
||||
}
|
||||
|
||||
/// Creates a ast::AssignmentStatement with input lhs and rhs expressions
|
||||
/// @param source the source information
|
||||
/// @param lhs the left hand side expression initializer
|
||||
/// @param rhs the right hand side expression initializer
|
||||
/// @returns the assignment statement pointer
|
||||
template <typename LhsExpressionInit, typename RhsExpressionInit>
|
||||
ast::AssignmentStatement* Assign(const Source& source,
|
||||
LhsExpressionInit&& lhs,
|
||||
RhsExpressionInit&& rhs) {
|
||||
return create<ast::AssignmentStatement>(
|
||||
source, Expr(std::forward<LhsExpressionInit>(lhs)),
|
||||
Expr(std::forward<RhsExpressionInit>(rhs)));
|
||||
}
|
||||
|
||||
/// Creates a ast::AssignmentStatement with input lhs and rhs expressions
|
||||
/// @param lhs the left hand side expression initializer
|
||||
/// @param rhs the right hand side expression initializer
|
||||
@@ -1351,6 +1381,14 @@ class ProgramBuilder {
|
||||
return create<ast::LoopStatement>(body, continuing);
|
||||
}
|
||||
|
||||
/// Creates a ast::VariableDeclStatement for the input variable
|
||||
/// @param source the source information
|
||||
/// @param var the variable to wrap in a decl statement
|
||||
/// @returns the variable decl statement pointer
|
||||
ast::VariableDeclStatement* Decl(const Source& source, ast::Variable* var) {
|
||||
return create<ast::VariableDeclStatement>(source, var);
|
||||
}
|
||||
|
||||
/// Creates a ast::VariableDeclStatement for the input variable
|
||||
/// @param var the variable to wrap in a decl statement
|
||||
/// @returns the variable decl statement pointer
|
||||
|
||||
Reference in New Issue
Block a user