summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/ParseContext.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/compiler/translator/ParseContext.h
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/compiler/translator/ParseContext.h')
-rwxr-xr-xgfx/angle/src/compiler/translator/ParseContext.h292
1 files changed, 150 insertions, 142 deletions
diff --git a/gfx/angle/src/compiler/translator/ParseContext.h b/gfx/angle/src/compiler/translator/ParseContext.h
index cdc80755a..cf153db36 100755
--- a/gfx/angle/src/compiler/translator/ParseContext.h
+++ b/gfx/angle/src/compiler/translator/ParseContext.h
@@ -11,12 +11,8 @@
#include "compiler/translator/DirectiveHandler.h"
#include "compiler/translator/Intermediate.h"
#include "compiler/translator/SymbolTable.h"
-#include "compiler/translator/QualifierTypes.h"
#include "compiler/preprocessor/Preprocessor.h"
-namespace sh
-{
-
struct TMatrixFields
{
bool wholeRow;
@@ -34,12 +30,47 @@ class TParseContext : angle::NonCopyable
public:
TParseContext(TSymbolTable &symt,
TExtensionBehavior &ext,
+ TIntermediate &interm,
sh::GLenum type,
ShShaderSpec spec,
- ShCompileOptions options,
+ int options,
bool checksPrecErrors,
TInfoSink &is,
- const ShBuiltInResources &resources);
+ const ShBuiltInResources &resources)
+ : intermediate(interm),
+ symbolTable(symt),
+ mDeferredSingleDeclarationErrorCheck(false),
+ mShaderType(type),
+ mShaderSpec(spec),
+ mCompileOptions(options),
+ mShaderVersion(100),
+ mTreeRoot(nullptr),
+ mLoopNestingLevel(0),
+ mStructNestingLevel(0),
+ mSwitchNestingLevel(0),
+ mCurrentFunctionType(nullptr),
+ mFunctionReturnsValue(false),
+ mChecksPrecisionErrors(checksPrecErrors),
+ mFragmentPrecisionHighOnESSL1(false),
+ mDefaultMatrixPacking(EmpColumnMajor),
+ mDefaultBlockStorage(EbsShared),
+ mDiagnostics(is),
+ mDirectiveHandler(ext,
+ mDiagnostics,
+ mShaderVersion,
+ mShaderType,
+ resources.WEBGL_debug_shader_precision == 1),
+ mPreprocessor(&mDiagnostics, &mDirectiveHandler),
+ mScanner(nullptr),
+ mUsesFragData(false),
+ mUsesFragColor(false),
+ mUsesSecondaryOutputs(false),
+ mMinProgramTexelOffset(resources.MinProgramTexelOffset),
+ mMaxProgramTexelOffset(resources.MaxProgramTexelOffset),
+ mComputeShaderLocalSizeDeclared(false)
+ {
+ mComputeShaderLocalSize.fill(-1);
+ }
const pp::Preprocessor &getPreprocessor() const { return mPreprocessor; }
pp::Preprocessor &getPreprocessor() { return mPreprocessor; }
@@ -62,8 +93,8 @@ class TParseContext : angle::NonCopyable
const char *token,
const char *extraInfo = "");
- TIntermBlock *getTreeRoot() const { return mTreeRoot; }
- void setTreeRoot(TIntermBlock *treeRoot) { mTreeRoot = treeRoot; }
+ TIntermNode *getTreeRoot() const { return mTreeRoot; }
+ void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
bool getFragmentPrecisionHigh() const
{
@@ -88,12 +119,6 @@ class TParseContext : angle::NonCopyable
bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; }
sh::WorkGroupSize getComputeShaderLocalSize() const;
- void enterFunctionDeclaration() { mDeclaringFunction = true; }
-
- void exitFunctionDeclaration() { mDeclaringFunction = false; }
-
- bool declaringFunction() const { return mDeclaringFunction; }
-
// 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);
TIntermTyped *parseVariableIdentifier(const TSourceLoc &location,
@@ -127,17 +152,16 @@ class TParseContext : angle::NonCopyable
bool checkIsNonVoid(const TSourceLoc &line, const TString &identifier, const TBasicType &type);
void checkIsScalarBool(const TSourceLoc &line, const TIntermTyped *type);
void checkIsScalarBool(const TSourceLoc &line, const TPublicType &pType);
- bool checkIsNotSampler(const TSourceLoc &line,
- const TTypeSpecifierNonArray &pType,
- const char *reason);
- bool checkIsNotImage(const TSourceLoc &line,
- const TTypeSpecifierNonArray &pType,
- const char *reason);
+ bool checkIsNotSampler(const TSourceLoc &line, const TPublicType &pType, const char *reason);
void checkDeclaratorLocationIsNotSpecified(const TSourceLoc &line, const TPublicType &pType);
void checkLocationIsNotSpecified(const TSourceLoc &location,
const TLayoutQualifier &layoutQualifier);
+ void checkOutParameterIsNotSampler(const TSourceLoc &line,
+ TQualifier qualifier,
+ const TType &type);
void checkIsParameterQualifierValid(const TSourceLoc &line,
- const TTypeQualifierBuilder &typeQualifierBuilder,
+ TQualifier qualifier,
+ TQualifier paramQualifier,
TType *type);
bool checkCanUseExtension(const TSourceLoc &line, const TString &extension);
void singleDeclarationErrorCheck(const TPublicType &publicType,
@@ -147,16 +171,14 @@ class TParseContext : angle::NonCopyable
int versionRequired);
bool checkWorkGroupSizeIsNotSpecified(const TSourceLoc &location,
const TLayoutQualifier &layoutQualifier);
- bool checkInternalFormatIsNotSpecified(const TSourceLoc &location,
- TLayoutImageInternalFormat internalFormat);
+
void functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *fnCall);
- void checkInvariantVariableQualifier(bool invariant,
- const TQualifier qualifier,
- const TSourceLoc &invariantLocation);
+ void checkInvariantIsOutVariableES3(const TQualifier qualifier,
+ const TSourceLoc &invariantLocation);
void checkInputOutputTypeIsValidES3(const TQualifier qualifier,
const TPublicType &type,
const TSourceLoc &qualifierLocation);
- void checkLocalVariableConstStorageQualifier(const TQualifierWrapperBase &qualifier);
+
const TPragma &pragma() const { return mDirectiveHandler.pragma(); }
const TExtensionBehavior &extensionBehavior() const { return mDirectiveHandler.extensionBehavior(); }
bool supportsExtension(const char *extension);
@@ -164,84 +186,86 @@ class TParseContext : angle::NonCopyable
void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
void handlePragmaDirective(const TSourceLoc &loc, const char *name, const char *value, bool stdgl);
+ bool containsSampler(const TType &type);
const TFunction* findFunction(
const TSourceLoc &line, TFunction *pfnCall, int inputShaderVersion, bool *builtIn = 0);
bool executeInitializer(const TSourceLoc &line,
const TString &identifier,
const TPublicType &pType,
TIntermTyped *initializer,
- TIntermBinary **initNode);
+ TIntermNode **intermNode);
- void addFullySpecifiedType(TPublicType *typeSpecifier);
- TPublicType addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder,
+ TPublicType addFullySpecifiedType(TQualifier qualifier,
+ bool invariant,
+ TLayoutQualifier layoutQualifier,
const TPublicType &typeSpecifier);
- TIntermDeclaration *parseSingleDeclaration(TPublicType &publicType,
- const TSourceLoc &identifierOrTypeLocation,
- const TString &identifier);
- TIntermDeclaration *parseSingleArrayDeclaration(TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &indexLocation,
- TIntermTyped *indexExpression);
- TIntermDeclaration *parseSingleInitDeclaration(const TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &initLocation,
- TIntermTyped *initializer);
+ TIntermAggregate *parseSingleDeclaration(TPublicType &publicType,
+ const TSourceLoc &identifierOrTypeLocation,
+ const TString &identifier);
+ TIntermAggregate *parseSingleArrayDeclaration(TPublicType &publicType,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &indexLocation,
+ TIntermTyped *indexExpression);
+ TIntermAggregate *parseSingleInitDeclaration(const TPublicType &publicType,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &initLocation,
+ TIntermTyped *initializer);
// Parse a declaration like "type a[n] = initializer"
// Note that this does not apply to declarations like "type[n] a = initializer"
- TIntermDeclaration *parseSingleArrayInitDeclaration(TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &indexLocation,
- TIntermTyped *indexExpression,
- const TSourceLoc &initLocation,
- TIntermTyped *initializer);
-
- TIntermAggregate *parseInvariantDeclaration(const TTypeQualifierBuilder &typeQualifierBuilder,
+ TIntermAggregate *parseSingleArrayInitDeclaration(TPublicType &publicType,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &indexLocation,
+ TIntermTyped *indexExpression,
+ const TSourceLoc &initLocation,
+ TIntermTyped *initializer);
+
+ TIntermAggregate *parseInvariantDeclaration(const TSourceLoc &invariantLoc,
const TSourceLoc &identifierLoc,
const TString *identifier,
const TSymbol *symbol);
- void parseDeclarator(TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- TIntermDeclaration *declarationOut);
- void parseArrayDeclarator(TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &arrayLocation,
- TIntermTyped *indexExpression,
- TIntermDeclaration *declarationOut);
- void parseInitDeclarator(const TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &initLocation,
- TIntermTyped *initializer,
- TIntermDeclaration *declarationOut);
+ TIntermAggregate *parseDeclarator(TPublicType &publicType,
+ TIntermAggregate *aggregateDeclaration,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier);
+ TIntermAggregate *parseArrayDeclarator(TPublicType &publicType,
+ TIntermAggregate *aggregateDeclaration,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &arrayLocation,
+ TIntermTyped *indexExpression);
+ TIntermAggregate *parseInitDeclarator(const TPublicType &publicType,
+ TIntermAggregate *aggregateDeclaration,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &initLocation,
+ TIntermTyped *initializer);
// Parse a declarator like "a[n] = initializer"
- void parseArrayInitDeclarator(const TPublicType &publicType,
- const TSourceLoc &identifierLocation,
- const TString &identifier,
- const TSourceLoc &indexLocation,
- TIntermTyped *indexExpression,
- const TSourceLoc &initLocation,
- TIntermTyped *initializer,
- TIntermDeclaration *declarationOut);
-
- void parseGlobalLayoutQualifier(const TTypeQualifierBuilder &typeQualifierBuilder);
- TIntermAggregate *addFunctionPrototypeDeclaration(const TFunction &parsedFunction,
+ TIntermAggregate *parseArrayInitDeclarator(const TPublicType &publicType,
+ TIntermAggregate *aggregateDeclaration,
+ const TSourceLoc &identifierLocation,
+ const TString &identifier,
+ const TSourceLoc &indexLocation,
+ TIntermTyped *indexExpression,
+ const TSourceLoc &initLocation,
+ TIntermTyped *initializer);
+
+ void parseGlobalLayoutQualifier(const TPublicType &typeQualifier);
+ TIntermAggregate *addFunctionPrototypeDeclaration(const TFunction &function,
const TSourceLoc &location);
- TIntermFunctionDefinition *addFunctionDefinition(const TFunction &function,
- TIntermAggregate *functionParameters,
- TIntermBlock *functionBody,
- const TSourceLoc &location);
- void parseFunctionDefinitionHeader(const TSourceLoc &location,
- TFunction **function,
- TIntermAggregate **aggregateOut);
+ TIntermAggregate *addFunctionDefinition(const TFunction &function,
+ TIntermAggregate *functionPrototype,
+ TIntermAggregate *functionBody,
+ const TSourceLoc &location);
+ void parseFunctionPrototype(const TSourceLoc &location,
+ TFunction *function,
+ TIntermAggregate **aggregateOut);
TFunction *parseFunctionDeclarator(const TSourceLoc &location,
TFunction *function);
TFunction *parseFunctionHeader(const TPublicType &type,
@@ -253,6 +277,8 @@ class TParseContext : angle::NonCopyable
TFunction *fnCall,
const TSourceLoc &line);
+ TIntermTyped *addConstStruct(
+ const TString &identifier, TIntermTyped *node, const TSourceLoc& line);
TIntermTyped *addIndexExpression(TIntermTyped *baseExpression,
const TSourceLoc& location,
TIntermTyped *indexExpression);
@@ -261,24 +287,20 @@ class TParseContext : angle::NonCopyable
const TString &fieldString,
const TSourceLoc &fieldLocation);
- TFieldList *addStructDeclaratorListWithQualifiers(
- const TTypeQualifierBuilder &typeQualifierBuilder,
- TPublicType *typeSpecifier,
- TFieldList *fieldList);
TFieldList *addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList);
- TTypeSpecifierNonArray addStructure(const TSourceLoc &structLine,
+ TPublicType addStructure(const TSourceLoc &structLine,
+ const TSourceLoc &nameLine,
+ const TString *structName,
+ TFieldList *fieldList);
+
+ TIntermAggregate* addInterfaceBlock(const TPublicType &typeQualifier,
const TSourceLoc &nameLine,
- const TString *structName,
- TFieldList *fieldList);
-
- TIntermDeclaration *addInterfaceBlock(const TTypeQualifierBuilder &typeQualifierBuilder,
- const TSourceLoc &nameLine,
- const TString &blockName,
- TFieldList *fieldList,
- const TString *instanceName,
- const TSourceLoc &instanceLine,
- TIntermTyped *arrayIndex,
- const TSourceLoc &arrayIndexLine);
+ const TString &blockName,
+ TFieldList *fieldList,
+ const TString *instanceName,
+ const TSourceLoc &instanceLine,
+ TIntermTyped *arrayIndex,
+ const TSourceLoc& arrayIndexLine);
void parseLocalSize(const TString &qualifierType,
const TSourceLoc &qualifierTypeLine,
@@ -293,10 +315,11 @@ class TParseContext : angle::NonCopyable
const TSourceLoc &qualifierTypeLine,
int intValue,
const TSourceLoc &intValueLine);
- TTypeQualifierBuilder *createTypeQualifierBuilder(const TSourceLoc &loc);
TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier,
TLayoutQualifier rightQualifier,
const TSourceLoc &rightQualifierLocation);
+ TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier,
+ const TSourceLoc &storageLoc, TQualifier storageQualifier);
// Performs an error check for embedded struct declarations.
void enterStructDeclaration(const TSourceLoc &line, const TString &identifier);
@@ -304,9 +327,7 @@ class TParseContext : angle::NonCopyable
void checkIsBelowStructNestingLimit(const TSourceLoc &line, const TField &field);
- TIntermSwitch *addSwitch(TIntermTyped *init,
- TIntermBlock *statementList,
- const TSourceLoc &loc);
+ TIntermSwitch *addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc);
TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc);
TIntermCase *addDefault(const TSourceLoc &loc);
@@ -325,22 +346,17 @@ class TParseContext : angle::NonCopyable
TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc);
void checkTextureOffsetConst(TIntermAggregate *functionCall);
- void checkImageMemoryAccessForBuiltinFunctions(TIntermAggregate *functionCall);
- void checkImageMemoryAccessForUserDefinedFunctions(const TFunction *functionDefinition,
- const TIntermAggregate *functionCall);
TIntermTyped *addFunctionCallOrMethod(TFunction *fnCall,
TIntermNode *paramNode,
TIntermNode *thisNode,
const TSourceLoc &loc,
bool *fatalError);
- TIntermTyped *addTernarySelection(TIntermTyped *cond,
- TIntermTyped *trueExpression,
- TIntermTyped *falseExpression,
- const TSourceLoc &line);
+ TIntermTyped *addTernarySelection(
+ TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &line);
// TODO(jmadill): make these private
- TIntermediate intermediate; // to build a parse tree
+ TIntermediate &intermediate; // to hold and build a parse tree
TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
private:
@@ -352,6 +368,18 @@ class TParseContext : angle::NonCopyable
const char *reason,
const char *token);
+ // Constant folding for element access. Note that the returned node does not have the correct
+ // type - it is expected to be fixed later.
+ TIntermConstantUnion *foldVectorSwizzle(TVectorFields &fields,
+ TIntermConstantUnion *baseNode,
+ const TSourceLoc &location);
+ TIntermConstantUnion *foldMatrixSubscript(int index,
+ TIntermConstantUnion *baseNode,
+ const TSourceLoc &location);
+ TIntermConstantUnion *foldArraySubscript(int index,
+ TIntermConstantUnion *baseNode,
+ const TSourceLoc &location);
+
bool declareVariable(const TSourceLoc &line, const TString &identifier, const TType &type, TVariable **variable);
void checkCanBeDeclaredWithoutInitializer(const TSourceLoc &line,
@@ -364,24 +392,10 @@ class TParseContext : angle::NonCopyable
// Assumes that multiplication op has already been set based on the types.
bool isMultiplicationTypeCombinationValid(TOperator op, const TType &left, const TType &right);
- bool checkIsMemoryQualifierNotSpecified(const TMemoryQualifier &memoryQualifier,
- const TSourceLoc &location);
- void checkOutParameterIsNotImage(const TSourceLoc &line,
- TQualifier qualifier,
- const TType &type);
- void checkOutParameterIsNotOpaqueType(const TSourceLoc &line,
- TQualifier qualifier,
- const TType &type);
- void checkOutParameterIsNotSampler(const TSourceLoc &line,
- TQualifier qualifier,
- const TType &type);
-
TIntermTyped *addBinaryMathInternal(
TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
- TIntermBinary *createAssign(TOperator op,
- TIntermTyped *left,
- TIntermTyped *right,
- const TSourceLoc &loc);
+ TIntermTyped *createAssign(
+ TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
// The funcReturnType parameter is expected to be non-null when the operation is a built-in function.
// It is expected to be null for other unary operators.
TIntermTyped *createUnaryMath(
@@ -395,18 +409,16 @@ class TParseContext : angle::NonCopyable
bool mDeferredSingleDeclarationErrorCheck;
sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
- ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
- ShCompileOptions mCompileOptions; // Options passed to TCompiler
+ ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
+ int mCompileOptions; // Options passed to TCompiler
int mShaderVersion;
- TIntermBlock *mTreeRoot; // root of parse tree being created
+ TIntermNode *mTreeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops
- int mStructNestingLevel; // incremented while parsing a struct declaration
+ int mStructNestingLevel; // incremented while parsing a struct declaration
int mSwitchNestingLevel; // 0 if outside all switch statements
- const TType
- *mCurrentFunctionType; // the return type of the function that's currently being parsed
+ const TType *mCurrentFunctionType; // the return type of the function that's currently being parsed
bool mFunctionReturnsValue; // true if a non-void function has a return
- bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared
- // without precision, explicit or implicit.
+ bool mChecksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
bool mFragmentPrecisionHighOnESSL1; // true if highp precision is supported when compiling
// ESSL1.
TLayoutMatrixPacking mDefaultMatrixPacking;
@@ -426,13 +438,9 @@ class TParseContext : angle::NonCopyable
// keep track of local group size declared in layout. It should be declared only once.
bool mComputeShaderLocalSizeDeclared;
sh::WorkGroupSize mComputeShaderLocalSize;
- // keeps track whether we are declaring / defining a function
- bool mDeclaringFunction;
};
int PaParseStrings(
size_t count, const char *const string[], const int length[], TParseContext *context);
-} // namespace sh
-
#endif // COMPILER_TRANSLATOR_PARSECONTEXT_H_