mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
ProgramBuilder: Tweak Return() signature
Instead of directly fowarding to ReturnStatement, pass the parameter through `Expr()`.
Also add a no-arg overload.
This means we can write `Return(1);`, `Return("a")`, `Return()`
Change-Id: I8f5df630f540f9cecdf82d24e2810a0844e025e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48046
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
a0cf62f415
commit
49668bbe17
@@ -1149,12 +1149,16 @@ class ProgramBuilder {
|
|||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an ast::ReturnStatement with the input args
|
/// Creates an ast::ReturnStatement with no return value
|
||||||
/// @param args arguments to construct a return statement with
|
|
||||||
/// @returns the return statement pointer
|
/// @returns the return statement pointer
|
||||||
template <typename... Args>
|
ast::ReturnStatement* Return() { return create<ast::ReturnStatement>(); }
|
||||||
ast::ReturnStatement* Return(Args&&... args) {
|
|
||||||
return create<ast::ReturnStatement>(std::forward<Args>(args)...);
|
/// Creates an ast::ReturnStatement with the given return value
|
||||||
|
/// @param val the return value
|
||||||
|
/// @returns the return statement pointer
|
||||||
|
template <typename EXPR>
|
||||||
|
ast::ReturnStatement* Return(EXPR&& val) {
|
||||||
|
return create<ast::ReturnStatement>(Expr(std::forward<EXPR>(val)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a ast::Struct and type::Struct, registering the type::Struct with
|
/// Creates a ast::Struct and type::Struct, registering the type::Struct with
|
||||||
|
|||||||
Reference in New Issue
Block a user