mirror of
https://github.com/libretro/glslang.git
synced 2024-11-27 09:51:24 +00:00
glslang front-end: track column numbers (they don't go anywhere yet, just get tracked). Andrew Woloszyn <awoloszyn@google.com>.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31506 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
edadf45605
commit
47632b7aaf
@ -177,8 +177,10 @@ inline const TString String(const int i, const int base = 10)
|
||||
}
|
||||
|
||||
struct TSourceLoc {
|
||||
void init() { string = 0; line = 0; column = 0; }
|
||||
int string;
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
|
||||
typedef TMap<TString, TString> TPragmaTable;
|
||||
|
@ -400,7 +400,7 @@ class TIntermNode {
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
|
||||
|
||||
TIntermNode() { loc.line = 0; loc.string = 0; }
|
||||
TIntermNode() { loc.init(); }
|
||||
virtual glslang::TSourceLoc getLoc() const { return loc; }
|
||||
virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
|
||||
virtual void traverse(glslang::TIntermTraverser*) = 0;
|
||||
|
@ -2819,7 +2819,8 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList
|
||||
// look for match
|
||||
bool found = false;
|
||||
TTypeList::const_iterator newMember;
|
||||
TSourceLoc memberLoc = {};
|
||||
TSourceLoc memberLoc;
|
||||
memberLoc.init();
|
||||
for (newMember = newTypeList.begin(); newMember != newTypeList.end(); ++newMember) {
|
||||
if (member->type->getFieldName() == newMember->type->getFieldName()) {
|
||||
found = true;
|
||||
|
@ -52,7 +52,9 @@ public:
|
||||
loc = new TSourceLoc[numSources];
|
||||
loc[currentSource].string = -stringBias;
|
||||
loc[currentSource].line = 1;
|
||||
loc[currentSource].column = 0;
|
||||
}
|
||||
|
||||
virtual ~TInputScanner()
|
||||
{
|
||||
delete [] loc;
|
||||
@ -68,8 +70,11 @@ public:
|
||||
return -1;
|
||||
|
||||
int ret = sources[currentSource][currentChar];
|
||||
if (ret == '\n')
|
||||
++loc[currentSource].column;
|
||||
if (ret == '\n') {
|
||||
++loc[currentSource].line;
|
||||
loc[currentSource].column = 0;
|
||||
}
|
||||
advance();
|
||||
|
||||
return ret;
|
||||
@ -87,9 +92,23 @@ public:
|
||||
// go back one character
|
||||
void unget()
|
||||
{
|
||||
if (currentChar > 0)
|
||||
if (currentChar > 0) {
|
||||
--currentChar;
|
||||
else {
|
||||
--loc[currentSource].column;
|
||||
if (loc[currentSource].column < 0) {
|
||||
// We've moved back past a new line. Find the
|
||||
// previous newline (or start of the file) to compute
|
||||
// the column count on the now current line.
|
||||
size_t ch = currentChar;
|
||||
while(ch > 0) {
|
||||
if (sources[currentSource][ch] == '\n') {
|
||||
break;
|
||||
}
|
||||
--ch;
|
||||
}
|
||||
loc[currentSource].column = currentChar - ch;
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
--currentSource;
|
||||
} while (currentSource > 0 && lengths[currentSource] == 0);
|
||||
@ -125,12 +144,14 @@ protected:
|
||||
if (currentSource < numSources) {
|
||||
loc[currentSource].string = loc[currentSource - 1].string + 1;
|
||||
loc[currentSource].line = 1;
|
||||
loc[currentSource].column = 0;
|
||||
}
|
||||
while (currentSource < numSources && lengths[currentSource] == 0) {
|
||||
++currentSource;
|
||||
if (currentSource < numSources) {
|
||||
loc[currentSource].string = loc[currentSource - 1].string + 1;
|
||||
loc[currentSource].line = 1;
|
||||
loc[currentSource].column = 0;
|
||||
}
|
||||
}
|
||||
currentChar = 0;
|
||||
|
@ -560,8 +560,7 @@ bool CompileDeferred(
|
||||
parseContext.addError();
|
||||
if (warnVersionNotFirst) {
|
||||
TSourceLoc loc;
|
||||
loc.line = 1;
|
||||
loc.string = 0;
|
||||
loc.init();
|
||||
parseContext.warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", "");
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,8 @@ namespace glslang {
|
||||
class TPpToken {
|
||||
public:
|
||||
TPpToken() : token(0), ival(0), space(false), dval(0.0), atom(0)
|
||||
{
|
||||
loc.line = 0;
|
||||
loc.string = 0;
|
||||
{
|
||||
loc.init();
|
||||
name[0] = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user