Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/compiler/translator/InfoSink.cpp
1693 views
1
//
2
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
#include "compiler/translator/InfoSink.h"
8
9
#include "compiler/translator/ImmutableString.h"
10
#include "compiler/translator/Types.h"
11
12
namespace sh
13
{
14
15
void TInfoSinkBase::prefix(Severity severity)
16
{
17
switch (severity)
18
{
19
case SH_WARNING:
20
sink.append("WARNING: ");
21
break;
22
case SH_ERROR:
23
sink.append("ERROR: ");
24
break;
25
default:
26
sink.append("UNKOWN ERROR: ");
27
break;
28
}
29
}
30
31
TInfoSinkBase &TInfoSinkBase::operator<<(const ImmutableString &str)
32
{
33
sink.append(str.data());
34
return *this;
35
}
36
37
TInfoSinkBase &TInfoSinkBase::operator<<(const TType &type)
38
{
39
if (type.isInvariant())
40
sink.append("invariant ");
41
if (type.getQualifier() != EvqTemporary && type.getQualifier() != EvqGlobal)
42
{
43
sink.append(type.getQualifierString());
44
sink.append(" ");
45
}
46
if (type.getPrecision() != EbpUndefined)
47
{
48
sink.append(type.getPrecisionString());
49
sink.append(" ");
50
}
51
52
const TMemoryQualifier &memoryQualifier = type.getMemoryQualifier();
53
if (memoryQualifier.readonly)
54
{
55
sink.append("readonly ");
56
}
57
if (memoryQualifier.writeonly)
58
{
59
sink.append("writeonly ");
60
}
61
if (memoryQualifier.coherent)
62
{
63
sink.append("coherent ");
64
}
65
if (memoryQualifier.restrictQualifier)
66
{
67
sink.append("restrict ");
68
}
69
if (memoryQualifier.volatileQualifier)
70
{
71
sink.append("volatile ");
72
}
73
74
if (type.isArray())
75
{
76
for (auto arraySizeIter = type.getArraySizes().rbegin();
77
arraySizeIter != type.getArraySizes().rend(); ++arraySizeIter)
78
{
79
*this << "array[" << (*arraySizeIter) << "] of ";
80
}
81
}
82
if (type.isMatrix())
83
{
84
*this << type.getCols() << "X" << type.getRows() << " matrix of ";
85
}
86
else if (type.isVector())
87
*this << type.getNominalSize() << "-component vector of ";
88
89
sink.append(type.getBasicString());
90
return *this;
91
}
92
93
void TInfoSinkBase::location(int file, int line)
94
{
95
TPersistStringStream stream = sh::InitializeStream<TPersistStringStream>();
96
if (line)
97
stream << file << ":" << line;
98
else
99
stream << file << ":? ";
100
stream << ": ";
101
102
sink.append(stream.str());
103
}
104
105
} // namespace sh
106
107