mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
(glslang) Further simplifications of InfoSink - get rid of message() and prefix() -
we want simple string concatenation/addition instead of all these layers
This commit is contained in:
parent
a2e525a1b6
commit
a176a935da
17
deps/glslang/glslang/glslang/Include/InfoSink.h
vendored
17
deps/glslang/glslang/glslang/Include/InfoSink.h
vendored
@ -76,17 +76,6 @@ public:
|
||||
TInfoSinkBase& operator<<(const TString& t) { append(t); return *this; }
|
||||
TInfoSinkBase& operator+(const char* s) { append(s); return *this; }
|
||||
const char* c_str() const { return sink.c_str(); }
|
||||
void prefix(TPrefixType message) {
|
||||
switch(message) {
|
||||
case EPrefixNone: break;
|
||||
case EPrefixWarning: append("WARNING: "); break;
|
||||
case EPrefixError: append("ERROR: "); break;
|
||||
case EPrefixInternalError: append("INTERNAL ERROR: "); break;
|
||||
case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;
|
||||
case EPrefixNote: append("NOTE: "); break;
|
||||
default: append("UNKNOWN ERROR: "); break;
|
||||
}
|
||||
}
|
||||
void location(const TSourceLoc& loc) {
|
||||
char locText[24];
|
||||
snprintf(locText, 24, ":%d", loc.line);
|
||||
@ -94,12 +83,6 @@ public:
|
||||
append(locText);
|
||||
append(": ");
|
||||
}
|
||||
void message(TPrefixType message, const char* s, const TSourceLoc& loc) {
|
||||
prefix(message);
|
||||
location(loc);
|
||||
append(s);
|
||||
append("\n");
|
||||
}
|
||||
|
||||
void append(const char* s);
|
||||
|
||||
|
@ -44,29 +44,6 @@ extern int yyparse(glslang::TParseContext*);
|
||||
|
||||
namespace glslang {
|
||||
|
||||
//
|
||||
// Used to output syntax, parsing, and semantic errors.
|
||||
//
|
||||
|
||||
void TParseContextBase::outputMessage(const TSourceLoc& loc, const char* szReason,
|
||||
const char* szToken,
|
||||
const char* szExtraInfoFormat,
|
||||
TPrefixType prefix, va_list args)
|
||||
{
|
||||
const int maxSize = MaxTokenLength + 200;
|
||||
char szExtraInfo[maxSize];
|
||||
|
||||
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
|
||||
|
||||
infoSink.info.prefix(prefix);
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
|
||||
|
||||
if (prefix == EPrefixError) {
|
||||
++numErrors;
|
||||
}
|
||||
}
|
||||
|
||||
void C_DECL TParseContextBase::error(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
@ -74,7 +51,13 @@ void C_DECL TParseContextBase::error(const TSourceLoc& loc, const char* szReason
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
const int maxSize = MaxTokenLength + 200;
|
||||
char szExtraInfo[maxSize];
|
||||
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
|
||||
++numErrors;
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
@ -88,7 +71,12 @@ void C_DECL TParseContextBase::warn(const TSourceLoc& loc, const char* szReason,
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
const int maxSize = MaxTokenLength + 200;
|
||||
char szExtraInfo[maxSize];
|
||||
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -97,7 +85,13 @@ void C_DECL TParseContextBase::ppError(const TSourceLoc& loc, const char* szReas
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
const int maxSize = MaxTokenLength + 200;
|
||||
char szExtraInfo[maxSize];
|
||||
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
|
||||
++numErrors;
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
@ -109,7 +103,12 @@ void C_DECL TParseContextBase::ppWarn(const TSourceLoc& loc, const char* szReaso
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
const int maxSize = MaxTokenLength + 200;
|
||||
char szExtraInfo[maxSize];
|
||||
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
@ -220,9 +220,6 @@ protected:
|
||||
virtual const char* getGlobalUniformBlockName() const { return ""; }
|
||||
virtual void setUniformBlockDefaults(TType&) const { }
|
||||
virtual void finalizeGlobalUniformBlockLayout(TVariable&) { }
|
||||
virtual void outputMessage(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, TPrefixType prefix,
|
||||
va_list args);
|
||||
virtual void trackLinkage(TSymbol& symbol);
|
||||
virtual void makeEditable(TSymbol*&);
|
||||
virtual TVariable* getEditableVariable(const char* name);
|
||||
|
@ -1506,7 +1506,10 @@ int TScanContext::tokenizeIdentifier()
|
||||
}
|
||||
|
||||
default:
|
||||
_parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
|
||||
_parseContext.infoSink.info.append("INTERNAL ERROR: ");
|
||||
_parseContext.infoSink.info.location(loc);
|
||||
_parseContext.infoSink.info.append("Unknown glslang keyword");
|
||||
_parseContext.infoSink.info.append("\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1101,7 +1101,7 @@ struct DoPreprocessing {
|
||||
bool success = true;
|
||||
if (_parseContext.getNumErrors() > 0) {
|
||||
success = false;
|
||||
_parseContext.infoSink.info.prefix(EPrefixError);
|
||||
_parseContext.infoSink.info.append("ERROR: ");
|
||||
_parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
|
||||
}
|
||||
return success;
|
||||
@ -1132,7 +1132,7 @@ struct DoFullParse{
|
||||
else
|
||||
success = intermediate.postProcess(intermediate.getTreeRoot(), _parseContext.getLanguage());
|
||||
} else if (! success) {
|
||||
_parseContext.infoSink.info.prefix(EPrefixError);
|
||||
_parseContext.infoSink.info.append("ERROR: ");
|
||||
_parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,10 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
|
||||
for (int i = 0; i < numExtensions; ++i) {
|
||||
switch (getExtensionBehavior(extensions[i])) {
|
||||
case EBhWarn:
|
||||
infoSink.info.message(EPrefixWarning, ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), loc);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info.append(("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str());
|
||||
infoSink.info.append("\n");
|
||||
// fall through
|
||||
case EBhRequire:
|
||||
case EBhEnable:
|
||||
@ -562,8 +565,13 @@ void TParseVersions::checkDeprecated(const TSourceLoc& loc, int profileMask, int
|
||||
if (forwardCompatible)
|
||||
error(loc, "deprecated, may be removed in future release", featureDesc, "");
|
||||
else if (! suppressWarnings())
|
||||
infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " +
|
||||
String(depVersion) + "; may be removed in future release").c_str(), loc);
|
||||
{
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info.append((TString(featureDesc) + " deprecated in version " +
|
||||
String(depVersion) + "; may be removed in future release").c_str());
|
||||
infoSink.info.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -605,11 +613,17 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
|
||||
for (int i = 0; i < numExtensions; ++i) {
|
||||
TExtensionBehavior behavior = getExtensionBehavior(extensions[i]);
|
||||
if (behavior == EBhDisable && relaxedErrors()) {
|
||||
infoSink.info.message(EPrefixWarning, "The following extension must be enabled to use this feature:", loc);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info.append("The following extension must be enabled to use this feature:");
|
||||
infoSink.info.append("\n");
|
||||
behavior = EBhWarn;
|
||||
}
|
||||
if (behavior == EBhWarn) {
|
||||
infoSink.info.message(EPrefixWarning, ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), loc);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info.location(loc);
|
||||
infoSink.info.append(("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str());
|
||||
infoSink.info.append("\n");
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
|
@ -1251,7 +1251,10 @@ static void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const
|
||||
}
|
||||
break;
|
||||
default:
|
||||
out.info.message(EPrefixInternalError, "Unknown constant", node->getLoc());
|
||||
out.info.append("INTERNAL ERROR: ");
|
||||
out.info.location(node->getLoc());
|
||||
out.info.append("Unknown constant");
|
||||
out.info.append("\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace glslang {
|
||||
//
|
||||
void TIntermediate::error(TInfoSink& infoSink, const char* message)
|
||||
{
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
|
||||
|
||||
++numErrors;
|
||||
@ -64,7 +64,7 @@ void TIntermediate::error(TInfoSink& infoSink, const char* message)
|
||||
// Link-time warning.
|
||||
void TIntermediate::warn(TInfoSink& infoSink, const char* message)
|
||||
{
|
||||
infoSink.info.prefix(EPrefixWarning);
|
||||
infoSink.info.append("WARNING: ");
|
||||
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
// compile-time or link-time error to have different values specified for the stride for the same buffer."
|
||||
if (xfbBuffers[b].stride != TQualifier::layoutXfbStrideEnd && xfbBuffers[b].implicitStride > xfbBuffers[b].stride) {
|
||||
error(infoSink, "xfb_stride is too small to hold all buffer entries:");
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info << " xfb_buffer " << (unsigned int)b << ", xfb_stride " << xfbBuffers[b].stride << ", minimum stride needed: " << xfbBuffers[b].implicitStride << "\n";
|
||||
}
|
||||
if (xfbBuffers[b].stride == TQualifier::layoutXfbStrideEnd)
|
||||
@ -446,11 +446,11 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
// multiple of 4, or a compile-time or link-time error results."
|
||||
if (xfbBuffers[b].containsDouble && ! IsMultipleOfPow2(xfbBuffers[b].stride, 8)) {
|
||||
error(infoSink, "xfb_stride must be multiple of 8 for buffer holding a double:");
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info << " xfb_buffer " << (unsigned int)b << ", xfb_stride " << xfbBuffers[b].stride << "\n";
|
||||
} else if (! IsMultipleOfPow2(xfbBuffers[b].stride, 4)) {
|
||||
error(infoSink, "xfb_stride must be multiple of 4:");
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info << " xfb_buffer " << (unsigned int)b << ", xfb_stride " << xfbBuffers[b].stride << "\n";
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
|
||||
// implementation-dependent constant gl_MaxTransformFeedbackInterleavedComponents."
|
||||
if (xfbBuffers[b].stride > (unsigned int)(4 * resources.maxTransformFeedbackInterleavedComponents)) {
|
||||
error(infoSink, "xfb_stride is too large:");
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info.append("ERROR: ");
|
||||
infoSink.info << " xfb_buffer " << (unsigned int)b << ", components (1/4 stride) needed are " << xfbBuffers[b].stride/4 << ", gl_MaxTransformFeedbackInterleavedComponents is " << resources.maxTransformFeedbackInterleavedComponents << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -855,7 +855,10 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
|
||||
return keyword;
|
||||
|
||||
default:
|
||||
_parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
|
||||
_parseContext.infoSink.info.append("INTERNAL ERROR: ");
|
||||
_parseContext.infoSink.info.location(loc);
|
||||
_parseContext.infoSink.info.append("Unknown glslang keyword");
|
||||
_parseContext.infoSink.info.append("\n");
|
||||
return EHTokNone;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user