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