gfx/angle/src/compiler/ParseHelper.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6 #ifndef _PARSER_HELPER_INCLUDED_
michael@0 7 #define _PARSER_HELPER_INCLUDED_
michael@0 8
michael@0 9 #include "compiler/Diagnostics.h"
michael@0 10 #include "compiler/DirectiveHandler.h"
michael@0 11 #include "compiler/localintermediate.h"
michael@0 12 #include "compiler/preprocessor/Preprocessor.h"
michael@0 13 #include "compiler/ShHandle.h"
michael@0 14 #include "compiler/SymbolTable.h"
michael@0 15
michael@0 16 struct TMatrixFields {
michael@0 17 bool wholeRow;
michael@0 18 bool wholeCol;
michael@0 19 int row;
michael@0 20 int col;
michael@0 21 };
michael@0 22
michael@0 23 //
michael@0 24 // The following are extra variables needed during parsing, grouped together so
michael@0 25 // they can be passed to the parser without needing a global.
michael@0 26 //
michael@0 27 struct TParseContext {
michael@0 28 TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
michael@0 29 intermediate(interm),
michael@0 30 symbolTable(symt),
michael@0 31 shaderType(type),
michael@0 32 shaderSpec(spec),
michael@0 33 compileOptions(options),
michael@0 34 sourcePath(sourcePath),
michael@0 35 treeRoot(0),
michael@0 36 loopNestingLevel(0),
michael@0 37 structNestingLevel(0),
michael@0 38 currentFunctionType(NULL),
michael@0 39 functionReturnsValue(false),
michael@0 40 checksPrecisionErrors(checksPrecErrors),
michael@0 41 diagnostics(is),
michael@0 42 directiveHandler(ext, diagnostics),
michael@0 43 preprocessor(&diagnostics, &directiveHandler),
michael@0 44 scanner(NULL) { }
michael@0 45 TIntermediate& intermediate; // to hold and build a parse tree
michael@0 46 TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
michael@0 47 ShShaderType shaderType; // vertex or fragment language (future: pack or unpack)
michael@0 48 ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
michael@0 49 int compileOptions;
michael@0 50 const char* sourcePath; // Path of source file or NULL.
michael@0 51 TIntermNode* treeRoot; // root of parse tree being created
michael@0 52 int loopNestingLevel; // 0 if outside all loops
michael@0 53 int structNestingLevel; // incremented while parsing a struct declaration
michael@0 54 const TType* currentFunctionType; // the return type of the function that's currently being parsed
michael@0 55 bool functionReturnsValue; // true if a non-void function has a return
michael@0 56 bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
michael@0 57 bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language.
michael@0 58 TString HashErrMsg;
michael@0 59 TDiagnostics diagnostics;
michael@0 60 TDirectiveHandler directiveHandler;
michael@0 61 pp::Preprocessor preprocessor;
michael@0 62 void* scanner;
michael@0 63
michael@0 64 int numErrors() const { return diagnostics.numErrors(); }
michael@0 65 TInfoSink& infoSink() { return diagnostics.infoSink(); }
michael@0 66 void error(const TSourceLoc& loc, const char *reason, const char* token,
michael@0 67 const char* extraInfo="");
michael@0 68 void warning(const TSourceLoc& loc, const char* reason, const char* token,
michael@0 69 const char* extraInfo="");
michael@0 70 void trace(const char* str);
michael@0 71 void recover();
michael@0 72
michael@0 73 bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc& line);
michael@0 74 bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, const TSourceLoc& line);
michael@0 75
michael@0 76 bool reservedErrorCheck(const TSourceLoc& line, const TString& identifier);
michael@0 77 void assignError(const TSourceLoc& line, const char* op, TString left, TString right);
michael@0 78 void unaryOpError(const TSourceLoc& line, const char* op, TString operand);
michael@0 79 void binaryOpError(const TSourceLoc& line, const char* op, TString left, TString right);
michael@0 80 bool precisionErrorCheck(const TSourceLoc& line, TPrecision precision, TBasicType type);
michael@0 81 bool lValueErrorCheck(const TSourceLoc& line, const char* op, TIntermTyped*);
michael@0 82 bool constErrorCheck(TIntermTyped* node);
michael@0 83 bool integerErrorCheck(TIntermTyped* node, const char* token);
michael@0 84 bool globalErrorCheck(const TSourceLoc& line, bool global, const char* token);
michael@0 85 bool constructorErrorCheck(const TSourceLoc& line, TIntermNode*, TFunction&, TOperator, TType*);
michael@0 86 bool arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* expr, int& size);
michael@0 87 bool arrayQualifierErrorCheck(const TSourceLoc& line, TPublicType type);
michael@0 88 bool arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type);
michael@0 89 bool arrayErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType type, TVariable*& variable);
michael@0 90 bool voidErrorCheck(const TSourceLoc&, const TString&, const TPublicType&);
michael@0 91 bool boolErrorCheck(const TSourceLoc&, const TIntermTyped*);
michael@0 92 bool boolErrorCheck(const TSourceLoc&, const TPublicType&);
michael@0 93 bool samplerErrorCheck(const TSourceLoc& line, const TPublicType& pType, const char* reason);
michael@0 94 bool structQualifierErrorCheck(const TSourceLoc& line, const TPublicType& pType);
michael@0 95 bool parameterSamplerErrorCheck(const TSourceLoc& line, TQualifier qualifier, const TType& type);
michael@0 96 bool nonInitConstErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType& type, bool array);
michael@0 97 bool nonInitErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType& type, TVariable*& variable);
michael@0 98 bool paramErrorCheck(const TSourceLoc& line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
michael@0 99 bool extensionErrorCheck(const TSourceLoc& line, const TString&);
michael@0 100
michael@0 101 const TPragma& pragma() const { return directiveHandler.pragma(); }
michael@0 102 const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); }
michael@0 103 bool supportsExtension(const char* extension);
michael@0 104 bool isExtensionEnabled(const char* extension) const;
michael@0 105
michael@0 106 bool containsSampler(TType& type);
michael@0 107 bool areAllChildConst(TIntermAggregate* aggrNode);
michael@0 108 const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, bool *builtIn = 0);
michael@0 109 bool executeInitializer(const TSourceLoc& line, TString& identifier, TPublicType& pType,
michael@0 110 TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
michael@0 111
michael@0 112 TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&);
michael@0 113 TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
michael@0 114 TIntermTyped* constructStruct(TIntermNode*, TType*, int, const TSourceLoc&, bool subset);
michael@0 115 TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, const TSourceLoc&, bool subset);
michael@0 116 TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&);
michael@0 117 TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&);
michael@0 118 TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line);
michael@0 119 TIntermTyped* addConstStruct(TString& , TIntermTyped*, const TSourceLoc&);
michael@0 120 TIntermTyped* addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc& location, TIntermTyped *indexExpression);
michael@0 121
michael@0 122 // Performs an error check for embedded struct declarations.
michael@0 123 // Returns true if an error was raised due to the declaration of
michael@0 124 // this struct.
michael@0 125 bool enterStructDeclaration(const TSourceLoc& line, const TString& identifier);
michael@0 126 void exitStructDeclaration();
michael@0 127
michael@0 128 bool structNestingErrorCheck(const TSourceLoc& line, const TField& field);
michael@0 129 };
michael@0 130
michael@0 131 int PaParseStrings(size_t count, const char* const string[], const int length[],
michael@0 132 TParseContext* context);
michael@0 133
michael@0 134 #endif // _PARSER_HELPER_INCLUDED_

mercurial