Hash :
1ae273ee
Author :
Date :
2025-08-27T10:47:59
Translator: Output struct members in OutputTree Bug: chromium:438038775 Change-Id: I2a1bed5207b1b2c26f20ee9ebd80fb00ec803bc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6891072 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
//
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/InfoSink.h"
#include "compiler/translator/ImmutableString.h"
#include "compiler/translator/Symbol.h"
#include "compiler/translator/Types.h"
namespace sh
{
void TInfoSinkBase::prefix(Severity severity)
{
switch (severity)
{
case SH_WARNING:
sink.append("WARNING: ");
break;
case SH_ERROR:
sink.append("ERROR: ");
break;
default:
sink.append("UNKOWN ERROR: ");
break;
}
}
TInfoSinkBase &TInfoSinkBase::operator<<(const ImmutableString &str)
{
sink.append(str.data());
return *this;
}
TInfoSinkBase &TInfoSinkBase::operator<<(const TType &type)
{
if (type.isInvariant())
sink.append("invariant ");
if (type.getQualifier() != EvqTemporary && type.getQualifier() != EvqGlobal)
{
sink.append(type.getQualifierString());
sink.append(" ");
}
if (type.getPrecision() != EbpUndefined)
{
sink.append(type.getPrecisionString());
sink.append(" ");
}
const TMemoryQualifier &memoryQualifier = type.getMemoryQualifier();
if (memoryQualifier.readonly)
{
sink.append("readonly ");
}
if (memoryQualifier.writeonly)
{
sink.append("writeonly ");
}
if (memoryQualifier.coherent)
{
sink.append("coherent ");
}
if (memoryQualifier.restrictQualifier)
{
sink.append("restrict ");
}
if (memoryQualifier.volatileQualifier)
{
sink.append("volatile ");
}
if (type.isArray())
{
for (auto arraySizeIter = type.getArraySizes().rbegin();
arraySizeIter != type.getArraySizes().rend(); ++arraySizeIter)
{
*this << "array[" << (*arraySizeIter) << "] of ";
}
}
if (type.isMatrix())
{
*this << static_cast<uint32_t>(type.getCols()) << "X"
<< static_cast<uint32_t>(type.getRows()) << " matrix of ";
}
else if (type.isVector())
*this << static_cast<uint32_t>(type.getNominalSize()) << "-component vector of ";
sink.append(type.getBasicString());
if (type.getStruct() != nullptr)
{
*this << ' ' << static_cast<const TSymbol &>(*type.getStruct());
if (type.isStructSpecifier())
{
*this << " (specifier)";
}
}
return *this;
}
TInfoSinkBase &TInfoSinkBase::operator<<(const TSymbol &symbol)
{
switch (symbol.symbolType())
{
case SymbolType::BuiltIn:
*this << symbol.name();
break;
case SymbolType::Empty:
*this << "''";
break;
case SymbolType::AngleInternal:
*this << '#' << symbol.name();
break;
case SymbolType::UserDefined:
*this << '\'' << symbol.name() << '\'';
break;
}
*this << " (symbol id " << symbol.uniqueId().get() << ")";
return *this;
}
TInfoSinkBase &TInfoSinkBase::operator<<(const TField &field)
{
ASSERT(field.symbolType() != SymbolType::Empty);
switch (field.symbolType())
{
case SymbolType::BuiltIn:
*this << field.name();
break;
case SymbolType::AngleInternal:
*this << '#' << field.name();
break;
case SymbolType::UserDefined:
*this << '\'' << field.name() << '\'';
break;
default:
UNREACHABLE();
}
return *this;
}
void TInfoSinkBase::location(int file, int line)
{
TPersistStringStream stream = sh::InitializeStream<TPersistStringStream>();
if (line)
stream << file << ":" << line;
else
stream << file << ":? ";
stream << ": ";
sink.append(stream.str());
}
} // namespace sh