summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2005-03-18 14:28:02 +0000
committerMichal Krol <mjkrol@gmail.org>2005-03-18 14:28:02 +0000
commit2fb2e27e28569371bd0d12aa74504d53bb04edc0 (patch)
tree87fd04629f66c78767e68ed8fe9ea2d552771042 /src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
parent5b641a516ecde984027d4fc1fe198195b7b861a7 (diff)
update against 03-Feb-2005 release
Diffstat (limited to 'src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp')
-rwxr-xr-xsrc/mesa/shader/slang/MachineIndependent/ParseHelper.cpp70
1 files changed, 58 insertions, 12 deletions
diff --git a/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp b/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
index d20aa2fa87..cfc42746ae 100755
--- a/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
+++ b/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
@@ -1,5 +1,5 @@
//
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -54,25 +54,62 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
return false;
}
- bool tooBig = false;
+ enum {
+ exyzw,
+ ergba,
+ estpq
+ } fieldSet[4];
for (int i = 0; i < fields.num; ++i) {
switch (compString[i]) {
- case 'x': case 'r': case 's': case '0':
+ case 'x':
fields.offsets[i] = 0;
+ fieldSet[i] = exyzw;
break;
- case 'y': case 'g': case 't': case '1':
+ case 'r':
+ fields.offsets[i] = 0;
+ fieldSet[i] = ergba;
+ break;
+ case 's':
+ fields.offsets[i] = 0;
+ fieldSet[i] = estpq;
+ break;
+ case 'y':
+ fields.offsets[i] = 1;
+ fieldSet[i] = exyzw;
+ break;
+ case 'g':
fields.offsets[i] = 1;
+ fieldSet[i] = ergba;
+ break;
+ case 't':
+ fields.offsets[i] = 1;
+ fieldSet[i] = estpq;
+ break;
+ case 'z':
+ fields.offsets[i] = 2;
+ fieldSet[i] = exyzw;
+ break;
+ case 'b':
+ fields.offsets[i] = 2;
+ fieldSet[i] = ergba;
break;
- case 'z': case 'b': case 'p': case '2':
- if (vecSize < 3)
- tooBig = true;
+ case 'p':
fields.offsets[i] = 2;
+ fieldSet[i] = estpq;
break;
- case 'w': case 'a': case 'q': case '3':
- if (vecSize < 4)
- tooBig = true;
+
+ case 'w':
+ fields.offsets[i] = 3;
+ fieldSet[i] = exyzw;
+ break;
+ case 'a':
fields.offsets[i] = 3;
+ fieldSet[i] = ergba;
+ break;
+ case 'q':
+ fields.offsets[i] = 3;
+ fieldSet[i] = estpq;
break;
default:
error(line, "illegal vector field selection", compString.c_str(), "");
@@ -80,11 +117,20 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
}
}
- if (tooBig) {
+ for (int i = 0; i < fields.num; ++i) {
+ if (fields.offsets[i] >= vecSize) {
error(line, "vector field selection out of range", compString.c_str(), "");
return false;
}
+ if (i > 0) {
+ if (fieldSet[i] != fieldSet[i-1]) {
+ error(line, "illegal - vector component fields not from the same set", compString.c_str(), "");
+ return false;
+ }
+ }
+ }
+
return true;
}
@@ -970,7 +1016,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOpe
TTypeList::iterator list;
TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
if (op == EOpConstructStruct) {
- TType ttype = fnCall->getReturnType();
+ const TType& ttype = fnCall->getReturnType();
structure = ttype.getStruct();
list = (*structure).begin();
}