зеркало из https://github.com/stride3d/xkslang.git
Non-functional: Rationalizing parse helper hierarchy, step 2 (effected error messaging and cascading errors).
This commit is contained in:
Родитель
273060c2d3
Коммит
a2a5dd474e
|
@ -2,5 +2,5 @@
|
|||
// For the version, it uses the latest git tag followed by the number of commits.
|
||||
// For the date, it uses the current date (when then script is run).
|
||||
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1546"
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1547"
|
||||
#define GLSLANG_DATE "01-Oct-2016"
|
||||
|
|
|
@ -36,12 +36,83 @@
|
|||
|
||||
// Implement the TParseContextBase class.
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
#include "ParseHelper.h"
|
||||
|
||||
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, ...)
|
||||
{
|
||||
if (messages & EShMsgOnlyPreprocessor)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
currentScanner->setEndOfInput();
|
||||
}
|
||||
|
||||
void C_DECL TParseContextBase::warn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
if (suppressWarnings())
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void C_DECL TParseContextBase::ppError(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
currentScanner->setEndOfInput();
|
||||
}
|
||||
|
||||
void C_DECL TParseContextBase::ppWarn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// Select the best matching function for 'call' from 'candidateList'.
|
||||
//
|
||||
// Assumptions
|
||||
|
@ -235,7 +306,6 @@ bool TParseContextBase::insertGlobalUniformBlock()
|
|||
}
|
||||
|
||||
return inserted;
|
||||
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "Scan.h"
|
||||
|
||||
#include "../OSDependent/osinclude.h"
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
#include "preprocessor/PpContext.h"
|
||||
|
@ -362,81 +361,6 @@ bool TParseContext::parseVectorFields(const TSourceLoc& loc, const TString& comp
|
|||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Errors
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Used to output syntax, parsing, and semantic errors.
|
||||
//
|
||||
|
||||
void TParseContext::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 TParseContext::error(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
if (messages & EShMsgOnlyPreprocessor)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
currentScanner->setEndOfInput();
|
||||
}
|
||||
|
||||
void C_DECL TParseContext::warn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
if (suppressWarnings())
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void C_DECL TParseContext::ppError(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
|
||||
if ((messages & EShMsgCascadingErrors) == 0)
|
||||
currentScanner->setEndOfInput();
|
||||
}
|
||||
|
||||
void C_DECL TParseContext::ppWarn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle seeing a variable identifier in the grammar.
|
||||
//
|
||||
|
|
|
@ -82,6 +82,15 @@ public:
|
|||
globalUniformBlock(nullptr) { }
|
||||
virtual ~TParseContextBase() { }
|
||||
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
|
||||
virtual void setLimits(const TBuiltInResource&) = 0;
|
||||
|
||||
EShLanguage getLanguage() const { return language; }
|
||||
|
@ -162,6 +171,9 @@ protected:
|
|||
// override this to set the language-specific name
|
||||
virtual const char* getGlobalUniformBlockName() { return ""; }
|
||||
virtual void finalizeGlobalUniformBlockLayout(TVariable&) { }
|
||||
void outputMessage(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, TPrefixType prefix,
|
||||
va_list args);
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -216,15 +228,6 @@ public:
|
|||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
|
||||
void parserError(const char* s); // for bison's yyerror
|
||||
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
|
||||
void reservedErrorCheck(const TSourceLoc&, const TString&);
|
||||
void reservedPpErrorCheck(const TSourceLoc&, const char* name, const char* op);
|
||||
bool lineContinuationCheck(const TSourceLoc&, bool endOfComment);
|
||||
|
@ -366,9 +369,6 @@ protected:
|
|||
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
|
||||
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
|
||||
void finalErrorCheck();
|
||||
void outputMessage(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, TPrefixType prefix,
|
||||
va_list args);
|
||||
|
||||
public:
|
||||
//
|
||||
|
|
|
@ -74,7 +74,7 @@ EShMessages DeriveOptions(Source source, Semantics semantics, Target target)
|
|||
case Source::GLSL:
|
||||
break;
|
||||
case Source::HLSL:
|
||||
result = EShMsgReadHlsl;
|
||||
result = static_cast<EShMessages>(result | EShMsgReadHlsl);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
|
||||
#include "../glslang/OSDependent/osinclude.h"
|
||||
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
namespace glslang {
|
||||
|
@ -234,69 +233,6 @@ bool HlslParseContext::parseVectorFields(const TSourceLoc& loc, const TString& c
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Used to output syntax, parsing, and semantic errors.
|
||||
//
|
||||
|
||||
void HlslParseContext::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 HlslParseContext::error(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
if (messages & EShMsgOnlyPreprocessor)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void C_DECL HlslParseContext::warn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
if (suppressWarnings())
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void C_DECL HlslParseContext::ppError(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void C_DECL HlslParseContext::ppWarn(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szExtraInfoFormat);
|
||||
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixWarning, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle seeing a variable identifier in the grammar.
|
||||
//
|
||||
|
|
|
@ -53,15 +53,6 @@ public:
|
|||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
|
||||
virtual const char* getGlobalUniformBlockName() { return "$Global"; }
|
||||
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
|
||||
void reservedPpErrorCheck(const TSourceLoc&, const char* /*name*/, const char* /*op*/) { }
|
||||
bool lineContinuationCheck(const TSourceLoc&, bool /*endOfComment*/) { return true; }
|
||||
bool lineDirectiveShouldSetNextLine() const { return true; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче