blob: cb73fd9d51bc49af5f74bc6e1b6c840b22e0963a [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Nicolas Capens16004fc2014-06-11 11:29:11 -04002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
Geoff Lang0a73dd82014-11-19 16:18:08 -05006#ifndef COMPILER_TRANSLATOR_PARSECONTEXT_H_
7#define COMPILER_TRANSLATOR_PARSECONTEXT_H_
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008
Jamie Madilld4a3a312014-06-25 16:04:56 -04009#include "compiler/translator/Compiler.h"
Geoff Lang17732822013-08-29 13:46:49 -040010#include "compiler/translator/Diagnostics.h"
11#include "compiler/translator/DirectiveHandler.h"
Jamie Madillb1a85f42014-08-19 15:23:24 -040012#include "compiler/translator/Intermediate.h"
Geoff Lang17732822013-08-29 13:46:49 -040013#include "compiler/translator/SymbolTable.h"
daniel@transgaming.comb401a922012-10-26 18:58:24 +000014#include "compiler/preprocessor/Preprocessor.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000015
Jamie Madill06145232015-05-13 13:10:01 -040016struct TMatrixFields
17{
daniel@transgaming.com0578f812010-05-17 09:58:39 +000018 bool wholeRow;
19 bool wholeCol;
20 int row;
21 int col;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000022};
23
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024//
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 Madill6e06b1f2015-05-14 10:01:17 -040028class TParseContext : angle::NonCopyable
Jamie Madill06145232015-05-13 13:10:01 -040029{
Jamie Madill6e06b1f2015-05-14 10:01:17 -040030 public:
Jamie Madill06145232015-05-13 13:10:01 -040031 TParseContext(TSymbolTable &symt,
32 TExtensionBehavior &ext,
33 TIntermediate &interm,
34 sh::GLenum type,
35 ShShaderSpec spec,
36 int options,
37 bool checksPrecErrors,
38 TInfoSink &is,
39 bool debugShaderPrecisionSupported)
40 : intermediate(interm),
41 symbolTable(symt),
Corentin Wallezbc99bb62015-05-14 17:42:20 -040042 mDeferredSingleDeclarationErrorCheck(false),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040043 mShaderType(type),
44 mShaderSpec(spec),
Corentin Wallezbc99bb62015-05-14 17:42:20 -040045 mShaderVersion(100),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040046 mTreeRoot(nullptr),
Jamie Madill06145232015-05-13 13:10:01 -040047 mLoopNestingLevel(0),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040048 mStructNestingLevel(0),
Jamie Madill06145232015-05-13 13:10:01 -040049 mSwitchNestingLevel(0),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040050 mCurrentFunctionType(nullptr),
Jamie Madill06145232015-05-13 13:10:01 -040051 mFunctionReturnsValue(false),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040052 mChecksPrecisionErrors(checksPrecErrors),
Olli Etuahoa6996682015-10-12 14:32:30 +030053 mFragmentPrecisionHighOnESSL1(false),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040054 mDefaultMatrixPacking(EmpColumnMajor),
55 mDefaultBlockStorage(EbsShared),
56 mDiagnostics(is),
Jamie Madill6e06b1f2015-05-14 10:01:17 -040057 mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported),
58 mPreprocessor(&mDiagnostics, &mDirectiveHandler),
59 mScanner(nullptr),
Jamie Madill14e95b32015-05-07 10:10:41 -040060 mUsesFragData(false),
Kimmo Kinnunenb18609b2015-07-16 14:13:11 +030061 mUsesFragColor(false),
62 mUsesSecondaryOutputs(false)
Olli Etuahofa33d582015-04-09 14:33:12 +030063 {
64 }
Jamie Madill06145232015-05-13 13:10:01 -040065
Jamie Madill6e06b1f2015-05-14 10:01:17 -040066 const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; }
67 pp::Preprocessor &getPreprocessor() { return mPreprocessor; }
68 void *getScanner() const { return mScanner; }
69 void setScanner(void *scanner) { mScanner = scanner; }
70 int getShaderVersion() const { return mShaderVersion; }
71 sh::GLenum getShaderType() const { return mShaderType; }
72 ShShaderSpec getShaderSpec() const { return mShaderSpec; }
73 int numErrors() const { return mDiagnostics.numErrors(); }
74 TInfoSink &infoSink() { return mDiagnostics.infoSink(); }
Jamie Madill06145232015-05-13 13:10:01 -040075 void error(const TSourceLoc &loc, const char *reason, const char *token,
76 const char *extraInfo="");
77 void warning(const TSourceLoc &loc, const char *reason, const char *token,
78 const char *extraInfo="");
Jamie Madill14e95b32015-05-07 10:10:41 -040079
daniel@transgaming.com0578f812010-05-17 09:58:39 +000080 void recover();
Jamie Madill6e06b1f2015-05-14 10:01:17 -040081 TIntermNode *getTreeRoot() const { return mTreeRoot; }
82 void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
83
Olli Etuahoa6996682015-10-12 14:32:30 +030084 bool getFragmentPrecisionHigh() const
Jamie Madill6e06b1f2015-05-14 10:01:17 -040085 {
Olli Etuahoa6996682015-10-12 14:32:30 +030086 return mFragmentPrecisionHighOnESSL1 || mShaderVersion >= 300;
87 }
88 void setFragmentPrecisionHighOnESSL1(bool fragmentPrecisionHigh)
89 {
90 mFragmentPrecisionHighOnESSL1 = fragmentPrecisionHigh;
Jamie Madill6e06b1f2015-05-14 10:01:17 -040091 }
92
93 bool getFunctionReturnsValue() const { return mFunctionReturnsValue; }
94 void setFunctionReturnsValue(bool functionReturnsValue)
95 {
96 mFunctionReturnsValue = functionReturnsValue;
97 }
98
99 void setLoopNestingLevel(int loopNestintLevel)
100 {
101 mLoopNestingLevel = loopNestintLevel;
102 }
103
104 const TType *getCurrentFunctionType() const { return mCurrentFunctionType; }
105 void setCurrentFunctionType(const TType *currentFunctionType)
106 {
107 mCurrentFunctionType = currentFunctionType;
108 }
109
110 void incrLoopNestingLevel() { ++mLoopNestingLevel; }
111 void decrLoopNestingLevel() { --mLoopNestingLevel; }
112
113 void incrSwitchNestingLevel() { ++mSwitchNestingLevel; }
114 void decrSwitchNestingLevel() { --mSwitchNestingLevel; }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115
Jamie Madill5c097022014-08-20 16:38:32 -0400116 // This method is guaranteed to succeed, even if no variable with 'name' exists.
117 const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol);
118
Jamie Madill06145232015-05-13 13:10:01 -0400119 bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc &line);
alokp@chromium.org75fe6b72011-08-14 05:31:22 +0000120
Jamie Madill06145232015-05-13 13:10:01 -0400121 bool reservedErrorCheck(const TSourceLoc &line, const TString &identifier);
122 void assignError(const TSourceLoc &line, const char *op, TString left, TString right);
123 void unaryOpError(const TSourceLoc &line, const char *op, TString operand);
124 void binaryOpError(const TSourceLoc &line, const char *op, TString left, TString right);
125 bool precisionErrorCheck(const TSourceLoc &line, TPrecision precision, TBasicType type);
126 bool lValueErrorCheck(const TSourceLoc &line, const char *op, TIntermTyped*);
127 bool constErrorCheck(TIntermTyped *node);
128 bool integerErrorCheck(TIntermTyped *node, const char *token);
129 bool globalErrorCheck(const TSourceLoc &line, bool global, const char *token);
130 bool constructorErrorCheck(const TSourceLoc &line, TIntermNode*, TFunction&, TOperator, TType*);
131 bool arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped *expr, int &size);
Olli Etuaho3739d232015-04-08 12:23:44 +0300132 bool arrayQualifierErrorCheck(const TSourceLoc &line, const TPublicType &type);
Jamie Madill06145232015-05-13 13:10:01 -0400133 bool arrayTypeErrorCheck(const TSourceLoc &line, const TPublicType &type);
Olli Etuaho6ed7bbe2015-04-07 18:08:46 +0300134 bool voidErrorCheck(const TSourceLoc &line, const TString &identifier, const TBasicType &type);
Jamie Madill075edd82013-07-08 13:30:19 -0400135 bool boolErrorCheck(const TSourceLoc&, const TIntermTyped*);
136 bool boolErrorCheck(const TSourceLoc&, const TPublicType&);
Jamie Madill06145232015-05-13 13:10:01 -0400137 bool samplerErrorCheck(const TSourceLoc &line, const TPublicType &pType, const char *reason);
138 bool locationDeclaratorListCheck(const TSourceLoc &line, const TPublicType &pType);
139 bool parameterSamplerErrorCheck(const TSourceLoc &line, TQualifier qualifier, const TType &type);
140 bool paramErrorCheck(const TSourceLoc &line, TQualifier qualifier, TQualifier paramQualifier, TType *type);
141 bool extensionErrorCheck(const TSourceLoc &line, const TString&);
142 bool singleDeclarationErrorCheck(const TPublicType &publicType, const TSourceLoc &identifierLocation);
143 bool layoutLocationErrorCheck(const TSourceLoc &location, const TLayoutQualifier &layoutQualifier);
Olli Etuahob6e07a62015-02-16 12:22:10 +0200144 bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *);
Olli Etuaho37ad4742015-04-27 13:18:50 +0300145 void es3InvariantErrorCheck(const TQualifier qualifier, const TSourceLoc &invariantLocation);
Olli Etuahocc36b982015-07-10 14:14:18 +0300146 void es3InputOutputTypeCheck(const TQualifier qualifier,
147 const TPublicType &type,
148 const TSourceLoc &qualifierLocation);
alokp@chromium.org8b851c62012-06-15 16:25:11 +0000149
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400150 const TPragma &pragma() const { return mDirectiveHandler.pragma(); }
151 const TExtensionBehavior &extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); }
Jamie Madill06145232015-05-13 13:10:01 -0400152 bool supportsExtension(const char *extension);
153 bool isExtensionEnabled(const char *extension) const;
154 void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
155 void handlePragmaDirective(const TSourceLoc &loc, const char *name, const char *value, bool stdgl);
alokp@chromium.org75fe6b72011-08-14 05:31:22 +0000156
Jamie Madill06145232015-05-13 13:10:01 -0400157 bool containsSampler(const TType &type);
158 bool areAllChildConst(TIntermAggregate *aggrNode);
159 const TFunction* findFunction(
160 const TSourceLoc &line, TFunction *pfnCall, int inputShaderVersion, bool *builtIn = 0);
161 bool executeInitializer(const TSourceLoc &line,
162 const TString &identifier,
163 const TPublicType &pType,
164 TIntermTyped *initializer,
165 TIntermNode **intermNode);
alokp@chromium.org75fe6b72011-08-14 05:31:22 +0000166
Jamie Madill06145232015-05-13 13:10:01 -0400167 TPublicType addFullySpecifiedType(TQualifier qualifier,
168 bool invariant,
169 TLayoutQualifier layoutQualifier,
170 const TPublicType &typeSpecifier);
Olli Etuahoe7847b02015-03-16 11:56:12 +0200171
Olli Etuahofa33d582015-04-09 14:33:12 +0300172 TIntermAggregate *parseSingleDeclaration(TPublicType &publicType,
Jamie Madill06145232015-05-13 13:10:01 -0400173 const TSourceLoc &identifierOrTypeLocation,
174 const TString &identifier);
Olli Etuahoe7847b02015-03-16 11:56:12 +0200175 TIntermAggregate *parseSingleArrayDeclaration(TPublicType &publicType,
Jamie Madill06145232015-05-13 13:10:01 -0400176 const TSourceLoc &identifierLocation,
177 const TString &identifier,
178 const TSourceLoc &indexLocation,
179 TIntermTyped *indexExpression);
180 TIntermAggregate *parseSingleInitDeclaration(const TPublicType &publicType,
181 const TSourceLoc &identifierLocation,
182 const TString &identifier,
183 const TSourceLoc &initLocation,
184 TIntermTyped *initializer);
Jamie Madill47e3ec02014-08-20 16:38:33 -0400185
Olli Etuaho3875ffd2015-04-10 16:45:14 +0300186 // Parse a declaration like "type a[n] = initializer"
187 // Note that this does not apply to declarations like "type[n] a = initializer"
188 TIntermAggregate *parseSingleArrayInitDeclaration(TPublicType &publicType,
Jamie Madill06145232015-05-13 13:10:01 -0400189 const TSourceLoc &identifierLocation,
190 const TString &identifier,
191 const TSourceLoc &indexLocation,
192 TIntermTyped *indexExpression,
193 const TSourceLoc &initLocation,
194 TIntermTyped *initializer);
Olli Etuaho3875ffd2015-04-10 16:45:14 +0300195
Jamie Madill06145232015-05-13 13:10:01 -0400196 TIntermAggregate *parseInvariantDeclaration(const TSourceLoc &invariantLoc,
197 const TSourceLoc &identifierLoc,
198 const TString *identifier,
199 const TSymbol *symbol);
Olli Etuahoe7847b02015-03-16 11:56:12 +0200200
Jamie Madill06145232015-05-13 13:10:01 -0400201 TIntermAggregate *parseDeclarator(TPublicType &publicType,
202 TIntermAggregate *aggregateDeclaration,
203 const TSourceLoc &identifierLocation,
204 const TString &identifier);
205 TIntermAggregate *parseArrayDeclarator(TPublicType &publicType,
206 TIntermAggregate *aggregateDeclaration,
207 const TSourceLoc &identifierLocation,
208 const TString &identifier,
209 const TSourceLoc &arrayLocation,
210 TIntermTyped *indexExpression);
211 TIntermAggregate *parseInitDeclarator(const TPublicType &publicType,
212 TIntermAggregate *aggregateDeclaration,
213 const TSourceLoc &identifierLocation,
214 const TString &identifier,
215 const TSourceLoc &initLocation,
216 TIntermTyped *initializer);
Olli Etuahoe7847b02015-03-16 11:56:12 +0200217
Olli Etuaho3875ffd2015-04-10 16:45:14 +0300218 // Parse a declarator like "a[n] = initializer"
Jamie Madill06145232015-05-13 13:10:01 -0400219 TIntermAggregate *parseArrayInitDeclarator(const TPublicType &publicType,
220 TIntermAggregate *aggregateDeclaration,
221 const TSourceLoc &identifierLocation,
222 const TString &identifier,
223 const TSourceLoc &indexLocation,
224 TIntermTyped *indexExpression,
225 const TSourceLoc &initLocation,
226 TIntermTyped *initializer);
Olli Etuaho3875ffd2015-04-10 16:45:14 +0300227
Jamie Madilla295edf2013-06-06 11:56:48 -0400228 void parseGlobalLayoutQualifier(const TPublicType &typeQualifier);
Jamie Madill185fb402015-06-12 15:48:48 -0400229 void parseFunctionPrototype(const TSourceLoc &location,
230 TFunction *function,
231 TIntermAggregate **aggregateOut);
232 TFunction *parseFunctionDeclarator(const TSourceLoc &location,
233 TFunction *function);
Jamie Madill06145232015-05-13 13:10:01 -0400234 TFunction *addConstructorFunc(const TPublicType &publicType);
235 TIntermTyped *addConstructor(TIntermNode *arguments,
236 TType *type,
237 TOperator op,
238 TFunction *fnCall,
239 const TSourceLoc &line);
240 TIntermTyped *foldConstConstructor(TIntermAggregate *aggrNode, const TType &type);
241 TIntermTyped *addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&);
242 TIntermTyped *addConstMatrixNode(int, TIntermTyped*, const TSourceLoc&);
243 TIntermTyped *addConstArrayNode(int index, TIntermTyped *node, const TSourceLoc &line);
244 TIntermTyped *addConstStruct(
245 const TString &identifier, TIntermTyped *node, const TSourceLoc& line);
246 TIntermTyped *addIndexExpression(TIntermTyped *baseExpression,
247 const TSourceLoc& location,
248 TIntermTyped *indexExpression);
249 TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression,
250 const TSourceLoc &dotLocation,
251 const TString &fieldString,
252 const TSourceLoc &fieldLocation);
shannonwoods@chromium.orga9100882013-05-30 00:11:39 +0000253
Jamie Madill06145232015-05-13 13:10:01 -0400254 TFieldList *addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList);
255 TPublicType addStructure(const TSourceLoc &structLine,
256 const TSourceLoc &nameLine,
257 const TString *structName,
258 TFieldList *fieldList);
kbr@chromium.org476541f2011-10-27 21:14:51 +0000259
Jamie Madill06145232015-05-13 13:10:01 -0400260 TIntermAggregate* addInterfaceBlock(const TPublicType &typeQualifier,
261 const TSourceLoc &nameLine,
262 const TString &blockName,
263 TFieldList *fieldList,
264 const TString *instanceName,
265 const TSourceLoc &instanceLine,
266 TIntermTyped *arrayIndex,
267 const TSourceLoc& arrayIndexLine);
shannonwoods@chromium.org5668c5d2013-05-30 00:11:48 +0000268
Jamie Madill06145232015-05-13 13:10:01 -0400269 TLayoutQualifier parseLayoutQualifier(
270 const TString &qualifierType, const TSourceLoc &qualifierTypeLine);
271 TLayoutQualifier parseLayoutQualifier(const TString &qualifierType,
272 const TSourceLoc &qualifierTypeLine,
273 const TString &intValueString,
274 int intValue,
275 const TSourceLoc &intValueLine);
Jamie Madilla5efff92013-06-06 11:56:47 -0400276 TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier);
Jamie Madillf2e0f9b2013-08-26 16:39:42 -0400277 TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier,
278 const TSourceLoc &storageLoc, TQualifier storageQualifier);
shannonwoods@chromium.org302adfe2013-05-30 00:21:06 +0000279
kbr@chromium.org476541f2011-10-27 21:14:51 +0000280 // Performs an error check for embedded struct declarations.
281 // Returns true if an error was raised due to the declaration of
282 // this struct.
Jamie Madill06145232015-05-13 13:10:01 -0400283 bool enterStructDeclaration(const TSourceLoc &line, const TString &identifier);
kbr@chromium.org476541f2011-10-27 21:14:51 +0000284 void exitStructDeclaration();
285
Jamie Madill06145232015-05-13 13:10:01 -0400286 bool structNestingErrorCheck(const TSourceLoc &line, const TField &field);
Olli Etuaho09b22472015-02-11 11:47:26 +0200287
Olli Etuahoa3a36662015-02-17 13:46:51 +0200288 TIntermSwitch *addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc);
289 TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc);
290 TIntermCase *addDefault(const TSourceLoc &loc);
291
Jamie Madill06145232015-05-13 13:10:01 -0400292 TIntermTyped *addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
293 TIntermTyped *addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
294 TIntermTyped *addBinaryMath(
295 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
296 TIntermTyped *addBinaryMathBooleanResult(
297 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
298 TIntermTyped *addAssign(
299 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
Olli Etuaho49300862015-02-20 14:54:49 +0200300
301 TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc);
302 TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc);
Olli Etuahoc4ba3be2015-03-02 14:42:24 +0200303
Jamie Madill06145232015-05-13 13:10:01 -0400304 TIntermTyped *addFunctionCallOrMethod(TFunction *fnCall,
305 TIntermNode *paramNode,
306 TIntermNode *thisNode,
307 const TSourceLoc &loc,
308 bool *fatalError);
Olli Etuahofc1806e2015-03-17 13:03:11 +0200309
Jamie Madill06145232015-05-13 13:10:01 -0400310 TIntermTyped *addTernarySelection(
311 TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line);
Olli Etuaho52901742015-04-15 13:42:45 +0300312
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400313 // TODO(jmadill): make these private
314 TIntermediate &intermediate; // to hold and build a parse tree
315 TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
316
Olli Etuahofc1806e2015-03-17 13:03:11 +0200317 private:
Olli Etuaho2935c582015-04-08 14:32:06 +0300318 bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable);
319
Olli Etuaho376f1b52015-04-13 13:23:41 +0300320 bool nonInitErrorCheck(const TSourceLoc &line, const TString &identifier, TPublicType *type);
321
Jamie Madill06145232015-05-13 13:10:01 -0400322 TIntermTyped *addBinaryMathInternal(
323 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
324 TIntermTyped *createAssign(
325 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
Olli Etuahof6c694b2015-03-26 14:50:53 +0200326 // The funcReturnType parameter is expected to be non-null when the operation is a built-in function.
327 // It is expected to be null for other unary operators.
Jamie Madill06145232015-05-13 13:10:01 -0400328 TIntermTyped *createUnaryMath(
329 TOperator op, TIntermTyped *child, const TSourceLoc &loc, const TType *funcReturnType);
Olli Etuahod6b14282015-03-17 14:31:35 +0200330
Olli Etuaho47fd36a2015-03-19 14:22:24 +0200331 // Return true if the checks pass
Jamie Madill06145232015-05-13 13:10:01 -0400332 bool binaryOpCommonCheck(
333 TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
Olli Etuahofa33d582015-04-09 14:33:12 +0300334
335 // Set to true when the last/current declarator list was started with an empty declaration.
336 bool mDeferredSingleDeclarationErrorCheck;
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400337
338 sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
339 ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
340 int mShaderVersion;
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400341 TIntermNode *mTreeRoot; // root of parse tree being created
342 int mLoopNestingLevel; // 0 if outside all loops
343 int mStructNestingLevel; // incremented while parsing a struct declaration
344 int mSwitchNestingLevel; // 0 if outside all switch statements
345 const TType *mCurrentFunctionType; // the return type of the function that's currently being parsed
346 bool mFunctionReturnsValue; // true if a non-void function has a return
347 bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
Olli Etuahoa6996682015-10-12 14:32:30 +0300348 bool mFragmentPrecisionHighOnESSL1; // true if highp precision is supported when compiling
349 // ESSL1.
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400350 TLayoutMatrixPacking mDefaultMatrixPacking;
351 TLayoutBlockStorage mDefaultBlockStorage;
352 TString mHashErrMsg;
353 TDiagnostics mDiagnostics;
354 TDirectiveHandler mDirectiveHandler;
355 pp::Preprocessor mPreprocessor;
356 void *mScanner;
Jamie Madill14e95b32015-05-07 10:10:41 -0400357 bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor
358 bool mUsesFragColor;
Kimmo Kinnunenb18609b2015-07-16 14:13:11 +0300359 bool mUsesSecondaryOutputs; // Track if we are using either gl_SecondaryFragData or
360 // gl_Secondary FragColor or both.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000361};
362
Jamie Madill06145232015-05-13 13:10:01 -0400363int PaParseStrings(
364 size_t count, const char *const string[], const int length[], TParseContext *context);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000365
Geoff Lang0a73dd82014-11-19 16:18:08 -0500366#endif // COMPILER_TRANSLATOR_PARSECONTEXT_H_