1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/Diagnostics.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +// 1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#include "compiler/Diagnostics.h" 1.11 + 1.12 +#include "compiler/compiler_debug.h" 1.13 +#include "compiler/InfoSink.h" 1.14 +#include "compiler/preprocessor/SourceLocation.h" 1.15 + 1.16 +TDiagnostics::TDiagnostics(TInfoSink& infoSink) : 1.17 + mInfoSink(infoSink), 1.18 + mNumErrors(0), 1.19 + mNumWarnings(0) 1.20 +{ 1.21 +} 1.22 + 1.23 +TDiagnostics::~TDiagnostics() 1.24 +{ 1.25 +} 1.26 + 1.27 +void TDiagnostics::writeInfo(Severity severity, 1.28 + const pp::SourceLocation& loc, 1.29 + const std::string& reason, 1.30 + const std::string& token, 1.31 + const std::string& extra) 1.32 +{ 1.33 + TPrefixType prefix = EPrefixNone; 1.34 + switch (severity) 1.35 + { 1.36 + case ERROR: 1.37 + ++mNumErrors; 1.38 + prefix = EPrefixError; 1.39 + break; 1.40 + case WARNING: 1.41 + ++mNumWarnings; 1.42 + prefix = EPrefixWarning; 1.43 + break; 1.44 + default: 1.45 + UNREACHABLE(); 1.46 + break; 1.47 + } 1.48 + 1.49 + TInfoSinkBase& sink = mInfoSink.info; 1.50 + /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ 1.51 + sink.prefix(prefix); 1.52 + sink.location(loc.file, loc.line); 1.53 + sink << "'" << token << "' : " << reason << " " << extra << "\n"; 1.54 +} 1.55 + 1.56 +void TDiagnostics::writeDebug(const std::string& str) 1.57 +{ 1.58 + mInfoSink.debug << str; 1.59 +} 1.60 + 1.61 +void TDiagnostics::print(ID id, 1.62 + const pp::SourceLocation& loc, 1.63 + const std::string& text) 1.64 +{ 1.65 + writeInfo(severity(id), loc, message(id), text, ""); 1.66 +}