Added mechanism to predefine associated macros for extensions. Also refactored the way extension behavior is initialized and updated.
Please note that I still need to add validation that appropriate extensions are enabled before using an extension function.
BUG=25
Review URL: http://codereview.appspot.com/2139042
git-svn-id: https://angleproject.googlecode.com/svn/trunk@413 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ParseHelper.h b/src/compiler/ParseHelper.h
index 792333f..fb29d94 100644
--- a/src/compiler/ParseHelper.h
+++ b/src/compiler/ParseHelper.h
@@ -6,9 +6,10 @@
#ifndef _PARSER_HELPER_INCLUDED_
#define _PARSER_HELPER_INCLUDED_
+#include "compiler/ExtensionBehavior.h"
+#include "compiler/localintermediate.h"
#include "compiler/ShHandle.h"
#include "compiler/SymbolTable.h"
-#include "compiler/localintermediate.h"
struct TMatrixFields {
bool wholeRow;
@@ -17,13 +18,6 @@
int col;
};
-typedef enum {
- EBhRequire,
- EBhEnable,
- EBhWarn,
- EBhDisable
-} TBehavior;
-
struct TPragma {
TPragma(bool o, bool d) : optimize(o), debug(d) { }
bool optimize;
@@ -36,12 +30,13 @@
// they can be passed to the parser without needing a global.
//
struct TParseContext {
- TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage l, EShSpec s, TInfoSink& is) :
- intermediate(interm), symbolTable(symt), infoSink(is), language(l), spec(s), treeRoot(0),
+ TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, EShLanguage l, EShSpec s, TInfoSink& is) :
+ intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), language(l), spec(s), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), contextPragma(true, false) { }
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
+ TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior.
TInfoSink& infoSink;
EShLanguage language; // vertex or fragment language (future: pack or unpack)
EShSpec spec; // The language specification compiler conforms to - GLES2 or WebGL.
@@ -53,8 +48,6 @@
bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
- TMap<TString, TBehavior> extensionBehavior;
- void initializeExtensionBehavior();
void error(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);