From 6eda12a55dea3f34d2938ba4493e9f6d0fcb3c96 Mon Sep 17 00:00:00 2001 From: James Price Date: Mon, 15 Mar 2021 17:35:02 +0000 Subject: [PATCH] [wgsl-writer] Use EmitDecorations() for function parameters Removes some duplicated code. Change-Id: I05120e5f443810e54babb842f0f993e4e0a7da79 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44603 Commit-Queue: James Price Reviewed-by: Ben Clayton --- src/writer/wgsl/generator_impl.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 273f934fd2..814dbf2d37 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -309,15 +309,11 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) { } first = false; - for (auto* deco : v->decorations()) { - out_ << "[["; - if (auto* builtin = deco->As()) { - out_ << "builtin(" << builtin->value() << ")"; + if (!v->decorations().empty()) { + if (!EmitDecorations(v->decorations())) { + return false; } - if (auto* location = deco->As()) { - out_ << "location(" << location->value() << ")"; - } - out_ << "]] "; + out_ << " "; } out_ << program_->Symbols().NameFor(v->symbol()) << " : ";