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
|
|
@ -66,8 +66,6 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef int TSourceLoc;
|
||||
|
||||
#include "PoolAlloc.h"
|
||||
|
||||
//
|
||||
|
|
@ -162,25 +160,10 @@ inline const TString String(const int i, const int base = 10)
|
|||
return text;
|
||||
}
|
||||
|
||||
const unsigned int SourceLocLineMask = 0xffff;
|
||||
const unsigned int SourceLocStringShift = 16;
|
||||
|
||||
__inline TPersistString FormatSourceLoc(const TSourceLoc loc)
|
||||
{
|
||||
const int maxSize = 64;
|
||||
char locText[maxSize];
|
||||
|
||||
int string = loc >> SourceLocStringShift;
|
||||
int line = loc & SourceLocLineMask;
|
||||
|
||||
if (line)
|
||||
snprintf(locText, maxSize, "%d:%d", string, line);
|
||||
else
|
||||
snprintf(locText, maxSize, "%d:? ", string);
|
||||
|
||||
return TPersistString(locText);
|
||||
}
|
||||
|
||||
struct TSourceLoc {
|
||||
int string;
|
||||
int line;
|
||||
};
|
||||
|
||||
typedef TMap<TString, TString> TPragmaTable;
|
||||
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,10 @@ public:
|
|||
}
|
||||
}
|
||||
void location(TSourceLoc loc) {
|
||||
append(FormatSourceLoc(loc).c_str());
|
||||
const int maxSize = 24;
|
||||
char locText[maxSize];
|
||||
snprintf(locText, maxSize, "%d:%d", loc.string, loc.line);
|
||||
append(locText);
|
||||
append(": ");
|
||||
}
|
||||
void message(TPrefixType message, const char* s) {
|
||||
|
|
|
|||
|
|
@ -142,11 +142,11 @@ struct TSampler {
|
|||
// Need to have association of line numbers to types in a list for building structs.
|
||||
//
|
||||
class TType;
|
||||
struct TTypeLine {
|
||||
struct TTypeLoc {
|
||||
TType* type;
|
||||
int line;
|
||||
TSourceLoc loc;
|
||||
};
|
||||
typedef TVector<TTypeLine> TTypeList;
|
||||
typedef TVector<TTypeLoc> TTypeList;
|
||||
|
||||
inline TTypeList* NewPoolTTypeList()
|
||||
{
|
||||
|
|
@ -347,9 +347,9 @@ public:
|
|||
int matrixRows : 4;
|
||||
TArraySizes arraySizes;
|
||||
const TType* userDef;
|
||||
int line;
|
||||
TSourceLoc loc;
|
||||
|
||||
void initType(int ln = 0)
|
||||
void initType(TSourceLoc l)
|
||||
{
|
||||
basicType = EbtVoid;
|
||||
vectorSize = 1;
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
matrixCols = 0;
|
||||
arraySizes = 0;
|
||||
userDef = 0;
|
||||
line = ln;
|
||||
loc = l;
|
||||
}
|
||||
|
||||
void initQualifiers(bool global = false)
|
||||
|
|
@ -367,9 +367,9 @@ public:
|
|||
qualifier.storage = EvqGlobal;
|
||||
}
|
||||
|
||||
void init(int line = 0, bool global = false)
|
||||
void init(TSourceLoc loc, bool global = false)
|
||||
{
|
||||
initType(line);
|
||||
initType(loc);
|
||||
sampler.clear();
|
||||
initQualifiers(global);
|
||||
}
|
||||
|
|
@ -479,10 +479,10 @@ public:
|
|||
// create the new structure here
|
||||
structure = NewPoolTTypeList();
|
||||
for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
|
||||
TTypeLine typeLine;
|
||||
typeLine.line = (*copyOf.structure)[i].line;
|
||||
typeLine.type = (*copyOf.structure)[i].type->clone(remapper);
|
||||
structure->push_back(typeLine);
|
||||
TTypeLoc typeLoc;
|
||||
typeLoc.loc = (*copyOf.structure)[i].loc;
|
||||
typeLoc.type = (*copyOf.structure)[i].type->clone(remapper);
|
||||
structure->push_back(typeLoc);
|
||||
}
|
||||
} else {
|
||||
structure = iter->second;
|
||||
|
|
|
|||
|
|
@ -320,9 +320,9 @@ class TIntermNode {
|
|||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
|
||||
TIntermNode() : line(0) {}
|
||||
virtual TSourceLoc getLine() const { return line; }
|
||||
virtual void setLine(TSourceLoc l) { line = l; }
|
||||
TIntermNode() { loc.line = 0; loc.string = 0; }
|
||||
virtual TSourceLoc getLoc() const { return loc; }
|
||||
virtual void setLoc(TSourceLoc l) { loc = l; }
|
||||
virtual void traverse(TIntermTraverser*) = 0;
|
||||
virtual TIntermTyped* getAsTyped() { return 0; }
|
||||
virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }
|
||||
|
|
@ -336,7 +336,7 @@ public:
|
|||
virtual TIntermBranch* getAsBranchNode() { return 0; }
|
||||
virtual ~TIntermNode() { }
|
||||
protected:
|
||||
TSourceLoc line;
|
||||
TSourceLoc loc;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue