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/InfoSink.h"
8 :
9 0 : void TInfoSinkBase::prefix(TPrefixType message) {
10 0 : switch(message) {
11 : case EPrefixNone:
12 0 : break;
13 : case EPrefixWarning:
14 0 : sink.append("WARNING: ");
15 0 : break;
16 : case EPrefixError:
17 0 : sink.append("ERROR: ");
18 0 : break;
19 : case EPrefixInternalError:
20 0 : sink.append("INTERNAL ERROR: ");
21 0 : break;
22 : case EPrefixUnimplemented:
23 0 : sink.append("UNIMPLEMENTED: ");
24 0 : break;
25 : case EPrefixNote:
26 0 : sink.append("NOTE: ");
27 0 : break;
28 : default:
29 0 : sink.append("UNKOWN ERROR: ");
30 0 : break;
31 : }
32 0 : }
33 :
34 0 : void TInfoSinkBase::location(TSourceLoc loc) {
35 0 : int string = 0, line = 0;
36 0 : DecodeSourceLoc(loc, &string, &line);
37 :
38 0 : TPersistStringStream stream;
39 0 : if (line)
40 0 : stream << string << ":" << line;
41 : else
42 0 : stream << string << ":? ";
43 0 : stream << ": ";
44 :
45 0 : sink.append(stream.str());
46 0 : }
47 :
48 0 : void TInfoSinkBase::message(TPrefixType message, const char* s) {
49 0 : prefix(message);
50 0 : sink.append(s);
51 0 : sink.append("\n");
52 0 : }
53 :
54 0 : void TInfoSinkBase::message(TPrefixType message, const char* s, TSourceLoc loc) {
55 0 : prefix(message);
56 0 : location(loc);
57 0 : sink.append(s);
58 0 : sink.append("\n");
59 0 : }
|