Path: blob/main_old/src/compiler/translator/InfoSink.cpp
1693 views
//1// Copyright 2002 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#include "compiler/translator/InfoSink.h"78#include "compiler/translator/ImmutableString.h"9#include "compiler/translator/Types.h"1011namespace sh12{1314void TInfoSinkBase::prefix(Severity severity)15{16switch (severity)17{18case SH_WARNING:19sink.append("WARNING: ");20break;21case SH_ERROR:22sink.append("ERROR: ");23break;24default:25sink.append("UNKOWN ERROR: ");26break;27}28}2930TInfoSinkBase &TInfoSinkBase::operator<<(const ImmutableString &str)31{32sink.append(str.data());33return *this;34}3536TInfoSinkBase &TInfoSinkBase::operator<<(const TType &type)37{38if (type.isInvariant())39sink.append("invariant ");40if (type.getQualifier() != EvqTemporary && type.getQualifier() != EvqGlobal)41{42sink.append(type.getQualifierString());43sink.append(" ");44}45if (type.getPrecision() != EbpUndefined)46{47sink.append(type.getPrecisionString());48sink.append(" ");49}5051const TMemoryQualifier &memoryQualifier = type.getMemoryQualifier();52if (memoryQualifier.readonly)53{54sink.append("readonly ");55}56if (memoryQualifier.writeonly)57{58sink.append("writeonly ");59}60if (memoryQualifier.coherent)61{62sink.append("coherent ");63}64if (memoryQualifier.restrictQualifier)65{66sink.append("restrict ");67}68if (memoryQualifier.volatileQualifier)69{70sink.append("volatile ");71}7273if (type.isArray())74{75for (auto arraySizeIter = type.getArraySizes().rbegin();76arraySizeIter != type.getArraySizes().rend(); ++arraySizeIter)77{78*this << "array[" << (*arraySizeIter) << "] of ";79}80}81if (type.isMatrix())82{83*this << type.getCols() << "X" << type.getRows() << " matrix of ";84}85else if (type.isVector())86*this << type.getNominalSize() << "-component vector of ";8788sink.append(type.getBasicString());89return *this;90}9192void TInfoSinkBase::location(int file, int line)93{94TPersistStringStream stream = sh::InitializeStream<TPersistStringStream>();95if (line)96stream << file << ":" << line;97else98stream << file << ":? ";99stream << ": ";100101sink.append(stream.str());102}103104} // namespace sh105106107