daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 7 | #include "compiler/InfoSink.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8 | |
alokp@chromium.org | 4e4facd | 2010-06-02 15:21:22 +0000 | [diff] [blame^] | 9 | void TInfoSinkBase::prefix(TPrefixType message) { |
| 10 | switch(message) { |
| 11 | case EPrefixNone: |
| 12 | break; |
| 13 | case EPrefixWarning: |
| 14 | sink.append("WARNING: "); |
| 15 | break; |
| 16 | case EPrefixError: |
| 17 | sink.append("ERROR: "); |
| 18 | break; |
| 19 | case EPrefixInternalError: |
| 20 | sink.append("INTERNAL ERROR: "); |
| 21 | break; |
| 22 | case EPrefixUnimplemented: |
| 23 | sink.append("UNIMPLEMENTED: "); |
| 24 | break; |
| 25 | case EPrefixNote: |
| 26 | sink.append("NOTE: "); |
| 27 | break; |
| 28 | default: |
| 29 | sink.append("UNKOWN ERROR: "); |
| 30 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 31 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 32 | } |
| 33 | |
alokp@chromium.org | 4e4facd | 2010-06-02 15:21:22 +0000 | [diff] [blame^] | 34 | void TInfoSinkBase::location(TSourceLoc loc) { |
| 35 | int string = loc >> SourceLocStringShift; |
| 36 | int line = loc & SourceLocLineMask; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | |
alokp@chromium.org | 4e4facd | 2010-06-02 15:21:22 +0000 | [diff] [blame^] | 38 | TPersistStringStream stream; |
| 39 | if (line) |
| 40 | stream << string << ":" << line; |
| 41 | else |
| 42 | stream << string << ":? "; |
| 43 | stream << ": "; |
| 44 | |
| 45 | sink.append(stream.str()); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 46 | } |
| 47 | |
alokp@chromium.org | 4e4facd | 2010-06-02 15:21:22 +0000 | [diff] [blame^] | 48 | void TInfoSinkBase::message(TPrefixType message, const char* s) { |
| 49 | prefix(message); |
| 50 | sink.append(s); |
| 51 | sink.append("\n"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | } |
| 53 | |
alokp@chromium.org | 4e4facd | 2010-06-02 15:21:22 +0000 | [diff] [blame^] | 54 | void TInfoSinkBase::message(TPrefixType message, const char* s, TSourceLoc loc) { |
| 55 | prefix(message); |
| 56 | location(loc); |
| 57 | sink.append(s); |
| 58 | sink.append("\n"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 59 | } |