diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/glslang.l')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/glslang.l | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/glslang.l b/src/3rdparty/angle/src/compiler/translator/glslang.l index ee4d28b6d6..d09358dd8a 100644 --- a/src/3rdparty/angle/src/compiler/translator/glslang.l +++ b/src/3rdparty/angle/src/compiler/translator/glslang.l @@ -28,8 +28,10 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wswitch-enum" #elif defined(_MSC_VER) +#pragma warning(disable: 4005) #pragma warning(disable: 4065) #pragma warning(disable: 4189) +#pragma warning(disable: 4244) #pragma warning(disable: 4505) #pragma warning(disable: 4701) #pragma warning(disable: 4702) @@ -49,6 +51,13 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). #pragma warning(disable : 4102) #endif +// Workaround for flex using the register keyword, deprecated in C++11. +#ifdef __cplusplus +#if __cplusplus > 199711L +#define register +#endif +#endif + #define YY_USER_ACTION \ yylloc->first_file = yylloc->last_file = yycolumn; \ yylloc->first_line = yylloc->last_line = yylineno; @@ -63,7 +72,7 @@ static int ES2_reserved_ES3_keyword(TParseContext *context, int token); static int ES2_keyword_ES3_reserved(TParseContext *context, int token); static int ES2_ident_ES3_keyword(TParseContext *context, int token); static int uint_constant(TParseContext *context); -static int int_constant(yyscan_t yyscanner); +static int int_constant(TParseContext *context); static int float_constant(yyscan_t yyscanner); static int floatsuffix_check(TParseContext* context); %} @@ -237,7 +246,7 @@ O [0-7] "sampler2DMSArray" | "isampler2DMSArray" | "usampler2DMSArray" { - if (context->shaderVersion < 300) { + if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } @@ -246,7 +255,7 @@ O [0-7] /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */ "packed" { - if (context->shaderVersion >= 300) + if (context->getShaderVersion() >= 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); @@ -312,9 +321,9 @@ O [0-7] return check_type(yyscanner); } -0[xX]{H}+ { return int_constant(yyscanner); } -0{O}+ { return int_constant(yyscanner); } -{D}+ { return int_constant(yyscanner); } +0[xX]{H}+ { return int_constant(context); } +0{O}+ { return int_constant(context); } +{D}+ { return int_constant(context); } 0[xX]{H}+[uU] { return uint_constant(context); } 0{O}+[uU] { return uint_constant(context); } @@ -390,7 +399,7 @@ O [0-7] yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { pp::Token token; - yyget_extra(yyscanner)->preprocessor.lex(&token); + yyget_extra(yyscanner)->getPreprocessor().lex(&token); yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); if (len < max_size) memcpy(buf, token.text.c_str(), len); @@ -408,7 +417,7 @@ int check_type(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; int token = IDENTIFIER; - TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->shaderVersion); + TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); if (symbol && symbol->isVariable()) { TVariable* variable = static_cast<TVariable*>(symbol); if (variable->isUserType()) { @@ -429,9 +438,9 @@ int reserved_word(yyscan_t yyscanner) { int ES2_reserved_ES3_keyword(TParseContext *context, int token) { - yyscan_t yyscanner = (yyscan_t) context->scanner; + yyscan_t yyscanner = (yyscan_t) context->getScanner(); - if (context->shaderVersion < 300) + if (context->getShaderVersion() < 300) { return reserved_word(yyscanner); } @@ -441,9 +450,9 @@ int ES2_reserved_ES3_keyword(TParseContext *context, int token) int ES2_keyword_ES3_reserved(TParseContext *context, int token) { - yyscan_t yyscanner = (yyscan_t) context->scanner; + yyscan_t yyscanner = (yyscan_t) context->getScanner(); - if (context->shaderVersion >= 300) + if (context->getShaderVersion() >= 300) { return reserved_word(yyscanner); } @@ -453,11 +462,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token) int ES2_ident_ES3_keyword(TParseContext *context, int token) { - struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; - yyscan_t yyscanner = (yyscan_t) context->scanner; + struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); + yyscan_t yyscanner = (yyscan_t) context->getScanner(); // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name - if (context->shaderVersion < 300) + if (context->getShaderVersion() < 300) { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); @@ -468,34 +477,35 @@ int ES2_ident_ES3_keyword(TParseContext *context, int token) int uint_constant(TParseContext *context) { - struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; - yyscan_t yyscanner = (yyscan_t) context->scanner; + struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); - if (context->shaderVersion < 300) + if (context->getShaderVersion() < 300) { context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->recover(); return 0; } - if (!atoi_clamp(yytext, &(yylval->lex.i))) - yyextra->warning(*yylloc, "Integer overflow", yytext, ""); + if (!atoi_clamp(yytext, &(yylval->lex.u))) + yyextra->error(*yylloc, "Integer overflow", yytext, ""); return UINTCONSTANT; } int floatsuffix_check(TParseContext* context) { - struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; + struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); - if (context->shaderVersion < 300) + if (context->getShaderVersion() < 300) { context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); context->recover(); return 0; } - if (!atof_clamp(yytext, &(yylval->lex.f))) + std::string text = yytext; + text.resize(text.size() - 1); + if (!strtof_clamp(text, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return(FLOATCONSTANT); @@ -506,18 +516,25 @@ void yyerror(YYLTYPE* lloc, TParseContext* context, void *scanner, const char* r context->recover(); } -int int_constant(yyscan_t yyscanner) { - struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; +int int_constant(TParseContext *context) { + struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); - if (!atoi_clamp(yytext, &(yylval->lex.i))) - yyextra->warning(*yylloc, "Integer overflow", yytext, ""); + unsigned int u; + if (!atoi_clamp(yytext, &u)) + { + if (context->getShaderVersion() >= 300) + yyextra->error(*yylloc, "Integer overflow", yytext, ""); + else + yyextra->warning(*yylloc, "Integer overflow", yytext, ""); + } + yylval->lex.i = static_cast<int>(u); return INTCONSTANT; } int float_constant(yyscan_t yyscanner) { struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; - if (!atof_clamp(yytext, &(yylval->lex.f))) + if (!strtof_clamp(yytext, &(yylval->lex.f))) yyextra->warning(*yylloc, "Float overflow", yytext, ""); return FLOATCONSTANT; } @@ -527,15 +544,15 @@ int glslang_initialize(TParseContext* context) { if (yylex_init_extra(context, &scanner)) return 1; - context->scanner = scanner; + context->setScanner(scanner); return 0; } int glslang_finalize(TParseContext* context) { - yyscan_t scanner = context->scanner; + yyscan_t scanner = context->getScanner(); if (scanner == NULL) return 0; - context->scanner = NULL; + context->setScanner(NULL); yylex_destroy(scanner); return 0; @@ -543,24 +560,26 @@ int glslang_finalize(TParseContext* context) { int glslang_scan(size_t count, const char* const string[], const int length[], TParseContext* context) { - yyrestart(NULL, context->scanner); - yyset_column(0, context->scanner); - yyset_lineno(1, context->scanner); + yyrestart(NULL, context->getScanner()); + yyset_column(0, context->getScanner()); + yyset_lineno(1, context->getScanner()); // Initialize preprocessor. - if (!context->preprocessor.init(count, string, length)) + pp::Preprocessor *preprocessor = &context->getPreprocessor(); + + if (!preprocessor->init(count, string, length)) return 1; // Define extension macros. const TExtensionBehavior& extBehavior = context->extensionBehavior(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end(); ++iter) { - context->preprocessor.predefineMacro(iter->first.c_str(), 1); + preprocessor->predefineMacro(iter->first.c_str(), 1); } - if (context->fragmentPrecisionHigh) - context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); + if (context->getFragmentPrecisionHigh()) + preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); - context->preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize(context->shaderSpec)); + preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); return 0; } |