mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-11 06:29:11 +00:00
ast: Simplify SizeExprToString()
Clean up as recommended in review: https://dawn-review.googlesource.com/c/tint/+/66380/6/src/ast/array.cc#34 Change-Id: I70d66ab552de4a4a4d869aedd2f3c3d9f59d2712 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66603 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
9e631b1645
commit
8c9458271c
@ -26,12 +26,9 @@ namespace ast {
|
|||||||
namespace {
|
namespace {
|
||||||
// Returns the string representation of an array size expression.
|
// Returns the string representation of an array size expression.
|
||||||
std::string SizeExprToString(const ast::Expression* size,
|
std::string SizeExprToString(const ast::Expression* size,
|
||||||
const SymbolTable* symbols = nullptr) {
|
const SymbolTable& symbols) {
|
||||||
if (auto* ident = size->As<ast::IdentifierExpression>()) {
|
if (auto* ident = size->As<ast::IdentifierExpression>()) {
|
||||||
if (symbols) {
|
return symbols.NameFor(ident->symbol);
|
||||||
return symbols->NameFor(ident->symbol);
|
|
||||||
}
|
|
||||||
return "<unknown>";
|
|
||||||
}
|
}
|
||||||
if (auto* scalar = size->As<ast::ScalarConstructorExpression>()) {
|
if (auto* scalar = size->As<ast::ScalarConstructorExpression>()) {
|
||||||
auto* literal = scalar->literal->As<ast::IntLiteral>();
|
auto* literal = scalar->literal->As<ast::IntLiteral>();
|
||||||
@ -65,7 +62,7 @@ std::string Array::FriendlyName(const SymbolTable& symbols) const {
|
|||||||
}
|
}
|
||||||
out << "array<" << type->FriendlyName(symbols);
|
out << "array<" << type->FriendlyName(symbols);
|
||||||
if (!IsRuntimeArray()) {
|
if (!IsRuntimeArray()) {
|
||||||
out << ", " << SizeExprToString(count, &symbols);
|
out << ", " << SizeExprToString(count, symbols);
|
||||||
}
|
}
|
||||||
out << ">";
|
out << ">";
|
||||||
return out.str();
|
return out.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user