Make TParseContext a class, with private data.
*re-land with build fix*
BUG=angleproject:995
Change-Id: I67d3ded8f6c705b54fb372857e07ce1a86b58475
Reviewed-on: https://chromium-review.googlesource.com/271162
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 8b5b12f..721e297 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -202,7 +202,7 @@
shaderType, shaderSpec, compileOptions, true,
infoSink, debugShaderPrecision);
- parseContext.fragmentPrecisionHigh = fragmentPrecisionHigh;
+ parseContext.setFragmentPrecisionHigh(fragmentPrecisionHigh);
SetGlobalParseContext(&parseContext);
// We preserve symbols at the built-in level from compile-to-compile.
@@ -211,8 +211,8 @@
// Parse shader.
bool success =
- (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
- (parseContext.treeRoot != NULL);
+ (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr, &parseContext) == 0) &&
+ (parseContext.getTreeRoot() != nullptr);
shaderVersion = parseContext.getShaderVersion();
if (success && MapSpecToShaderVersion(shaderSpec) < shaderVersion)
@@ -222,7 +222,7 @@
success = false;
}
- TIntermNode *root = NULL;
+ TIntermNode *root = nullptr;
if (success)
{
@@ -232,7 +232,7 @@
symbolTable.setGlobalInvariant();
}
- root = parseContext.treeRoot;
+ root = parseContext.getTreeRoot();
success = intermediate.postProcess(root);
// Disallow expressions deemed too complex.
diff --git a/src/compiler/translator/InitializeParseContext.h b/src/compiler/translator/InitializeParseContext.h
index fa9b885..70dac70 100644
--- a/src/compiler/translator/InitializeParseContext.h
+++ b/src/compiler/translator/InitializeParseContext.h
@@ -10,7 +10,7 @@
bool InitializeParseContextIndex();
void FreeParseContextIndex();
-struct TParseContext;
+class TParseContext;
extern void SetGlobalParseContext(TParseContext* context);
extern TParseContext* GetGlobalParseContext();
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 5b8f209..784032d 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -185,8 +185,8 @@
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- diagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
- srcLoc, reason, token, extraInfo);
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
+ srcLoc, reason, token, extraInfo);
}
@@ -196,8 +196,8 @@
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- diagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
- srcLoc, reason, token, extraInfo);
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
+ srcLoc, reason, token, extraInfo);
}
//
@@ -236,7 +236,7 @@
}
bool TParseContext::precisionErrorCheck(const TSourceLoc& line, TPrecision precision, TBasicType type){
- if (!checksPrecisionErrors)
+ if (!mChecksPrecisionErrors)
return false;
switch( type ){
case EbtFloat:
@@ -433,7 +433,7 @@
error(line, reservedErrMsg, "gl_");
return true;
}
- if (IsWebGLBasedSpec(shaderSpec)) {
+ if (IsWebGLBasedSpec(mShaderSpec)) {
if (identifier.compare(0, 6, "webgl_") == 0) {
error(line, reservedErrMsg, "webgl_");
return true;
@@ -442,7 +442,7 @@
error(line, reservedErrMsg, "_webgl_");
return true;
}
- if (shaderSpec == SH_CSS_SHADERS_SPEC && identifier.compare(0, 4, "css_") == 0) {
+ if (mShaderSpec == SH_CSS_SHADERS_SPEC && identifier.compare(0, 4, "css_") == 0) {
error(line, reservedErrMsg, "css_");
return true;
}
@@ -736,7 +736,7 @@
bool TParseContext::arrayQualifierErrorCheck(const TSourceLoc &line, const TPublicType &type)
{
if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexIn) ||
- (type.qualifier == EvqConst && shaderVersion < 300))
+ (type.qualifier == EvqConst && mShaderVersion < 300))
{
error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str());
return true;
@@ -779,7 +779,7 @@
// Generate informative error messages for ESSL1.
// In ESSL3 arrays and structures containing arrays can be constant.
- if (shaderVersion < 300 && type->isStructureContainingArrays())
+ if (mShaderVersion < 300 && type->isStructureContainingArrays())
{
error(line, "structures containing arrays may not be declared constant since they cannot be initialized", identifier.c_str());
}
@@ -814,10 +814,10 @@
if (type.isArray() && identifier.compare(0, 15, "gl_LastFragData") == 0)
{
const TVariable *maxDrawBuffers =
- static_cast<const TVariable *>(symbolTable.findBuiltIn("gl_MaxDrawBuffers", shaderVersion));
+ static_cast<const TVariable *>(symbolTable.findBuiltIn("gl_MaxDrawBuffers", mShaderVersion));
if (type.getArraySize() == maxDrawBuffers->getConstPointer()->getIConst())
{
- if (TSymbol *builtInSymbol = symbolTable.findBuiltIn(identifier, shaderVersion))
+ if (TSymbol *builtInSymbol = symbolTable.findBuiltIn(identifier, mShaderVersion))
{
needsReservedErrorCheck = extensionErrorCheck(line, builtInSymbol->getExtension());
}
@@ -1006,7 +1006,7 @@
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- directiveHandler.handleExtension(srcLoc, extName, behavior);
+ mDirectiveHandler.handleExtension(srcLoc, extName, behavior);
}
void TParseContext::handlePragmaDirective(const TSourceLoc& loc, const char* name, const char* value, bool stdgl)
@@ -1014,7 +1014,7 @@
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- directiveHandler.handlePragma(srcLoc, name, value, stdgl);
+ mDirectiveHandler.handlePragma(srcLoc, name, value, stdgl);
}
/////////////////////////////////////////////////////////////////////////////////
@@ -1043,7 +1043,7 @@
{
variable = static_cast<const TVariable*>(symbol);
- if (symbolTable.findBuiltIn(variable->getName(), shaderVersion) &&
+ if (symbolTable.findBuiltIn(variable->getName(), mShaderVersion) &&
!variable->getExtension().empty() &&
extensionErrorCheck(location, variable->getExtension()))
{
@@ -1224,7 +1224,7 @@
returnType.clearArrayness();
}
- if (shaderVersion < 300)
+ if (mShaderVersion < 300)
{
if (qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
{
@@ -1645,7 +1645,7 @@
const TLayoutQualifier layoutQualifier = typeQualifier.layoutQualifier;
ASSERT(!layoutQualifier.isEmpty());
- if (shaderVersion < 300)
+ if (mShaderVersion < 300)
{
error(typeQualifier.line, "layout qualifiers supported in GLSL ES 3.00 only", "layout");
recover();
@@ -1660,12 +1660,12 @@
if (layoutQualifier.matrixPacking != EmpUnspecified)
{
- defaultMatrixPacking = layoutQualifier.matrixPacking;
+ mDefaultMatrixPacking = layoutQualifier.matrixPacking;
}
if (layoutQualifier.blockStorage != EbsUnspecified)
{
- defaultBlockStorage = layoutQualifier.blockStorage;
+ mDefaultBlockStorage = layoutQualifier.blockStorage;
}
}
@@ -2016,12 +2016,12 @@
if (blockLayoutQualifier.matrixPacking == EmpUnspecified)
{
- blockLayoutQualifier.matrixPacking = defaultMatrixPacking;
+ blockLayoutQualifier.matrixPacking = mDefaultMatrixPacking;
}
if (blockLayoutQualifier.blockStorage == EbsUnspecified)
{
- blockLayoutQualifier.blockStorage = defaultBlockStorage;
+ blockLayoutQualifier.blockStorage = mDefaultBlockStorage;
}
TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName);
@@ -2135,12 +2135,12 @@
bool TParseContext::enterStructDeclaration(const TSourceLoc& line, const TString& identifier)
{
- ++structNestingLevel;
+ ++mStructNestingLevel;
// Embedded structure definitions are not supported per GLSL ES spec.
// They aren't allowed in GLSL either, but we need to detect this here
// so we don't rely on the GLSL compiler to catch it.
- if (structNestingLevel > 1) {
+ if (mStructNestingLevel > 1) {
error(line, "", "Embedded struct definitions are not allowed");
return true;
}
@@ -2150,7 +2150,7 @@
void TParseContext::exitStructDeclaration()
{
- --structNestingLevel;
+ --mStructNestingLevel;
}
namespace {
@@ -2161,7 +2161,7 @@
bool TParseContext::structNestingErrorCheck(const TSourceLoc& line, const TField& field)
{
- if (!IsWebGLBasedSpec(shaderSpec)) {
+ if (!IsWebGLBasedSpec(mShaderSpec)) {
return false;
}
@@ -2517,7 +2517,7 @@
}
else
{
- if (shaderVersion < 300)
+ if (mShaderVersion < 300)
{
error(dotLocation, " field selection requires structure, vector, or matrix on left hand side", fieldString.c_str());
}
@@ -2914,7 +2914,7 @@
{
if (left->isArray() || right->isArray())
{
- if (shaderVersion < 300)
+ if (mShaderVersion < 300)
{
error(loc, "Invalid operation for arrays", GetOperatorString(op));
return false;
@@ -2994,7 +2994,7 @@
case EOpEqual:
case EOpNotEqual:
// ESSL 1.00 sections 5.7, 5.8, 5.9
- if (shaderVersion < 300 && left->getType().isStructureContainingArrays())
+ if (mShaderVersion < 300 && left->getType().isStructureContainingArrays())
{
error(loc, "undefined operation for structs containing arrays", GetOperatorString(op));
return false;
@@ -3002,7 +3002,7 @@
// Samplers as l-values are disallowed also in ESSL 3.00, see section 4.1.7,
// we interpret the spec so that this extends to structs containing samplers,
// similarly to ESSL 1.00 spec.
- if ((shaderVersion < 300 || op == EOpAssign || op == EOpInitialize) &&
+ if ((mShaderVersion < 300 || op == EOpAssign || op == EOpInitialize) &&
left->getType().isStructureContainingSamplers())
{
error(loc, "undefined operation for structs containing samplers", GetOperatorString(op));
@@ -3153,7 +3153,7 @@
}
break;
case EOpReturn:
- if (currentFunctionType->getBasicType() != EbtVoid)
+ if (mCurrentFunctionType->getBasicType() != EbtVoid)
{
error(loc, "non-void function must return a value", "return");
recover();
@@ -3170,12 +3170,12 @@
{
ASSERT(op == EOpReturn);
mFunctionReturnsValue = true;
- if (currentFunctionType->getBasicType() == EbtVoid)
+ if (mCurrentFunctionType->getBasicType() == EbtVoid)
{
error(loc, "void function cannot return a value", "return");
recover();
}
- else if (*currentFunctionType != returnValue->getType())
+ else if (*mCurrentFunctionType != returnValue->getType())
{
error(loc, "function return is not matching type:", "return");
recover();
@@ -3259,7 +3259,7 @@
//
const TFunction* fnCandidate;
bool builtIn;
- fnCandidate = findFunction(loc, fnCall, shaderVersion, &builtIn);
+ fnCandidate = findFunction(loc, fnCall, mShaderVersion, &builtIn);
if (fnCandidate)
{
//
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index c1be7c9..d328e9a 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -25,8 +25,9 @@
// The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global.
//
-struct TParseContext : angle::NonCopyable
+class TParseContext : angle::NonCopyable
{
+ public:
TParseContext(TSymbolTable &symt,
TExtensionBehavior &ext,
TIntermediate &interm,
@@ -38,58 +39,73 @@
bool debugShaderPrecisionSupported)
: intermediate(interm),
symbolTable(symt),
- shaderType(type),
- shaderSpec(spec),
- compileOptions(options),
- treeRoot(nullptr),
+ mShaderType(type),
+ mShaderSpec(spec),
+ mCompileOptions(options),
+ mTreeRoot(nullptr),
mLoopNestingLevel(0),
- structNestingLevel(0),
+ mStructNestingLevel(0),
mSwitchNestingLevel(0),
- currentFunctionType(nullptr),
+ mCurrentFunctionType(nullptr),
mFunctionReturnsValue(false),
- checksPrecisionErrors(checksPrecErrors),
- fragmentPrecisionHigh(false),
- defaultMatrixPacking(EmpColumnMajor),
- defaultBlockStorage(EbsShared),
- diagnostics(is),
- shaderVersion(100),
- directiveHandler(ext, diagnostics, shaderVersion, debugShaderPrecisionSupported),
- preprocessor(&diagnostics, &directiveHandler),
- scanner(nullptr),
+ mChecksPrecisionErrors(checksPrecErrors),
+ mFragmentPrecisionHigh(false),
+ mDefaultMatrixPacking(EmpColumnMajor),
+ mDefaultBlockStorage(EbsShared),
+ mDiagnostics(is),
+ mShaderVersion(100),
+ mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported),
+ mPreprocessor(&mDiagnostics, &mDirectiveHandler),
+ mScanner(nullptr),
mDeferredSingleDeclarationErrorCheck(false)
{
}
- TIntermediate &intermediate; // to hold and build a parse tree
- TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
- sh::GLenum shaderType; // vertex or fragment language (future: pack or unpack)
- ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
- int shaderVersion;
- int compileOptions;
- TIntermNode *treeRoot; // root of parse tree being created
- int mLoopNestingLevel; // 0 if outside all loops
- 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(); }
+ const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; }
+ pp::Preprocessor &getPreprocessor() { return mPreprocessor; }
+ void *getScanner() const { return mScanner; }
+ void setScanner(void *scanner) { mScanner = scanner; }
+ int getShaderVersion() const { return mShaderVersion; }
+ sh::GLenum getShaderType() const { return mShaderType; }
+ ShShaderSpec getShaderSpec() const { return mShaderSpec; }
+ int numErrors() const { return mDiagnostics.numErrors(); }
+ TInfoSink &infoSink() { return mDiagnostics.infoSink(); }
void error(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo="");
void warning(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo="");
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.
const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol);
@@ -123,8 +139,8 @@
bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *);
void es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation);
- const TPragma &pragma() const { return directiveHandler.pragma(); }
- const TExtensionBehavior &extensionBehavior() const { return directiveHandler.extensionBehavior(); }
+ const TPragma &pragma() const { return mDirectiveHandler.pragma(); }
+ const TExtensionBehavior &extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); }
bool supportsExtension(const char *extension);
bool isExtensionEnabled(const char *extension) const;
void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
@@ -281,6 +297,10 @@
TIntermTyped *addTernarySelection(
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:
bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable);
@@ -301,6 +321,26 @@
// Set to true when the last/current declarator list was started with an empty declaration.
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(
diff --git a/src/compiler/translator/ValidateGlobalInitializer.h b/src/compiler/translator/ValidateGlobalInitializer.h
index 28c005b..c3d2a47 100644
--- a/src/compiler/translator/ValidateGlobalInitializer.h
+++ b/src/compiler/translator/ValidateGlobalInitializer.h
@@ -8,7 +8,7 @@
#define COMPILER_TRANSLATOR_VALIDATEGLOBALINITIALIZER_H_
class TIntermTyped;
-struct TParseContext;
+class TParseContext;
// Returns true if the initializer is valid.
bool ValidateGlobalInitializer(TIntermTyped *initializer, const TParseContext *context, bool *warning);
diff --git a/src/compiler/translator/ValidateLimitations.cpp b/src/compiler/translator/ValidateLimitations.cpp
index 1236706..e247a28 100644
--- a/src/compiler/translator/ValidateLimitations.cpp
+++ b/src/compiler/translator/ValidateLimitations.cpp
@@ -389,7 +389,7 @@
bool valid = true;
TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable;
- TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->shaderVersion);
+ TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->getShaderVersion());
ASSERT(symbol && symbol->isFunction());
TFunction *function = static_cast<TFunction *>(symbol);
for (ParamIndex::const_iterator i = pIndex.begin();
diff --git a/src/compiler/translator/ValidateSwitch.h b/src/compiler/translator/ValidateSwitch.h
index 88b68a5..ddbefc5 100644
--- a/src/compiler/translator/ValidateSwitch.h
+++ b/src/compiler/translator/ValidateSwitch.h
@@ -9,7 +9,7 @@
#include "compiler/translator/IntermNode.h"
-struct TParseContext;
+class TParseContext;
class ValidateSwitch : public TIntermTraverser
{
diff --git a/src/compiler/translator/glslang.h b/src/compiler/translator/glslang.h
index db31e69..0555e96 100644
--- a/src/compiler/translator/glslang.h
+++ b/src/compiler/translator/glslang.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_GLSLANG_H_
#define COMPILER_TRANSLATOR_GLSLANG_H_
-struct TParseContext;
+class TParseContext;
extern int glslang_initialize(TParseContext* context);
extern int glslang_finalize(TParseContext* context);
diff --git a/src/compiler/translator/glslang.l b/src/compiler/translator/glslang.l
index 1d2a640..a4d6e25 100644
--- a/src/compiler/translator/glslang.l
+++ b/src/compiler/translator/glslang.l
@@ -246,7 +246,7 @@
"sampler2DMSArray" |
"isampler2DMSArray" |
"usampler2DMSArray" {
- if (context->shaderVersion < 300) {
+ if (context->getShaderVersion() < 300) {
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
@@ -255,7 +255,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);
@@ -399,7 +399,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);
@@ -417,7 +417,7 @@
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()) {
@@ -438,9 +438,9 @@
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);
}
@@ -450,9 +450,9 @@
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);
}
@@ -462,11 +462,11 @@
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);
@@ -477,10 +477,10 @@
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();
+ yyscan_t yyscanner = (yyscan_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();
@@ -495,9 +495,9 @@
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();
@@ -536,15 +536,15 @@
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;
@@ -552,24 +552,26 @@
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;
}
diff --git a/src/compiler/translator/glslang.y b/src/compiler/translator/glslang.y
index fef2e08..4a540ae 100644
--- a/src/compiler/translator/glslang.y
+++ b/src/compiler/translator/glslang.y
@@ -110,28 +110,28 @@
} while (0)
#define VERTEX_ONLY(S, L) { \
- if (context->shaderType != GL_VERTEX_SHADER) { \
+ if (context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex shaders only ", S); \
context->recover(); \
} \
}
#define FRAG_ONLY(S, L) { \
- if (context->shaderType != GL_FRAGMENT_SHADER) { \
+ if (context->getShaderType() != GL_FRAGMENT_SHADER) { \
context->error(L, " supported in fragment shaders only ", S); \
context->recover(); \
} \
}
#define ES2_ONLY(S, L) { \
- if (context->shaderVersion != 100) { \
+ if (context->getShaderVersion() != 100) { \
context->error(L, " supported in GLSL ES 1.00 only ", S); \
context->recover(); \
} \
}
#define ES3_ONLY(TOKEN, LINE, REASON) { \
- if (context->shaderVersion != 300) { \
+ if (context->getShaderVersion() != 300) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 only ", TOKEN); \
context->recover(); \
} \
@@ -633,7 +633,7 @@
$$ = aggNode;
}
| PRECISION precision_qualifier type_specifier_no_prec SEMICOLON {
- if (($2 == EbpHigh) && (context->shaderType == GL_FRAGMENT_SHADER) && !context->fragmentPrecisionHigh) {
+ if (($2 == EbpHigh) && (context->getShaderType() == GL_FRAGMENT_SHADER) && !context->getFragmentPrecisionHigh()) {
context->error(@1, "precision is not supported in fragment shader", "highp");
context->recover();
}
@@ -671,7 +671,7 @@
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName(), context->shaderVersion));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName(), context->getShaderVersion()));
if (prevDec) {
if (prevDec->getReturnType() != $1->getReturnType()) {
context->error(@2, "overloaded functions must have the same return type", $1->getReturnType().getBasicString());
@@ -688,7 +688,7 @@
//
// Check for previously declared variables using the same name.
//
- TSymbol *prevSym = context->symbolTable.find($1->getName(), context->shaderVersion);
+ TSymbol *prevSym = context->symbolTable.find($1->getName(), context->getShaderVersion());
if (prevSym)
{
if (!prevSym->isFunction())
@@ -934,7 +934,7 @@
if ($1.array) {
ES3_ONLY("[]", @1, "first-class-array");
- if (context->shaderVersion != 300) {
+ if (context->getShaderVersion() != 300) {
$1.clearArrayness();
}
}
@@ -971,7 +971,7 @@
ES2_ONLY("varying", @1);
if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "varying"))
context->recover();
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
$$.setBasic(EbtVoid, EvqVaryingOut, @1);
else
$$.setBasic(EbtVoid, EvqVaryingIn, @1);
@@ -980,7 +980,7 @@
ES2_ONLY("varying", @1);
if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
$$.setBasic(EbtVoid, EvqVaryingOut, @1);
else
$$.setBasic(EbtVoid, EvqVaryingIn, @1);
@@ -1030,29 +1030,29 @@
}
| IN_QUAL {
ES3_ONLY("in", @1, "storage qualifier");
- $$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
+ $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
}
| OUT_QUAL {
ES3_ONLY("out", @1, "storage qualifier");
- $$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
+ $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
}
| CENTROID IN_QUAL {
ES3_ONLY("centroid in", @1, "storage qualifier");
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
{
context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid in' in the vertex shader");
context->recover();
}
- $$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
+ $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
}
| CENTROID OUT_QUAL {
ES3_ONLY("centroid out", @1, "storage qualifier");
- if (context->shaderType == GL_FRAGMENT_SHADER)
+ if (context->getShaderType() == GL_FRAGMENT_SHADER)
{
context->error(@1, "invalid storage qualifier", "it is an error to use 'centroid out' in the fragment shader");
context->recover();
}
- $$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
+ $$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
}
| UNIFORM {
if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "uniform"))
@@ -1530,9 +1530,9 @@
;
switch_statement
- : SWITCH LEFT_PAREN expression RIGHT_PAREN { ++context->mSwitchNestingLevel; } compound_statement {
+ : SWITCH LEFT_PAREN expression RIGHT_PAREN { context->incrSwitchNestingLevel(); } compound_statement {
$$ = context->addSwitch($3, $6, @1);
- --context->mSwitchNestingLevel;
+ context->decrSwitchNestingLevel();
}
;
@@ -1567,22 +1567,22 @@
;
iteration_statement
- : WHILE LEFT_PAREN { context->symbolTable.push(); ++context->mLoopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope {
+ : WHILE LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } condition RIGHT_PAREN statement_no_new_scope {
context->symbolTable.pop();
$$ = context->intermediate.addLoop(ELoopWhile, 0, $4, 0, $6, @1);
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
- | DO { ++context->mLoopNestingLevel; } statement_with_scope WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
+ | DO { context->incrLoopNestingLevel(); } statement_with_scope WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
if (context->boolErrorCheck(@8, $6))
context->recover();
$$ = context->intermediate.addLoop(ELoopDoWhile, 0, $6, 0, $3, @4);
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
- | FOR LEFT_PAREN { context->symbolTable.push(); ++context->mLoopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
+ | FOR LEFT_PAREN { context->symbolTable.push(); context->incrLoopNestingLevel(); } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
context->symbolTable.pop();
$$ = context->intermediate.addLoop(ELoopFor, $4, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), $7, @1);
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
;
@@ -1639,11 +1639,11 @@
translation_unit
: external_declaration {
$$ = $1;
- context->treeRoot = $$;
+ context->setTreeRoot($$);
}
| translation_unit external_declaration {
$$ = context->intermediate.growAggregate($1, $2, @$);
- context->treeRoot = $$;
+ context->setTreeRoot($$);
}
;
@@ -1660,7 +1660,7 @@
: function_prototype {
TFunction* function = $1.function;
- const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
+ const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->getShaderVersion());
if (builtIn)
{
@@ -1668,7 +1668,7 @@
context->recover();
}
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->shaderVersion));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->getShaderVersion()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
@@ -1706,8 +1706,8 @@
//
// Remember the return type for later checking for RETURN statements.
//
- context->currentFunctionType = &(prevDec->getReturnType());
- context->mFunctionReturnsValue = false;
+ context->setCurrentFunctionType(&(prevDec->getReturnType()));
+ context->setFunctionReturnsValue(false);
//
// Insert parameters into the symbol table.
@@ -1746,12 +1746,12 @@
}
context->intermediate.setAggregateOperator(paramNodes, EOpParameters, @1);
$1.intermAggregate = paramNodes;
- context->mLoopNestingLevel = 0;
+ context->setLoopNestingLevel(0);
}
compound_statement_no_new_scope {
//?? Check that all paths return a value if return type != void ?
// May be best done as post process phase on intermediate code
- if (context->currentFunctionType->getBasicType() != EbtVoid && ! context->mFunctionReturnsValue) {
+ if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && !context->getFunctionReturnsValue()) {
context->error(@1, "function does not return a value:", "", $1.function->getName().c_str());
context->recover();
}
@@ -1774,5 +1774,5 @@
%%
int glslang_parse(TParseContext* context) {
- return yyparse(context, context->scanner);
+ return yyparse(context, context->getScanner());
}
diff --git a/src/compiler/translator/glslang_lex.cpp b/src/compiler/translator/glslang_lex.cpp
index 1d5c049..c7804a7 100644
--- a/src/compiler/translator/glslang_lex.cpp
+++ b/src/compiler/translator/glslang_lex.cpp
@@ -1759,7 +1759,7 @@
case 134:
YY_RULE_SETUP
{
- if (context->shaderVersion < 300) {
+ if (context->getShaderVersion() < 300) {
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
@@ -1770,7 +1770,7 @@
case 135:
YY_RULE_SETUP
{
- if (context->shaderVersion >= 300)
+ if (context->getShaderVersion() >= 300)
{
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
@@ -3234,7 +3234,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);
@@ -3252,7 +3252,7 @@
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()) {
@@ -3273,9 +3273,9 @@
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);
}
@@ -3285,9 +3285,9 @@
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);
}
@@ -3297,11 +3297,11 @@
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);
@@ -3312,10 +3312,10 @@
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();
+ yyscan_t yyscanner = (yyscan_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();
@@ -3330,9 +3330,9 @@
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();
@@ -3371,15 +3371,15 @@
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;
@@ -3387,24 +3387,26 @@
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;
}
diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp
index 75f5644..23bb762 100644
--- a/src/compiler/translator/glslang_tab.cpp
+++ b/src/compiler/translator/glslang_tab.cpp
@@ -354,28 +354,28 @@
} while (0)
#define VERTEX_ONLY(S, L) { \
- if (context->shaderType != GL_VERTEX_SHADER) { \
+ if (context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex shaders only ", S); \
context->recover(); \
} \
}
#define FRAG_ONLY(S, L) { \
- if (context->shaderType != GL_FRAGMENT_SHADER) { \
+ if (context->getShaderType() != GL_FRAGMENT_SHADER) { \
context->error(L, " supported in fragment shaders only ", S); \
context->recover(); \
} \
}
#define ES2_ONLY(S, L) { \
- if (context->shaderVersion != 100) { \
+ if (context->getShaderVersion() != 100) { \
context->error(L, " supported in GLSL ES 1.00 only ", S); \
context->recover(); \
} \
}
#define ES3_ONLY(TOKEN, LINE, REASON) { \
- if (context->shaderVersion != 300) { \
+ if (context->getShaderVersion() != 300) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 only ", TOKEN); \
context->recover(); \
} \
@@ -3110,7 +3110,7 @@
case 90:
{
- if (((yyvsp[-2].interm.precision) == EbpHigh) && (context->shaderType == GL_FRAGMENT_SHADER) && !context->fragmentPrecisionHigh) {
+ if (((yyvsp[-2].interm.precision) == EbpHigh) && (context->getShaderType() == GL_FRAGMENT_SHADER) && !context->getFragmentPrecisionHigh()) {
context->error((yylsp[-3]), "precision is not supported in fragment shader", "highp");
context->recover();
}
@@ -3170,7 +3170,7 @@
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[-1].interm.function)->getMangledName(), context->shaderVersion));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[-1].interm.function)->getMangledName(), context->getShaderVersion()));
if (prevDec) {
if (prevDec->getReturnType() != (yyvsp[-1].interm.function)->getReturnType()) {
context->error((yylsp[0]), "overloaded functions must have the same return type", (yyvsp[-1].interm.function)->getReturnType().getBasicString());
@@ -3187,7 +3187,7 @@
//
// Check for previously declared variables using the same name.
//
- TSymbol *prevSym = context->symbolTable.find((yyvsp[-1].interm.function)->getName(), context->shaderVersion);
+ TSymbol *prevSym = context->symbolTable.find((yyvsp[-1].interm.function)->getName(), context->getShaderVersion());
if (prevSym)
{
if (!prevSym->isFunction())
@@ -3540,7 +3540,7 @@
if ((yyvsp[0].interm.type).array) {
ES3_ONLY("[]", (yylsp[0]), "first-class-array");
- if (context->shaderVersion != 300) {
+ if (context->getShaderVersion() != 300) {
(yyvsp[0].interm.type).clearArrayness();
}
}
@@ -3598,7 +3598,7 @@
ES2_ONLY("varying", (yylsp[0]));
if (context->globalErrorCheck((yylsp[0]), context->symbolTable.atGlobalLevel(), "varying"))
context->recover();
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
(yyval.interm.type).setBasic(EbtVoid, EvqVaryingOut, (yylsp[0]));
else
(yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yylsp[0]));
@@ -3612,7 +3612,7 @@
ES2_ONLY("varying", (yylsp[-1]));
if (context->globalErrorCheck((yylsp[-1]), context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
(yyval.interm.type).setBasic(EbtVoid, EvqVaryingOut, (yylsp[-1]));
else
(yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yylsp[-1]));
@@ -3704,7 +3704,7 @@
{
ES3_ONLY("in", (yylsp[0]), "storage qualifier");
- (yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
+ (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
}
break;
@@ -3713,7 +3713,7 @@
{
ES3_ONLY("out", (yylsp[0]), "storage qualifier");
- (yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
+ (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
}
break;
@@ -3722,12 +3722,12 @@
{
ES3_ONLY("centroid in", (yylsp[-1]), "storage qualifier");
- if (context->shaderType == GL_VERTEX_SHADER)
+ if (context->getShaderType() == GL_VERTEX_SHADER)
{
context->error((yylsp[-1]), "invalid storage qualifier", "it is an error to use 'centroid in' in the vertex shader");
context->recover();
}
- (yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
+ (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexIn;
}
break;
@@ -3736,12 +3736,12 @@
{
ES3_ONLY("centroid out", (yylsp[-1]), "storage qualifier");
- if (context->shaderType == GL_FRAGMENT_SHADER)
+ if (context->getShaderType() == GL_FRAGMENT_SHADER)
{
context->error((yylsp[-1]), "invalid storage qualifier", "it is an error to use 'centroid out' in the fragment shader");
context->recover();
}
- (yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
+ (yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqCentroidOut;
}
break;
@@ -4662,7 +4662,7 @@
case 247:
- { ++context->mSwitchNestingLevel; }
+ { context->incrSwitchNestingLevel(); }
break;
@@ -4670,7 +4670,7 @@
{
(yyval.interm.intermSwitch) = context->addSwitch((yyvsp[-3].interm.intermTypedNode), (yyvsp[0].interm.intermAggregate), (yylsp[-5]));
- --context->mSwitchNestingLevel;
+ context->decrSwitchNestingLevel();
}
break;
@@ -4720,7 +4720,7 @@
case 253:
- { context->symbolTable.push(); ++context->mLoopNestingLevel; }
+ { context->symbolTable.push(); context->incrLoopNestingLevel(); }
break;
@@ -4729,14 +4729,14 @@
{
context->symbolTable.pop();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopWhile, 0, (yyvsp[-2].interm.intermTypedNode), 0, (yyvsp[0].interm.intermNode), (yylsp[-5]));
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
break;
case 255:
- { ++context->mLoopNestingLevel; }
+ { context->incrLoopNestingLevel(); }
break;
@@ -4747,14 +4747,14 @@
context->recover();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopDoWhile, 0, (yyvsp[-2].interm.intermTypedNode), 0, (yyvsp[-5].interm.intermNode), (yylsp[-4]));
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
break;
case 257:
- { context->symbolTable.push(); ++context->mLoopNestingLevel; }
+ { context->symbolTable.push(); context->incrLoopNestingLevel(); }
break;
@@ -4763,7 +4763,7 @@
{
context->symbolTable.pop();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[-3].interm.intermNode), reinterpret_cast<TIntermTyped*>((yyvsp[-2].interm.nodePair).node1), reinterpret_cast<TIntermTyped*>((yyvsp[-2].interm.nodePair).node2), (yyvsp[0].interm.intermNode), (yylsp[-6]));
- --context->mLoopNestingLevel;
+ context->decrLoopNestingLevel();
}
break;
@@ -4863,7 +4863,7 @@
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
- context->treeRoot = (yyval.interm.intermNode);
+ context->setTreeRoot((yyval.interm.intermNode));
}
break;
@@ -4872,7 +4872,7 @@
{
(yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[-1].interm.intermNode), (yyvsp[0].interm.intermNode), (yyloc));
- context->treeRoot = (yyval.interm.intermNode);
+ context->setTreeRoot((yyval.interm.intermNode));
}
break;
@@ -4898,7 +4898,7 @@
{
TFunction* function = (yyvsp[0].interm).function;
- const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
+ const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->getShaderVersion());
if (builtIn)
{
@@ -4906,7 +4906,7 @@
context->recover();
}
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->shaderVersion));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->getShaderVersion()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
@@ -4944,8 +4944,8 @@
//
// Remember the return type for later checking for RETURN statements.
//
- context->currentFunctionType = &(prevDec->getReturnType());
- context->mFunctionReturnsValue = false;
+ context->setCurrentFunctionType(&(prevDec->getReturnType()));
+ context->setFunctionReturnsValue(false);
//
// Insert parameters into the symbol table.
@@ -4984,7 +4984,7 @@
}
context->intermediate.setAggregateOperator(paramNodes, EOpParameters, (yylsp[0]));
(yyvsp[0].interm).intermAggregate = paramNodes;
- context->mLoopNestingLevel = 0;
+ context->setLoopNestingLevel(0);
}
break;
@@ -4994,7 +4994,7 @@
{
//?? Check that all paths return a value if return type != void ?
// May be best done as post process phase on intermediate code
- if (context->currentFunctionType->getBasicType() != EbtVoid && ! context->mFunctionReturnsValue) {
+ if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && !context->getFunctionReturnsValue()) {
context->error((yylsp[-2]), "function does not return a value:", "", (yyvsp[-2].interm).function->getName().c_str());
context->recover();
}
@@ -5255,5 +5255,5 @@
int glslang_parse(TParseContext* context) {
- return yyparse(context, context->scanner);
+ return yyparse(context, context->getScanner());
}