Commit 749fe340 by Jamie Madill

Revert "Make TParseContext a class, with private data."

Causing build errors on Linux: FAILED: ninja -t msvc -e environment.x86 -- C:\b\build\goma/gomacc "C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\angle\src\compiler\translator\translator_lib.ParseContext.obj.rsp /c ..\..\third_party\angle\src\compiler\translator\ParseContext.cpp /Foobj\third_party\angle\src\compiler\translator\translator_lib.ParseContext.obj /Fdobj\third_party\angle\src\translator_lib.cc.pdb c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\validateglobalinitializer.h(11) : error C2220: warning treated as error - no 'object' file generated c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\validateglobalinitializer.h(11) : warning C4099: 'TParseContext' : type name first seen using 'class' now seen using 'struct' c:\b\build\slave\gpu_win_builder__dbg_\build\src\third_party\angle\src\compiler\translator\parsecontext.h(28) : see declaration of 'TParseContext' BUG=angleproject:995 This reverts commit 6c0c2987. Change-Id: I49a8b7df9bc8b7c4892bf3af5e2c7a6444fba890 Reviewed-on: https://chromium-review.googlesource.com/270767Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6c0c2987
...@@ -202,7 +202,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[], ...@@ -202,7 +202,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
shaderType, shaderSpec, compileOptions, true, shaderType, shaderSpec, compileOptions, true,
infoSink, debugShaderPrecision); infoSink, debugShaderPrecision);
parseContext.setFragmentPrecisionHigh(fragmentPrecisionHigh); parseContext.fragmentPrecisionHigh = fragmentPrecisionHigh;
SetGlobalParseContext(&parseContext); SetGlobalParseContext(&parseContext);
// We preserve symbols at the built-in level from compile-to-compile. // We preserve symbols at the built-in level from compile-to-compile.
...@@ -211,8 +211,8 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[], ...@@ -211,8 +211,8 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
// Parse shader. // Parse shader.
bool success = bool success =
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr, &parseContext) == 0) && (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
(parseContext.getTreeRoot() != nullptr); (parseContext.treeRoot != NULL);
shaderVersion = parseContext.getShaderVersion(); shaderVersion = parseContext.getShaderVersion();
if (success && MapSpecToShaderVersion(shaderSpec) < shaderVersion) if (success && MapSpecToShaderVersion(shaderSpec) < shaderVersion)
...@@ -222,7 +222,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[], ...@@ -222,7 +222,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
success = false; success = false;
} }
TIntermNode *root = nullptr; TIntermNode *root = NULL;
if (success) if (success)
{ {
...@@ -232,7 +232,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[], ...@@ -232,7 +232,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
symbolTable.setGlobalInvariant(); symbolTable.setGlobalInvariant();
} }
root = parseContext.getTreeRoot(); root = parseContext.treeRoot;
success = intermediate.postProcess(root); success = intermediate.postProcess(root);
// Disallow expressions deemed too complex. // Disallow expressions deemed too complex.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
bool InitializeParseContextIndex(); bool InitializeParseContextIndex();
void FreeParseContextIndex(); void FreeParseContextIndex();
class TParseContext; struct TParseContext;
extern void SetGlobalParseContext(TParseContext* context); extern void SetGlobalParseContext(TParseContext* context);
extern TParseContext* GetGlobalParseContext(); extern TParseContext* GetGlobalParseContext();
......
...@@ -25,9 +25,8 @@ struct TMatrixFields ...@@ -25,9 +25,8 @@ struct TMatrixFields
// The following are extra variables needed during parsing, grouped together so // The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global. // they can be passed to the parser without needing a global.
// //
class TParseContext : angle::NonCopyable struct TParseContext : angle::NonCopyable
{ {
public:
TParseContext(TSymbolTable &symt, TParseContext(TSymbolTable &symt,
TExtensionBehavior &ext, TExtensionBehavior &ext,
TIntermediate &interm, TIntermediate &interm,
...@@ -39,73 +38,58 @@ class TParseContext : angle::NonCopyable ...@@ -39,73 +38,58 @@ class TParseContext : angle::NonCopyable
bool debugShaderPrecisionSupported) bool debugShaderPrecisionSupported)
: intermediate(interm), : intermediate(interm),
symbolTable(symt), symbolTable(symt),
mShaderType(type), shaderType(type),
mShaderSpec(spec), shaderSpec(spec),
mCompileOptions(options), compileOptions(options),
mTreeRoot(nullptr), treeRoot(nullptr),
mLoopNestingLevel(0), mLoopNestingLevel(0),
mStructNestingLevel(0), structNestingLevel(0),
mSwitchNestingLevel(0), mSwitchNestingLevel(0),
mCurrentFunctionType(nullptr), currentFunctionType(nullptr),
mFunctionReturnsValue(false), mFunctionReturnsValue(false),
mChecksPrecisionErrors(checksPrecErrors), checksPrecisionErrors(checksPrecErrors),
mFragmentPrecisionHigh(false), fragmentPrecisionHigh(false),
mDefaultMatrixPacking(EmpColumnMajor), defaultMatrixPacking(EmpColumnMajor),
mDefaultBlockStorage(EbsShared), defaultBlockStorage(EbsShared),
mDiagnostics(is), diagnostics(is),
mShaderVersion(100), shaderVersion(100),
mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported), directiveHandler(ext, diagnostics, shaderVersion, debugShaderPrecisionSupported),
mPreprocessor(&mDiagnostics, &mDirectiveHandler), preprocessor(&diagnostics, &directiveHandler),
mScanner(nullptr), scanner(nullptr),
mDeferredSingleDeclarationErrorCheck(false) mDeferredSingleDeclarationErrorCheck(false)
{ {
} }
const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; } TIntermediate &intermediate; // to hold and build a parse tree
pp::Preprocessor &getPreprocessor() { return mPreprocessor; } TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
void *getScanner() const { return mScanner; } sh::GLenum shaderType; // vertex or fragment language (future: pack or unpack)
void setScanner(void *scanner) { mScanner = scanner; } ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
int getShaderVersion() const { return mShaderVersion; } int shaderVersion;
sh::GLenum getShaderType() const { return mShaderType; } int compileOptions;
ShShaderSpec getShaderSpec() const { return mShaderSpec; } TIntermNode *treeRoot; // root of parse tree being created
int numErrors() const { return mDiagnostics.numErrors(); } int mLoopNestingLevel; // 0 if outside all loops
TInfoSink &infoSink() { return mDiagnostics.infoSink(); } int structNestingLevel; // incremented while parsing a struct declaration
int mSwitchNestingLevel; // 0 if outside all switch statements
const TType *currentFunctionType; // the return type of the function that's currently being parsed
bool mFunctionReturnsValue; // true if a non-void function has a return
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language.
TLayoutMatrixPacking defaultMatrixPacking;
TLayoutBlockStorage defaultBlockStorage;
TString HashErrMsg;
TDiagnostics diagnostics;
TDirectiveHandler directiveHandler;
pp::Preprocessor preprocessor;
void *scanner;
int getShaderVersion() const { return shaderVersion; }
int numErrors() const { return diagnostics.numErrors(); }
TInfoSink &infoSink() { return diagnostics.infoSink(); }
void error(const TSourceLoc &loc, const char *reason, const char *token, void error(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo=""); const char *extraInfo="");
void warning(const TSourceLoc &loc, const char *reason, const char *token, void warning(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo=""); const char *extraInfo="");
void recover(); void recover();
TIntermNode *getTreeRoot() const { return mTreeRoot; }
void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
bool getFragmentPrecisionHigh() const { return mFragmentPrecisionHigh; }
void setFragmentPrecisionHigh(bool fragmentPrecisionHigh)
{
mFragmentPrecisionHigh = fragmentPrecisionHigh;
}
bool getFunctionReturnsValue() const { return mFunctionReturnsValue; }
void setFunctionReturnsValue(bool functionReturnsValue)
{
mFunctionReturnsValue = functionReturnsValue;
}
void setLoopNestingLevel(int loopNestintLevel)
{
mLoopNestingLevel = loopNestintLevel;
}
const TType *getCurrentFunctionType() const { return mCurrentFunctionType; }
void setCurrentFunctionType(const TType *currentFunctionType)
{
mCurrentFunctionType = currentFunctionType;
}
void incrLoopNestingLevel() { ++mLoopNestingLevel; }
void decrLoopNestingLevel() { --mLoopNestingLevel; }
void incrSwitchNestingLevel() { ++mSwitchNestingLevel; }
void decrSwitchNestingLevel() { --mSwitchNestingLevel; }
// This method is guaranteed to succeed, even if no variable with 'name' exists. // This method is guaranteed to succeed, even if no variable with 'name' exists.
const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol); const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol);
...@@ -139,8 +123,8 @@ class TParseContext : angle::NonCopyable ...@@ -139,8 +123,8 @@ class TParseContext : angle::NonCopyable
bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *); bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *);
void es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation); void es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation);
const TPragma &pragma() const { return mDirectiveHandler.pragma(); } const TPragma &pragma() const { return directiveHandler.pragma(); }
const TExtensionBehavior &extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); } const TExtensionBehavior &extensionBehavior() const { return directiveHandler.extensionBehavior(); }
bool supportsExtension(const char *extension); bool supportsExtension(const char *extension);
bool isExtensionEnabled(const char *extension) const; bool isExtensionEnabled(const char *extension) const;
void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior); void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
...@@ -297,10 +281,6 @@ class TParseContext : angle::NonCopyable ...@@ -297,10 +281,6 @@ class TParseContext : angle::NonCopyable
TIntermTyped *addTernarySelection( TIntermTyped *addTernarySelection(
TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line); TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line);
// TODO(jmadill): make these private
TIntermediate &intermediate; // to hold and build a parse tree
TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
private: private:
bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable); bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable);
...@@ -321,26 +301,6 @@ class TParseContext : angle::NonCopyable ...@@ -321,26 +301,6 @@ class TParseContext : angle::NonCopyable
// Set to true when the last/current declarator list was started with an empty declaration. // Set to true when the last/current declarator list was started with an empty declaration.
bool mDeferredSingleDeclarationErrorCheck; bool mDeferredSingleDeclarationErrorCheck;
sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
int mShaderVersion;
int mCompileOptions;
TIntermNode *mTreeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops
int mStructNestingLevel; // incremented while parsing a struct declaration
int mSwitchNestingLevel; // 0 if outside all switch statements
const TType *mCurrentFunctionType; // the return type of the function that's currently being parsed
bool mFunctionReturnsValue; // true if a non-void function has a return
bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
bool mFragmentPrecisionHigh; // true if highp precision is supported in the fragment language.
TLayoutMatrixPacking mDefaultMatrixPacking;
TLayoutBlockStorage mDefaultBlockStorage;
TString mHashErrMsg;
TDiagnostics mDiagnostics;
TDirectiveHandler mDirectiveHandler;
pp::Preprocessor mPreprocessor;
void *mScanner;
}; };
int PaParseStrings( int PaParseStrings(
......
...@@ -389,7 +389,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate *node) ...@@ -389,7 +389,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate *node)
bool valid = true; bool valid = true;
TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable; TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable;
TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->getShaderVersion()); TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->shaderVersion);
ASSERT(symbol && symbol->isFunction()); ASSERT(symbol && symbol->isFunction());
TFunction *function = static_cast<TFunction *>(symbol); TFunction *function = static_cast<TFunction *>(symbol);
for (ParamIndex::const_iterator i = pIndex.begin(); for (ParamIndex::const_iterator i = pIndex.begin();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
class TParseContext; struct TParseContext;
class ValidateSwitch : public TIntermTraverser class ValidateSwitch : public TIntermTraverser
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_GLSLANG_H_ #ifndef COMPILER_TRANSLATOR_GLSLANG_H_
#define COMPILER_TRANSLATOR_GLSLANG_H_ #define COMPILER_TRANSLATOR_GLSLANG_H_
class TParseContext; struct TParseContext;
extern int glslang_initialize(TParseContext* context); extern int glslang_initialize(TParseContext* context);
extern int glslang_finalize(TParseContext* context); extern int glslang_finalize(TParseContext* context);
......
...@@ -246,7 +246,7 @@ O [0-7] ...@@ -246,7 +246,7 @@ O [0-7]
"sampler2DMSArray" | "sampler2DMSArray" |
"isampler2DMSArray" | "isampler2DMSArray" |
"usampler2DMSArray" { "usampler2DMSArray" {
if (context->getShaderVersion() < 300) { if (context->shaderVersion < 300) {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
} }
...@@ -255,7 +255,7 @@ O [0-7] ...@@ -255,7 +255,7 @@ O [0-7]
/* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */ /* Reserved keywords in GLSL ES 1.00 that are not reserved in GLSL ES 3.00 */
"packed" { "packed" {
if (context->getShaderVersion() >= 300) if (context->shaderVersion >= 300)
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -399,7 +399,7 @@ O [0-7] ...@@ -399,7 +399,7 @@ O [0-7]
yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
pp::Token token; pp::Token token;
yyget_extra(yyscanner)->getPreprocessor().lex(&token); yyget_extra(yyscanner)->preprocessor.lex(&token);
yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size();
if (len < max_size) if (len < max_size)
memcpy(buf, token.text.c_str(), len); memcpy(buf, token.text.c_str(), len);
...@@ -417,7 +417,7 @@ int check_type(yyscan_t yyscanner) { ...@@ -417,7 +417,7 @@ int check_type(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER; int token = IDENTIFIER;
TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->shaderVersion);
if (symbol && symbol->isVariable()) { if (symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol); TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) { if (variable->isUserType()) {
...@@ -438,9 +438,9 @@ int reserved_word(yyscan_t yyscanner) { ...@@ -438,9 +438,9 @@ int reserved_word(yyscan_t yyscanner) {
int ES2_reserved_ES3_keyword(TParseContext *context, int token) int ES2_reserved_ES3_keyword(TParseContext *context, int token)
{ {
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
return reserved_word(yyscanner); return reserved_word(yyscanner);
} }
...@@ -450,9 +450,9 @@ int ES2_reserved_ES3_keyword(TParseContext *context, int token) ...@@ -450,9 +450,9 @@ int ES2_reserved_ES3_keyword(TParseContext *context, int token)
int ES2_keyword_ES3_reserved(TParseContext *context, int token) int ES2_keyword_ES3_reserved(TParseContext *context, int token)
{ {
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() >= 300) if (context->shaderVersion >= 300)
{ {
return reserved_word(yyscanner); return reserved_word(yyscanner);
} }
...@@ -462,11 +462,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token) ...@@ -462,11 +462,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token)
int ES2_ident_ES3_keyword(TParseContext *context, int token) int ES2_ident_ES3_keyword(TParseContext *context, int token)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
// not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -477,10 +477,10 @@ int ES2_ident_ES3_keyword(TParseContext *context, int token) ...@@ -477,10 +477,10 @@ int ES2_ident_ES3_keyword(TParseContext *context, int token)
int uint_constant(TParseContext *context) int uint_constant(TParseContext *context)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, "");
context->recover(); context->recover();
...@@ -495,9 +495,9 @@ int uint_constant(TParseContext *context) ...@@ -495,9 +495,9 @@ int uint_constant(TParseContext *context)
int floatsuffix_check(TParseContext* context) int floatsuffix_check(TParseContext* context)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext);
context->recover(); context->recover();
...@@ -536,15 +536,15 @@ int glslang_initialize(TParseContext* context) { ...@@ -536,15 +536,15 @@ int glslang_initialize(TParseContext* context) {
if (yylex_init_extra(context, &scanner)) if (yylex_init_extra(context, &scanner))
return 1; return 1;
context->setScanner(scanner); context->scanner = scanner;
return 0; return 0;
} }
int glslang_finalize(TParseContext* context) { int glslang_finalize(TParseContext* context) {
yyscan_t scanner = context->getScanner(); yyscan_t scanner = context->scanner;
if (scanner == NULL) return 0; if (scanner == NULL) return 0;
context->setScanner(NULL); context->scanner = NULL;
yylex_destroy(scanner); yylex_destroy(scanner);
return 0; return 0;
...@@ -552,26 +552,24 @@ int glslang_finalize(TParseContext* context) { ...@@ -552,26 +552,24 @@ int glslang_finalize(TParseContext* context) {
int glslang_scan(size_t count, const char* const string[], const int length[], int glslang_scan(size_t count, const char* const string[], const int length[],
TParseContext* context) { TParseContext* context) {
yyrestart(NULL, context->getScanner()); yyrestart(NULL, context->scanner);
yyset_column(0, context->getScanner()); yyset_column(0, context->scanner);
yyset_lineno(1, context->getScanner()); yyset_lineno(1, context->scanner);
// Initialize preprocessor. // Initialize preprocessor.
pp::Preprocessor *preprocessor = &context->getPreprocessor(); if (!context->preprocessor.init(count, string, length))
if (!preprocessor->init(count, string, length))
return 1; return 1;
// Define extension macros. // Define extension macros.
const TExtensionBehavior& extBehavior = context->extensionBehavior(); const TExtensionBehavior& extBehavior = context->extensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) { iter != extBehavior.end(); ++iter) {
preprocessor->predefineMacro(iter->first.c_str(), 1); context->preprocessor.predefineMacro(iter->first.c_str(), 1);
} }
if (context->getFragmentPrecisionHigh()) if (context->fragmentPrecisionHigh)
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); context->preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize(context->shaderSpec));
return 0; return 0;
} }
......
...@@ -1759,7 +1759,7 @@ case 133: ...@@ -1759,7 +1759,7 @@ case 133:
case 134: case 134:
YY_RULE_SETUP YY_RULE_SETUP
{ {
if (context->getShaderVersion() < 300) { if (context->shaderVersion < 300) {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
} }
...@@ -1770,7 +1770,7 @@ YY_RULE_SETUP ...@@ -1770,7 +1770,7 @@ YY_RULE_SETUP
case 135: case 135:
YY_RULE_SETUP YY_RULE_SETUP
{ {
if (context->getShaderVersion() >= 300) if (context->shaderVersion >= 300)
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -3234,7 +3234,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) ...@@ -3234,7 +3234,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) { yy_size_t string_input(char* buf, yy_size_t max_size, yyscan_t yyscanner) {
pp::Token token; pp::Token token;
yyget_extra(yyscanner)->getPreprocessor().lex(&token); yyget_extra(yyscanner)->preprocessor.lex(&token);
yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size(); yy_size_t len = token.type == pp::Token::LAST ? 0 : token.text.size();
if (len < max_size) if (len < max_size)
memcpy(buf, token.text.c_str(), len); memcpy(buf, token.text.c_str(), len);
...@@ -3252,7 +3252,7 @@ int check_type(yyscan_t yyscanner) { ...@@ -3252,7 +3252,7 @@ int check_type(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER; int token = IDENTIFIER;
TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->getShaderVersion()); TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->shaderVersion);
if (symbol && symbol->isVariable()) { if (symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol); TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) { if (variable->isUserType()) {
...@@ -3273,9 +3273,9 @@ int reserved_word(yyscan_t yyscanner) { ...@@ -3273,9 +3273,9 @@ int reserved_word(yyscan_t yyscanner) {
int ES2_reserved_ES3_keyword(TParseContext *context, int token) int ES2_reserved_ES3_keyword(TParseContext *context, int token)
{ {
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
return reserved_word(yyscanner); return reserved_word(yyscanner);
} }
...@@ -3285,9 +3285,9 @@ int ES2_reserved_ES3_keyword(TParseContext *context, int token) ...@@ -3285,9 +3285,9 @@ int ES2_reserved_ES3_keyword(TParseContext *context, int token)
int ES2_keyword_ES3_reserved(TParseContext *context, int token) int ES2_keyword_ES3_reserved(TParseContext *context, int token)
{ {
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() >= 300) if (context->shaderVersion >= 300)
{ {
return reserved_word(yyscanner); return reserved_word(yyscanner);
} }
...@@ -3297,11 +3297,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token) ...@@ -3297,11 +3297,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token)
int ES2_ident_ES3_keyword(TParseContext *context, int token) int ES2_ident_ES3_keyword(TParseContext *context, int token)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
// not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name // not a reserved word in GLSL ES 1.00, so could be used as an identifier/type name
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
yylval->lex.string = NewPoolTString(yytext); yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner); return check_type(yyscanner);
...@@ -3312,10 +3312,10 @@ int ES2_ident_ES3_keyword(TParseContext *context, int token) ...@@ -3312,10 +3312,10 @@ int ES2_ident_ES3_keyword(TParseContext *context, int token)
int uint_constant(TParseContext *context) int uint_constant(TParseContext *context)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
yyscan_t yyscanner = (yyscan_t) context->getScanner(); yyscan_t yyscanner = (yyscan_t) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, "");
context->recover(); context->recover();
...@@ -3330,9 +3330,9 @@ int uint_constant(TParseContext *context) ...@@ -3330,9 +3330,9 @@ int uint_constant(TParseContext *context)
int floatsuffix_check(TParseContext* context) int floatsuffix_check(TParseContext* context)
{ {
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner(); struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
if (context->getShaderVersion() < 300) if (context->shaderVersion < 300)
{ {
context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext); context->error(*yylloc, "Floating-point suffix unsupported prior to GLSL ES 3.00", yytext);
context->recover(); context->recover();
...@@ -3371,15 +3371,15 @@ int glslang_initialize(TParseContext* context) { ...@@ -3371,15 +3371,15 @@ int glslang_initialize(TParseContext* context) {
if (yylex_init_extra(context,&scanner)) if (yylex_init_extra(context,&scanner))
return 1; return 1;
context->setScanner(scanner); context->scanner = scanner;
return 0; return 0;
} }
int glslang_finalize(TParseContext* context) { int glslang_finalize(TParseContext* context) {
yyscan_t scanner = context->getScanner(); yyscan_t scanner = context->scanner;
if (scanner == NULL) return 0; if (scanner == NULL) return 0;
context->setScanner(NULL); context->scanner = NULL;
yylex_destroy(scanner); yylex_destroy(scanner);
return 0; return 0;
...@@ -3387,26 +3387,24 @@ int glslang_finalize(TParseContext* context) { ...@@ -3387,26 +3387,24 @@ int glslang_finalize(TParseContext* context) {
int glslang_scan(size_t count, const char* const string[], const int length[], int glslang_scan(size_t count, const char* const string[], const int length[],
TParseContext* context) { TParseContext* context) {
yyrestart(NULL,context->getScanner()); yyrestart(NULL,context->scanner);
yyset_column(0,context->getScanner()); yyset_column(0,context->scanner);
yyset_lineno(1,context->getScanner()); yyset_lineno(1,context->scanner);
// Initialize preprocessor. // Initialize preprocessor.
pp::Preprocessor *preprocessor = &context->getPreprocessor(); if (!context->preprocessor.init(count, string, length))
if (!preprocessor->init(count, string, length))
return 1; return 1;
// Define extension macros. // Define extension macros.
const TExtensionBehavior& extBehavior = context->extensionBehavior(); const TExtensionBehavior& extBehavior = context->extensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) { iter != extBehavior.end(); ++iter) {
preprocessor->predefineMacro(iter->first.c_str(), 1); context->preprocessor.predefineMacro(iter->first.c_str(), 1);
} }
if (context->getFragmentPrecisionHigh()) if (context->fragmentPrecisionHigh)
preprocessor->predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1); context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
preprocessor->setMaxTokenSize(GetGlobalMaxTokenSize(context->getShaderSpec())); context->preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize(context->shaderSpec));
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment