Commit 0a65584a by Alexis Hetu Committed by Alexis Hétu

Better encapsulation for TParseContext

Changed 15 public members of TParseContext so that they are now private and added the appropriate setters/getters, along with the required code changes in the parser. Change-Id: I0a3ea67540d165e9837a3fe8e64fda4843a3cf96 Reviewed-on: https://swiftshader-review.googlesource.com/3543Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent d2264145
......@@ -122,12 +122,12 @@ bool TCompiler::compile(const char* const shaderStrings[],
// Parse shader.
bool success =
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
(parseContext.treeRoot != NULL);
(parseContext.getTreeRoot() != NULL);
shaderVersion = parseContext.getShaderVersion();
if (success) {
TIntermNode* root = parseContext.treeRoot;
TIntermNode* root = parseContext.getTreeRoot();
success = intermediate.postProcess(root);
if (success)
......
......@@ -10,7 +10,7 @@
bool InitializeParseContextIndex();
void FreeParseContextIndex();
struct TParseContext;
class TParseContext;
extern void SetGlobalParseContext(TParseContext* context);
extern TParseContext* GetGlobalParseContext();
......
......@@ -154,7 +154,7 @@ namespace glsl
{
emitScope = scope;
currentScope = GLOBAL;
mContext.treeRoot->traverse(this);
mContext.getTreeRoot()->traverse(this);
}
void OutputASM::freeTemporary(Temporary *temporary)
......
......@@ -182,8 +182,8 @@ void TParseContext::error(const TSourceLoc& loc,
{
pp::SourceLocation srcLoc;
DecodeSourceLoc(loc, &srcLoc.file, &srcLoc.line);
diagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
srcLoc, reason, token, extraInfo);
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
srcLoc, reason, token, extraInfo);
}
......@@ -192,13 +192,13 @@ void TParseContext::warning(const TSourceLoc& loc,
const char* extraInfo) {
pp::SourceLocation srcLoc;
DecodeSourceLoc(loc, &srcLoc.file, &srcLoc.line);
diagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
srcLoc, reason, token, extraInfo);
mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
srcLoc, reason, token, extraInfo);
}
void TParseContext::trace(const char* str)
{
diagnostics.writeDebug(str);
mDiagnostics.writeDebug(str);
}
//
......@@ -237,7 +237,7 @@ void TParseContext::binaryOpError(const TSourceLoc &line, const char* op, TStrin
}
bool TParseContext::precisionErrorCheck(const TSourceLoc &line, TPrecision precision, TBasicType type){
if (!checksPrecisionErrors)
if (!mChecksPrecisionErrors)
return false;
switch( type ){
case EbtFloat:
......@@ -847,7 +847,7 @@ bool TParseContext::arrayTypeErrorCheck(const TSourceLoc &line, TPublicType type
bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, const TSourceLoc &line)
{
bool builtIn = false;
TSymbol* symbol = symbolTable.find(node->getSymbol(), shaderVersion, &builtIn);
TSymbol* symbol = symbolTable.find(node->getSymbol(), mShaderVersion, &builtIn);
if (symbol == 0) {
error(line, " undeclared identifier", node->getSymbol().c_str());
return true;
......@@ -860,7 +860,7 @@ bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size,
// special casing to test index value of gl_FragData. If the accessed index is >= gl_MaxDrawBuffers
// its an error
if (node->getSymbol() == "gl_FragData") {
TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", shaderVersion, &builtIn);
TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", mShaderVersion, &builtIn);
ASSERT(fragData);
int fragDataValue = static_cast<TVariable*>(fragData)->getConstPointer()[0].getIConst();
......@@ -934,7 +934,7 @@ bool TParseContext::nonInitErrorCheck(const TSourceLoc &line, const TString& ide
// 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",
......@@ -969,7 +969,7 @@ bool TParseContext::declareVariable(const TSourceLoc &line, const TString &ident
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())
{
error(line, "redeclaration of gl_LastFragData with size != gl_MaxDrawBuffers", identifier.c_str());
......@@ -1066,14 +1066,14 @@ void TParseContext::handleExtensionDirective(const TSourceLoc &line, const char*
{
pp::SourceLocation loc;
DecodeSourceLoc(line, &loc.file, &loc.line);
directiveHandler.handleExtension(loc, extName, behavior);
mDirectiveHandler.handleExtension(loc, extName, behavior);
}
void TParseContext::handlePragmaDirective(const TSourceLoc &line, const char* name, const char* value)
{
pp::SourceLocation loc;
DecodeSourceLoc(line, &loc.file, &loc.line);
directiveHandler.handlePragma(loc, name, value);
mDirectiveHandler.handlePragma(loc, name, value);
}
/////////////////////////////////////////////////////////////////////////////////
......@@ -1102,7 +1102,7 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
{
variable = static_cast<const TVariable*>(symbol);
if(symbolTable.findBuiltIn(variable->getName(), shaderVersion))
if(symbolTable.findBuiltIn(variable->getName(), mShaderVersion))
{
recover();
}
......@@ -1149,9 +1149,9 @@ const TFunction* TParseContext::findFunction(const TSourceLoc &line, TFunction*
{
// First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename.
const TSymbol* symbol = symbolTable.find(call->getName(), shaderVersion, builtIn);
const TSymbol* symbol = symbolTable.find(call->getName(), mShaderVersion, builtIn);
if (symbol == 0) {
symbol = symbolTable.find(call->getMangledName(), shaderVersion, builtIn);
symbol = symbolTable.find(call->getMangledName(), mShaderVersion, builtIn);
}
if (symbol == 0) {
......@@ -1292,7 +1292,7 @@ TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, bool inva
returnType.clearArrayness();
}
if(shaderVersion < 300)
if(mShaderVersion < 300)
{
if(qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
{
......@@ -1703,7 +1703,7 @@ TIntermAggregate *TParseContext::parseArrayInitDeclarator(const TPublicType &pub
void TParseContext::parseGlobalLayoutQualifier(const TPublicType &typeQualifier)
{
if(shaderVersion < 300)
if(mShaderVersion < 300)
{
error(typeQualifier.line, "layout qualifiers supported in GLSL ES 3.00 only", "layout");
recover();
......@@ -1728,12 +1728,12 @@ void TParseContext::parseGlobalLayoutQualifier(const TPublicType &typeQualifier)
if(layoutQualifier.matrixPacking != EmpUnspecified)
{
defaultMatrixPacking = layoutQualifier.matrixPacking;
mDefaultMatrixPacking = layoutQualifier.matrixPacking;
}
if(layoutQualifier.blockStorage != EbsUnspecified)
{
defaultBlockStorage = layoutQualifier.blockStorage;
mDefaultBlockStorage = layoutQualifier.blockStorage;
}
}
......@@ -2080,12 +2080,12 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
if(blockLayoutQualifier.matrixPacking == EmpUnspecified)
{
blockLayoutQualifier.matrixPacking = defaultMatrixPacking;
blockLayoutQualifier.matrixPacking = mDefaultMatrixPacking;
}
if(blockLayoutQualifier.blockStorage == EbsUnspecified)
{
blockLayoutQualifier.blockStorage = defaultBlockStorage;
blockLayoutQualifier.blockStorage = mDefaultBlockStorage;
}
TSymbol* blockNameSymbol = new TSymbol(&blockName);
......@@ -2535,7 +2535,7 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
}
else
{
if(shaderVersion < 300)
if(mShaderVersion < 300)
{
error(dotLocation, " field selection requires structure, vector, or matrix on left hand side",
fieldString.c_str());
......@@ -2785,12 +2785,12 @@ TPublicType TParseContext::addStructure(const TSourceLoc &structLine, const TSou
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;
}
......@@ -2800,7 +2800,7 @@ bool TParseContext::enterStructDeclaration(const TSourceLoc &line, const TString
void TParseContext::exitStructDeclaration()
{
--structNestingLevel;
--mStructNestingLevel;
}
bool TParseContext::structNestingErrorCheck(const TSourceLoc &line, const TField &field)
......@@ -2897,7 +2897,7 @@ bool TParseContext::binaryOpCommonCheck(TOperator op, TIntermTyped *left, TInter
{
if(left->isArray() || right->isArray())
{
if(shaderVersion < 300)
if(mShaderVersion < 300)
{
error(loc, "Invalid operation for arrays", getOperatorString(op));
return false;
......@@ -2977,7 +2977,7 @@ bool TParseContext::binaryOpCommonCheck(TOperator op, TIntermTyped *left, TInter
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;
......@@ -2985,7 +2985,7 @@ bool TParseContext::binaryOpCommonCheck(TOperator op, TIntermTyped *left, TInter
// 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));
......@@ -3041,7 +3041,7 @@ TIntermSwitch *TParseContext::addSwitch(TIntermTyped *init, TIntermAggregate *st
TIntermCase *TParseContext::addCase(TIntermTyped *condition, const TSourceLoc &loc)
{
if(switchNestingLevel == 0)
if(mSwitchNestingLevel == 0)
{
error(loc, "case labels need to be inside switch statements", "case");
recover();
......@@ -3079,7 +3079,7 @@ TIntermCase *TParseContext::addCase(TIntermTyped *condition, const TSourceLoc &l
TIntermCase *TParseContext::addDefault(const TSourceLoc &loc)
{
if(switchNestingLevel == 0)
if(mSwitchNestingLevel == 0)
{
error(loc, "default labels need to be inside switch statements", "default");
recover();
......@@ -3205,21 +3205,21 @@ TIntermBranch *TParseContext::addBranch(TOperator op, const TSourceLoc &loc)
switch(op)
{
case EOpContinue:
if(loopNestingLevel <= 0)
if(mLoopNestingLevel <= 0)
{
error(loc, "continue statement only allowed in loops", "");
recover();
}
break;
case EOpBreak:
if(loopNestingLevel <= 0 && switchNestingLevel <= 0)
if(mLoopNestingLevel <= 0 && mSwitchNestingLevel <= 0)
{
error(loc, "break statement only allowed in loops and switch statements", "");
recover();
}
break;
case EOpReturn:
if(currentFunctionType->getBasicType() != EbtVoid)
if(mCurrentFunctionType->getBasicType() != EbtVoid)
{
error(loc, "non-void function must return a value", "return");
recover();
......@@ -3235,13 +3235,13 @@ TIntermBranch *TParseContext::addBranch(TOperator op, const TSourceLoc &loc)
TIntermBranch *TParseContext::addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc)
{
ASSERT(op == EOpReturn);
functionReturnsValue = true;
if(currentFunctionType->getBasicType() == EbtVoid)
mFunctionReturnsValue = true;
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();
......
......@@ -24,68 +24,81 @@ struct TMatrixFields {
// The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global.
//
struct TParseContext {
class TParseContext {
public:
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, GLenum type, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
intermediate(interm),
symbolTable(symt),
shaderType(type),
compileOptions(options),
sourcePath(sourcePath),
treeRoot(0),
lexAfterType(false),
loopNestingLevel(0),
switchNestingLevel(0),
structNestingLevel(0),
inTypeParen(false),
currentFunctionType(NULL),
functionReturnsValue(false),
checksPrecisionErrors(checksPrecErrors),
defaultMatrixPacking(EmpColumnMajor),
defaultBlockStorage(EbsShared),
diagnostics(is),
shaderVersion(100),
directiveHandler(ext, diagnostics, shaderVersion),
preprocessor(&diagnostics, &directiveHandler),
scanner(NULL),
mDeferredSingleDeclarationErrorCheck(false),
AfterEOF(false),
mDeferredSingleDeclarationErrorCheck(false),
mShaderType(type),
mShaderVersion(100),
mTreeRoot(0),
mLoopNestingLevel(0),
mSwitchNestingLevel(0),
mStructNestingLevel(0),
mCurrentFunctionType(NULL),
mFunctionReturnsValue(false),
mChecksPrecisionErrors(checksPrecErrors),
mDefaultMatrixPacking(EmpColumnMajor),
mDefaultBlockStorage(EbsShared),
mDiagnostics(is),
mDirectiveHandler(ext, mDiagnostics, mShaderVersion),
mPreprocessor(&mDiagnostics, &mDirectiveHandler),
mScanner(NULL),
mUsesFragData(false),
mUsesFragColor(false) { }
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
GLenum shaderType; // vertex or fragment language (future: pack or unpack)
int shaderVersion;
int compileOptions;
const char* sourcePath; // Path of source file or NULL.
TIntermNode* treeRoot; // root of parse tree being created
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
int loopNestingLevel; // 0 if outside all loops
int switchNestingLevel; // 0 if outside all switch statements
int structNestingLevel; // incremented while parsing a struct declaration
bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // 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.
TLayoutMatrixPacking defaultMatrixPacking;
TLayoutBlockStorage defaultBlockStorage;
TString HashErrMsg;
bool AfterEOF;
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; }
GLenum getShaderType() const { return mShaderType; }
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 trace(const char* str);
void recover();
void incrSwitchNestingLevel() { ++switchNestingLevel; }
void decrSwitchNestingLevel() { --switchNestingLevel; }
TIntermNode *getTreeRoot() const { return mTreeRoot; }
void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
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);
......@@ -121,11 +134,11 @@ struct TParseContext {
bool layoutLocationErrorCheck(const TSourceLoc& location, const TLayoutQualifier &layoutQualifier);
bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *);
const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); }
const TExtensionBehavior& extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); }
bool supportsExtension(const char* extension);
void handleExtensionDirective(const TSourceLoc &line, const char* extName, const char* behavior);
const TPragma& pragma() const { return directiveHandler.pragma(); }
const TPragma& pragma() const { return mDirectiveHandler.pragma(); }
void handlePragmaDirective(const TSourceLoc &line, const char* name, const char* value);
bool containsSampler(TType& type);
......@@ -221,8 +234,26 @@ private:
// Return true if the checks pass
bool binaryOpCommonCheck(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
bool mDeferredSingleDeclarationErrorCheck;
bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor
// Set to true when the last/current declarator list was started with an empty declaration.
bool mDeferredSingleDeclarationErrorCheck;
GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
int mShaderVersion;
TIntermNode *mTreeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops
int mSwitchNestingLevel; // 0 if outside all switch statements
int mStructNestingLevel; // incremented while parsing a struct declaration
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.
TLayoutMatrixPacking mDefaultMatrixPacking;
TLayoutBlockStorage mDefaultBlockStorage;
TDiagnostics mDiagnostics;
TDirectiveHandler mDirectiveHandler;
pp::Preprocessor mPreprocessor;
void *mScanner;
bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor
bool mUsesFragColor;
};
......
......@@ -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);
......
......@@ -440,7 +440,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node)
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();
......
......@@ -10,7 +10,7 @@
#include "intermediate.h"
#include <set>
struct TParseContext;
class TParseContext;
class ValidateSwitch : public TIntermTraverser
{
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
struct TParseContext;
class TParseContext;
extern int glslang_initialize(TParseContext* context);
extern int glslang_finalize(TParseContext* context);
......
......@@ -241,7 +241,7 @@ O [0-7]
"sampler2DMSArray" |
"isampler2DMSArray" |
"usampler2DMSArray" {
if (context->shaderVersion < 300) {
if (context->getShaderVersion() < 300) {
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
......@@ -250,7 +250,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);
......@@ -395,7 +395,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);
......@@ -412,7 +412,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 (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
......@@ -434,9 +434,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);
}
......@@ -446,9 +446,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);
}
......@@ -458,11 +458,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token)
int ES2_identifier_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);
......@@ -473,10 +473,10 @@ int ES2_identifier_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();
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();
......@@ -491,9 +491,9 @@ int uint_constant(TParseContext *context)
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();
......@@ -523,7 +523,7 @@ int float_constant(yyscan_t yyscanner) {
}
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner();
if (context->AfterEOF) {
context->error(*lloc, reason, "unexpected EOF");
......@@ -538,15 +538,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;
......@@ -554,12 +554,12 @@ 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_lineno(EncodeSourceLoc(0, 1), context->scanner);
yyrestart(NULL, context->getScanner());
yyset_lineno(EncodeSourceLoc(0, 1), context->getScanner());
context->AfterEOF = false;
// Initialize preprocessor.
if (!context->preprocessor.init(count, string, length))
if (!context->getPreprocessor().init(count, string, length))
return 1;
// Define extension macros.
......@@ -567,10 +567,10 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter)
{
context->preprocessor.predefineMacro(iter->first.c_str(), 1);
context->getPreprocessor().predefineMacro(iter->first.c_str(), 1);
}
context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
context->getPreprocessor().predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
return 0;
}
......
......@@ -39,7 +39,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
#define YYENABLE_NLS 0
#define YYLEX_PARAM context->scanner
#define YYLEX_PARAM context->getScanner()
%}
%expect 1 /* One shift reduce conflict because of if | else */
......@@ -94,36 +94,36 @@ extern void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason);
#define YYLLOC_DEFAULT(Current, Rhs, N) do { (Current) = YYRHSLOC(Rhs, N ? 1 : 0); } while (0)
#define FRAG_VERT_ONLY(S, L) { \
if (context->shaderType != GL_FRAGMENT_SHADER && \
context->shaderType != GL_VERTEX_SHADER) { \
if (context->getShaderType() != GL_FRAGMENT_SHADER && \
context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex/fragment shaders only ", S); \
context->recover(); \
} \
}
#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(S, L) { \
if (context->shaderVersion != 300) { \
if (context->getShaderVersion() != 300) { \
context->error(L, " supported in GLSL ES 3.00 only ", S); \
context->recover(); \
} \
......@@ -782,7 +782,7 @@ function_prototype
//
// 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());
......@@ -1135,7 +1135,7 @@ type_qualifier
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);
......@@ -1144,7 +1144,7 @@ type_qualifier
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, EvqInvariantVaryingOut, @1);
else
$$.setBasic(EbtVoid, EvqInvariantVaryingIn, @1);
......@@ -1179,32 +1179,32 @@ storage_qualifier
}
| IN_QUAL {
ES3_ONLY("in", @1);
$$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
$$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
$$.line = @1;
}
| OUT_QUAL {
ES3_ONLY("out", @1);
$$.qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
$$.qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
$$.line = @1;
}
| CENTROID IN_QUAL {
ES3_ONLY("centroid in", @1);
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;
$$.line = @2;
}
| CENTROID OUT_QUAL {
ES3_ONLY("centroid out", @1);
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;
$$.line = @2;
}
| UNIFORM {
......@@ -1738,22 +1738,22 @@ condition
;
iteration_statement
: WHILE LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } 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->loopNestingLevel;
context->decrLoopNestingLevel();
}
| DO { ++context->loopNestingLevel; } 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->loopNestingLevel;
context->decrLoopNestingLevel();
}
| FOR LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } 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->loopNestingLevel;
context->decrLoopNestingLevel();
}
;
......@@ -1810,11 +1810,11 @@ jump_statement
translation_unit
: external_declaration {
$$ = $1;
context->treeRoot = $$;
context->setTreeRoot($$);
}
| translation_unit external_declaration {
$$ = context->intermediate.growAggregate($1, $2, 0);
context->treeRoot = $$;
context->setTreeRoot($$);
}
;
......@@ -1831,7 +1831,7 @@ function_definition
: 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)
{
......@@ -1839,7 +1839,7 @@ function_definition
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
......@@ -1871,8 +1871,8 @@ function_definition
//
// Remember the return type for later checking for RETURN statements.
//
context->currentFunctionType = &(prevDec->getReturnType());
context->functionReturnsValue = false;
context->setCurrentFunctionType(&(prevDec->getReturnType()));
context->setFunctionReturnsValue(false);
//
// Insert parameters into the symbol table.
......@@ -1911,12 +1911,12 @@ function_definition
}
context->intermediate.setAggregateOperator(paramNodes, EOpParameters, @1);
$1.intermAggregate = paramNodes;
context->loopNestingLevel = 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->functionReturnsValue) {
if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && ! context->getFunctionReturnsValue()) {
context->error(@1, "function does not return a value:", "", $1.function->getName().c_str());
context->recover();
}
......
......@@ -1772,7 +1772,7 @@ case 137:
case 138:
YY_RULE_SETUP
{
if (context->shaderVersion < 300) {
if (context->getShaderVersion() < 300) {
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
......@@ -1783,7 +1783,7 @@ YY_RULE_SETUP
case 139:
YY_RULE_SETUP
{
if (context->shaderVersion >= 300)
if (context->getShaderVersion() >= 300)
{
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
......@@ -3287,7 +3287,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
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);
......@@ -3304,7 +3304,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 (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
......@@ -3326,9 +3326,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);
}
......@@ -3338,9 +3338,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);
}
......@@ -3350,11 +3350,11 @@ int ES2_keyword_ES3_reserved(TParseContext *context, int token)
int ES2_identifier_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);
......@@ -3365,10 +3365,10 @@ int ES2_identifier_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();
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();
......@@ -3383,9 +3383,9 @@ int uint_constant(TParseContext *context)
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();
......@@ -3415,7 +3415,7 @@ int float_constant(yyscan_t yyscanner) {
}
void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
struct yyguts_t* yyg = (struct yyguts_t*) context->getScanner();
if (context->AfterEOF) {
context->error(*lloc, reason, "unexpected EOF");
......@@ -3430,15 +3430,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;
......@@ -3446,12 +3446,12 @@ 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_lineno(EncodeSourceLoc(0, 1),context->scanner);
yyrestart(NULL,context->getScanner());
yyset_lineno(EncodeSourceLoc(0, 1),context->getScanner());
context->AfterEOF = false;
// Initialize preprocessor.
if (!context->preprocessor.init(count, string, length))
if (!context->getPreprocessor().init(count, string, length))
return 1;
// Define extension macros.
......@@ -3459,10 +3459,10 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter)
{
context->preprocessor.predefineMacro(iter->first.c_str(), 1);
context->getPreprocessor().predefineMacro(iter->first.c_str(), 1);
}
context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
context->getPreprocessor().predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
return 0;
}
......
......@@ -93,7 +93,7 @@
#define YYENABLE_NLS 0
#define YYLEX_PARAM context->scanner
#define YYLEX_PARAM context->getScanner()
......@@ -330,36 +330,36 @@ extern void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason);
#define YYLLOC_DEFAULT(Current, Rhs, N) do { (Current) = YYRHSLOC(Rhs, N ? 1 : 0); } while (0)
#define FRAG_VERT_ONLY(S, L) { \
if (context->shaderType != GL_FRAGMENT_SHADER && \
context->shaderType != GL_VERTEX_SHADER) { \
if (context->getShaderType() != GL_FRAGMENT_SHADER && \
context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex/fragment shaders only ", S); \
context->recover(); \
} \
}
#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(S, L) { \
if (context->shaderVersion != 300) { \
if (context->getShaderVersion() != 300) { \
context->error(L, " supported in GLSL ES 3.00 only ", S); \
context->recover(); \
} \
......@@ -3337,7 +3337,7 @@ yyreduce:
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getMangledName(), context->shaderVersion));
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getMangledName(), context->getShaderVersion()));
if (prevDec) {
if (prevDec->getReturnType() != (yyvsp[(1) - (2)].interm.function)->getReturnType()) {
context->error((yylsp[(2) - (2)]), "overloaded functions must have the same return type", (yyvsp[(1) - (2)].interm.function)->getReturnType().getBasicString());
......@@ -3713,7 +3713,7 @@ yyreduce:
ES2_ONLY("varying", (yylsp[(1) - (1)]));
if (context->globalErrorCheck((yylsp[(1) - (1)]), 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[(1) - (1)]));
else
(yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yylsp[(1) - (1)]));
......@@ -3726,7 +3726,7 @@ yyreduce:
ES2_ONLY("varying", (yylsp[(1) - (2)]));
if (context->globalErrorCheck((yylsp[(1) - (2)]), context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
if (context->shaderType == GL_VERTEX_SHADER)
if (context->getShaderType() == GL_VERTEX_SHADER)
(yyval.interm.type).setBasic(EbtVoid, EvqInvariantVaryingOut, (yylsp[(1) - (2)]));
else
(yyval.interm.type).setBasic(EbtVoid, EvqInvariantVaryingIn, (yylsp[(1) - (2)]));
......@@ -3786,7 +3786,7 @@ yyreduce:
{
ES3_ONLY("in", (yylsp[(1) - (1)]));
(yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
(yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentIn : EvqVertexIn;
(yyval.interm.type).line = (yylsp[(1) - (1)]);
}
break;
......@@ -3795,7 +3795,7 @@ yyreduce:
{
ES3_ONLY("out", (yylsp[(1) - (1)]));
(yyval.interm.type).qualifier = (context->shaderType == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
(yyval.interm.type).qualifier = (context->getShaderType() == GL_FRAGMENT_SHADER) ? EvqFragmentOut : EvqVertexOut;
(yyval.interm.type).line = (yylsp[(1) - (1)]);
}
break;
......@@ -3804,12 +3804,12 @@ yyreduce:
{
ES3_ONLY("centroid in", (yylsp[(1) - (2)]));
if (context->shaderType == GL_VERTEX_SHADER)
if (context->getShaderType() == GL_VERTEX_SHADER)
{
context->error((yylsp[(1) - (2)]), "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;
(yyval.interm.type).line = (yylsp[(2) - (2)]);
}
break;
......@@ -3818,12 +3818,12 @@ yyreduce:
{
ES3_ONLY("centroid out", (yylsp[(1) - (2)]));
if (context->shaderType == GL_FRAGMENT_SHADER)
if (context->getShaderType() == GL_FRAGMENT_SHADER)
{
context->error((yylsp[(1) - (2)]), "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;
(yyval.interm.type).line = (yylsp[(2) - (2)]);
}
break;
......@@ -4706,7 +4706,7 @@ yyreduce:
case 248:
{ context->symbolTable.push(); ++context->loopNestingLevel; }
{ context->symbolTable.push(); context->incrLoopNestingLevel(); }
break;
case 249:
......@@ -4714,13 +4714,13 @@ yyreduce:
{
context->symbolTable.pop();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopWhile, 0, (yyvsp[(4) - (6)].interm.intermTypedNode), 0, (yyvsp[(6) - (6)].interm.intermNode), (yylsp[(1) - (6)]));
--context->loopNestingLevel;
context->decrLoopNestingLevel();
}
break;
case 250:
{ ++context->loopNestingLevel; }
{ context->incrLoopNestingLevel(); }
break;
case 251:
......@@ -4730,13 +4730,13 @@ yyreduce:
context->recover();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopDoWhile, 0, (yyvsp[(6) - (8)].interm.intermTypedNode), 0, (yyvsp[(3) - (8)].interm.intermNode), (yylsp[(4) - (8)]));
--context->loopNestingLevel;
context->decrLoopNestingLevel();
}
break;
case 252:
{ context->symbolTable.push(); ++context->loopNestingLevel; }
{ context->symbolTable.push(); context->incrLoopNestingLevel(); }
break;
case 253:
......@@ -4744,7 +4744,7 @@ yyreduce:
{
context->symbolTable.pop();
(yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yylsp[(1) - (7)]));
--context->loopNestingLevel;
context->decrLoopNestingLevel();
}
break;
......@@ -4832,7 +4832,7 @@ yyreduce:
{
(yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
context->treeRoot = (yyval.interm.intermNode);
context->setTreeRoot((yyval.interm.intermNode));
}
break;
......@@ -4840,7 +4840,7 @@ yyreduce:
{
(yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0);
context->treeRoot = (yyval.interm.intermNode);
context->setTreeRoot((yyval.interm.intermNode));
}
break;
......@@ -4863,7 +4863,7 @@ yyreduce:
{
TFunction* function = (yyvsp[(1) - (1)].interm).function;
const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->getShaderVersion());
if (builtIn)
{
......@@ -4871,7 +4871,7 @@ yyreduce:
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
......@@ -4903,8 +4903,8 @@ yyreduce:
//
// Remember the return type for later checking for RETURN statements.
//
context->currentFunctionType = &(prevDec->getReturnType());
context->functionReturnsValue = false;
context->setCurrentFunctionType(&(prevDec->getReturnType()));
context->setFunctionReturnsValue(false);
//
// Insert parameters into the symbol table.
......@@ -4943,7 +4943,7 @@ yyreduce:
}
context->intermediate.setAggregateOperator(paramNodes, EOpParameters, (yylsp[(1) - (1)]));
(yyvsp[(1) - (1)].interm).intermAggregate = paramNodes;
context->loopNestingLevel = 0;
context->setLoopNestingLevel(0);
}
break;
......@@ -4952,7 +4952,7 @@ yyreduce:
{
//?? 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->functionReturnsValue) {
if (context->getCurrentFunctionType()->getBasicType() != EbtVoid && ! context->getFunctionReturnsValue()) {
context->error((yylsp[(1) - (3)]), "function does not return a value:", "", (yyvsp[(1) - (3)].interm).function->getName().c_str());
context->recover();
}
......
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