1 | // |
---|---|
2 | // Copyright (c) 2002-2010 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 | if (type.isArray()) |
52 | { |
53 | for (auto arraySizeIter = type.getArraySizes()->rbegin(); |
54 | arraySizeIter != type.getArraySizes()->rend(); ++arraySizeIter) |
55 | { |
56 | *this << "array["<< (*arraySizeIter) << "] of "; |
57 | } |
58 | } |
59 | if (type.isMatrix()) |
60 | { |
61 | *this << type.getCols() << "X"<< type.getRows() << " matrix of "; |
62 | } |
63 | else if (type.isVector()) |
64 | *this << type.getNominalSize() << "-component vector of "; |
65 | |
66 | sink.append(type.getBasicString()); |
67 | return *this; |
68 | } |
69 | |
70 | void TInfoSinkBase::location(int file, int line) |
71 | { |
72 | TPersistStringStream stream = sh::InitializeStream<TPersistStringStream>(); |
73 | if (line) |
74 | stream << file << ":"<< line; |
75 | else |
76 | stream << file << ":? "; |
77 | stream << ": "; |
78 | |
79 | sink.append(stream.str()); |
80 | } |
81 | |
82 | } // namespace sh |
83 |