daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
Nicolas Capens | 16004fc | 2014-06-11 11:29:11 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 6 | #ifndef COMPILER_TRANSLATOR_PARSECONTEXT_H_ |
| 7 | #define COMPILER_TRANSLATOR_PARSECONTEXT_H_ |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8 | |
Jamie Madill | d4a3a31 | 2014-06-25 16:04:56 -0400 | [diff] [blame] | 9 | #include "compiler/translator/Compiler.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 10 | #include "compiler/translator/Diagnostics.h" |
| 11 | #include "compiler/translator/DirectiveHandler.h" |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 12 | #include "compiler/translator/Intermediate.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 13 | #include "compiler/translator/SymbolTable.h" |
daniel@transgaming.com | b401a92 | 2012-10-26 18:58:24 +0000 | [diff] [blame] | 14 | #include "compiler/preprocessor/Preprocessor.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 15 | |
| 16 | struct TMatrixFields { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 17 | bool wholeRow; |
| 18 | bool wholeCol; |
| 19 | int row; |
| 20 | int col; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 23 | // |
| 24 | // The following are extra variables needed during parsing, grouped together so |
| 25 | // they can be passed to the parser without needing a global. |
| 26 | // |
| 27 | struct TParseContext { |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 28 | TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, sh::GLenum type, ShShaderSpec spec, int options, bool checksPrecErrors, TInfoSink& is, bool debugShaderPrecisionSupported) : |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 29 | intermediate(interm), |
| 30 | symbolTable(symt), |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 31 | shaderType(type), |
| 32 | shaderSpec(spec), |
| 33 | compileOptions(options), |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 34 | treeRoot(0), |
Olli Etuaho | 4930086 | 2015-02-20 14:54:49 +0200 | [diff] [blame] | 35 | mLoopNestingLevel(0), |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 36 | structNestingLevel(0), |
Olli Etuaho | 53f076f | 2015-02-20 10:55:14 +0200 | [diff] [blame] | 37 | mSwitchNestingLevel(0), |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 38 | currentFunctionType(NULL), |
Olli Etuaho | 4930086 | 2015-02-20 14:54:49 +0200 | [diff] [blame] | 39 | mFunctionReturnsValue(false), |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 40 | checksPrecisionErrors(checksPrecErrors), |
Nico Weber | 092e1a1 | 2015-03-09 07:40:11 -0700 | [diff] [blame] | 41 | fragmentPrecisionHigh(false), |
Jamie Madill | 099c0f3 | 2013-06-20 11:55:52 -0400 | [diff] [blame] | 42 | defaultMatrixPacking(EmpColumnMajor), |
Jamie Madill | 1566ef7 | 2013-06-20 11:55:54 -0400 | [diff] [blame] | 43 | defaultBlockStorage(EbsShared), |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 44 | diagnostics(is), |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 45 | shaderVersion(100), |
Olli Etuaho | 853dc1a | 2014-11-06 17:25:48 +0200 | [diff] [blame] | 46 | directiveHandler(ext, diagnostics, shaderVersion, debugShaderPrecisionSupported), |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 47 | preprocessor(&diagnostics, &directiveHandler), |
Olli Etuaho | fa33d58 | 2015-04-09 14:33:12 +0300 | [diff] [blame] | 48 | scanner(NULL), |
| 49 | mDeferredSingleDeclarationErrorCheck(false) |
| 50 | { |
| 51 | } |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 52 | TIntermediate& intermediate; // to hold and build a parse tree |
| 53 | TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 54 | sh::GLenum shaderType; // vertex or fragment language (future: pack or unpack) |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 55 | ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 56 | int shaderVersion; |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 57 | int compileOptions; |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 58 | TIntermNode* treeRoot; // root of parse tree being created |
Olli Etuaho | 4930086 | 2015-02-20 14:54:49 +0200 | [diff] [blame] | 59 | int mLoopNestingLevel; // 0 if outside all loops |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 60 | int structNestingLevel; // incremented while parsing a struct declaration |
Olli Etuaho | 53f076f | 2015-02-20 10:55:14 +0200 | [diff] [blame] | 61 | int mSwitchNestingLevel; // 0 if outside all switch statements |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 62 | const TType* currentFunctionType; // the return type of the function that's currently being parsed |
Olli Etuaho | 4930086 | 2015-02-20 14:54:49 +0200 | [diff] [blame] | 63 | bool mFunctionReturnsValue; // true if a non-void function has a return |
zmo@google.com | dc4b4f8 | 2011-06-17 00:42:53 +0000 | [diff] [blame] | 64 | bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit. |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 65 | bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language. |
Jamie Madill | 099c0f3 | 2013-06-20 11:55:52 -0400 | [diff] [blame] | 66 | TLayoutMatrixPacking defaultMatrixPacking; |
Jamie Madill | 1566ef7 | 2013-06-20 11:55:54 -0400 | [diff] [blame] | 67 | TLayoutBlockStorage defaultBlockStorage; |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 68 | TString HashErrMsg; |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 69 | TDiagnostics diagnostics; |
| 70 | TDirectiveHandler directiveHandler; |
| 71 | pp::Preprocessor preprocessor; |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 72 | void* scanner; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 73 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 74 | int getShaderVersion() const { return shaderVersion; } |
alokp@chromium.org | 6b49571 | 2012-06-29 00:06:58 +0000 | [diff] [blame] | 75 | int numErrors() const { return diagnostics.numErrors(); } |
alokp@chromium.org | 646ea1e | 2012-06-15 17:36:31 +0000 | [diff] [blame] | 76 | TInfoSink& infoSink() { return diagnostics.infoSink(); } |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 77 | void error(const TSourceLoc& loc, const char *reason, const char* token, |
maxvujovic@gmail.com | c6b3b3c | 2012-06-27 22:49:39 +0000 | [diff] [blame] | 78 | const char* extraInfo=""); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 79 | void warning(const TSourceLoc& loc, const char* reason, const char* token, |
maxvujovic@gmail.com | c6b3b3c | 2012-06-27 22:49:39 +0000 | [diff] [blame] | 80 | const char* extraInfo=""); |
alokp@chromium.org | 8b851c6 | 2012-06-15 16:25:11 +0000 | [diff] [blame] | 81 | void trace(const char* str); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 82 | void recover(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 83 | |
Jamie Madill | 5c09702 | 2014-08-20 16:38:32 -0400 | [diff] [blame] | 84 | // This method is guaranteed to succeed, even if no variable with 'name' exists. |
| 85 | const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol); |
| 86 | |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 87 | bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc& line); |
| 88 | bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, const TSourceLoc& line); |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 89 | |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 90 | bool reservedErrorCheck(const TSourceLoc& line, const TString& identifier); |
| 91 | void assignError(const TSourceLoc& line, const char* op, TString left, TString right); |
| 92 | void unaryOpError(const TSourceLoc& line, const char* op, TString operand); |
| 93 | void binaryOpError(const TSourceLoc& line, const char* op, TString left, TString right); |
| 94 | bool precisionErrorCheck(const TSourceLoc& line, TPrecision precision, TBasicType type); |
| 95 | bool lValueErrorCheck(const TSourceLoc& line, const char* op, TIntermTyped*); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 96 | bool constErrorCheck(TIntermTyped* node); |
| 97 | bool integerErrorCheck(TIntermTyped* node, const char* token); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 98 | bool globalErrorCheck(const TSourceLoc& line, bool global, const char* token); |
| 99 | bool constructorErrorCheck(const TSourceLoc& line, TIntermNode*, TFunction&, TOperator, TType*); |
| 100 | bool arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* expr, int& size); |
Olli Etuaho | 3739d23 | 2015-04-08 12:23:44 +0300 | [diff] [blame] | 101 | bool arrayQualifierErrorCheck(const TSourceLoc &line, const TPublicType &type); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 102 | bool arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type); |
Olli Etuaho | 6ed7bbe | 2015-04-07 18:08:46 +0300 | [diff] [blame] | 103 | bool voidErrorCheck(const TSourceLoc &line, const TString &identifier, const TBasicType &type); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 104 | bool boolErrorCheck(const TSourceLoc&, const TIntermTyped*); |
| 105 | bool boolErrorCheck(const TSourceLoc&, const TPublicType&); |
| 106 | bool samplerErrorCheck(const TSourceLoc& line, const TPublicType& pType, const char* reason); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 107 | bool locationDeclaratorListCheck(const TSourceLoc& line, const TPublicType &pType); |
| 108 | bool parameterSamplerErrorCheck(const TSourceLoc& line, TQualifier qualifier, const TType& type); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 109 | bool paramErrorCheck(const TSourceLoc& line, TQualifier qualifier, TQualifier paramQualifier, TType* type); |
| 110 | bool extensionErrorCheck(const TSourceLoc& line, const TString&); |
Olli Etuaho | fa33d58 | 2015-04-09 14:33:12 +0300 | [diff] [blame] | 111 | bool singleDeclarationErrorCheck(TPublicType &publicType, const TSourceLoc &identifierLocation); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 112 | bool layoutLocationErrorCheck(const TSourceLoc& location, const TLayoutQualifier &layoutQualifier); |
Olli Etuaho | b6e07a6 | 2015-02-16 12:22:10 +0200 | [diff] [blame] | 113 | bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *); |
alokp@chromium.org | 8b851c6 | 2012-06-15 16:25:11 +0000 | [diff] [blame] | 114 | |
Jamie Madill | 7a217de | 2013-07-08 15:10:00 -0400 | [diff] [blame] | 115 | const TPragma& pragma() const { return directiveHandler.pragma(); } |
alokp@chromium.org | 73bc298 | 2012-06-19 18:48:05 +0000 | [diff] [blame] | 116 | const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); } |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 117 | bool supportsExtension(const char* extension); |
Jamie Madill | 5d287f5 | 2013-07-12 15:38:19 -0400 | [diff] [blame] | 118 | bool isExtensionEnabled(const char* extension) const; |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 119 | void handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior); |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 120 | void handlePragmaDirective(const TSourceLoc& loc, const char* name, const char* value, bool stdgl); |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 121 | |
| 122 | bool containsSampler(TType& type); |
| 123 | bool areAllChildConst(TIntermAggregate* aggrNode); |
Austin Kinross | 3ae6465 | 2015-01-26 15:51:39 -0800 | [diff] [blame] | 124 | const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int inputShaderVersion, bool *builtIn = 0); |
Olli Etuaho | 2935c58 | 2015-04-08 14:32:06 +0300 | [diff] [blame] | 125 | bool executeInitializer(const TSourceLoc &line, const TString &identifier, TPublicType &pType, |
Olli Etuaho | e7847b0 | 2015-03-16 11:56:12 +0200 | [diff] [blame] | 126 | TIntermTyped *initializer, TIntermNode **intermNode); |
alokp@chromium.org | 75fe6b7 | 2011-08-14 05:31:22 +0000 | [diff] [blame] | 127 | |
shannonwoods@chromium.org | 0f376ca | 2013-05-30 00:19:23 +0000 | [diff] [blame] | 128 | TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier); |
Jamie Madill | a5efff9 | 2013-06-06 11:56:47 -0400 | [diff] [blame] | 129 | TPublicType addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType& typeSpecifier); |
Olli Etuaho | e7847b0 | 2015-03-16 11:56:12 +0200 | [diff] [blame] | 130 | |
Olli Etuaho | fa33d58 | 2015-04-09 14:33:12 +0300 | [diff] [blame] | 131 | TIntermAggregate *parseSingleDeclaration(TPublicType &publicType, |
| 132 | const TSourceLoc &identifierOrTypeLocation, const TString &identifier); |
Olli Etuaho | e7847b0 | 2015-03-16 11:56:12 +0200 | [diff] [blame] | 133 | TIntermAggregate *parseSingleArrayDeclaration(TPublicType &publicType, |
| 134 | const TSourceLoc &identifierLocation, const TString &identifier, |
| 135 | const TSourceLoc &indexLocation, TIntermTyped *indexExpression); |
| 136 | TIntermAggregate *parseSingleInitDeclaration(TPublicType &publicType, |
| 137 | const TSourceLoc &identifierLocation, const TString &identifier, |
| 138 | const TSourceLoc &initLocation, TIntermTyped *initializer); |
Jamie Madill | 47e3ec0 | 2014-08-20 16:38:33 -0400 | [diff] [blame] | 139 | |
Olli Etuaho | 3875ffd | 2015-04-10 16:45:14 +0300 | [diff] [blame] | 140 | // Parse a declaration like "type a[n] = initializer" |
| 141 | // Note that this does not apply to declarations like "type[n] a = initializer" |
| 142 | TIntermAggregate *parseSingleArrayInitDeclaration(TPublicType &publicType, |
| 143 | const TSourceLoc &identifierLocation, const TString &identifier, |
| 144 | const TSourceLoc &indexLocation, TIntermTyped *indexExpression, |
| 145 | const TSourceLoc &initLocation, TIntermTyped *initializer); |
| 146 | |
Olli Etuaho | e7847b0 | 2015-03-16 11:56:12 +0200 | [diff] [blame] | 147 | TIntermAggregate *parseInvariantDeclaration(const TSourceLoc &invariantLoc, const TSourceLoc &identifierLoc, |
| 148 | const TString *identifier, const TSymbol *symbol); |
| 149 | |
| 150 | TIntermAggregate *parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, |
| 151 | const TSourceLoc &identifierLocation, const TString &identifier); |
| 152 | TIntermAggregate *parseArrayDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, |
| 153 | const TSourceLoc &identifierLocation, const TString &identifier, |
| 154 | const TSourceLoc &arrayLocation, TIntermTyped *indexExpression); |
| 155 | TIntermAggregate *parseInitDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, |
| 156 | const TSourceLoc &identifierLocation, const TString &identifier, |
| 157 | const TSourceLoc &initLocation, TIntermTyped *initializer); |
| 158 | |
Olli Etuaho | 3875ffd | 2015-04-10 16:45:14 +0300 | [diff] [blame] | 159 | // Parse a declarator like "a[n] = initializer" |
| 160 | TIntermAggregate *parseArrayInitDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, |
| 161 | const TSourceLoc& identifierLocation, const TString &identifier, |
| 162 | const TSourceLoc& indexLocation, TIntermTyped *indexExpression, |
| 163 | const TSourceLoc &initLocation, TIntermTyped *initializer); |
| 164 | |
Jamie Madill | a295edf | 2013-06-06 11:56:48 -0400 | [diff] [blame] | 165 | void parseGlobalLayoutQualifier(const TPublicType &typeQualifier); |
shannonwoods@chromium.org | 1885113 | 2013-05-30 00:19:54 +0000 | [diff] [blame] | 166 | TFunction *addConstructorFunc(TPublicType publicType); |
Olli Etuaho | 2120370 | 2014-11-13 16:16:21 +0200 | [diff] [blame] | 167 | TIntermTyped* addConstructor(TIntermNode*, TType*, TOperator, TFunction*, const TSourceLoc&); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 168 | TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 169 | TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&); |
| 170 | TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&); |
| 171 | TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line); |
| 172 | TIntermTyped* addConstStruct(const TString &identifier, TIntermTyped *node, const TSourceLoc& line); |
| 173 | TIntermTyped* addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc& location, TIntermTyped *indexExpression); |
| 174 | TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc& dotLocation, const TString &fieldString, const TSourceLoc& fieldLocation); |
shannonwoods@chromium.org | a910088 | 2013-05-30 00:11:39 +0000 | [diff] [blame] | 175 | |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 176 | TFieldList *addStructDeclaratorList(const TPublicType& typeSpecifier, TFieldList *fieldList); |
| 177 | TPublicType addStructure(const TSourceLoc& structLine, const TSourceLoc& nameLine, const TString *structName, TFieldList* fieldList); |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 178 | |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 179 | TIntermAggregate* addInterfaceBlock(const TPublicType& typeQualifier, const TSourceLoc& nameLine, const TString& blockName, TFieldList* fieldList, |
| 180 | const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine); |
shannonwoods@chromium.org | 5668c5d | 2013-05-30 00:11:48 +0000 | [diff] [blame] | 181 | |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 182 | TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine); |
| 183 | TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine); |
Jamie Madill | a5efff9 | 2013-06-06 11:56:47 -0400 | [diff] [blame] | 184 | TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier); |
Jamie Madill | f2e0f9b | 2013-08-26 16:39:42 -0400 | [diff] [blame] | 185 | TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier, |
| 186 | const TSourceLoc &storageLoc, TQualifier storageQualifier); |
shannonwoods@chromium.org | 302adfe | 2013-05-30 00:21:06 +0000 | [diff] [blame] | 187 | |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 188 | // Performs an error check for embedded struct declarations. |
| 189 | // Returns true if an error was raised due to the declaration of |
| 190 | // this struct. |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 191 | bool enterStructDeclaration(const TSourceLoc& line, const TString& identifier); |
kbr@chromium.org | 476541f | 2011-10-27 21:14:51 +0000 | [diff] [blame] | 192 | void exitStructDeclaration(); |
| 193 | |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 194 | bool structNestingErrorCheck(const TSourceLoc& line, const TField& field); |
Olli Etuaho | 09b2247 | 2015-02-11 11:47:26 +0200 | [diff] [blame] | 195 | |
Olli Etuaho | a3a3666 | 2015-02-17 13:46:51 +0200 | [diff] [blame] | 196 | TIntermSwitch *addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc); |
| 197 | TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc); |
| 198 | TIntermCase *addDefault(const TSourceLoc &loc); |
| 199 | |
Olli Etuaho | 09b2247 | 2015-02-11 11:47:26 +0200 | [diff] [blame] | 200 | TIntermTyped *addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &); |
| 201 | TIntermTyped *addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &); |
| 202 | TIntermTyped *addBinaryMath(TOperator op, TIntermTyped *left, TIntermTyped *right, |
| 203 | const TSourceLoc &); |
| 204 | TIntermTyped *addBinaryMathBooleanResult(TOperator op, TIntermTyped *left, TIntermTyped *right, |
| 205 | const TSourceLoc &); |
Olli Etuaho | d6b1428 | 2015-03-17 14:31:35 +0200 | [diff] [blame] | 206 | TIntermTyped *addAssign(TOperator op, TIntermTyped *left, TIntermTyped *right, |
| 207 | const TSourceLoc &loc); |
Olli Etuaho | 4930086 | 2015-02-20 14:54:49 +0200 | [diff] [blame] | 208 | |
| 209 | TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc); |
| 210 | TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc); |
Olli Etuaho | c4ba3be | 2015-03-02 14:42:24 +0200 | [diff] [blame] | 211 | |
| 212 | TIntermTyped *addFunctionCallOrMethod(TFunction *fnCall, TIntermNode *node, |
| 213 | const TSourceLoc &loc, bool *fatalError); |
Olli Etuaho | fc1806e | 2015-03-17 13:03:11 +0200 | [diff] [blame] | 214 | |
Olli Etuaho | 5290174 | 2015-04-15 13:42:45 +0300 | [diff] [blame^] | 215 | TIntermTyped *addTernarySelection(TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, |
| 216 | const TSourceLoc &line); |
| 217 | |
Olli Etuaho | fc1806e | 2015-03-17 13:03:11 +0200 | [diff] [blame] | 218 | private: |
Olli Etuaho | 2935c58 | 2015-04-08 14:32:06 +0300 | [diff] [blame] | 219 | bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable); |
| 220 | |
Olli Etuaho | 376f1b5 | 2015-04-13 13:23:41 +0300 | [diff] [blame] | 221 | bool nonInitErrorCheck(const TSourceLoc &line, const TString &identifier, TPublicType *type); |
| 222 | |
Olli Etuaho | fc1806e | 2015-03-17 13:03:11 +0200 | [diff] [blame] | 223 | TIntermTyped *addBinaryMathInternal(TOperator op, TIntermTyped *left, TIntermTyped *right, |
| 224 | const TSourceLoc &loc); |
Olli Etuaho | d6b1428 | 2015-03-17 14:31:35 +0200 | [diff] [blame] | 225 | TIntermTyped *createAssign(TOperator op, TIntermTyped *left, TIntermTyped *right, |
| 226 | const TSourceLoc &loc); |
Olli Etuaho | f6c694b | 2015-03-26 14:50:53 +0200 | [diff] [blame] | 227 | // The funcReturnType parameter is expected to be non-null when the operation is a built-in function. |
| 228 | // It is expected to be null for other unary operators. |
| 229 | TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc, |
| 230 | const TType *funcReturnType); |
Olli Etuaho | d6b1428 | 2015-03-17 14:31:35 +0200 | [diff] [blame] | 231 | |
Olli Etuaho | 47fd36a | 2015-03-19 14:22:24 +0200 | [diff] [blame] | 232 | // Return true if the checks pass |
| 233 | bool binaryOpCommonCheck(TOperator op, TIntermTyped *left, TIntermTyped *right, |
Olli Etuaho | d6b1428 | 2015-03-17 14:31:35 +0200 | [diff] [blame] | 234 | const TSourceLoc &loc); |
Olli Etuaho | fa33d58 | 2015-04-09 14:33:12 +0300 | [diff] [blame] | 235 | |
| 236 | // Set to true when the last/current declarator list was started with an empty declaration. |
| 237 | bool mDeferredSingleDeclarationErrorCheck; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 240 | int PaParseStrings(size_t count, const char* const string[], const int length[], |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 241 | TParseContext* context); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 242 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 243 | #endif // COMPILER_TRANSLATOR_PARSECONTEXT_H_ |