mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
[wgsl-reader] Allow decorations on function return types
Add a return type decoration list field to ast::Function. Bug: tint:513 Change-Id: I41c1087f21a87731eb48ec7642997da5ae7f2baa Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44601 Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
20a438a5c3
commit
feecbe0d83
@@ -28,13 +28,15 @@ Function::Function(const Source& source,
|
||||
VariableList params,
|
||||
type::Type* return_type,
|
||||
BlockStatement* body,
|
||||
DecorationList decorations)
|
||||
DecorationList decorations,
|
||||
DecorationList return_type_decorations)
|
||||
: Base(source),
|
||||
symbol_(symbol),
|
||||
params_(std::move(params)),
|
||||
return_type_(return_type),
|
||||
body_(body),
|
||||
decorations_(std::move(decorations)) {
|
||||
decorations_(std::move(decorations)),
|
||||
return_type_decorations_(std::move(return_type_decorations)) {
|
||||
for (auto* param : params_) {
|
||||
TINT_ASSERT(param);
|
||||
}
|
||||
@@ -77,7 +79,8 @@ Function* Function::Clone(CloneContext* ctx) const {
|
||||
auto* ret = ctx->Clone(return_type_);
|
||||
auto* b = ctx->Clone(body_);
|
||||
auto decos = ctx->Clone(decorations_);
|
||||
return ctx->dst->create<Function>(src, sym, p, ret, b, decos);
|
||||
auto ret_decos = ctx->Clone(return_type_decorations_);
|
||||
return ctx->dst->create<Function>(src, sym, p, ret, b, decos, ret_decos);
|
||||
}
|
||||
|
||||
void Function::to_str(const semantic::Info& sem,
|
||||
|
||||
@@ -42,12 +42,14 @@ class Function : public Castable<Function, Node> {
|
||||
/// @param return_type the return type
|
||||
/// @param body the function body
|
||||
/// @param decorations the function decorations
|
||||
/// @param return_type_decorations the return type decorations
|
||||
Function(const Source& source,
|
||||
Symbol symbol,
|
||||
VariableList params,
|
||||
type::Type* return_type,
|
||||
BlockStatement* body,
|
||||
DecorationList decorations);
|
||||
DecorationList decorations,
|
||||
DecorationList return_type_decorations);
|
||||
/// Move constructor
|
||||
Function(Function&&);
|
||||
|
||||
@@ -74,6 +76,11 @@ class Function : public Castable<Function, Node> {
|
||||
/// @returns the function return type.
|
||||
type::Type* return_type() const { return return_type_; }
|
||||
|
||||
/// @returns the decorations attached to the function return type.
|
||||
const DecorationList& return_type_decorations() const {
|
||||
return return_type_decorations_;
|
||||
}
|
||||
|
||||
/// @returns a pointer to the last statement of the function or nullptr if
|
||||
// function is empty
|
||||
const Statement* get_last_statement() const;
|
||||
@@ -108,6 +115,7 @@ class Function : public Castable<Function, Node> {
|
||||
type::Type* const return_type_;
|
||||
BlockStatement* const body_;
|
||||
DecorationList const decorations_;
|
||||
DecorationList const return_type_decorations_;
|
||||
};
|
||||
|
||||
/// A list of functions
|
||||
|
||||
Reference in New Issue
Block a user