Eliminate flex as the GLSL lexical analyzer, going from two nested lexical analyzers down to one, leaving just the preprocessor's lexical analysis. A new layer replaces it, to translate from the preprocessor's view of tokenization to glslang's view of tokenization.
Also: - change source locations from an int to TSourceLoc (shader number, line number) throughout - various improvements to the preprocessor git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22277 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
73ed17a87b
commit
5f1a0b7998
35 changed files with 2535 additions and 2515 deletions
|
|
@ -44,10 +44,15 @@
|
|||
#include "SymbolTable.h"
|
||||
#include "ParseHelper.h"
|
||||
#include "Scan.h"
|
||||
#include "ScanContext.h"
|
||||
|
||||
#include "../Include/ShHandle.h"
|
||||
#include "InitializeDll.h"
|
||||
|
||||
extern "C" {
|
||||
#include "preprocessor/preprocess.h"
|
||||
}
|
||||
|
||||
#define SH_EXPORTING
|
||||
#include "../Public/ShaderLang.h"
|
||||
#include "Initialize.h"
|
||||
|
|
@ -99,8 +104,9 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
|
|||
symbolTable = &symbolTables[language];
|
||||
|
||||
TParseContext parseContext(*symbolTable, intermediate, true, version, profile, language, infoSink);
|
||||
|
||||
ThreadLocalParseContext() = &parseContext;
|
||||
glslang::TScanContext scanContext(parseContext);
|
||||
parseContext.scanContext = &scanContext;
|
||||
|
||||
assert(symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
|
||||
|
||||
|
|
@ -123,8 +129,6 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
|
|||
return false;
|
||||
}
|
||||
|
||||
ResetFlex();
|
||||
|
||||
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
|
||||
i != BuiltInStrings[parseContext.language].end(); ++i) {
|
||||
const char* builtInShaders[1];
|
||||
|
|
@ -132,7 +136,7 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
|
|||
|
||||
builtInShaders[0] = (*i).c_str();
|
||||
builtInLengths[0] = (int) (*i).size();
|
||||
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext, 0) != 0) {
|
||||
if (! parseContext.parseShaderStrings(const_cast<char**>(builtInShaders), builtInLengths, 1) != 0) {
|
||||
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
|
||||
printf("Unable to parse built-ins\n");
|
||||
|
||||
|
|
@ -271,6 +275,8 @@ int ShInitialize()
|
|||
PerProcessGPA = new TPoolAllocator(true);
|
||||
}
|
||||
|
||||
glslang::TScanContext::fillInKeywordMap();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -411,19 +417,24 @@ int ShCompile(
|
|||
AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage());
|
||||
|
||||
TParseContext parseContext(symbolTable, intermediate, false, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
|
||||
glslang::TScanContext scanContext(parseContext);
|
||||
parseContext.scanContext = &scanContext;
|
||||
|
||||
TSourceLoc beginning;
|
||||
beginning.line = 1;
|
||||
beginning.string = 0;
|
||||
|
||||
if (! goodProfile)
|
||||
parseContext.error(1, "incorrect", "#version", "");
|
||||
parseContext.error(beginning, "incorrect", "#version", "");
|
||||
|
||||
parseContext.initializeExtensionBehavior();
|
||||
if (versionStatementMissing)
|
||||
parseContext.warn(1, "statement missing: use #version on first line of shader", "#version", "");
|
||||
parseContext.warn(beginning, "statement missing: use #version on first line of shader", "#version", "");
|
||||
else if (profile == EEsProfile && version >= 300 && versionNotFirst)
|
||||
parseContext.error(1, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
|
||||
parseContext.error(beginning, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
|
||||
|
||||
ThreadLocalParseContext() = &parseContext;
|
||||
|
||||
ResetFlex();
|
||||
InitPreprocessor();
|
||||
|
||||
//
|
||||
|
|
@ -440,8 +451,8 @@ int ShCompile(
|
|||
if (parseContext.insertBuiltInArrayAtGlobalLevel())
|
||||
success = false;
|
||||
|
||||
int ret = PaParseStrings(const_cast<char**>(shaderStrings), lengths, numStrings, parseContext, parseContext.getPreamble());
|
||||
if (ret)
|
||||
bool ret = parseContext.parseShaderStrings(const_cast<char**>(shaderStrings), lengths, numStrings);
|
||||
if (! ret)
|
||||
success = false;
|
||||
intermediate.addSymbolLinkageNodes(parseContext.treeRoot, parseContext.linkage, parseContext.language, symbolTable);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue