+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _BASICTYPES_INCLUDED_\r
-#define _BASICTYPES_INCLUDED_\r
-\r
-//\r
-// Basic type. Arrays, vectors, etc., are orthogonal to this.\r
-//\r
-enum TBasicType {\r
- EbtVoid,\r
- EbtFloat,\r
- EbtInt,\r
- EbtBool,\r
- EbtSampler1D,\r
- EbtSampler2D,\r
- EbtSampler3D,\r
- EbtSamplerCube,\r
- EbtSampler1DShadow,\r
- EbtSampler2DShadow,\r
- EbtStruct,\r
- EbtAddress\r
-};\r
-\r
-__inline bool IsSampler(TBasicType type)\r
-{ \r
- return type >= EbtSampler1D && type <= EbtSampler2DShadow;\r
-}\r
-\r
-//\r
-// Qualifiers and built-ins. These are mainly used to see what can be read\r
-// or written, and by the machine dependent translator to know which registers\r
-// to allocate variables in. Since built-ins tend to go to different registers\r
-// than varying or uniform, it makes sense they are peers, not sub-classes.\r
-//\r
-enum TQualifier {\r
- EvqTemporary, // For temporaries (within a function), read/write\r
- EvqGlobal, // For globals read/write\r
- EvqConst, // User defined constants and non-output parameters in functions\r
- EvqAttribute, // Readonly \r
- EvqVaryingIn, // readonly, fragment shaders only\r
- EvqVaryingOut, // vertex shaders only read/write\r
- EvqUniform, // Readonly, vertex and fragment\r
-\r
- // pack/unpack input and output\r
- EvqInput,\r
- EvqOutput,\r
-\r
- // parameters\r
- EvqIn,\r
- EvqOut,\r
- EvqInOut,\r
- EvqConstReadOnly,\r
-\r
- // built-ins written by vertex shader\r
- EvqPosition,\r
- EvqPointSize,\r
- EvqClipVertex,\r
-\r
- // built-ins read by fragment shader\r
- EvqFace,\r
- EvqFragCoord,\r
-\r
- // built-ins written by fragment shader\r
- EvqFragColor,\r
- EvqFragDepth,\r
-\r
- // end of list\r
- EvqLast\r
-};\r
-\r
-//\r
-// This is just for debug print out, carried along with the definitions above.\r
-//\r
-__inline const char* getQualifierString(TQualifier q) \r
-{\r
- switch (q) {\r
- case EvqTemporary: return "Temporary"; break;\r
- case EvqGlobal: return "Global"; break;\r
- case EvqConst: return "const"; break;\r
- case EvqConstReadOnly: return "const"; break;\r
- case EvqAttribute: return "attribute"; break;\r
- case EvqVaryingIn: return "varying"; break;\r
- case EvqVaryingOut: return "varying"; break;\r
- case EvqUniform: return "uniform"; break;\r
- case EvqIn: return "in"; break;\r
- case EvqOut: return "out"; break;\r
- case EvqInOut: return "inout"; break;\r
- case EvqInput: return "input"; break;\r
- case EvqOutput: return "output"; break;\r
- case EvqPosition: return "Position"; break;\r
- case EvqPointSize: return "PointSize"; break;\r
- case EvqClipVertex: return "ClipVertex"; break;\r
- case EvqFace: return "Face"; break;\r
- case EvqFragCoord: return "FragCoord"; break;\r
- case EvqFragColor: return "FragColor"; break;\r
- case EvqFragDepth: return "FragDepth"; break;\r
- default: return "unknown qualifier";\r
- }\r
-}\r
-\r
-#endif // _BASICTYPES_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _COMMON_INCLUDED_\r
-#define _COMMON_INCLUDED_\r
-\r
-#ifdef _WIN32\r
- #include <basetsd.h>\r
-#elif defined (solaris)\r
- #include <sys/int_types.h>\r
- #define UINT_PTR uintptr_t\r
-#else\r
- #include <stdint.h>\r
- #define UINT_PTR uintptr_t\r
-#endif\r
-\r
-/* windows only pragma */\r
-#ifdef _MSC_VER\r
- #pragma warning(disable : 4786) // Don't warn about too long identifiers\r
- #pragma warning(disable : 4514) // unused inline method\r
- #pragma warning(disable : 4201) // nameless union\r
-#endif\r
-\r
-//\r
-// Doing the push and pop below for warnings does not leave the warning state\r
-// the way it was. This seems like a defect in the compiler. We would like\r
-// to do this, but since it does not work correctly right now, it is turned\r
-// off.\r
-//\r
-//??#pragma warning(push, 3)\r
-\r
- #include <set>\r
- #include <vector>\r
- #include <map>\r
- #include <list>\r
- #include <string>\r
- #include <stdio.h>\r
-\r
-//??#pragma warning(pop)\r
-\r
-typedef int TSourceLoc;\r
-\r
-#include <assert.h>\r
-#include "PoolAlloc.h"\r
-\r
-//\r
-// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.\r
-//\r
-#define POOL_ALLOCATOR_NEW_DELETE(A) \\r
- void* operator new(size_t s) { return (A).allocate(s); } \\r
- void* operator new(size_t, void *_Where) { return (_Where); } \\r
- void operator delete(void*) { } \\r
- void operator delete(void *, void *) { } \\r
- void* operator new[](size_t s) { return (A).allocate(s); } \\r
- void* operator new[](size_t, void *_Where) { return (_Where); } \\r
- void operator delete[](void*) { } \\r
- void operator delete[](void *, void *) { }\r
-\r
-#ifdef _M_AMD64\r
-//\r
-// The current version of STL that comes with the PSDK (as required for the AMD64 compiler)\r
-// has a very old version of the STL which is very out of date. As a result, various additions needed\r
-// making to it to get the compilers compiling!\r
-//\r
-\r
-//\r
-// A new version of the Map template class - the operator[] now returns the correct type reference\r
-//\r
-template <class _K, class _Ty, class _Pr = std::less<_K>, class _A = std::allocator<_Ty> >\r
-class TBaseMap : public std::map <_K, _Ty, _Pr, _A >\r
-{\r
-public :\r
- _Ty& operator[] (const _K& _Kv)\r
- {\r
- iterator _P = insert(value_type(_Kv, _Ty())).first;\r
- return ((*_P).second); \r
- }\r
- \r
- explicit TBaseMap(const _Pr& _Pred = _Pr(), const _A& _Al = _A())\r
- : std::map<_K, _Ty, _Pr, _A >(_Pred, _Al) {};\r
-\r
-\r
-};\r
-\r
-//\r
-// A new version of the List template class - the begin function now checks for NULL to eliminate access violations\r
-//\r
-template <class _Ty, class _A = std::allocator<_Ty> >\r
-class TBaseList : public std::list <_Ty, _A >\r
-{\r
-public :\r
- iterator begin()\r
- {\r
- return (iterator(_Head == 0 ? 0 : _Acc::_Next(_Head))); \r
- }\r
- \r
- const_iterator begin() const\r
- {\r
- return (const_iterator(_Head == 0 ? 0 : _Acc::_Next(_Head))); \r
- }\r
- \r
- // \r
- // These are required - apparently!\r
- //\r
- explicit TBaseList(const _A& _Al = _A()) \r
- : std::list<_Ty, _A >(_Al) {};\r
- explicit TBaseList(size_type _N, const _Ty& _V = _Ty(), const _A& _Al = _A())\r
- : std::list<_Ty, _A >(N, _V, _Al) {};\r
-\r
-};\r
-\r
-//\r
-// A new version of the set class - this defines the required insert method\r
-//\r
-template<class _K, class _Pr = std::less<_K>, class _A = std::allocator<_K> >\r
-class TBaseSet : public std::set <_K, _Pr, _A>\r
-{\r
-public :\r
-\r
- //\r
- // This method wasn't defined\r
- //\r
- template<class _Iter>\r
- void insert(_Iter _First, _Iter _Last)\r
- { // insert [_First, _Last)\r
- for (; _First != _Last; ++_First)\r
- this->insert(*_First);\r
- }\r
- \r
- // \r
- // These methods were not resolved if I declared the previous method??\r
- //\r
- _Pairib insert(const value_type& _X)\r
- {\r
- _Imp::_Pairib _Ans = _Tr.insert(_X);\r
- return (_Pairib(_Ans.first, _Ans.second)); \r
- }\r
- \r
- iterator insert(iterator _P, const value_type& _X)\r
- {\r
- return (_Tr.insert((_Imp::iterator&)_P, _X)); \r
- }\r
- \r
- void insert(_It _F, _It _L)\r
- {\r
- for (; _F != _L; ++_F)\r
- _Tr.insert(*_F); \r
- }\r
-\r
-};\r
-\r
-#else\r
-\r
-#define TBaseMap std::map\r
-#define TBaseList std::list\r
-#define TBaseSet std::set\r
-\r
-#endif //_M_AMD64\r
-\r
-//\r
-// Pool version of string.\r
-//\r
-typedef pool_allocator<char> TStringAllocator;\r
-typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;\r
-inline TString* NewPoolTString(const char* s)\r
-{\r
- void* memory = GlobalPoolAllocator.allocate(sizeof(TString));\r
- return new(memory) TString(s);\r
-}\r
-\r
-//\r
-// Pool allocator versions of vectors, lists, and maps\r
-//\r
-template <class T> class TVector : public std::vector<T, pool_allocator<T> > {\r
-public:\r
- typedef typename std::vector<T, pool_allocator<T> >::size_type size_type;\r
- TVector() : std::vector<T, pool_allocator<T> >() {}\r
- TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a) {}\r
- TVector(size_type i): std::vector<T, pool_allocator<T> >(i) {}\r
-};\r
-\r
-template <class T> class TList : public TBaseList <T, pool_allocator<T> > {\r
-public:\r
- typedef typename TBaseList<T, pool_allocator<T> >::size_type size_type;\r
- TList() : TBaseList<T, pool_allocator<T> >() {}\r
- TList(const pool_allocator<T>& a) : TBaseList<T, pool_allocator<T> >(a) {}\r
- TList(size_type i): TBaseList<T, pool_allocator<T> >(i) {}\r
-};\r
-\r
-// This is called TStlSet, because TSet is taken by an existing compiler class.\r
-template <class T, class CMP> class TStlSet : public std::set<T, CMP, pool_allocator<T> > {\r
- // No pool allocator versions of constructors in std::set.\r
-};\r
-\r
-\r
-template <class K, class D, class CMP = std::less<K> > class TMap :\r
- public TBaseMap<K, D, CMP, pool_allocator<std::pair<K, D> > > {\r
-public:\r
- typedef pool_allocator<std::pair <K, D> > tAllocator;\r
-\r
- TMap() : TBaseMap<K, D, CMP, tAllocator >() {}\r
-/*\r
- TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator >(key_compare(), a) {}\r
-*/\r
- TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator >() {}\r
-};\r
-\r
-//\r
-// Persistent string memory. Should only be used for strings that survive\r
-// across compiles/links.\r
-//\r
-typedef std::basic_string<char> TPersistString;\r
-\r
-//\r
-// templatized min and max functions.\r
-//\r
-template <class T> T Min(const T a, const T b) { return a < b ? a : b; }\r
-template <class T> T Max(const T a, const T b) { return a > b ? a : b; }\r
-\r
-//\r
-// Create a TString object from an integer.\r
-//\r
-inline const TString String(const int i, const int base = 10)\r
-{\r
- char text[16]; // 32 bit ints are at most 10 digits in base 10\r
- \r
- #ifdef _WIN32\r
- itoa(i, text, base);\r
- #else\r
- // we assume base 10 for all cases\r
- sprintf(text, "%d", i);\r
- #endif\r
-\r
- return text;\r
-}\r
-\r
-const unsigned int SourceLocLineMask = 0xffff;\r
-const unsigned int SourceLocStringShift = 16;\r
-\r
-__inline TPersistString FormatSourceLoc(const TSourceLoc loc)\r
-{\r
- char locText[64];\r
-\r
- int string = loc >> SourceLocStringShift;\r
- int line = loc & SourceLocLineMask;\r
-\r
- if (line)\r
- sprintf(locText, "%d:%d", string, line);\r
- else\r
- sprintf(locText, "%d:? ", string);\r
-\r
- return TPersistString(locText);\r
-}\r
-typedef TMap<TString, TString> TPragmaTable;\r
-typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;\r
-\r
-#endif // _COMMON_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _CONSTANT_UNION_INCLUDED_\r
-#define _CONSTANT_UNION_INCLUDED_\r
-\r
-\r
-class constUnion {\r
-public:\r
-\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) \r
- union {\r
- int iConst; // used for ivec\r
- bool bConst; // used for bvec\r
- float fConst; // used for vec, mat\r
- } ;\r
-};\r
-\r
-#endif // _CONSTANT_UNION_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _INFOSINK_INCLUDED_\r
-#define _INFOSINK_INCLUDED_\r
-\r
-#include "../Include/Common.h"\r
-#include <math.h>\r
-\r
-//\r
-// TPrefixType is used to centralize how info log messages start.\r
-// See below.\r
-//\r
-enum TPrefixType {\r
- EPrefixNone,\r
- EPrefixWarning,\r
- EPrefixError,\r
- EPrefixInternalError,\r
- EPrefixUnimplemented\r
-};\r
-\r
-enum TOutputStream {\r
- ENull = 0,\r
- EDebugger = 0x01,\r
- EStdOut = 0x02,\r
- EString = 0x04\r
-};\r
-//\r
-// Encapsulate info logs for all objects that have them.\r
-//\r
-// The methods are a general set of tools for getting a variety of\r
-// messages and types inserted into the log.\r
-//\r
-class TInfoSinkBase {\r
-public:\r
- TInfoSinkBase() : outputStream(4) {}\r
- void erase() { sink.erase(); }\r
- TInfoSinkBase& operator<<(const TPersistString& t) { append(t); return *this; }\r
- TInfoSinkBase& operator<<(char c) { append(1, c); return *this; }\r
- TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }\r
- TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }\r
- TInfoSinkBase& operator<<(const unsigned int n) { append(String(n)); return *this; }\r
- TInfoSinkBase& operator<<(float n) { char buf[40]; \r
- sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?\r
- "%f" : "%g", n);\r
- append(buf); \r
- return *this; }\r
- TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; }\r
- TInfoSinkBase& operator+(const TString& t) { append(t); return *this; }\r
- TInfoSinkBase& operator<<(const TString& t) { append(t); return *this; }\r
- TInfoSinkBase& operator+(const char* s) { append(s); return *this; }\r
- const char* c_str() const { return sink.c_str(); }\r
- void prefix(TPrefixType message) {\r
- switch(message) {\r
- case EPrefixNone: break;\r
- case EPrefixWarning: append("WARNING: "); break;\r
- case EPrefixError: append("ERROR: "); break;\r
- case EPrefixInternalError: append("INTERNAL ERROR: "); break;\r
- case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;\r
- default: append("UNKOWN ERROR: "); break;\r
- }\r
- }\r
- void location(TSourceLoc loc) {\r
- append(FormatSourceLoc(loc).c_str());\r
- append(": ");\r
- }\r
- void message(TPrefixType message, const char* s) {\r
- prefix(message);\r
- append(s);\r
- append("\n");\r
- }\r
- void message(TPrefixType message, const char* s, TSourceLoc loc) {\r
- prefix(message);\r
- location(loc);\r
- append(s);\r
- append("\n");\r
- }\r
- \r
- void setOutputStream(int output = 4)\r
- {\r
- outputStream = output;\r
- }\r
-\r
-protected:\r
- void append(const char *s); \r
-\r
- void append(int count, char c);\r
- void append(const TPersistString& t);\r
- void append(const TString& t);\r
-\r
- void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2) \r
- sink.reserve(sink.capacity() + sink.capacity() / 2); }\r
- void appendToStream(const char* s);\r
- TPersistString sink;\r
- int outputStream;\r
-};\r
-\r
-class TInfoSink {\r
-public:\r
- TInfoSinkBase info;\r
- TInfoSinkBase debug;\r
-};\r
-\r
-#endif // _INFOSINK_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef __INITIALIZE_GLOBALS_INCLUDED_\r
-#define __INITIALIZE_GLOBALS_INCLUDED_\r
-\r
-void InitializeGlobalPools();\r
-void FreeGlobalPools();\r
-bool InitializePoolIndex();\r
-void FreePoolIndex();\r
-\r
-#endif // __INITIALIZE_GLOBALS_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_\r
-#define __INITIALIZE_PARSE_CONTEXT_INCLUDED_\r
-#include "osinclude.h"\r
-\r
-bool InitializeParseContextIndex();\r
-bool InitializeGlobalParseContext();\r
-bool FreeParseContext();\r
-bool FreeParseContextIndex();\r
-\r
-#endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _POOLALLOC_INCLUDED_\r
-#define _POOLALLOC_INCLUDED_\r
-\r
-#ifdef _DEBUG\r
-# define GUARD_BLOCKS // define to enable guard block sanity checking\r
-#endif\r
-\r
-//\r
-// This header defines an allocator that can be used to efficiently\r
-// allocate a large number of small requests for heap memory, with the \r
-// intention that they are not individually deallocated, but rather \r
-// collectively deallocated at one time.\r
-//\r
-// This simultaneously\r
-//\r
-// * Makes each individual allocation much more efficient; the\r
-// typical allocation is trivial.\r
-// * Completely avoids the cost of doing individual deallocation.\r
-// * Saves the trouble of tracking down and plugging a large class of leaks.\r
-//\r
-// Individual classes can use this allocator by supplying their own\r
-// new and delete methods.\r
-//\r
-// STL containers can use this allocator by using the pool_allocator\r
-// class as the allocator (second) template argument.\r
-//\r
-\r
-#include <stddef.h>\r
-#include <vector>\r
-\r
-// If we are using guard blocks, we must track each indivual\r
-// allocation. If we aren't using guard blocks, these\r
-// never get instantiated, so won't have any impact.\r
-// \r
-\r
-class TAllocation {\r
-public:\r
- TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :\r
- size(size), mem(mem), prevAlloc(prev) {\r
- // Allocations are bracketed:\r
- // [allocationHeader][initialGuardBlock][userData][finalGuardBlock]\r
- // This would be cleaner with if (guardBlockSize)..., but that\r
- // makes the compiler print warnings about 0 length memsets,\r
- // even with the if() protecting them.\r
-# ifdef GUARD_BLOCKS\r
- memset(preGuard(), guardBlockBeginVal, guardBlockSize);\r
- memset(data(), userDataFill, size);\r
- memset(postGuard(), guardBlockEndVal, guardBlockSize);\r
-# endif\r
- }\r
- \r
- void check() const {\r
- checkGuardBlock(preGuard(), guardBlockBeginVal, "before");\r
- checkGuardBlock(postGuard(), guardBlockEndVal, "after");\r
- }\r
-\r
- void checkAllocList() const;\r
-\r
- // Return total size needed to accomodate user buffer of 'size',\r
- // plus our tracking data.\r
- inline static size_t allocationSize(size_t size) {\r
- return size + 2 * guardBlockSize + headerSize();\r
- }\r
- \r
- // Offset from surrounding buffer to get to user data buffer.\r
- inline static unsigned char* offsetAllocation(unsigned char* m) {\r
- return m + guardBlockSize + headerSize();\r
- }\r
-\r
-private:\r
- void checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const;\r
-\r
- // Find offsets to pre and post guard blocks, and user data buffer\r
- unsigned char* preGuard() const { return mem + headerSize(); }\r
- unsigned char* data() const { return preGuard() + guardBlockSize; }\r
- unsigned char* postGuard() const { return data() + size; }\r
-\r
- size_t size; // size of the user data area\r
- unsigned char* mem; // beginning of our allocation (pts to header)\r
- TAllocation* prevAlloc; // prior allocation in the chain\r
-\r
- // Support MSVC++ 6.0\r
- const static unsigned char guardBlockBeginVal;\r
- const static unsigned char guardBlockEndVal;\r
- const static unsigned char userDataFill;\r
-\r
-# ifdef GUARD_BLOCKS\r
- const static size_t guardBlockSize;\r
- inline static size_t headerSize() { return sizeof(TAllocation); }\r
-# else\r
- const static size_t guardBlockSize;\r
- inline static size_t headerSize() { return 0; }\r
-# endif\r
-};\r
- \r
-//\r
-// There are several stacks. One is to track the pushing and popping\r
-// of the user, and not yet implemented. The others are simply a \r
-// repositories of free pages or used pages.\r
-//\r
-// Page stacks are linked together with a simple header at the beginning\r
-// of each allocation obtained from the underlying OS. Multi-page allocations\r
-// are returned to the OS. Individual page allocations are kept for future\r
-// re-use.\r
-//\r
-// The "page size" used is not, nor must it match, the underlying OS\r
-// page size. But, having it be about that size or equal to a set of \r
-// pages is likely most optimal.\r
-//\r
-class TPoolAllocator {\r
-public:\r
- TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);\r
-\r
- //\r
- // Don't call the destructor just to free up the memory, call pop()\r
- //\r
- ~TPoolAllocator();\r
-\r
- //\r
- // Call push() to establish a new place to pop memory too. Does not\r
- // have to be called to get things started.\r
- //\r
- void push();\r
-\r
- //\r
- // Call pop() to free all memory allocated since the last call to push(),\r
- // or if no last call to push, frees all memory since first allocation.\r
- //\r
- void pop();\r
-\r
- //\r
- // Call popAll() to free all memory allocated.\r
- //\r
- void popAll();\r
-\r
- //\r
- // Call allocate() to actually acquire memory. Returns 0 if no memory\r
- // available, otherwise a properly aligned pointer to 'numBytes' of memory.\r
- //\r
- void* allocate(size_t numBytes);\r
-\r
- //\r
- // There is no deallocate. The point of this class is that\r
- // deallocation can be skipped by the user of it, as the model\r
- // of use is to simultaneously deallocate everything at once\r
- // by calling pop(), and to not have to solve memory leak problems.\r
- //\r
-\r
-protected:\r
- friend struct tHeader;\r
- \r
- struct tHeader {\r
- tHeader(tHeader* nextPage, size_t pageCount) :\r
-#ifdef GUARD_BLOCKS\r
- lastAllocation(0),\r
-#endif\r
- nextPage(nextPage), pageCount(pageCount) { }\r
-\r
- ~tHeader() {\r
-#ifdef GUARD_BLOCKS\r
- if (lastAllocation)\r
- lastAllocation->checkAllocList();\r
-#endif\r
- }\r
-\r
- tHeader* nextPage;\r
- size_t pageCount;\r
-#ifdef GUARD_BLOCKS\r
- TAllocation* lastAllocation;\r
-#endif\r
- };\r
-\r
- struct tAllocState {\r
- size_t offset;\r
- tHeader* page;\r
- };\r
- typedef std::vector<tAllocState> tAllocStack;\r
-\r
- // Track allocations if and only if we're using guard blocks\r
- void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) {\r
-# ifdef GUARD_BLOCKS\r
- new(memory) TAllocation(numBytes, memory, block->lastAllocation);\r
- block->lastAllocation = reinterpret_cast<TAllocation*>(memory);\r
-# endif\r
-\r
- // This is optimized entirely away if GUARD_BLOCKS is not defined.\r
- return TAllocation::offsetAllocation(memory);\r
- }\r
-\r
- bool global; // should be true if this object is globally scoped\r
- size_t pageSize; // granularity of allocation from the OS\r
- size_t alignment; // all returned allocations will be aligned at \r
- // this granularity, which will be a power of 2\r
- size_t alignmentMask;\r
- size_t headerSkip; // amount of memory to skip to make room for the\r
- // header (basically, size of header, rounded\r
- // up to make it aligned\r
- size_t currentPageOffset; // next offset in top of inUseList to allocate from\r
- tHeader* freeList; // list of popped memory\r
- tHeader* inUseList; // list of all memory currently being used\r
- tAllocStack stack; // stack of where to allocate from, to partition pool\r
-\r
- int numCalls; // just an interesting statistic\r
- size_t totalBytes; // just an interesting statistic\r
-private:\r
- TPoolAllocator& operator=(const TPoolAllocator&); // dont allow assignment operator\r
- TPoolAllocator(const TPoolAllocator&); // dont allow default copy constructor\r
-};\r
-\r
-\r
-//\r
-// There could potentially be many pools with pops happening at\r
-// different times. But a simple use is to have a global pop\r
-// with everyone using the same global allocator.\r
-//\r
-typedef TPoolAllocator* PoolAllocatorPointer;\r
-extern TPoolAllocator& GetGlobalPoolAllocator();\r
-#define GlobalPoolAllocator GetGlobalPoolAllocator()\r
-struct TThreadGlobalPools\r
-{\r
- TPoolAllocator* globalPoolAllocator;\r
-};\r
-\r
-//\r
-// This STL compatible allocator is intended to be used as the allocator\r
-// parameter to templatized STL containers, like vector and map.\r
-//\r
-// It will use the pools for allocation, and not\r
-// do any deallocation, but will still do destruction.\r
-//\r
-template<class T>\r
-class pool_allocator {\r
-public:\r
- typedef size_t size_type;\r
- typedef ptrdiff_t difference_type;\r
- typedef T *pointer;\r
- typedef const T *const_pointer;\r
- typedef T& reference;\r
- typedef const T& const_reference;\r
- typedef T value_type;\r
- template<class Other> \r
- struct rebind {\r
- typedef pool_allocator<Other> other;\r
- };\r
- pointer address(reference x) const { return &x; }\r
- const_pointer address(const_reference x) const { return &x; }\r
-\r
-#ifdef USING_SGI_STL\r
- pool_allocator() { }\r
-#else\r
- pool_allocator() : allocator(GlobalPoolAllocator) { }\r
- pool_allocator(TPoolAllocator& a) : allocator(a) { }\r
- pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }\r
-#endif\r
-\r
-#if defined(_MSC_VER) && _MSC_VER >= 1300\r
- template<class Other>\r
-#ifdef USING_SGI_STL\r
- pool_allocator(const pool_allocator<Other>& p) /*: allocator(p.getAllocator())*/ { }\r
-#else\r
- pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }\r
-#endif\r
-#endif\r
-\r
-#ifndef _WIN32\r
- template<class Other>\r
- pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }\r
-#endif\r
-\r
-#ifdef USING_SGI_STL\r
- static pointer allocate(size_type n) { \r
- return reinterpret_cast<pointer>(getAllocator().allocate(n)); }\r
- pointer allocate(size_type n, const void*) { \r
- return reinterpret_cast<pointer>(getAllocator().allocate(n)); }\r
-\r
- static void deallocate(void*, size_type) { }\r
- static void deallocate(pointer, size_type) { }\r
-#else\r
- pointer allocate(size_type n) { \r
- return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }\r
- pointer allocate(size_type n, const void*) { \r
- return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }\r
-\r
- void deallocate(void*, size_type) { }\r
- void deallocate(pointer, size_type) { }\r
-#endif\r
-\r
- pointer _Charalloc(size_t n) {\r
- return reinterpret_cast<pointer>(getAllocator().allocate(n)); }\r
-\r
- void construct(pointer p, const T& val) { new ((void *)p) T(val); }\r
- void destroy(pointer p) { p->T::~T(); }\r
-\r
- bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }\r
- bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }\r
-\r
- size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }\r
- size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }\r
-\r
-#ifdef USING_SGI_STL\r
- //void setAllocator(TPoolAllocator* a) { allocator = a; }\r
- static TPoolAllocator& getAllocator() { return GlobalPoolAllocator; }\r
-#else\r
- void setAllocator(TPoolAllocator* a) { allocator = *a; }\r
- TPoolAllocator& getAllocator() const { return allocator; }\r
-\r
-protected:\r
- TPoolAllocator& allocator;\r
-#endif\r
-};\r
-\r
-#endif // _POOLALLOC_INCLUDED_\r
+++ /dev/null
-/*\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#ifndef _RESOURCE_LIMITS_INCLUDED_\r
-#define _RESOURCE_LIMITS_INCLUDED_\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-typedef struct TBuiltInResource_ {\r
- int maxLights;\r
- int maxClipPlanes;\r
- int maxTextureUnits;\r
- int maxTextureCoords;\r
- int maxVertexAttribs;\r
- int maxVertexUniformComponents;\r
- int maxVaryingFloats;\r
- int maxVertexTextureImageUnits;\r
- int maxCombinedTextureImageUnits;\r
- int maxTextureImageUnits;\r
- int maxFragmentUniformComponents;\r
- int maxDrawBuffers;\r
-} TBuiltInResource;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* _RESOURCE_LIMITS_INCLUDED_ */\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _SHHANDLE_INCLUDED_\r
-#define _SHHANDLE_INCLUDED_\r
-\r
-//\r
-// Machine independent part of the compiler private objects\r
-// sent as ShHandle to the driver.\r
-//\r
-// This should not be included by driver code.\r
-//\r
-\r
-#define SH_EXPORTING\r
-#include "../Public/ShaderLangExt.h"\r
-#include "InfoSink.h"\r
-\r
-class TCompiler;\r
-class TLinker;\r
-class TUniformMap;\r
-namespace Lf {\r
- class TBindingList;\r
- class TLinker;\r
- class TLibrary;\r
-}\r
-\r
-//\r
-// The base class used to back handles returned to the driver.\r
-//\r
-class TShHandleBase {\r
-public:\r
- TShHandleBase() { }\r
- virtual ~TShHandleBase() { }\r
- virtual TCompiler* getAsCompiler() { return 0; }\r
- virtual TLinker* getAsLinker() { return 0; }\r
- virtual Lf::TLinker* getAsNewLinker() { return 0; }\r
- virtual TUniformMap* getAsUniformMap() { return 0; }\r
- virtual Lf::TBindingList* getAsBindingList() { return 0; }\r
- virtual Lf::TLibrary* getAsLibrary() { return 0; }\r
-};\r
-//\r
-// The base class for the machine dependent linker to derive from\r
-// for managing where uniforms live.\r
-//\r
-class TUniformMap : public TShHandleBase {\r
-public:\r
- TUniformMap() { }\r
- virtual ~TUniformMap() { }\r
- virtual TUniformMap* getAsUniformMap() { return this; }\r
- virtual int getLocation(const char* name) = 0; \r
- virtual TInfoSink& getInfoSink() { return infoSink; }\r
- TInfoSink infoSink;\r
-};\r
-\r
-class TIntermNode;\r
-\r
-//\r
-// The base class for the machine dependent compiler to derive from\r
-// for managing object code from the compile.\r
-//\r
-class TCompiler : public TShHandleBase {\r
-public:\r
- TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false) { }\r
- virtual ~TCompiler() { }\r
- EShLanguage getLanguage() { return language; }\r
- virtual TInfoSink& getInfoSink() { return infoSink; }\r
-\r
- virtual bool compile(TIntermNode* root) = 0;\r
-\r
- virtual TCompiler* getAsCompiler() { return this; }\r
- virtual bool linkable() { return haveValidObjectCode; }\r
- \r
- TInfoSink& infoSink;\r
-protected:\r
- EShLanguage language;\r
- bool haveValidObjectCode; \r
-};\r
-\r
-//\r
-// Link operations are base on a list of compile results...\r
-//\r
-typedef TVector<TCompiler*> TCompilerList;\r
-typedef TVector<TShHandleBase*> THandleList;\r
-\r
-//\r
-// The base class for the machine dependent linker to derive from\r
-// to manage the resulting executable.\r
-//\r
-\r
-class TLinker : public TShHandleBase {\r
-public:\r
- TLinker(EShExecutable e, TInfoSink& iSink) : \r
- infoSink(iSink),\r
- executable(e), \r
- haveReturnableObjectCode(false),\r
- appAttributeBindings(0),\r
- fixedAttributeBindings(0),\r
- excludedAttributes(0),\r
- excludedCount(0),\r
- uniformBindings(0) { }\r
- virtual TLinker* getAsLinker() { return this; }\r
- virtual ~TLinker() { }\r
- virtual bool link(TCompilerList&, TUniformMap*) = 0;\r
- virtual bool link(THandleList&) { return false; }\r
- virtual void setAppAttributeBindings(const ShBindingTable* t) { appAttributeBindings = t; }\r
- virtual void setFixedAttributeBindings(const ShBindingTable* t) { fixedAttributeBindings = t; }\r
- virtual void getAttributeBindings(ShBindingTable const **t) const = 0;\r
- virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }\r
- virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }\r
- virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here\r
- virtual TInfoSink& getInfoSink() { return infoSink; }\r
- TInfoSink& infoSink;\r
-protected:\r
- EShExecutable executable;\r
- bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver\r
-\r
- const ShBindingTable* appAttributeBindings;\r
- const ShBindingTable* fixedAttributeBindings;\r
- const int* excludedAttributes;\r
- int excludedCount;\r
- ShBindingTable* uniformBindings; // created by the linker \r
-};\r
-\r
-//\r
-// This is the interface between the machine independent code\r
-// and the machine dependent code.\r
-//\r
-// The machine dependent code should derive from the classes\r
-// above. Then Construct*() and Delete*() will create and \r
-// destroy the machine dependent objects, which contain the\r
-// above machine independent information.\r
-//\r
-TCompiler* ConstructCompiler(EShLanguage, int);\r
-\r
-TShHandleBase* ConstructLinker(EShExecutable, int);\r
-TShHandleBase* ConstructBindings();\r
-TShHandleBase* ConstructLibrary();\r
-void DeleteLinker(TShHandleBase*);\r
- \r
-TUniformMap* ConstructUniformMap();\r
-void DeleteCompiler(TCompiler*);\r
-\r
-void DeleteUniformMap(TUniformMap*);\r
-void freeTargetDependentData(void*);\r
-\r
-#endif // _SHHANDLE_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _TYPES_INCLUDED\r
-#define _TYPES_INCLUDED\r
-\r
-#include "../Include/Common.h"\r
-#include "../Include/BaseTypes.h"\r
-\r
-//\r
-// Need to have association of line numbers to types in a list for building structs.\r
-//\r
-class TType;\r
-struct TTypeLine {\r
- TType* type;\r
- int line;\r
-};\r
-typedef TVector<TTypeLine> TTypeList;\r
-\r
-inline TTypeList* NewPoolTTypeList()\r
-{\r
- void* memory = GlobalPoolAllocator.allocate(sizeof(TTypeList));\r
- return new(memory) TTypeList;\r
-}\r
-\r
-//\r
-// This is a workaround for a problem with the yacc stack, It can't have\r
-// types that the compiler thinks non-trivial constructors. It should \r
-// just be used while recognizing the grammar, not anything else. Pointers\r
-// could be used, but also trying to avoid lots of memory management overhead.\r
-//\r
-// Not as bad as it looks, there is no actual assumption that the fields\r
-// match up or are name the same or anything like that.\r
-//\r
-class TPublicType {\r
-public:\r
- TBasicType type;\r
- TQualifier qualifier;\r
- int size; // size of vector or matrix, not size of array\r
- bool matrix;\r
- bool array;\r
- TType* userDef;\r
- int line;\r
-};\r
-\r
-typedef std::map<TTypeList*, TTypeList*> TStructureMap;\r
-typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;\r
-//\r
-// Base class for things that have a type.\r
-//\r
-class TType {\r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
- explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :\r
- type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0),\r
- structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), typeName(0), mangled(0)\r
- { }\r
- explicit TType(TPublicType p) : \r
- type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0), \r
- structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), typeName(0), mangled(0)\r
- {\r
- if (p.userDef) {\r
- structure = p.userDef->getStruct();\r
- structureSize = setStructSize(p.userDef->getStruct());\r
- typeName = NewPoolTString(p.userDef->getTypeName().c_str());\r
- }\r
- }\r
- explicit TType(TTypeList* userDef, TString n) : \r
- type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),\r
- structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {\r
- structureSize = setStructSize(userDef);\r
- typeName = NewPoolTString(n.c_str());\r
- }\r
- explicit TType() {}\r
- virtual ~TType() {}\r
-\r
- TType (const TType& type) { *this = type; }\r
- \r
- void copyType(const TType& copyOf, TStructureMap& remapper)\r
- {\r
- type = copyOf.type;\r
- qualifier = copyOf.qualifier;\r
- size = copyOf.size;\r
- matrix = copyOf.matrix;\r
- array = copyOf.array;\r
- arraySize = copyOf.arraySize;\r
- \r
- TStructureMapIterator iter;\r
- if (copyOf.structure) {\r
- if ((iter = remapper.find(structure)) == remapper.end()) {\r
- // create the new structure here\r
- structure = NewPoolTTypeList();\r
- for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {\r
- TTypeLine typeLine;\r
- typeLine.line = (*copyOf.structure)[i].line;\r
- typeLine.type = (*copyOf.structure)[i].type->clone(remapper);\r
- structure->push_back(typeLine);\r
- }\r
- } else {\r
- structure = iter->second;\r
- }\r
- } else\r
- structure = 0;\r
-\r
- fieldName = 0;\r
- if (copyOf.fieldName)\r
- fieldName = NewPoolTString(copyOf.fieldName->c_str());\r
- typeName = 0;\r
- if (copyOf.typeName)\r
- typeName = NewPoolTString(copyOf.typeName->c_str());\r
- \r
- mangled = 0;\r
- if (copyOf.mangled)\r
- mangled = NewPoolTString(copyOf.mangled->c_str());\r
-\r
- structureSize = copyOf.structureSize;\r
- maxArraySize = copyOf.maxArraySize;\r
- assert (copyOf.arrayInformationType == 0);\r
- arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level\r
- }\r
-\r
- TType* clone(TStructureMap& remapper)\r
- {\r
- TType *newType = new TType();\r
- newType->copyType(*this, remapper);\r
-\r
- return newType;\r
- }\r
- \r
- int setStructSize(TTypeList* userDef)\r
- {\r
- int stSize = 0;\r
- for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {\r
- if (((*tl).type)->isArray()) { \r
- if (((*tl).type)->getStruct()) {\r
- int structSize = setStructSize(((*tl).type)->getStruct());\r
- stSize += structSize * ((*tl).type)->getArraySize();\r
- } else {\r
- stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();\r
- }\r
- } else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){\r
- stSize += ((*tl).type)->getInstanceSize();\r
- } else if (((*tl).type)->getStruct()) {\r
- //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case\r
- // of nested/embedded structs.\r
- stSize += setStructSize(((*tl).type)->getStruct());\r
- } else \r
- stSize += 1;\r
- }\r
- structureSize = stSize;\r
- return stSize;\r
- }\r
-\r
- virtual void setType(TBasicType t, int s, bool m, bool a, int aS = 0)\r
- { type = t; size = s; matrix = m; array = a; arraySize = aS; }\r
- virtual void setType(TBasicType t, int s, bool m, TType* userDef = 0)\r
- { type = t; \r
- size = s; \r
- matrix = m; \r
- if (userDef)\r
- structure = userDef->getStruct(); \r
- // leave array information intact.\r
- }\r
- virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }\r
- virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }\r
- virtual const TString& getTypeName() const\r
- { \r
- assert (typeName); \r
- return *typeName; \r
- }\r
-\r
- virtual const TString& getFieldName() const\r
- { \r
- assert (fieldName);\r
- return *fieldName; \r
- }\r
- \r
- virtual TBasicType getBasicType() const { return type; }\r
- virtual TQualifier getQualifier() const { return qualifier; }\r
- virtual void changeQualifier(TQualifier q) { qualifier = q; }\r
-\r
- // One-dimensional size of single instance type\r
- virtual int getNominalSize() const { return size; } \r
- \r
- // Full-dimensional size of single instance of type\r
- virtual int getInstanceSize() const \r
- {\r
- if (matrix)\r
- return size * size;\r
- else\r
- return size;\r
- }\r
- \r
- virtual bool isMatrix() const { return matrix ? true : false; }\r
- virtual bool isArray() const { return array ? true : false; }\r
- int getArraySize() const { return arraySize; }\r
- void setArraySize(int s) { array = true; arraySize = s; }\r
- void setMaxArraySize (int s) { maxArraySize = s; }\r
- int getMaxArraySize () const { return maxArraySize; }\r
- void setArrayInformationType(TType* t) { arrayInformationType = t; }\r
- TType* getArrayInformationType() { return arrayInformationType; }\r
- virtual bool isVector() const { return size > 1 && !matrix; }\r
- static char* getBasicString(TBasicType t) {\r
- switch (t) {\r
- case EbtVoid: return "void"; break;\r
- case EbtFloat: return "float"; break;\r
- case EbtInt: return "int"; break;\r
- case EbtBool: return "bool"; break;\r
- case EbtSampler1D: return "sampler1D"; break;\r
- case EbtSampler2D: return "sampler2D"; break;\r
- case EbtSampler3D: return "sampler3D"; break;\r
- case EbtSamplerCube: return "samplerCube"; break;\r
- case EbtSampler1DShadow: return "sampler1DShadow"; break;\r
- case EbtSampler2DShadow: return "sampler2DShadow"; break;\r
- case EbtStruct: return "structure"; break;\r
- default: return "unknown type";\r
- }\r
- }\r
- const char* getBasicString() const { return TType::getBasicString(type); }\r
- const char* getQualifierString() const { return ::getQualifierString(qualifier); }\r
- TTypeList* getStruct() { return structure; }\r
- int getStructSize() const { return structureSize; }\r
- TTypeList* getStruct() const { return structure; }\r
- TString& getMangledName() {\r
- if (!mangled) {\r
- mangled = NewPoolTString("");\r
- buildMangledName(*mangled); \r
- *mangled+=';';\r
- }\r
- \r
- return *mangled;\r
- }\r
- bool operator==(const TType& right) const {\r
- return type == right.type &&\r
- size == right.size &&\r
- matrix == right.matrix &&\r
- array == right.array &&\r
- structure == right.structure;\r
- // don't check the qualifier, it's not ever what's being sought after\r
- }\r
- bool operator!=(const TType& right) const {\r
- return !operator==(right);\r
- }\r
- TString getCompleteString() const;\r
- \r
-protected:\r
- void buildMangledName(TString&);\r
-\r
- TBasicType type : 6;\r
- TQualifier qualifier : 7;\r
- int size : 8; // size of vector or matrix, not size of array\r
- unsigned int matrix : 1;\r
- unsigned int array : 1;\r
-\r
- int arraySize;\r
- TTypeList* structure; // 0 unless this is a struct\r
- int structureSize;\r
- int maxArraySize;\r
- TType* arrayInformationType;\r
- TString *fieldName; // for structure field names\r
- TString *typeName; // for structure field type name\r
- TString *mangled;\r
-\r
-};\r
-\r
-#endif // _TYPES_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// Definition of the in-memory high-level intermediate representation\r
-// of shaders. This is a tree that parser creates.\r
-//\r
-// Nodes in the tree are defined as a hierarchy of classes derived from \r
-// TIntermNode. Each is a node in a tree. There is no preset branching factor;\r
-// each node can have it's own type of list of children.\r
-//\r
-\r
-#ifndef __INTERMEDIATE_H\r
-#define __INTERMEDIATE_H\r
-\r
-#include "../Include/Common.h"\r
-#include "../Include/Types.h"\r
-#include "../Include/ConstantUnion.h"\r
-\r
-//\r
-// Operators used by the high-level (parse tree) representation.\r
-//\r
-enum TOperator {\r
- EOpNull, // if in a node, should only mean a node is still being built\r
- EOpSequence, // denotes a list of statements, or parameters, etc.\r
- EOpFunctionCall, \r
- EOpFunction, // For function definition\r
- EOpParameters, // an aggregate listing the parameters to a function\r
-\r
- //\r
- // Unary operators\r
- //\r
- \r
- EOpNegative,\r
- EOpLogicalNot,\r
- EOpVectorLogicalNot,\r
- EOpBitwiseNot,\r
-\r
- EOpPostIncrement,\r
- EOpPostDecrement,\r
- EOpPreIncrement,\r
- EOpPreDecrement,\r
-\r
- EOpConvIntToBool,\r
- EOpConvFloatToBool,\r
- EOpConvBoolToFloat,\r
- EOpConvIntToFloat,\r
- EOpConvFloatToInt,\r
- EOpConvBoolToInt,\r
-\r
- //\r
- // binary operations\r
- //\r
-\r
- EOpAdd,\r
- EOpSub,\r
- EOpMul,\r
- EOpDiv,\r
- EOpMod,\r
- EOpRightShift,\r
- EOpLeftShift,\r
- EOpAnd,\r
- EOpInclusiveOr,\r
- EOpExclusiveOr,\r
- EOpEqual,\r
- EOpNotEqual,\r
- EOpVectorEqual,\r
- EOpVectorNotEqual,\r
- EOpLessThan,\r
- EOpGreaterThan,\r
- EOpLessThanEqual,\r
- EOpGreaterThanEqual,\r
- EOpComma,\r
-\r
- EOpVectorTimesScalar,\r
- EOpVectorTimesMatrix,\r
- EOpMatrixTimesVector,\r
- EOpMatrixTimesScalar,\r
-\r
- EOpLogicalOr,\r
- EOpLogicalXor,\r
- EOpLogicalAnd,\r
-\r
- EOpIndexDirect,\r
- EOpIndexIndirect,\r
- EOpIndexDirectStruct,\r
-\r
- EOpVectorSwizzle,\r
-\r
- //\r
- // Built-in functions potentially mapped to operators\r
- //\r
-\r
- EOpRadians,\r
- EOpDegrees,\r
- EOpSin,\r
- EOpCos,\r
- EOpTan,\r
- EOpAsin,\r
- EOpAcos,\r
- EOpAtan,\r
-\r
- EOpPow,\r
- EOpExp,\r
- EOpLog,\r
- EOpExp2,\r
- EOpLog2,\r
- EOpSqrt,\r
- EOpInverseSqrt,\r
-\r
- EOpAbs,\r
- EOpSign,\r
- EOpFloor,\r
- EOpCeil,\r
- EOpFract,\r
- EOpMin,\r
- EOpMax,\r
- EOpClamp,\r
- EOpMix,\r
- EOpStep,\r
- EOpSmoothStep,\r
-\r
- EOpLength,\r
- EOpDistance,\r
- EOpDot,\r
- EOpCross,\r
- EOpNormalize,\r
- EOpFaceForward,\r
- EOpReflect,\r
- EOpRefract,\r
-\r
- EOpDPdx, // Fragment only\r
- EOpDPdy, // Fragment only\r
- EOpFwidth, // Fragment only\r
-\r
- EOpMatrixTimesMatrix,\r
-\r
- EOpAny,\r
- EOpAll,\r
- \r
- EOpItof, // pack/unpack only\r
- EOpFtoi, // pack/unpack only \r
- EOpSkipPixels, // pack/unpack only\r
- EOpReadInput, // unpack only\r
- EOpWritePixel, // unpack only\r
- EOpBitmapLsb, // unpack only\r
- EOpBitmapMsb, // unpack only\r
- EOpWriteOutput, // pack only\r
- EOpReadPixel, // pack only\r
- \r
- //\r
- // Branch\r
- //\r
-\r
- EOpKill, // Fragment only\r
- EOpReturn,\r
- EOpBreak,\r
- EOpContinue,\r
-\r
- //\r
- // Constructors\r
- //\r
-\r
- EOpConstructInt,\r
- EOpConstructBool,\r
- EOpConstructFloat,\r
- EOpConstructVec2,\r
- EOpConstructVec3,\r
- EOpConstructVec4,\r
- EOpConstructBVec2,\r
- EOpConstructBVec3,\r
- EOpConstructBVec4,\r
- EOpConstructIVec2,\r
- EOpConstructIVec3,\r
- EOpConstructIVec4,\r
- EOpConstructMat2,\r
- EOpConstructMat3,\r
- EOpConstructMat4,\r
- EOpConstructStruct,\r
-\r
- //\r
- // moves\r
- //\r
- \r
- EOpAssign,\r
- EOpAddAssign,\r
- EOpSubAssign,\r
- EOpMulAssign,\r
- EOpVectorTimesMatrixAssign,\r
- EOpVectorTimesScalarAssign,\r
- EOpMatrixTimesScalarAssign,\r
- EOpMatrixTimesMatrixAssign,\r
- EOpDivAssign,\r
- EOpModAssign,\r
- EOpAndAssign,\r
- EOpInclusiveOrAssign,\r
- EOpExclusiveOrAssign,\r
- EOpLeftShiftAssign,\r
- EOpRightShiftAssign\r
-};\r
-\r
-class TIntermTraverser;\r
-class TIntermAggregate;\r
-class TIntermBinary;\r
-class TIntermConstantUnion;\r
-class TIntermSelection;\r
-class TIntermTyped;\r
-class TIntermSymbol;\r
-class TInfoSink;\r
-\r
-//\r
-// Base class for the tree nodes\r
-//\r
-class TIntermNode {\r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
-\r
- TIntermNode() : line(0) {}\r
- virtual TSourceLoc getLine() const { return line; }\r
- virtual void setLine(TSourceLoc l) { line = l; }\r
- virtual void traverse(TIntermTraverser*) = 0;\r
- virtual TIntermTyped* getAsTyped() { return 0; }\r
- virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }\r
- virtual TIntermAggregate* getAsAggregate() { return 0; }\r
- virtual TIntermBinary* getAsBinaryNode() { return 0; }\r
- virtual TIntermSelection* getAsSelectionNode() { return 0; }\r
- virtual TIntermSymbol* getAsSymbolNode() { return 0; }\r
- virtual ~TIntermNode() { }\r
-protected:\r
- TSourceLoc line;\r
-};\r
-\r
-//\r
-// This is just to help yacc.\r
-//\r
-struct TIntermNodePair {\r
- TIntermNode* node1;\r
- TIntermNode* node2;\r
-};\r
-\r
-class TIntermSymbol;\r
-class TIntermBinary;\r
-\r
-//\r
-// Intermediate class for nodes that have a type.\r
-//\r
-class TIntermTyped : public TIntermNode {\r
-public:\r
- TIntermTyped(const TType& t) : type(t) { }\r
- virtual TIntermTyped* getAsTyped() { return this; }\r
- virtual void setType(const TType& t) { type = t; }\r
- virtual TType getType() const { return type; }\r
- virtual TType* getTypePointer() { return &type; }\r
- \r
- virtual TBasicType getBasicType() const { return type.getBasicType(); }\r
- virtual TQualifier getQualifier() const { return type.getQualifier(); }\r
- virtual int getNominalSize() const { return type.getNominalSize(); }\r
- virtual int getSize() const { return type.getInstanceSize(); }\r
- virtual bool isMatrix() const { return type.isMatrix(); }\r
- virtual bool isArray() const { return type.isArray(); }\r
- virtual bool isVector() const { return type.isVector(); }\r
- const char* getBasicString() const { return type.getBasicString(); }\r
- const char* getQualifierString() const { return type.getQualifierString(); }\r
- TString getCompleteString() const { return type.getCompleteString(); }\r
-\r
-protected:\r
- TType type;\r
-};\r
-\r
-//\r
-// Handle for, do-while, and while loops.\r
-//\r
-class TIntermLoop : public TIntermNode {\r
-public:\r
- TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : \r
- body(aBody),\r
- test(aTest),\r
- terminal(aTerminal),\r
- first(testFirst) { }\r
- virtual void traverse(TIntermTraverser*);\r
- TIntermNode* getBody() { return body; }\r
- TIntermTyped* getTest() { return test; }\r
- TIntermTyped* getTerminal() { return terminal; }\r
- bool testFirst() { return first; }\r
-protected:\r
- TIntermNode* body; // code to loop over\r
- TIntermTyped* test; // exit condition associated with loop, could be 0 for 'for' loops\r
- TIntermTyped* terminal; // exists for for-loops\r
- bool first; // true for while and for, not for do-while\r
-};\r
-\r
-//\r
-// Handle break, continue, return, and kill.\r
-//\r
-class TIntermBranch : public TIntermNode {\r
-public:\r
- TIntermBranch(TOperator op, TIntermTyped* e) :\r
- flowOp(op),\r
- expression(e) { }\r
- virtual void traverse(TIntermTraverser*);\r
- TOperator getFlowOp() { return flowOp; }\r
- TIntermTyped* getExpression() { return expression; }\r
-protected:\r
- TOperator flowOp;\r
- TIntermTyped* expression; // non-zero except for "return exp;" statements\r
-};\r
-\r
-//\r
-// Nodes that correspond to symbols or constants in the source code.\r
-//\r
-class TIntermSymbol : public TIntermTyped {\r
-public:\r
- // if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. If sym comes from\r
- // per process globalpoolallocator, then it causes increased memory usage per compile\r
- // it is essential to use "symbol = sym" to assign to symbol\r
- TIntermSymbol(int i, const TString& sym, const TType& t) : \r
- TIntermTyped(t), id(i) { symbol = sym;} \r
- virtual int getId() const { return id; }\r
- virtual const TString& getSymbol() const { return symbol; }\r
- virtual void traverse(TIntermTraverser*);\r
- virtual TIntermSymbol* getAsSymbolNode() { return this; }\r
-protected:\r
- int id;\r
- TString symbol;\r
-};\r
-\r
-class TIntermConstantUnion : public TIntermTyped {\r
-public:\r
- TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }\r
- constUnion* getUnionArrayPointer() const { return unionArrayPointer; }\r
- void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }\r
- virtual TIntermConstantUnion* getAsConstantUnion() { return this; }\r
- virtual void traverse(TIntermTraverser* );\r
- virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&, bool);\r
-protected:\r
- constUnion *unionArrayPointer;\r
-};\r
-\r
-//\r
-// Intermediate class for node types that hold operators.\r
-//\r
-class TIntermOperator : public TIntermTyped {\r
-public:\r
- TOperator getOp() { return op; }\r
- bool modifiesState() const;\r
- bool isConstructor() const;\r
- virtual bool promote(TInfoSink&) { return true; }\r
-protected:\r
- TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}\r
- TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {} \r
- TOperator op;\r
-};\r
-\r
-//\r
-// Nodes for all the basic binary math operators.\r
-//\r
-class TIntermBinary : public TIntermOperator {\r
-public:\r
- TIntermBinary(TOperator o) : TIntermOperator(o) {}\r
- virtual void traverse(TIntermTraverser*);\r
- virtual void setLeft(TIntermTyped* n) { left = n; }\r
- virtual void setRight(TIntermTyped* n) { right = n; }\r
- virtual TIntermTyped* getLeft() const { return left; }\r
- virtual TIntermTyped* getRight() const { return right; }\r
- virtual TIntermBinary* getAsBinaryNode() { return this; }\r
- virtual bool promote(TInfoSink&);\r
-protected:\r
- TIntermTyped* left;\r
- TIntermTyped* right;\r
-};\r
-\r
-//\r
-// Nodes for unary math operators.\r
-//\r
-class TIntermUnary : public TIntermOperator {\r
-public:\r
- TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}\r
- TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}\r
- virtual void traverse(TIntermTraverser*);\r
- virtual void setOperand(TIntermTyped* o) { operand = o; }\r
- virtual TIntermTyped* getOperand() { return operand; }\r
- virtual bool promote(TInfoSink&);\r
-protected:\r
- TIntermTyped* operand;\r
-};\r
-\r
-typedef TVector<TIntermNode*> TIntermSequence;\r
-typedef TVector<int> TQualifierList;\r
-//\r
-// Nodes that operate on an arbitrary sized set of children.\r
-//\r
-class TIntermAggregate : public TIntermOperator {\r
-public:\r
- TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }\r
- TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }\r
- ~TIntermAggregate() { delete pragmaTable; }\r
- virtual TIntermAggregate* getAsAggregate() { return this; }\r
- virtual void setOperator(TOperator o) { op = o; }\r
- virtual TIntermSequence& getSequence() { return sequence; }\r
- virtual void setName(const TString& n) { name = n; }\r
- virtual const TString& getName() const { return name; }\r
- virtual void traverse(TIntermTraverser*);\r
- virtual void setUserDefined() { userDefined = true; }\r
- virtual bool isUserDefined() { return userDefined; }\r
- virtual TQualifierList& getQualifier() { return qualifier; }\r
- void setOptimize(bool o) { optimize = o; }\r
- void setDebug(bool d) { debug = d; }\r
- bool getOptimize() { return optimize; }\r
- bool getDebug() { return debug; }\r
- void addToPragmaTable(const TPragmaTable& pTable);\r
- const TPragmaTable& getPragmaTable() const { return *pragmaTable; }\r
-protected:\r
- TIntermAggregate(const TIntermAggregate&); // disallow copy constructor\r
- TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator\r
- TIntermSequence sequence;\r
- TQualifierList qualifier;\r
- TString name;\r
- bool userDefined; // used for user defined function names\r
- bool optimize;\r
- bool debug;\r
- TPragmaTable *pragmaTable;\r
-};\r
-\r
-//\r
-// For if tests. Simplified since there is no switch statement.\r
-//\r
-class TIntermSelection : public TIntermTyped {\r
-public:\r
- TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :\r
- TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}\r
- TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :\r
- TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}\r
- virtual void traverse(TIntermTraverser*);\r
- virtual TIntermNode* getCondition() const { return condition; }\r
- virtual TIntermNode* getTrueBlock() const { return trueBlock; }\r
- virtual TIntermNode* getFalseBlock() const { return falseBlock; }\r
- virtual TIntermSelection* getAsSelectionNode() { return this; }\r
-protected:\r
- TIntermTyped* condition;\r
- TIntermNode* trueBlock;\r
- TIntermNode* falseBlock;\r
-};\r
-\r
-//\r
-// For traversing the tree. User should derive from this, \r
-// put their traversal specific data in it, and then pass\r
-// it to a Traverse method.\r
-//\r
-// When using this, just fill in the methods for nodes you want visited.\r
-// Return false from a pre-visit to skip visiting that node's subtree.\r
-//\r
-class TIntermTraverser {\r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
-\r
- TIntermTraverser() : \r
- visitSymbol(0), \r
- visitConstantUnion(0),\r
- visitBinary(0),\r
- visitUnary(0),\r
- visitSelection(0),\r
- visitAggregate(0),\r
- visitLoop(0),\r
- visitBranch(0),\r
- depth(0),\r
- preVisit(true),\r
- postVisit(false),\r
- rightToLeft(false) {}\r
-\r
- void (*visitSymbol)(TIntermSymbol*, TIntermTraverser*);\r
- void (*visitConstantUnion)(TIntermConstantUnion*, TIntermTraverser*);\r
- bool (*visitBinary)(bool preVisit, TIntermBinary*, TIntermTraverser*);\r
- bool (*visitUnary)(bool preVisit, TIntermUnary*, TIntermTraverser*);\r
- bool (*visitSelection)(bool preVisit, TIntermSelection*, TIntermTraverser*);\r
- bool (*visitAggregate)(bool preVisit, TIntermAggregate*, TIntermTraverser*);\r
- bool (*visitLoop)(bool preVisit, TIntermLoop*, TIntermTraverser*);\r
- bool (*visitBranch)(bool preVisit, TIntermBranch*, TIntermTraverser*);\r
-\r
- int depth;\r
- bool preVisit;\r
- bool postVisit;\r
- bool rightToLeft;\r
-};\r
-\r
-#endif // __INTERMEDIATE_H\r
+++ /dev/null
-#line 2 "Gen_glslang.cpp"
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp,v 1.3 2005/03/18 14:30:27 michal Exp $
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-#include <unistd.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-
-#define yywrap() 1
-#define YY_SKIP_YYWRAP
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 144
-#define YY_END_OF_BUFFER 145
-static yyconst short int yy_accept[428] =
- { 0,
- 0, 0, 0, 0, 145, 143, 142, 142, 127, 133,
- 138, 122, 123, 131, 130, 119, 128, 126, 132, 143,
- 143, 120, 116, 134, 121, 135, 139, 143, 124, 125,
- 137, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 117, 136, 118, 129, 141, 144, 143, 143, 113,
- 99, 118, 107, 102, 97, 105, 95, 106, 96, 0,
- 94, 0, 98, 90, 0, 0, 0, 125, 117, 124,
- 114, 110, 112, 111, 115, 86, 103, 109, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,
-
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 11, 13, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 104, 108, 140,
- 93, 0, 1, 92, 0, 0, 88, 89, 0, 100,
- 101, 0, 0, 43, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 9, 0, 0, 0, 0, 0, 0, 0, 17,
- 0, 0, 0, 0, 0, 14, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 87, 86, 0, 19, 0, 0,
- 83, 0, 0, 0, 0, 0, 0, 0, 12, 46,
- 0, 0, 0, 0, 0, 51, 65, 0, 0, 0,
- 0, 0, 0, 62, 24, 25, 26, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 49, 20, 0, 0, 0, 0, 0, 0, 27, 28,
- 29, 18, 0, 0, 140, 0, 0, 92, 0, 0,
- 0, 0, 6, 33, 34, 35, 44, 3, 0, 0,
- 0, 0, 76, 77, 78, 0, 21, 66, 16, 73,
-
- 74, 75, 70, 71, 72, 0, 15, 68, 0, 30,
- 31, 32, 0, 0, 0, 0, 0, 0, 0, 63,
- 0, 0, 0, 0, 0, 0, 0, 45, 0, 85,
- 0, 0, 10, 0, 0, 91, 0, 0, 0, 0,
- 64, 59, 54, 0, 0, 0, 69, 50, 57, 23,
- 0, 82, 58, 42, 52, 0, 0, 0, 0, 0,
- 0, 93, 92, 0, 0, 53, 22, 0, 0, 0,
- 0, 0, 0, 47, 4, 0, 5, 0, 0, 7,
- 60, 0, 0, 55, 0, 0, 0, 0, 48, 67,
- 56, 2, 61, 84, 36, 37, 38, 0, 0, 0,
-
- 0, 0, 0, 0, 0, 0, 0, 39, 0, 0,
- 0, 0, 0, 79, 0, 80, 0, 0, 0, 40,
- 0, 41, 0, 0, 0, 81, 0
- } ;
-
-static yyconst int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 5, 1, 1, 1, 6, 7, 1, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
- 19, 20, 21, 21, 21, 22, 22, 23, 24, 25,
- 26, 27, 28, 1, 29, 29, 30, 31, 32, 29,
- 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
- 33, 34, 35, 33, 33, 33, 33, 36, 33, 33,
- 37, 1, 38, 39, 33, 1, 40, 41, 42, 43,
-
- 44, 45, 46, 47, 48, 33, 49, 50, 51, 52,
- 53, 54, 33, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst int yy_meta[68] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- 2, 2, 1, 1, 1, 1, 1, 1, 2, 2,
- 2, 2, 3, 3, 3, 3, 1, 1, 1, 2,
- 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 1, 1, 1, 1
- } ;
-
-static yyconst short int yy_base[432] =
- { 0,
- 0, 0, 67, 0, 678, 679, 679, 679, 651, 109,
- 130, 679, 679, 650, 127, 679, 126, 124, 139, 151,
- 671, 647, 679, 151, 647, 121, 679, 668, 679, 679,
- 124, 147, 154, 155, 158, 171, 174, 157, 156, 184,
- 175, 160, 178, 162, 176, 181, 190, 197, 193, 195,
- 179, 679, 193, 679, 679, 679, 679, 656, 666, 679,
- 679, 679, 679, 679, 679, 679, 679, 679, 679, 665,
- 679, 665, 679, 246, 663, 662, 0, 679, 679, 679,
- 639, 679, 679, 679, 638, 253, 679, 679, 612, 605,
- 608, 616, 615, 602, 617, 604, 610, 598, 595, 608,
-
- 595, 592, 592, 598, 586, 593, 590, 600, 586, 592,
- 597, 679, 136, 596, 587, 581, 586, 588, 578, 592,
- 592, 575, 580, 577, 566, 200, 580, 576, 578, 567,
- 570, 136, 575, 567, 579, 203, 572, 679, 679, 263,
- 275, 616, 679, 282, 614, 311, 318, 325, 613, 679,
- 679, 612, 611, 679, 559, 563, 572, 569, 553, 553,
- 200, 568, 565, 565, 563, 560, 552, 558, 545, 556,
- 559, 679, 556, 544, 551, 553, 546, 535, 534, 547,
- 548, 543, 268, 544, 535, 532, 536, 534, 525, 528,
- 526, 536, 522, 520, 520, 522, 519, 530, 529, 201,
-
- 524, 519, 508, 290, 526, 528, 517, 562, 561, 337,
- 560, 349, 356, 559, 0, 363, 514, 679, 512, 293,
- 679, 504, 502, 510, 499, 516, 505, 297, 679, 679,
- 499, 509, 509, 494, 368, 679, 679, 371, 498, 492,
- 491, 492, 374, 679, 679, 679, 679, 490, 495, 486,
- 499, 494, 486, 490, 482, 485, 489, 494, 493, 484,
- 679, 679, 490, 479, 479, 484, 483, 480, 679, 679,
- 679, 679, 470, 482, 379, 386, 521, 393, 400, 520,
- 422, 482, 679, 679, 679, 679, 679, 679, 470, 471,
- 465, 475, 679, 679, 679, 466, 679, 679, 679, 679,
-
- 679, 679, 679, 679, 679, 473, 679, 679, 471, 679,
- 679, 679, 461, 466, 456, 469, 469, 458, 465, 679,
- 463, 465, 449, 458, 464, 459, 447, 679, 449, 679,
- 448, 451, 679, 429, 448, 679, 440, 439, 439, 452,
- 679, 454, 679, 453, 452, 439, 679, 679, 679, 679,
- 435, 679, 679, 679, 679, 432, 443, 436, 442, 439,
- 434, 679, 679, 426, 438, 679, 679, 431, 438, 437,
- 419, 441, 418, 679, 679, 418, 679, 413, 412, 679,
- 679, 411, 410, 679, 422, 405, 404, 376, 679, 679,
- 679, 679, 679, 679, 397, 242, 397, 389, 382, 384,
-
- 380, 380, 379, 324, 321, 321, 310, 679, 308, 292,
- 282, 266, 268, 285, 265, 679, 246, 258, 229, 679,
- 221, 679, 199, 145, 131, 679, 679, 471, 179, 473,
- 475
- } ;
-
-static yyconst short int yy_def[432] =
- { 0,
- 427, 1, 427, 3, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 428, 427, 427, 427, 427, 429, 427, 427, 427,
- 427, 427, 427, 427, 427, 430, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 431,
- 427, 428, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 429, 430, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 431, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 0, 427, 427, 427,
- 427
- } ;
-
-static yyconst short int yy_nxt[747] =
- { 0,
- 6, 7, 8, 7, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 21, 21, 21,
- 21, 21, 22, 23, 24, 25, 26, 27, 28, 28,
- 28, 28, 28, 28, 28, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 28, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 28, 28, 28, 52, 53, 54, 55, 6, 56, 57,
- 56, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 58, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 59, 59, 59, 59, 59,
-
- 59, 59, 59, 6, 6, 6, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
- 6, 6, 6, 6, 61, 62, 63, 66, 68, 70,
- 70, 70, 70, 70, 70, 70, 84, 85, 71, 87,
- 86, 69, 67, 72, 74, 64, 79, 86, 86, 86,
- 86, 86, 88, 86, 73, 86, 75, 75, 75, 75,
- 75, 75, 76, 80, 86, 81, 82, 86, 86, 86,
- 149, 86, 86, 200, 86, 177, 77, 86, 178, 179,
- 426, 201, 180, 86, 94, 110, 86, 425, 86, 116,
-
- 86, 97, 89, 90, 95, 98, 91, 96, 92, 109,
- 99, 77, 93, 104, 111, 120, 100, 117, 138, 119,
- 101, 105, 102, 106, 122, 137, 107, 115, 112, 123,
- 118, 103, 108, 121, 134, 113, 124, 125, 135, 193,
- 128, 424, 114, 129, 132, 264, 126, 136, 133, 127,
- 205, 130, 206, 265, 194, 223, 224, 139, 131, 144,
- 423, 145, 145, 145, 145, 145, 145, 145, 152, 152,
- 152, 152, 152, 152, 152, 400, 401, 146, 208, 208,
- 208, 208, 208, 208, 208, 245, 246, 247, 422, 146,
- 70, 70, 70, 70, 70, 70, 70, 211, 211, 211,
-
- 211, 211, 211, 211, 421, 420, 210, 269, 270, 271,
- 284, 285, 286, 212, 293, 294, 295, 419, 210, 418,
- 417, 213, 416, 213, 415, 212, 214, 214, 214, 214,
- 214, 214, 214, 75, 75, 75, 75, 75, 75, 76,
- 76, 76, 76, 76, 76, 76, 76, 276, 414, 276,
- 413, 412, 277, 277, 277, 277, 277, 277, 277, 279,
- 411, 279, 410, 409, 280, 280, 280, 280, 280, 280,
- 280, 214, 214, 214, 214, 214, 214, 214, 152, 152,
- 152, 152, 152, 152, 152, 300, 301, 302, 303, 304,
- 305, 310, 311, 312, 208, 208, 208, 208, 208, 208,
-
- 208, 277, 277, 277, 277, 277, 277, 277, 211, 211,
- 211, 211, 211, 211, 211, 280, 280, 280, 280, 280,
- 280, 280, 408, 407, 212, 336, 406, 405, 404, 403,
- 402, 399, 362, 398, 397, 396, 212, 214, 214, 214,
- 214, 214, 214, 214, 277, 277, 277, 277, 277, 277,
- 277, 363, 395, 394, 393, 392, 391, 385, 386, 387,
- 390, 389, 384, 280, 280, 280, 280, 280, 280, 280,
- 388, 142, 142, 142, 153, 153, 209, 209, 383, 382,
- 381, 380, 379, 378, 377, 376, 375, 374, 373, 372,
- 371, 370, 369, 368, 367, 366, 365, 364, 361, 360,
-
- 359, 358, 357, 356, 355, 354, 353, 352, 351, 350,
- 349, 348, 347, 346, 345, 344, 343, 342, 341, 340,
- 339, 338, 337, 335, 334, 333, 332, 331, 330, 329,
- 328, 327, 326, 325, 324, 323, 322, 321, 320, 319,
- 318, 317, 316, 315, 314, 313, 309, 308, 307, 306,
- 299, 298, 297, 296, 292, 291, 290, 289, 288, 287,
- 283, 282, 281, 278, 275, 275, 274, 273, 272, 268,
- 267, 266, 263, 262, 261, 260, 259, 258, 257, 256,
- 255, 254, 253, 252, 251, 250, 249, 248, 244, 243,
- 242, 241, 240, 239, 238, 237, 236, 235, 234, 233,
-
- 232, 231, 230, 229, 228, 227, 226, 225, 222, 221,
- 220, 219, 218, 217, 216, 216, 215, 74, 143, 207,
- 204, 203, 202, 199, 198, 197, 196, 195, 192, 191,
- 190, 189, 188, 187, 186, 185, 184, 183, 182, 181,
- 176, 175, 174, 173, 172, 171, 170, 169, 168, 167,
- 166, 165, 164, 163, 162, 161, 160, 159, 158, 157,
- 156, 155, 154, 151, 150, 148, 147, 143, 141, 140,
- 72, 86, 83, 78, 74, 65, 60, 427, 5, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427
- } ;
-
-static yyconst short int yy_chk[747] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 10, 10, 11, 15, 17, 18,
- 18, 18, 18, 18, 18, 18, 26, 26, 19, 31,
- 32, 17, 15, 19, 20, 11, 24, 33, 34, 39,
- 38, 35, 31, 42, 19, 44, 20, 20, 20, 20,
- 20, 20, 20, 24, 36, 24, 24, 37, 41, 45,
- 429, 43, 51, 132, 46, 113, 20, 40, 113, 113,
- 425, 132, 113, 47, 34, 39, 49, 424, 50, 42,
-
- 48, 35, 32, 32, 34, 35, 33, 34, 33, 38,
- 35, 20, 33, 37, 39, 45, 35, 43, 53, 44,
- 36, 37, 36, 37, 46, 51, 37, 41, 40, 47,
- 43, 36, 37, 45, 50, 40, 47, 47, 50, 126,
- 48, 423, 40, 48, 49, 200, 47, 50, 49, 47,
- 136, 48, 136, 200, 126, 161, 161, 53, 48, 74,
- 421, 74, 74, 74, 74, 74, 74, 74, 86, 86,
- 86, 86, 86, 86, 86, 396, 396, 74, 140, 140,
- 140, 140, 140, 140, 140, 183, 183, 183, 419, 74,
- 141, 141, 141, 141, 141, 141, 141, 144, 144, 144,
-
- 144, 144, 144, 144, 418, 417, 141, 204, 204, 204,
- 220, 220, 220, 144, 228, 228, 228, 415, 141, 414,
- 413, 146, 412, 146, 411, 144, 146, 146, 146, 146,
- 146, 146, 146, 147, 147, 147, 147, 147, 147, 147,
- 148, 148, 148, 148, 148, 148, 148, 210, 410, 210,
- 409, 407, 210, 210, 210, 210, 210, 210, 210, 212,
- 406, 212, 405, 404, 212, 212, 212, 212, 212, 212,
- 212, 213, 213, 213, 213, 213, 213, 213, 216, 216,
- 216, 216, 216, 216, 216, 235, 235, 235, 238, 238,
- 238, 243, 243, 243, 275, 275, 275, 275, 275, 275,
-
- 275, 276, 276, 276, 276, 276, 276, 276, 278, 278,
- 278, 278, 278, 278, 278, 279, 279, 279, 279, 279,
- 279, 279, 403, 402, 278, 281, 401, 400, 399, 398,
- 397, 395, 334, 388, 387, 386, 278, 281, 281, 281,
- 281, 281, 281, 281, 334, 334, 334, 334, 334, 334,
- 334, 335, 385, 383, 382, 379, 378, 372, 372, 372,
- 376, 373, 371, 335, 335, 335, 335, 335, 335, 335,
- 372, 428, 428, 428, 430, 430, 431, 431, 370, 369,
- 368, 365, 364, 361, 360, 359, 358, 357, 356, 351,
- 346, 345, 344, 342, 340, 339, 338, 337, 332, 331,
-
- 329, 327, 326, 325, 324, 323, 322, 321, 319, 318,
- 317, 316, 315, 314, 313, 309, 306, 296, 292, 291,
- 290, 289, 282, 280, 277, 274, 273, 268, 267, 266,
- 265, 264, 263, 260, 259, 258, 257, 256, 255, 254,
- 253, 252, 251, 250, 249, 248, 242, 241, 240, 239,
- 234, 233, 232, 231, 227, 226, 225, 224, 223, 222,
- 219, 217, 214, 211, 209, 208, 207, 206, 205, 203,
- 202, 201, 199, 198, 197, 196, 195, 194, 193, 192,
- 191, 190, 189, 188, 187, 186, 185, 184, 182, 181,
- 180, 179, 178, 177, 176, 175, 174, 173, 171, 170,
-
- 169, 168, 167, 166, 165, 164, 163, 162, 160, 159,
- 158, 157, 156, 155, 153, 152, 149, 145, 142, 137,
- 135, 134, 133, 131, 130, 129, 128, 127, 125, 124,
- 123, 122, 121, 120, 119, 118, 117, 116, 115, 114,
- 111, 110, 109, 108, 107, 106, 105, 104, 103, 102,
- 101, 100, 99, 98, 97, 96, 95, 94, 93, 92,
- 91, 90, 89, 85, 81, 76, 75, 72, 70, 59,
- 58, 28, 25, 22, 21, 14, 9, 5, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
-
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- 427, 427, 427, 427, 427, 427
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "glslang.l"
-#define INITIAL 0
-/*\r
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-*/\r
-/* Based on\r
-ANSI C grammar, Lex specification\r
-\r
-In 1985, Jeff Lee published this Lex specification together with a Yacc \r
-grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted \r
-both to net.sources in 1987; that original, as mentioned in the answer \r
-to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net, \r
-file usenet/net.sources/ansi.c.grammar.Z. \r
-\r
-I intend to keep this version as close to the current C Standard grammar \r
-as possible; please let me know if you discover discrepancies. \r
-\r
-Jutta Degener, 1995 \r
-*/\r
-#define YY_NO_UNPUT 1
-#line 59 "glslang.l"
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include "ParseHelper.h"\r
-#include "glslang_tab.h"\r
-\r
-/* windows only pragma */\r
-#ifdef _MSC_VER\r
-#pragma warning(disable : 4102)\r
-#endif\r
-\r
-int yy_input(char* buf, int max_size);\r
-TSourceLoc yylineno;\r
-\r
-#ifdef _WIN32\r
- extern int yyparse(TParseContext&);\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext) \r
-#else\r
- extern int yyparse(void*);\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)\r
- #define parseContext (*((TParseContext*)(parseContextLocal)))\r
-#endif\r
- \r
-#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))\r
-\r
-#define YY_NEVER_INTERACTIVE 1
-#define FIELDS 1
-\r
-#line 753 "Gen_glslang.cpp"
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = '*', n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 91 "glslang.l"
-
-#line 906 "Gen_glslang.cpp"
-
- if ( yy_init )
- {
- yy_init = 0;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 428 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 679 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 92 "glslang.l"
-{ /* ?? carriage and/or line-feed? */ };\r
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 94 "glslang.l"
-{ pyylval->lex.line = yylineno; return(ATTRIBUTE); }\r
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 95 "glslang.l"
-{ pyylval->lex.line = yylineno; return(CONST_QUAL); }\r
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 96 "glslang.l"
-{ pyylval->lex.line = yylineno; return(UNIFORM); }\r
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 97 "glslang.l"
-{ pyylval->lex.line = yylineno; return(VARYING); }\r
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 99 "glslang.l"
-{ pyylval->lex.line = yylineno; return(BREAK); }\r
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 100 "glslang.l"
-{ pyylval->lex.line = yylineno; return(CONTINUE); }\r
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 101 "glslang.l"
-{ pyylval->lex.line = yylineno; return(DO); }\r
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 102 "glslang.l"
-{ pyylval->lex.line = yylineno; return(FOR); }\r
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 103 "glslang.l"
-{ pyylval->lex.line = yylineno; return(WHILE); }\r
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 105 "glslang.l"
-{ pyylval->lex.line = yylineno; return(IF); }\r
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 106 "glslang.l"
-{ pyylval->lex.line = yylineno; return(ELSE); }\r
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 108 "glslang.l"
-{ pyylval->lex.line = yylineno; return(IN_QUAL); }\r
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 109 "glslang.l"
-{ pyylval->lex.line = yylineno; return(OUT_QUAL); }\r
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 110 "glslang.l"
-{ pyylval->lex.line = yylineno; return(INOUT_QUAL); }\r
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 112 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }\r
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 113 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }\r
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 114 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }\r
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 115 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }\r
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 116 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }\r
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 117 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }\r
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 119 "glslang.l"
-{ pyylval->lex.line = yylineno; return(DISCARD); }\r
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 120 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RETURN); }\r
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 122 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }\r
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 123 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }\r
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 124 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }\r
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 126 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }\r
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 127 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }\r
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 128 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }\r
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 129 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }\r
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 130 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }\r
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 131 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }\r
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 132 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }\r
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 133 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }\r
- YY_BREAK
-case 35:
-YY_RULE_SETUP
-#line 134 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }\r
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 136 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }\r
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 137 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }\r
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 138 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }\r
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 139 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }\r
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-#line 140 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }\r
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-#line 141 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }\r
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-#line 143 "glslang.l"
-{ pyylval->lex.line = yylineno; return(STRUCT); }\r
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-#line 145 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-#line 147 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 45:
-YY_RULE_SETUP
-#line 148 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 46:
-YY_RULE_SETUP
-#line 149 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 47:
-YY_RULE_SETUP
-#line 150 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 48:
-YY_RULE_SETUP
-#line 151 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 49:
-YY_RULE_SETUP
-#line 152 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 50:
-YY_RULE_SETUP
-#line 153 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 51:
-YY_RULE_SETUP
-#line 155 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 52:
-YY_RULE_SETUP
-#line 156 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 53:
-YY_RULE_SETUP
-#line 157 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 54:
-YY_RULE_SETUP
-#line 159 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 55:
-YY_RULE_SETUP
-#line 160 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 56:
-YY_RULE_SETUP
-#line 161 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 57:
-YY_RULE_SETUP
-#line 162 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 58:
-YY_RULE_SETUP
-#line 163 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 59:
-YY_RULE_SETUP
-#line 164 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 60:
-YY_RULE_SETUP
-#line 165 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 61:
-YY_RULE_SETUP
-#line 166 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 62:
-YY_RULE_SETUP
-#line 168 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 63:
-YY_RULE_SETUP
-#line 169 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 64:
-YY_RULE_SETUP
-#line 170 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 65:
-YY_RULE_SETUP
-#line 171 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 66:
-YY_RULE_SETUP
-#line 172 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 67:
-YY_RULE_SETUP
-#line 173 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 68:
-YY_RULE_SETUP
-#line 175 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 69:
-YY_RULE_SETUP
-#line 176 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 70:
-YY_RULE_SETUP
-#line 178 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 71:
-YY_RULE_SETUP
-#line 179 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 72:
-YY_RULE_SETUP
-#line 180 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 73:
-YY_RULE_SETUP
-#line 181 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 74:
-YY_RULE_SETUP
-#line 182 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 75:
-YY_RULE_SETUP
-#line 183 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 76:
-YY_RULE_SETUP
-#line 184 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 77:
-YY_RULE_SETUP
-#line 185 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 78:
-YY_RULE_SETUP
-#line 186 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 79:
-YY_RULE_SETUP
-#line 188 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 80:
-YY_RULE_SETUP
-#line 189 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 81:
-YY_RULE_SETUP
-#line 190 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 82:
-YY_RULE_SETUP
-#line 192 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 83:
-YY_RULE_SETUP
-#line 193 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 84:
-YY_RULE_SETUP
-#line 195 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 85:
-YY_RULE_SETUP
-#line 196 "glslang.l"
-{ PaReservedWord(); return 0; }\r
- YY_BREAK
-case 86:
-YY_RULE_SETUP
-#line 198 "glslang.l"
-{ \r
- pyylval->lex.line = yylineno; \r
- pyylval->lex.string = NewPoolTString(yytext); \r
- return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); \r
-}\r
- YY_BREAK
-case 87:
-YY_RULE_SETUP
-#line 204 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
- YY_BREAK
-case 88:
-YY_RULE_SETUP
-#line 205 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
- YY_BREAK
-case 89:
-YY_RULE_SETUP
-#line 206 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}\r
- YY_BREAK
-case 90:
-YY_RULE_SETUP
-#line 207 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
- YY_BREAK
-case 91:
-YY_RULE_SETUP
-#line 209 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
- YY_BREAK
-case 92:
-YY_RULE_SETUP
-#line 210 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
- YY_BREAK
-case 93:
-YY_RULE_SETUP
-#line 211 "glslang.l"
-{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
- YY_BREAK
-case 94:
-YY_RULE_SETUP
-#line 213 "glslang.l"
-{ int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; } \r
- YY_BREAK
-case 95:
-YY_RULE_SETUP
-#line 215 "glslang.l"
-{ pyylval->lex.line = yylineno; return(ADD_ASSIGN); }\r
- YY_BREAK
-case 96:
-YY_RULE_SETUP
-#line 216 "glslang.l"
-{ pyylval->lex.line = yylineno; return(SUB_ASSIGN); }\r
- YY_BREAK
-case 97:
-YY_RULE_SETUP
-#line 217 "glslang.l"
-{ pyylval->lex.line = yylineno; return(MUL_ASSIGN); }\r
- YY_BREAK
-case 98:
-YY_RULE_SETUP
-#line 218 "glslang.l"
-{ pyylval->lex.line = yylineno; return(DIV_ASSIGN); }\r
- YY_BREAK
-case 99:
-YY_RULE_SETUP
-#line 219 "glslang.l"
-{ pyylval->lex.line = yylineno; return(MOD_ASSIGN); }\r
- YY_BREAK
-case 100:
-YY_RULE_SETUP
-#line 220 "glslang.l"
-{ pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }\r
- YY_BREAK
-case 101:
-YY_RULE_SETUP
-#line 221 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }\r
- YY_BREAK
-case 102:
-YY_RULE_SETUP
-#line 222 "glslang.l"
-{ pyylval->lex.line = yylineno; return(AND_ASSIGN); }\r
- YY_BREAK
-case 103:
-YY_RULE_SETUP
-#line 223 "glslang.l"
-{ pyylval->lex.line = yylineno; return(XOR_ASSIGN); }\r
- YY_BREAK
-case 104:
-YY_RULE_SETUP
-#line 224 "glslang.l"
-{ pyylval->lex.line = yylineno; return(OR_ASSIGN); }\r
- YY_BREAK
-case 105:
-YY_RULE_SETUP
-#line 226 "glslang.l"
-{ pyylval->lex.line = yylineno; return(INC_OP); }\r
- YY_BREAK
-case 106:
-YY_RULE_SETUP
-#line 227 "glslang.l"
-{ pyylval->lex.line = yylineno; return(DEC_OP); }\r
- YY_BREAK
-case 107:
-YY_RULE_SETUP
-#line 228 "glslang.l"
-{ pyylval->lex.line = yylineno; return(AND_OP); }\r
- YY_BREAK
-case 108:
-YY_RULE_SETUP
-#line 229 "glslang.l"
-{ pyylval->lex.line = yylineno; return(OR_OP); }\r
- YY_BREAK
-case 109:
-YY_RULE_SETUP
-#line 230 "glslang.l"
-{ pyylval->lex.line = yylineno; return(XOR_OP); }\r
- YY_BREAK
-case 110:
-YY_RULE_SETUP
-#line 231 "glslang.l"
-{ pyylval->lex.line = yylineno; return(LE_OP); }\r
- YY_BREAK
-case 111:
-YY_RULE_SETUP
-#line 232 "glslang.l"
-{ pyylval->lex.line = yylineno; return(GE_OP); }\r
- YY_BREAK
-case 112:
-YY_RULE_SETUP
-#line 233 "glslang.l"
-{ pyylval->lex.line = yylineno; return(EQ_OP); }\r
- YY_BREAK
-case 113:
-YY_RULE_SETUP
-#line 234 "glslang.l"
-{ pyylval->lex.line = yylineno; return(NE_OP); }\r
- YY_BREAK
-case 114:
-YY_RULE_SETUP
-#line 235 "glslang.l"
-{ pyylval->lex.line = yylineno; return(LEFT_OP); }\r
- YY_BREAK
-case 115:
-YY_RULE_SETUP
-#line 236 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RIGHT_OP); }\r
- YY_BREAK
-case 116:
-YY_RULE_SETUP
-#line 237 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }\r
- YY_BREAK
-case 117:
-YY_RULE_SETUP
-#line 238 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }\r
- YY_BREAK
-case 118:
-YY_RULE_SETUP
-#line 239 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RIGHT_BRACE); }\r
- YY_BREAK
-case 119:
-YY_RULE_SETUP
-#line 240 "glslang.l"
-{ pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }\r
- YY_BREAK
-case 120:
-YY_RULE_SETUP
-#line 241 "glslang.l"
-{ pyylval->lex.line = yylineno; return(COLON); }\r
- YY_BREAK
-case 121:
-YY_RULE_SETUP
-#line 242 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }\r
- YY_BREAK
-case 122:
-YY_RULE_SETUP
-#line 243 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }\r
- YY_BREAK
-case 123:
-YY_RULE_SETUP
-#line 244 "glslang.l"
-{ pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }\r
- YY_BREAK
-case 124:
-YY_RULE_SETUP
-#line 245 "glslang.l"
-{ pyylval->lex.line = yylineno; return(LEFT_BRACKET); }\r
- YY_BREAK
-case 125:
-YY_RULE_SETUP
-#line 246 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }\r
- YY_BREAK
-case 126:
-YY_RULE_SETUP
-#line 247 "glslang.l"
-{ BEGIN(FIELDS); return(DOT); }\r
- YY_BREAK
-case 127:
-YY_RULE_SETUP
-#line 248 "glslang.l"
-{ pyylval->lex.line = yylineno; return(BANG); }\r
- YY_BREAK
-case 128:
-YY_RULE_SETUP
-#line 249 "glslang.l"
-{ pyylval->lex.line = yylineno; return(DASH); }\r
- YY_BREAK
-case 129:
-YY_RULE_SETUP
-#line 250 "glslang.l"
-{ pyylval->lex.line = yylineno; return(TILDE); }\r
- YY_BREAK
-case 130:
-YY_RULE_SETUP
-#line 251 "glslang.l"
-{ pyylval->lex.line = yylineno; return(PLUS); }\r
- YY_BREAK
-case 131:
-YY_RULE_SETUP
-#line 252 "glslang.l"
-{ pyylval->lex.line = yylineno; return(STAR); }\r
- YY_BREAK
-case 132:
-YY_RULE_SETUP
-#line 253 "glslang.l"
-{ pyylval->lex.line = yylineno; return(SLASH); }\r
- YY_BREAK
-case 133:
-YY_RULE_SETUP
-#line 254 "glslang.l"
-{ pyylval->lex.line = yylineno; return(PERCENT); }\r
- YY_BREAK
-case 134:
-YY_RULE_SETUP
-#line 255 "glslang.l"
-{ pyylval->lex.line = yylineno; return(LEFT_ANGLE); }\r
- YY_BREAK
-case 135:
-YY_RULE_SETUP
-#line 256 "glslang.l"
-{ pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }\r
- YY_BREAK
-case 136:
-YY_RULE_SETUP
-#line 257 "glslang.l"
-{ pyylval->lex.line = yylineno; return(VERTICAL_BAR); }\r
- YY_BREAK
-case 137:
-YY_RULE_SETUP
-#line 258 "glslang.l"
-{ pyylval->lex.line = yylineno; return(CARET); }\r
- YY_BREAK
-case 138:
-YY_RULE_SETUP
-#line 259 "glslang.l"
-{ pyylval->lex.line = yylineno; return(AMPERSAND); }\r
- YY_BREAK
-case 139:
-YY_RULE_SETUP
-#line 260 "glslang.l"
-{ pyylval->lex.line = yylineno; return(QUESTION); }\r
- YY_BREAK
-case 140:
-YY_RULE_SETUP
-#line 262 "glslang.l"
-{ \r
-BEGIN(INITIAL); \r
- pyylval->lex.line = yylineno; \r
- pyylval->lex.string = NewPoolTString(yytext); \r
- return FIELD_SELECTION; }\r
- YY_BREAK
-case 141:
-YY_RULE_SETUP
-#line 267 "glslang.l"
-{}\r
- YY_BREAK
-case 142:
-YY_RULE_SETUP
-#line 269 "glslang.l"
-{ }\r
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(FIELDS):
-#line 270 "glslang.l"
-{ (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}\r
- YY_BREAK
-case 143:
-YY_RULE_SETUP
-#line 271 "glslang.l"
-{ parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";\r
- return 0; }\r
- YY_BREAK
-case 144:
-YY_RULE_SETUP
-#line 274 "glslang.l"
-ECHO;
- YY_BREAK
-#line 1723 "Gen_glslang.cpp"
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
-
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 428 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 428 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 427);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
- register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
-
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
- }
-#endif /* ifndef YY_NO_UNPUT */
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /* fall through */
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- return EOF;
-
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
-
- return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( ! b )
- return;
-
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
-
- yy_flex_free( (void *) b );
- }
-
-
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
- {
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
- }
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
-
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 274 "glslang.l"
-
-\r
-\r
-//Including Pre-processor.\r
-extern "C" {\r
- #include "./preprocessor/preprocess.h"\r
-} \r
-\r
-//\r
-// The YY_INPUT macro just calls this. Maybe this could be just put into\r
-// the macro directly.\r
-//\r
-\r
-int yy_input(char* buf, int max_size)\r
-{\r
- char *char_token =NULL;\r
- int len;\r
-\r
- if ((len = yylex_CPP(buf, max_size)) == 0)\r
- return 0;\r
- if (len >= max_size) \r
- YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );\r
-\r
- buf[len] = ' ';\r
- return len+1;\r
-}\r
-\r
-\r
-//\r
-// Parse an array of strings using yyparse. We set up globals used by\r
-// yywrap.\r
-//\r
-// Returns 0 for success, as per yyparse().\r
-//\r
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)\r
-{\r
- int argv0len;\r
- ScanFromString(argv[0]); \r
- \r
- //Storing the Current Compiler Parse context into the cpp structure.\r
- cpp->pC = (void*)&parseContextLocal;\r
- \r
- if (!argv || argc == 0 || !argv[0])\r
- return 1;\r
- \r
- if (!strLen) {\r
- argv0len = (int) strlen(argv[0]);\r
- strLen = &argv0len;\r
- }\r
- yyrestart(0);\r
- (&parseContextLocal)->AfterEOF = false;\r
- cpp->PaWhichStr = 0;\r
- cpp->PaArgv = argv;\r
- cpp->PaArgc = argc;\r
- cpp->PaStrLen = strLen;\r
- yylineno = 1;\r
- \r
- if (*cpp->PaStrLen >= 0) { \r
- int ret;\r
- #ifdef _WIN32\r
- ret = yyparse(parseContextLocal);\r
- #else\r
- ret = yyparse((void*)(&parseContextLocal));\r
- #endif\r
- if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)\r
- return 1;\r
- else\r
- return 0;\r
- }\r
- else\r
- return 0;\r
-}\r
-\r
-void yyerror(char *s) \r
-{\r
- if (((TParseContext *)cpp->pC)->AfterEOF) {\r
- if (cpp->tokensBeforeEOF == 1) {\r
- GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");\r
- GlobalParseContext->recover();\r
- }\r
- } else {\r
- GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");\r
- GlobalParseContext->recover();\r
- } \r
-}\r
-\r
-void PaReservedWord()\r
-{\r
- GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)\r
-{\r
- symbol = parseContextLocal.symbolTable.find(id);\r
- if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {\r
- TVariable* variable = static_cast<TVariable*>(symbol);\r
- if (variable->isUserType()) {\r
- parseContextLocal.lexAfterType = true;\r
- return TYPE_NAME;\r
- }\r
- }\r
- \r
- return IDENTIFIER;\r
-}\r
-\r
-int PaParseComment(int &lineno, TParseContext& parseContextLocal)\r
-{\r
- int transitionFlag = 0;\r
- int nextChar;\r
- \r
- while (transitionFlag != 2) {\r
- nextChar = yyinput();\r
- if (nextChar == '\n')\r
- lineno++;\r
- switch (nextChar) {\r
- case '*' :\r
- transitionFlag = 1;\r
- break;\r
- case '/' : /* if star is the previous character, then it is the end of comment */\r
- if (transitionFlag == 1) {\r
- return 1 ;\r
- }\r
- break;\r
- case EOF :\r
- /* Raise error message here */\r
- parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");\r
- GlobalParseContext->recover();\r
- return YY_NULL; \r
- default : /* Any other character will be a part of the comment */\r
- transitionFlag = 0;\r
- }\r
- }\r
- return 1;\r
-}\r
-\r
-extern "C" {\r
-\r
-void CPPDebugLogMsg(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);\r
-}\r
-\r
-void CPPWarningToInfoLog(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); \r
-}\r
-\r
-void CPPShInfoLogMsg(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-void CPPErrorToInfoLog(char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-void SetLineNumber(int line)\r
-{\r
- yylineno &= ~SourceLocLineMask;\r
- yylineno |= line;\r
-}\r
-\r
-void SetStringNumber(int string)\r
-{\r
- yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);\r
-}\r
-\r
-int GetStringNumber(void)\r
-{\r
- return yylineno >> 16;\r
-}\r
-\r
-int GetLineNumber(void)\r
-{\r
- return yylineno & SourceLocLineMask;\r
-}\r
-\r
-void IncLineNumber(void)\r
-{\r
- if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)\r
- ++yylineno;\r
-}\r
-\r
-void DecLineNumber(void)\r
-{\r
- if ((yylineno & SourceLocLineMask) > 0)\r
- --yylineno;\r
-}\r
-\r
-void HandlePragma(const char **tokens, int numTokens)\r
-{\r
- if (!strcmp(tokens[0], "optimize")) {\r
- if (numTokens != 4) {\r
- CPPShInfoLogMsg("optimize pragma syntax is incorrect");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");\r
- return;\r
- }\r
- \r
- if (!strcmp(tokens[2], "on"))\r
- ((TParseContext *)cpp->pC)->contextPragma.optimize = true;\r
- else if (!strcmp(tokens[2], "off"))\r
- ((TParseContext *)cpp->pC)->contextPragma.optimize = false;\r
- else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");\r
- return;\r
- }\r
- } else if (!strcmp(tokens[0], "debug")) {\r
- if (numTokens != 4) {\r
- CPPShInfoLogMsg("debug pragma syntax is incorrect");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");\r
- return;\r
- }\r
- \r
- if (!strcmp(tokens[2], "on"))\r
- ((TParseContext *)cpp->pC)->contextPragma.debug = true;\r
- else if (!strcmp(tokens[2], "off"))\r
- ((TParseContext *)cpp->pC)->contextPragma.debug = false;\r
- else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");\r
- return;\r
- }\r
- } else {\r
- /*\r
- // implementation specific pragma\r
- // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma\r
- // For now, just ignore the pragma that the implementation cannot recognize\r
- // An Example of one such implementation for a pragma that has a syntax like\r
- // #pragma pragmaname(pragmavalue)\r
- // This implementation stores the current pragmavalue against the pragma name in pragmaTable.\r
- if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { \r
- TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;\r
- TPragmaTable::iterator iter;\r
- iter = pragmaTable.find(TString(tokens[0]));\r
- if (iter != pragmaTable.end()) {\r
- iter->second = tokens[2];\r
- } else {\r
- pragmaTable[tokens[0]] = tokens[2];\r
- } \r
- }\r
- */\r
- }\r
-}\r
-\r
-void StoreStr(char *string)\r
-{\r
- TString strSrc;\r
- strSrc = TString(string);\r
-\r
- ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;\r
-}\r
-\r
-const char* GetStrfromTStr(void)\r
-{\r
- cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();\r
- return cpp->ErrMsg;\r
-}\r
-\r
-void ResetTString(void)\r
-{\r
- ((TParseContext *)cpp->pC)->HashErrMsg = "";\r
-}\r
-\r
-TBehavior GetBehavior(const char* behavior)\r
-{\r
- if (!strcmp("require", behavior))\r
- return EBhRequire;\r
- else if (!strcmp("enable", behavior))\r
- return EBhEnable;\r
- else if (!strcmp("disable", behavior))\r
- return EBhDisable;\r
- else if (!strcmp("warn", behavior))\r
- return EBhWarn;\r
- else {\r
- CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());\r
- return EBhDisable;\r
- } \r
-}\r
-\r
-void updateExtensionBehavior(const char* extName, const char* behavior)\r
-{\r
- TBehavior behaviorVal = GetBehavior(behavior);\r
- TMap<TString, TBehavior>:: iterator iter;\r
- TString msg;\r
- \r
- // special cased for all extension\r
- if (!strcmp(extName, "all")) {\r
- if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {\r
- CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); \r
- return;\r
- } else {\r
- for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)\r
- iter->second = behaviorVal;\r
- } \r
- } else {\r
- iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));\r
- if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {\r
- switch (behaviorVal) {\r
- case EBhRequire:\r
- CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); \r
- break;\r
- case EBhEnable:\r
- case EBhWarn:\r
- case EBhDisable:\r
- msg = TString("extension '") + extName + "' is not supported";\r
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); \r
- break;\r
- }\r
- return;\r
- } else\r
- iter->second = behaviorVal;\r
- }\r
-}\r
- \r
-}\r
-\r
-void setInitialState()\r
-{\r
- yy_start = 1;\r
-}\r
+++ /dev/null
-/* A Bison parser, made by GNU Bison 1.875. */
-
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* Written by Richard Stallman by simplifying the original so called
- ``semantic'' parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 1
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- ATTRIBUTE = 258,
- CONST_QUAL = 259,
- BOOL_TYPE = 260,
- FLOAT_TYPE = 261,
- INT_TYPE = 262,
- BREAK = 263,
- CONTINUE = 264,
- DO = 265,
- ELSE = 266,
- FOR = 267,
- IF = 268,
- DISCARD = 269,
- RETURN = 270,
- BVEC2 = 271,
- BVEC3 = 272,
- BVEC4 = 273,
- IVEC2 = 274,
- IVEC3 = 275,
- IVEC4 = 276,
- VEC2 = 277,
- VEC3 = 278,
- VEC4 = 279,
- MATRIX2 = 280,
- MATRIX3 = 281,
- MATRIX4 = 282,
- IN_QUAL = 283,
- OUT_QUAL = 284,
- INOUT_QUAL = 285,
- UNIFORM = 286,
- VARYING = 287,
- STRUCT = 288,
- VOID_TYPE = 289,
- WHILE = 290,
- SAMPLER1D = 291,
- SAMPLER2D = 292,
- SAMPLER3D = 293,
- SAMPLERCUBE = 294,
- SAMPLER1DSHADOW = 295,
- SAMPLER2DSHADOW = 296,
- IDENTIFIER = 297,
- TYPE_NAME = 298,
- FLOATCONSTANT = 299,
- INTCONSTANT = 300,
- BOOLCONSTANT = 301,
- FIELD_SELECTION = 302,
- LEFT_OP = 303,
- RIGHT_OP = 304,
- INC_OP = 305,
- DEC_OP = 306,
- LE_OP = 307,
- GE_OP = 308,
- EQ_OP = 309,
- NE_OP = 310,
- AND_OP = 311,
- OR_OP = 312,
- XOR_OP = 313,
- MUL_ASSIGN = 314,
- DIV_ASSIGN = 315,
- ADD_ASSIGN = 316,
- MOD_ASSIGN = 317,
- LEFT_ASSIGN = 318,
- RIGHT_ASSIGN = 319,
- AND_ASSIGN = 320,
- XOR_ASSIGN = 321,
- OR_ASSIGN = 322,
- SUB_ASSIGN = 323,
- LEFT_PAREN = 324,
- RIGHT_PAREN = 325,
- LEFT_BRACKET = 326,
- RIGHT_BRACKET = 327,
- LEFT_BRACE = 328,
- RIGHT_BRACE = 329,
- DOT = 330,
- COMMA = 331,
- COLON = 332,
- EQUAL = 333,
- SEMICOLON = 334,
- BANG = 335,
- DASH = 336,
- TILDE = 337,
- PLUS = 338,
- STAR = 339,
- SLASH = 340,
- PERCENT = 341,
- LEFT_ANGLE = 342,
- RIGHT_ANGLE = 343,
- VERTICAL_BAR = 344,
- CARET = 345,
- AMPERSAND = 346,
- QUESTION = 347
- };
-#endif
-#define ATTRIBUTE 258
-#define CONST_QUAL 259
-#define BOOL_TYPE 260
-#define FLOAT_TYPE 261
-#define INT_TYPE 262
-#define BREAK 263
-#define CONTINUE 264
-#define DO 265
-#define ELSE 266
-#define FOR 267
-#define IF 268
-#define DISCARD 269
-#define RETURN 270
-#define BVEC2 271
-#define BVEC3 272
-#define BVEC4 273
-#define IVEC2 274
-#define IVEC3 275
-#define IVEC4 276
-#define VEC2 277
-#define VEC3 278
-#define VEC4 279
-#define MATRIX2 280
-#define MATRIX3 281
-#define MATRIX4 282
-#define IN_QUAL 283
-#define OUT_QUAL 284
-#define INOUT_QUAL 285
-#define UNIFORM 286
-#define VARYING 287
-#define STRUCT 288
-#define VOID_TYPE 289
-#define WHILE 290
-#define SAMPLER1D 291
-#define SAMPLER2D 292
-#define SAMPLER3D 293
-#define SAMPLERCUBE 294
-#define SAMPLER1DSHADOW 295
-#define SAMPLER2DSHADOW 296
-#define IDENTIFIER 297
-#define TYPE_NAME 298
-#define FLOATCONSTANT 299
-#define INTCONSTANT 300
-#define BOOLCONSTANT 301
-#define FIELD_SELECTION 302
-#define LEFT_OP 303
-#define RIGHT_OP 304
-#define INC_OP 305
-#define DEC_OP 306
-#define LE_OP 307
-#define GE_OP 308
-#define EQ_OP 309
-#define NE_OP 310
-#define AND_OP 311
-#define OR_OP 312
-#define XOR_OP 313
-#define MUL_ASSIGN 314
-#define DIV_ASSIGN 315
-#define ADD_ASSIGN 316
-#define MOD_ASSIGN 317
-#define LEFT_ASSIGN 318
-#define RIGHT_ASSIGN 319
-#define AND_ASSIGN 320
-#define XOR_ASSIGN 321
-#define OR_ASSIGN 322
-#define SUB_ASSIGN 323
-#define LEFT_PAREN 324
-#define RIGHT_PAREN 325
-#define LEFT_BRACKET 326
-#define RIGHT_BRACKET 327
-#define LEFT_BRACE 328
-#define RIGHT_BRACE 329
-#define DOT 330
-#define COMMA 331
-#define COLON 332
-#define EQUAL 333
-#define SEMICOLON 334
-#define BANG 335
-#define DASH 336
-#define TILDE 337
-#define PLUS 338
-#define STAR 339
-#define SLASH 340
-#define PERCENT 341
-#define LEFT_ANGLE 342
-#define RIGHT_ANGLE 343
-#define VERTICAL_BAR 344
-#define CARET 345
-#define AMPERSAND 346
-#define QUESTION 347
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 39 "glslang.y"
-
-
-/* Based on:
-ANSI C Yacc grammar
-
-In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
-matching Lex specification) for the April 30, 1985 draft version of the
-ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that
-original, as mentioned in the answer to question 17.25 of the comp.lang.c
-FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
-
-I intend to keep this version as close to the current C Standard grammar as
-possible; please let me know if you discover discrepancies.
-
-Jutta Degener, 1995
-*/
-
-#include "SymbolTable.h"
-#include "ParseHelper.h"
-#include "../Public/ShaderLang.h"
-
-#ifdef _WIN32
- #define YYPARSE_PARAM parseContext
- #define YYPARSE_PARAM_DECL TParseContext&
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
- #define YYLEX_PARAM parseContext
-#else
- #define YYPARSE_PARAM parseContextLocal
- #define parseContext (*((TParseContext*)(parseContextLocal)))
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
- #define YYLEX_PARAM (void*)(parseContextLocal)
- extern void yyerror(char*);
-#endif
-
-#define FRAG_VERT_ONLY(S, L) { \
- if (parseContext.language != EShLangFragment && \
- parseContext.language != EShLangVertex) { \
- parseContext.error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-#define VERTEX_ONLY(S, L) { \
- if (parseContext.language != EShLangVertex) { \
- parseContext.error(L, " supported in vertex shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-#define FRAG_ONLY(S, L) { \
- if (parseContext.language != EShLangFragment) { \
- parseContext.error(L, " supported in fragment shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-#define PACK_ONLY(S, L) { \
- if (parseContext.language != EShLangPack) { \
- parseContext.error(L, " supported in pack shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-#define UNPACK_ONLY(S, L) { \
- if (parseContext.language != EShLangUnpack) { \
- parseContext.error(L, " supported in unpack shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-#define PACK_UNPACK_ONLY(S, L) { \
- if (parseContext.language != EShLangUnpack && \
- parseContext.language != EShLangPack) { \
- parseContext.error(L, " supported in pack/unpack shaders only ", S, "", ""); \
- parseContext.recover(); \
- } \
-}
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 1
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 117 "glslang.y"
-typedef union YYSTYPE {
- struct {
- TSourceLoc line;
- union {
- TString *string;
- float f;
- int i;
- bool b;
- };
- TSymbol* symbol;
- } lex;
- struct {
- TSourceLoc line;
- TOperator op;
- union {
- TIntermNode* intermNode;
- TIntermNodePair nodePair;
- TIntermTyped* intermTypedNode;
- TIntermAggregate* intermAggregate;
- };
- union {
- TPublicType type;
- TQualifier qualifier;
- TFunction* function;
- TParameter param;
- TTypeLine typeLine;
- TTypeList* typeList;
- };
- } interm;
-} YYSTYPE;
-/* Line 191 of yacc.c. */
-#line 369 "glslang.tab.c"
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-#line 148 "glslang.y"
-
-#ifndef _WIN32
- extern int yylex(YYSTYPE*, void*);
-#endif
-
-
-/* Line 214 of yacc.c. */
-#line 386 "glslang.tab.c"
-
-#if ! defined (yyoverflow) || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
-# else
-# ifndef YYSTACK_USE_ALLOCA
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# else
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-# define YYSTACK_ALLOC malloc
-# define YYSTACK_FREE free
-# endif
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
-
-
-#if (! defined (yyoverflow) \
- && (! defined (__cplusplus) \
- || (YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- short yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- register YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined (__STDC__) || defined (__cplusplus)
- typedef signed char yysigned_char;
-#else
- typedef short yysigned_char;
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 59
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 1231
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 93
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 75
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 214
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 331
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 347
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const unsigned char yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const unsigned short yyprhs[] =
-{
- 0, 0, 3, 5, 7, 9, 11, 13, 17, 19,
- 24, 26, 30, 33, 36, 38, 40, 43, 46, 49,
- 51, 54, 58, 61, 63, 65, 67, 69, 71, 73,
- 75, 77, 79, 81, 83, 85, 87, 89, 91, 93,
- 95, 97, 99, 102, 105, 108, 110, 112, 114, 116,
- 118, 122, 126, 130, 132, 136, 140, 142, 146, 150,
- 152, 156, 160, 164, 168, 170, 174, 178, 180, 184,
- 186, 190, 192, 196, 198, 202, 204, 208, 210, 214,
- 216, 222, 224, 228, 230, 232, 234, 236, 238, 240,
- 242, 244, 246, 248, 250, 252, 256, 258, 261, 264,
- 267, 269, 271, 274, 278, 282, 285, 291, 295, 298,
- 302, 305, 306, 308, 310, 312, 314, 319, 321, 325,
- 331, 338, 344, 346, 349, 354, 360, 365, 367, 370,
- 372, 374, 376, 378, 380, 382, 384, 386, 388, 390,
- 392, 394, 396, 398, 400, 402, 404, 406, 408, 410,
- 412, 414, 416, 418, 420, 422, 424, 426, 432, 437,
- 439, 442, 446, 448, 452, 454, 459, 461, 463, 465,
- 467, 469, 471, 473, 475, 477, 480, 481, 482, 488,
- 490, 492, 495, 499, 501, 504, 506, 509, 515, 519,
- 521, 523, 528, 529, 536, 537, 546, 547, 555, 557,
- 559, 561, 562, 565, 569, 572, 575, 578, 582, 585,
- 587, 590, 592, 594, 595
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const short yyrhs[] =
-{
- 164, 0, -1, 42, -1, 94, -1, 45, -1, 44,
- -1, 46, -1, 69, 121, 70, -1, 95, -1, 96,
- 71, 97, 72, -1, 98, -1, 96, 75, 47, -1,
- 96, 50, -1, 96, 51, -1, 121, -1, 99, -1,
- 101, 70, -1, 100, 70, -1, 102, 34, -1, 102,
- -1, 102, 119, -1, 101, 76, 119, -1, 103, 69,
- -1, 104, -1, 42, -1, 6, -1, 7, -1, 5,
- -1, 22, -1, 23, -1, 24, -1, 16, -1, 17,
- -1, 18, -1, 19, -1, 20, -1, 21, -1, 25,
- -1, 26, -1, 27, -1, 43, -1, 96, -1, 50,
- 105, -1, 51, 105, -1, 106, 105, -1, 83, -1,
- 81, -1, 80, -1, 82, -1, 105, -1, 107, 84,
- 105, -1, 107, 85, 105, -1, 107, 86, 105, -1,
- 107, -1, 108, 83, 107, -1, 108, 81, 107, -1,
- 108, -1, 109, 48, 108, -1, 109, 49, 108, -1,
- 109, -1, 110, 87, 109, -1, 110, 88, 109, -1,
- 110, 52, 109, -1, 110, 53, 109, -1, 110, -1,
- 111, 54, 110, -1, 111, 55, 110, -1, 111, -1,
- 112, 91, 111, -1, 112, -1, 113, 90, 112, -1,
- 113, -1, 114, 89, 113, -1, 114, -1, 115, 56,
- 114, -1, 115, -1, 116, 58, 115, -1, 116, -1,
- 117, 57, 116, -1, 117, -1, 117, 92, 121, 77,
- 119, -1, 118, -1, 105, 120, 119, -1, 78, -1,
- 59, -1, 60, -1, 62, -1, 61, -1, 68, -1,
- 63, -1, 64, -1, 65, -1, 66, -1, 67, -1,
- 119, -1, 121, 76, 119, -1, 118, -1, 124, 79,
- -1, 132, 79, -1, 125, 70, -1, 127, -1, 126,
- -1, 127, 129, -1, 126, 76, 129, -1, 134, 42,
- 69, -1, 136, 42, -1, 136, 42, 71, 122, 72,
- -1, 135, 130, 128, -1, 130, 128, -1, 135, 130,
- 131, -1, 130, 131, -1, -1, 28, -1, 29, -1,
- 30, -1, 136, -1, 136, 71, 122, 72, -1, 133,
- -1, 132, 76, 42, -1, 132, 76, 42, 71, 72,
- -1, 132, 76, 42, 71, 122, 72, -1, 132, 76,
- 42, 78, 142, -1, 134, -1, 134, 42, -1, 134,
- 42, 71, 72, -1, 134, 42, 71, 122, 72, -1,
- 134, 42, 78, 142, -1, 136, -1, 135, 136, -1,
- 4, -1, 3, -1, 32, -1, 31, -1, 34, -1,
- 6, -1, 7, -1, 5, -1, 22, -1, 23, -1,
- 24, -1, 16, -1, 17, -1, 18, -1, 19, -1,
- 20, -1, 21, -1, 25, -1, 26, -1, 27, -1,
- 36, -1, 37, -1, 38, -1, 39, -1, 40, -1,
- 41, -1, 137, -1, 43, -1, 33, 42, 73, 138,
- 74, -1, 33, 73, 138, 74, -1, 139, -1, 138,
- 139, -1, 136, 140, 79, -1, 141, -1, 140, 76,
- 141, -1, 42, -1, 42, 71, 122, 72, -1, 119,
- -1, 123, -1, 146, -1, 145, -1, 143, -1, 152,
- -1, 153, -1, 156, -1, 163, -1, 73, 74, -1,
- -1, -1, 73, 147, 151, 148, 74, -1, 150, -1,
- 145, -1, 73, 74, -1, 73, 151, 74, -1, 144,
- -1, 151, 144, -1, 79, -1, 121, 79, -1, 13,
- 69, 121, 70, 154, -1, 144, 11, 144, -1, 144,
- -1, 121, -1, 134, 42, 78, 142, -1, -1, 35,
- 69, 157, 155, 70, 149, -1, -1, 10, 158, 144,
- 35, 69, 121, 70, 79, -1, -1, 12, 69, 159,
- 160, 162, 70, 149, -1, 152, -1, 143, -1, 155,
- -1, -1, 161, 79, -1, 161, 79, 121, -1, 9,
- 79, -1, 8, 79, -1, 15, 79, -1, 15, 121,
- 79, -1, 14, 79, -1, 165, -1, 164, 165, -1,
- 166, -1, 123, -1, -1, 124, 167, 150, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const unsigned short yyrline[] =
-{
- 0, 210, 210, 245, 248, 261, 266, 271, 277, 280,
- 348, 351, 460, 470, 483, 491, 586, 590, 597, 601,
- 608, 614, 623, 629, 640, 656, 657, 658, 659, 660,
- 661, 662, 663, 664, 665, 666, 667, 668, 669, 670,
- 671, 682, 685, 695, 705, 727, 728, 729, 730, 736,
- 737, 746, 755, 767, 768, 776, 787, 788, 797, 809,
- 810, 820, 830, 840, 853, 854, 864, 877, 878, 890,
- 891, 903, 904, 916, 917, 930, 931, 944, 945, 958,
- 959, 976, 977, 990, 991, 992, 993, 994, 995, 996,
- 997, 998, 999, 1000, 1004, 1007, 1018, 1026, 1027, 1035,
- 1071, 1074, 1081, 1089, 1110, 1129, 1140, 1167, 1172, 1182,
- 1187, 1197, 1200, 1203, 1206, 1212, 1217, 1235, 1238, 1246,
- 1254, 1262, 1284, 1288, 1297, 1306, 1315, 1405, 1408, 1425,
- 1429, 1436, 1444, 1453, 1458, 1463, 1468, 1479, 1484, 1489,
- 1494, 1499, 1504, 1509, 1514, 1519, 1524, 1530, 1536, 1542,
- 1548, 1554, 1560, 1566, 1572, 1578, 1583, 1596, 1606, 1614,
- 1617, 1632, 1650, 1654, 1660, 1665, 1681, 1685, 1689, 1690,
- 1696, 1697, 1698, 1699, 1700, 1704, 1705, 1705, 1705, 1713,
- 1714, 1719, 1722, 1730, 1733, 1739, 1740, 1744, 1752, 1756,
- 1766, 1771, 1788, 1788, 1793, 1793, 1800, 1800, 1813, 1816,
- 1822, 1825, 1831, 1835, 1842, 1849, 1856, 1863, 1874, 1883,
- 1887, 1894, 1897, 1903, 1903
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "ATTRIBUTE", "CONST_QUAL", "BOOL_TYPE",
- "FLOAT_TYPE", "INT_TYPE", "BREAK", "CONTINUE", "DO", "ELSE", "FOR",
- "IF", "DISCARD", "RETURN", "BVEC2", "BVEC3", "BVEC4", "IVEC2", "IVEC3",
- "IVEC4", "VEC2", "VEC3", "VEC4", "MATRIX2", "MATRIX3", "MATRIX4",
- "IN_QUAL", "OUT_QUAL", "INOUT_QUAL", "UNIFORM", "VARYING", "STRUCT",
- "VOID_TYPE", "WHILE", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D",
- "SAMPLERCUBE", "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "IDENTIFIER",
- "TYPE_NAME", "FLOATCONSTANT", "INTCONSTANT", "BOOLCONSTANT",
- "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP",
- "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN",
- "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN",
- "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "LEFT_PAREN",
- "RIGHT_PAREN", "LEFT_BRACKET", "RIGHT_BRACKET", "LEFT_BRACE",
- "RIGHT_BRACE", "DOT", "COMMA", "COLON", "EQUAL", "SEMICOLON", "BANG",
- "DASH", "TILDE", "PLUS", "STAR", "SLASH", "PERCENT", "LEFT_ANGLE",
- "RIGHT_ANGLE", "VERTICAL_BAR", "CARET", "AMPERSAND", "QUESTION",
- "$accept", "variable_identifier", "primary_expression",
- "postfix_expression", "integer_expression", "function_call",
- "function_call_generic", "function_call_header_no_parameters",
- "function_call_header_with_parameters", "function_call_header",
- "function_identifier", "constructor_identifier", "unary_expression",
- "unary_operator", "multiplicative_expression", "additive_expression",
- "shift_expression", "relational_expression", "equality_expression",
- "and_expression", "exclusive_or_expression", "inclusive_or_expression",
- "logical_and_expression", "logical_xor_expression",
- "logical_or_expression", "conditional_expression",
- "assignment_expression", "assignment_operator", "expression",
- "constant_expression", "declaration", "function_prototype",
- "function_declarator", "function_header_with_parameters",
- "function_header", "parameter_declarator", "parameter_declaration",
- "parameter_qualifier", "parameter_type_specifier",
- "init_declarator_list", "single_declaration", "fully_specified_type",
- "type_qualifier", "type_specifier", "struct_specifier",
- "struct_declaration_list", "struct_declaration",
- "struct_declarator_list", "struct_declarator", "initializer",
- "declaration_statement", "statement", "simple_statement",
- "compound_statement", "@1", "@2", "statement_no_new_scope",
- "compound_statement_no_new_scope", "statement_list",
- "expression_statement", "selection_statement",
- "selection_rest_statement", "condition", "iteration_statement", "@3",
- "@4", "@5", "for_init_statement", "conditionopt", "for_rest_statement",
- "jump_statement", "translation_unit", "external_declaration",
- "function_definition", "@6", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const unsigned short yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
- 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
- 345, 346, 347
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const unsigned char yyr1[] =
-{
- 0, 93, 94, 95, 95, 95, 95, 95, 96, 96,
- 96, 96, 96, 96, 97, 98, 99, 99, 100, 100,
- 101, 101, 102, 103, 103, 104, 104, 104, 104, 104,
- 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
- 104, 105, 105, 105, 105, 106, 106, 106, 106, 107,
- 107, 107, 107, 108, 108, 108, 109, 109, 109, 110,
- 110, 110, 110, 110, 111, 111, 111, 112, 112, 113,
- 113, 114, 114, 115, 115, 116, 116, 117, 117, 118,
- 118, 119, 119, 120, 120, 120, 120, 120, 120, 120,
- 120, 120, 120, 120, 121, 121, 122, 123, 123, 124,
- 125, 125, 126, 126, 127, 128, 128, 129, 129, 129,
- 129, 130, 130, 130, 130, 131, 131, 132, 132, 132,
- 132, 132, 133, 133, 133, 133, 133, 134, 134, 135,
- 135, 135, 135, 136, 136, 136, 136, 136, 136, 136,
- 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
- 136, 136, 136, 136, 136, 136, 136, 137, 137, 138,
- 138, 139, 140, 140, 141, 141, 142, 143, 144, 144,
- 145, 145, 145, 145, 145, 146, 147, 148, 146, 149,
- 149, 150, 150, 151, 151, 152, 152, 153, 154, 154,
- 155, 155, 157, 156, 158, 156, 159, 156, 160, 160,
- 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
- 164, 165, 165, 167, 166
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const unsigned char yyr2[] =
-{
- 0, 2, 1, 1, 1, 1, 1, 3, 1, 4,
- 1, 3, 2, 2, 1, 1, 2, 2, 2, 1,
- 2, 3, 2, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 1, 1, 1, 1, 1,
- 3, 3, 3, 1, 3, 3, 1, 3, 3, 1,
- 3, 3, 3, 3, 1, 3, 3, 1, 3, 1,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 5, 1, 3, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 1, 2, 2, 2,
- 1, 1, 2, 3, 3, 2, 5, 3, 2, 3,
- 2, 0, 1, 1, 1, 1, 4, 1, 3, 5,
- 6, 5, 1, 2, 4, 5, 4, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 5, 4, 1,
- 2, 3, 1, 3, 1, 4, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 0, 0, 5, 1,
- 1, 2, 3, 1, 2, 1, 2, 5, 3, 1,
- 1, 4, 0, 6, 0, 8, 0, 7, 1, 1,
- 1, 0, 2, 3, 2, 2, 2, 3, 2, 1,
- 2, 1, 1, 0, 3
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const unsigned char yydefact[] =
-{
- 0, 130, 129, 136, 134, 135, 140, 141, 142, 143,
- 144, 145, 137, 138, 139, 146, 147, 148, 132, 131,
- 0, 133, 149, 150, 151, 152, 153, 154, 156, 212,
- 213, 0, 101, 111, 0, 117, 122, 0, 127, 155,
- 0, 209, 211, 0, 0, 97, 0, 99, 111, 112,
- 113, 114, 102, 0, 111, 0, 98, 123, 128, 1,
- 210, 0, 0, 0, 159, 0, 214, 103, 108, 110,
- 115, 0, 118, 104, 0, 0, 0, 164, 0, 162,
- 158, 160, 136, 134, 135, 0, 0, 194, 0, 0,
- 0, 0, 140, 141, 142, 143, 144, 145, 137, 138,
- 139, 146, 147, 148, 0, 2, 156, 5, 4, 6,
- 0, 0, 0, 176, 181, 185, 47, 46, 48, 45,
- 3, 8, 41, 10, 15, 0, 0, 19, 0, 23,
- 49, 0, 53, 56, 59, 64, 67, 69, 71, 73,
- 75, 77, 79, 81, 94, 0, 167, 0, 170, 183,
- 169, 168, 0, 171, 172, 173, 174, 105, 0, 107,
- 109, 0, 0, 27, 25, 26, 31, 32, 33, 34,
- 35, 36, 28, 29, 30, 37, 38, 39, 40, 124,
- 49, 96, 0, 166, 126, 157, 0, 0, 161, 205,
- 204, 0, 196, 0, 208, 206, 0, 192, 42, 43,
- 0, 175, 0, 12, 13, 0, 0, 17, 16, 0,
- 18, 20, 22, 84, 85, 87, 86, 89, 90, 91,
- 92, 93, 88, 83, 0, 44, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 186, 182, 184,
- 0, 0, 119, 0, 121, 125, 0, 163, 0, 0,
- 0, 207, 0, 7, 177, 0, 14, 11, 21, 82,
- 50, 51, 52, 55, 54, 57, 58, 62, 63, 60,
- 61, 65, 66, 68, 70, 72, 74, 76, 78, 0,
- 95, 0, 116, 120, 165, 0, 199, 198, 201, 0,
- 190, 0, 0, 0, 9, 0, 106, 0, 200, 0,
- 0, 189, 187, 0, 0, 178, 80, 0, 202, 0,
- 0, 0, 180, 193, 179, 0, 203, 197, 188, 191,
- 195
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const short yydefgoto[] =
-{
- -1, 120, 121, 122, 265, 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
- 138, 139, 140, 141, 142, 143, 144, 224, 145, 182,
- 146, 147, 31, 32, 33, 68, 52, 53, 69, 34,
- 35, 36, 37, 38, 39, 63, 64, 78, 79, 184,
- 148, 149, 150, 151, 202, 303, 323, 324, 152, 153,
- 154, 312, 302, 155, 262, 191, 259, 298, 309, 310,
- 156, 40, 41, 42, 46
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -297
-static const short yypact[] =
-{
- 1149, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -27, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -42, -28, -32, 4, 18, -297, 19, 1188, -297, -297,
- 1108, -297, -297, -10, 1188, -297, -3, -297, 36, -297,
- -297, -297, -297, 1188, 83, 33, -297, -9, -297, -297,
- -297, 1188, 39, 1025, -297, 235, -297, -297, -297, -297,
- -18, 1188, -52, -297, 685, 957, 1064, -17, 20, -297,
- -297, -297, 29, 45, 63, 21, 23, -297, 75, 77,
- 66, 753, 78, 79, 81, 82, 84, 85, 87, 89,
- 90, 91, 93, 94, 95, 96, 97, -297, -297, -297,
- 957, 957, 957, 120, -297, -297, -297, -297, -297, -297,
- -297, -297, 5, -297, -297, 98, 1, 821, 100, -297,
- 57, 957, 42, -56, 37, -40, 76, 61, 80, 106,
- 111, 138, -41, -297, -297, 30, -297, -42, -297, -297,
- -297, -297, 316, -297, -297, -297, -297, 127, 957, -297,
- -297, 889, 957, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, 128, -297, -297, -297, 957, 39, -297, -297,
- -297, 397, -297, 957, -297, -297, 31, -297, -297, -297,
- 3, -297, 397, -297, -297, 957, 152, -297, -297, 957,
- -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, -297, -297, 957, -297, 957, 957, 957, 957,
- 957, 957, 957, 957, 957, 957, 957, 957, 957, 957,
- 957, 957, 957, 957, 957, 957, 957, -297, -297, -297,
- 957, 129, -297, 130, -297, -297, 131, -297, 169, 549,
- 12, -297, 617, -297, 397, 133, 134, -297, -297, -297,
- -297, -297, -297, 42, 42, -56, -56, 37, 37, 37,
- 37, -40, -40, 76, 61, 80, 106, 111, 138, 60,
- -297, 135, -297, -297, -297, 137, -297, -297, 617, 397,
- 134, 167, 141, 140, -297, 957, -297, 957, -297, 136,
- 142, 205, -297, 143, 478, -297, -297, 13, 957, 478,
- 397, 957, -297, -297, -297, 139, 134, -297, -297, -297,
- -297
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const short yypgoto[] =
-{
- -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, -53, -297, -91, -89, -143, -97, -20, -16,
- -21, -15, -14, -22, -297, -57, -75, -297, -90, -155,
- 9, 10, -297, -297, -297, 154, 175, 172, 160, -297,
- -297, -257, -19, -33, -297, 171, -4, -297, 46, -160,
- -25, -107, -296, -297, -297, -297, -84, 190, 35, 6,
- -297, -297, -35, -297, -297, -297, -297, -297, -297, -297,
- -297, -297, 224, -297, -297
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -101
-static const short yytable[] =
-{
- 183, 196, 254, 251, 58, 301, 253, 1, 2, 29,
- 30, 62, 233, 234, 54, 43, 244, 181, 322, 161,
- 70, 180, 200, 322, 157, 229, 162, 230, 62, 54,
- 62, 256, 49, 50, 51, 18, 19, 45, 70, 1,
- 2, 301, 47, 62, 48, 249, 44, 235, 236, 29,
- 30, 245, 211, 158, 186, 203, 204, 198, 199, 81,
- 73, 57, 74, 61, 49, 50, 51, 18, 19, 75,
- 65, 208, 81, 263, -100, 72, 205, 209, 225, 246,
- 206, 77, 299, 325, 258, 231, 232, 183, 246, 246,
- 277, 278, 279, 280, 55, 291, 187, 56, -27, 188,
- 189, 181, 190, 260, 181, 180, 246, 246, 180, 247,
- 261, 49, 50, 51, -25, 266, 213, 214, 215, 216,
- 217, 218, 219, 220, 221, 222, 226, 227, 228, 181,
- 237, 238, -26, 180, 268, 223, 246, 305, 273, 274,
- 281, 282, 275, 276, 192, 194, 193, -31, -32, 269,
- -33, -34, 239, -35, -36, 289, -28, 249, -29, -30,
- -37, 329, -38, -39, 197, -24, -40, 242, 207, 212,
- 240, 290, 300, 270, 271, 272, 180, 180, 180, 180,
- 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
- 180, 180, 311, 181, 201, 241, 243, 180, 250, 267,
- 255, 292, 293, 294, 295, 304, 307, 306, 300, 313,
- 246, 314, 319, 328, 315, 318, 320, 317, 330, 283,
- 285, 321, 288, 67, 284, 159, 71, 286, 326, 287,
- 316, 160, 76, 257, 296, 327, 66, 264, 1, 2,
- 82, 83, 84, 85, 86, 87, 183, 88, 89, 90,
- 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 308, 60, 297, 18, 19, 20, 21,
- 104, 22, 23, 24, 25, 26, 27, 105, 106, 107,
- 108, 109, 0, 0, 0, 110, 111, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 112, 0, 0, 0, 113, 114,
- 0, 0, 0, 0, 115, 116, 117, 118, 119, 1,
- 2, 82, 83, 84, 85, 86, 87, 0, 88, 89,
- 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 0, 0, 0, 18, 19, 20,
- 21, 104, 22, 23, 24, 25, 26, 27, 105, 106,
- 107, 108, 109, 0, 0, 0, 110, 111, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 112, 0, 0, 0, 113,
- 248, 0, 0, 0, 0, 115, 116, 117, 118, 119,
- 1, 2, 82, 83, 84, 85, 86, 87, 0, 88,
- 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 99, 100, 101, 102, 103, 0, 0, 0, 18, 19,
- 20, 21, 104, 22, 23, 24, 25, 26, 27, 105,
- 106, 107, 108, 109, 0, 0, 0, 110, 111, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
- 113, 0, 0, 0, 0, 0, 115, 116, 117, 118,
- 119, 1, 2, 82, 83, 84, 85, 86, 87, 0,
- 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
- 98, 99, 100, 101, 102, 103, 0, 0, 0, 18,
- 19, 20, 21, 104, 22, 23, 24, 25, 26, 27,
- 105, 106, 107, 108, 109, 0, 0, 0, 110, 111,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 112, 0, 0,
- 0, 65, 1, 2, 82, 83, 84, 115, 116, 117,
- 118, 119, 0, 0, 0, 92, 93, 94, 95, 96,
- 97, 98, 99, 100, 101, 102, 103, 0, 0, 0,
- 18, 19, 20, 21, 0, 22, 23, 24, 25, 26,
- 27, 105, 106, 107, 108, 109, 0, 0, 0, 110,
- 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
- 1, 2, 82, 83, 84, 0, 0, 0, 115, 116,
- 117, 118, 119, 92, 93, 94, 95, 96, 97, 98,
- 99, 100, 101, 102, 103, 0, 0, 0, 18, 19,
- 20, 21, 0, 22, 23, 24, 25, 26, 27, 105,
- 106, 107, 108, 109, 0, 0, 0, 110, 111, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
- 163, 164, 165, 0, 0, 0, 0, 116, 117, 118,
- 119, 166, 167, 168, 169, 170, 171, 172, 173, 174,
- 175, 176, 177, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 105, 178, 107,
- 108, 109, 0, 0, 0, 110, 111, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 112, 0, 0, 179, 163, 164,
- 165, 0, 0, 0, 0, 116, 117, 118, 119, 166,
- 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
- 177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 105, 178, 107, 108, 109,
- 0, 0, 0, 110, 111, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 112, 0, 0, 0, 163, 164, 165, 0,
- 0, 0, 195, 116, 117, 118, 119, 166, 167, 168,
- 169, 170, 171, 172, 173, 174, 175, 176, 177, 0,
- 0, 0, 0, 0, 0, 210, 0, 0, 0, 0,
- 0, 0, 0, 105, 178, 107, 108, 109, 0, 0,
- 0, 110, 111, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 112, 0, 0, 0, 163, 164, 165, 0, 0, 0,
- 0, 116, 117, 118, 119, 166, 167, 168, 169, 170,
- 171, 172, 173, 174, 175, 176, 177, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 105, 178, 107, 108, 109, 0, 0, 0, 110,
- 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
- 0, 252, 163, 164, 165, 0, 0, 0, 0, 116,
- 117, 118, 119, 166, 167, 168, 169, 170, 171, 172,
- 173, 174, 175, 176, 177, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 105,
- 178, 107, 108, 109, 0, 0, 0, 110, 111, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
- 3, 4, 5, 0, 0, 0, 0, 116, 117, 118,
- 119, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 0, 0, 0, 0, 0, 20, 21,
- 0, 22, 23, 24, 25, 26, 27, 0, 28, 3,
- 4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 0, 0, 0, 0, 0, 20, 21, 80,
- 22, 23, 24, 25, 26, 27, 0, 28, 59, 0,
- 0, 1, 2, 3, 4, 5, 0, 0, 0, 0,
- 0, 0, 0, 0, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 0, 0, 185, 18,
- 19, 20, 21, 0, 22, 23, 24, 25, 26, 27,
- 0, 28, 1, 2, 3, 4, 5, 0, 0, 0,
- 0, 0, 0, 0, 0, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 0, 0, 0,
- 18, 19, 20, 21, 0, 22, 23, 24, 25, 26,
- 27, 0, 28, 3, 4, 5, 0, 0, 0, 0,
- 0, 0, 0, 0, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 0, 0, 0, 0,
- 0, 20, 21, 0, 22, 23, 24, 25, 26, 27,
- 0, 28
-};
-
-static const short yycheck[] =
-{
- 75, 91, 162, 158, 37, 262, 161, 3, 4, 0,
- 0, 44, 52, 53, 33, 42, 57, 74, 314, 71,
- 53, 74, 112, 319, 42, 81, 78, 83, 61, 48,
- 63, 186, 28, 29, 30, 31, 32, 79, 71, 3,
- 4, 298, 70, 76, 76, 152, 73, 87, 88, 40,
- 40, 92, 127, 71, 71, 50, 51, 110, 111, 63,
- 69, 42, 71, 73, 28, 29, 30, 31, 32, 78,
- 73, 70, 76, 70, 70, 42, 71, 76, 131, 76,
- 75, 42, 70, 70, 191, 48, 49, 162, 76, 76,
- 233, 234, 235, 236, 76, 250, 76, 79, 69, 79,
- 79, 158, 79, 193, 161, 158, 76, 76, 161, 79,
- 79, 28, 29, 30, 69, 205, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 84, 85, 86, 186,
- 54, 55, 69, 186, 209, 78, 76, 77, 229, 230,
- 237, 238, 231, 232, 69, 79, 69, 69, 69, 224,
- 69, 69, 91, 69, 69, 245, 69, 264, 69, 69,
- 69, 321, 69, 69, 69, 69, 69, 56, 70, 69,
- 90, 246, 262, 226, 227, 228, 229, 230, 231, 232,
- 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
- 243, 244, 299, 250, 74, 89, 58, 250, 71, 47,
- 72, 72, 72, 72, 35, 72, 69, 72, 298, 42,
- 76, 70, 70, 320, 74, 79, 11, 307, 79, 239,
- 241, 78, 244, 48, 240, 71, 54, 242, 318, 243,
- 305, 71, 61, 187, 259, 319, 46, 202, 3, 4,
- 5, 6, 7, 8, 9, 10, 321, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 298, 40, 259, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, -1, -1, -1, 50, 51, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 69, -1, -1, -1, 73, 74,
- -1, -1, -1, -1, 79, 80, 81, 82, 83, 3,
- 4, 5, 6, 7, 8, 9, 10, -1, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, -1, -1, -1, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, -1, -1, -1, 50, 51, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 69, -1, -1, -1, 73,
- 74, -1, -1, -1, -1, 79, 80, 81, 82, 83,
- 3, 4, 5, 6, 7, 8, 9, 10, -1, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, -1, -1, -1, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
- 73, -1, -1, -1, -1, -1, 79, 80, 81, 82,
- 83, 3, 4, 5, 6, 7, 8, 9, 10, -1,
- 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, -1, -1, -1, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, -1, -1, -1, 50, 51,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 69, -1, -1,
- -1, 73, 3, 4, 5, 6, 7, 79, 80, 81,
- 82, 83, -1, -1, -1, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
- 31, 32, 33, 34, -1, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, -1, -1, -1, 50,
- 51, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 69, -1,
- 3, 4, 5, 6, 7, -1, -1, -1, 79, 80,
- 81, 82, 83, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, -1, -1, -1, 31, 32,
- 33, 34, -1, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
- 5, 6, 7, -1, -1, -1, -1, 80, 81, 82,
- 83, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 42, 43, 44,
- 45, 46, -1, -1, -1, 50, 51, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 69, -1, -1, 72, 5, 6,
- 7, -1, -1, -1, -1, 80, 81, 82, 83, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 42, 43, 44, 45, 46,
- -1, -1, -1, 50, 51, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 69, -1, -1, -1, 5, 6, 7, -1,
- -1, -1, 79, 80, 81, 82, 83, 16, 17, 18,
- 19, 20, 21, 22, 23, 24, 25, 26, 27, -1,
- -1, -1, -1, -1, -1, 34, -1, -1, -1, -1,
- -1, -1, -1, 42, 43, 44, 45, 46, -1, -1,
- -1, 50, 51, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 69, -1, -1, -1, 5, 6, 7, -1, -1, -1,
- -1, 80, 81, 82, 83, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 42, 43, 44, 45, 46, -1, -1, -1, 50,
- 51, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 69, -1,
- -1, 72, 5, 6, 7, -1, -1, -1, -1, 80,
- 81, 82, 83, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 42,
- 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
- 5, 6, 7, -1, -1, -1, -1, 80, 81, 82,
- 83, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, -1, -1, -1, -1, -1, 33, 34,
- -1, 36, 37, 38, 39, 40, 41, -1, 43, 5,
- 6, 7, -1, -1, -1, -1, -1, -1, -1, -1,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, -1, -1, -1, -1, -1, 33, 34, 74,
- 36, 37, 38, 39, 40, 41, -1, 43, 0, -1,
- -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
- -1, -1, -1, -1, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, -1, -1, 74, 31,
- 32, 33, 34, -1, 36, 37, 38, 39, 40, 41,
- -1, 43, 3, 4, 5, 6, 7, -1, -1, -1,
- -1, -1, -1, -1, -1, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
- 31, 32, 33, 34, -1, 36, 37, 38, 39, 40,
- 41, -1, 43, 5, 6, 7, -1, -1, -1, -1,
- -1, -1, -1, -1, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
- -1, 33, 34, -1, 36, 37, 38, 39, 40, 41,
- -1, 43
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const unsigned char yystos[] =
-{
- 0, 3, 4, 5, 6, 7, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 31, 32,
- 33, 34, 36, 37, 38, 39, 40, 41, 43, 123,
- 124, 125, 126, 127, 132, 133, 134, 135, 136, 137,
- 164, 165, 166, 42, 73, 79, 167, 70, 76, 28,
- 29, 30, 129, 130, 135, 76, 79, 42, 136, 0,
- 165, 73, 136, 138, 139, 73, 150, 129, 128, 131,
- 136, 130, 42, 69, 71, 78, 138, 42, 140, 141,
- 74, 139, 5, 6, 7, 8, 9, 10, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 35, 42, 43, 44, 45, 46,
- 50, 51, 69, 73, 74, 79, 80, 81, 82, 83,
- 94, 95, 96, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 115, 116, 117, 118, 119, 121, 123, 124, 143, 144,
- 145, 146, 151, 152, 153, 156, 163, 42, 71, 128,
- 131, 71, 78, 5, 6, 7, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 43, 72,
- 105, 118, 122, 119, 142, 74, 71, 76, 79, 79,
- 79, 158, 69, 69, 79, 79, 121, 69, 105, 105,
- 121, 74, 147, 50, 51, 71, 75, 70, 70, 76,
- 34, 119, 69, 59, 60, 61, 62, 63, 64, 65,
- 66, 67, 68, 78, 120, 105, 84, 85, 86, 81,
- 83, 48, 49, 52, 53, 87, 88, 54, 55, 91,
- 90, 89, 56, 58, 57, 92, 76, 79, 74, 144,
- 71, 122, 72, 122, 142, 72, 122, 141, 144, 159,
- 121, 79, 157, 70, 151, 97, 121, 47, 119, 119,
- 105, 105, 105, 107, 107, 108, 108, 109, 109, 109,
- 109, 110, 110, 111, 112, 113, 114, 115, 116, 121,
- 119, 122, 72, 72, 72, 35, 143, 152, 160, 70,
- 121, 134, 155, 148, 72, 77, 72, 69, 155, 161,
- 162, 144, 154, 42, 70, 74, 119, 121, 79, 70,
- 11, 78, 145, 149, 150, 70, 121, 149, 144, 142,
- 79
-};
-
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
-#endif
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror ("syntax error: cannot back up");\
- YYERROR; \
- } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-/* YYLLOC_DEFAULT -- Compute the default location (before the actions
- are run). */
-
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = Rhs[1].first_line; \
- Current.first_column = Rhs[1].first_column; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
-#endif
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval, YYLEX_PARAM)
-#else
-# define YYLEX yylex (&yylval)
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-# define YYDSYMPRINT(Args) \
-do { \
- if (yydebug) \
- yysymprint Args; \
-} while (0)
-
-# define YYDSYMPRINTF(Title, Token, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yysymprint (stderr, \
- Token, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (cinluded). |
-`------------------------------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yy_stack_print (short *bottom, short *top)
-#else
-static void
-yy_stack_print (bottom, top)
- short *bottom;
- short *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (/* Nothing. */; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yy_reduce_print (int yyrule)
-#else
-static void
-yy_reduce_print (yyrule)
- int yyrule;
-#endif
-{
- int yyi;
- unsigned int yylineno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
- yyrule - 1, yylineno);
- /* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
- YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
- YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YYDSYMPRINT(Args)
-# define YYDSYMPRINTF(Title, Token, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#if YYMAXDEPTH == 0
-# undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-\f
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined (__GLIBC__) && defined (_STRING_H)
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-# if defined (__STDC__) || defined (__cplusplus)
-yystrlen (const char *yystr)
-# else
-yystrlen (yystr)
- const char *yystr;
-# endif
-{
- register const char *yys = yystr;
-
- while (*yys++ != '\0')
- continue;
-
- return yys - yystr - 1;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-# if defined (__STDC__) || defined (__cplusplus)
-yystpcpy (char *yydest, const char *yysrc)
-# else
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-# endif
-{
- register char *yyd = yydest;
- register const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-#endif /* !YYERROR_VERBOSE */
-
-\f
-
-#if YYDEBUG
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yysymprint (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
-
- if (yytype < YYNTOKENS)
- {
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-# ifdef YYPRINT
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- }
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- switch (yytype)
- {
- default:
- break;
- }
- YYFPRINTF (yyoutput, ")");
-}
-
-#endif /* ! YYDEBUG */
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yydestruct (int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yytype, yyvaluep)
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-\f
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM);
-# else
-int yyparse ();
-# endif
-#else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM)
-# else
-int yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-# endif
-#else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
- /* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
- register int yystate;
- register int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- short yyssa[YYINITDEPTH];
- short *yyss = yyssa;
- register short *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- register YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK (yyvsp--, yyssp--)
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* When reducing, the number of symbols on the RHS of the reduced
- rule. */
- int yylen;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks.
- */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow ("parser stack overflow",
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyoverflowlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyoverflowlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- short *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyoverflowlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 210 "glslang.y"
- {
- // The symbol table search was done in the lexical phase
- const TSymbol* symbol = yyvsp[0].lex.symbol;
- const TVariable* variable;
- if (symbol == 0) {
- parseContext.error(yyvsp[0].lex.line, "undeclared identifier", yyvsp[0].lex.string->c_str(), "");
- parseContext.recover();
- TType type(EbtFloat);
- TVariable* fakeVariable = new TVariable(yyvsp[0].lex.string, type);
- parseContext.symbolTable.insert(*fakeVariable);
- variable = fakeVariable;
- } else {
- // This identifier can only be a variable type symbol
- if (! symbol->isVariable()) {
- parseContext.error(yyvsp[0].lex.line, "variable expected", yyvsp[0].lex.string->c_str(), "");
- parseContext.recover();
- }
- variable = static_cast<const TVariable*>(symbol);
- }
-
- // don't delete $1.string, it's used by error recovery, and the pool
- // pop will reclaim the memory
-
- if (variable->getType().getQualifier() == EvqConst ) {
- constUnion* constArray = variable->getConstPointer();
- TType t(variable->getType());
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(constArray, t, yyvsp[0].lex.line);
- } else
- yyval.interm.intermTypedNode = parseContext.intermediate.addSymbol(variable->getUniqueId(),
- variable->getName(),
- variable->getType(), yyvsp[0].lex.line);
- ;}
- break;
-
- case 3:
-#line 245 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 4:
-#line 248 "glslang.y"
- {
- //
- // INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders,
- // check for overflow for constants
- //
- if (abs(yyvsp[0].lex.i) >= (1 << 16)) {
- parseContext.error(yyvsp[0].lex.line, " integer constant overflow", "", "");
- parseContext.recover();
- }
- constUnion *unionArray = new constUnion[1];
- unionArray->iConst = yyvsp[0].lex.i;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
- ;}
- break;
-
- case 5:
-#line 261 "glslang.y"
- {
- constUnion *unionArray = new constUnion[1];
- unionArray->fConst = yyvsp[0].lex.f;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[0].lex.line);
- ;}
- break;
-
- case 6:
-#line 266 "glslang.y"
- {
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = yyvsp[0].lex.b;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[0].lex.line);
- ;}
- break;
-
- case 7:
-#line 271 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
- ;}
- break;
-
- case 8:
-#line 277 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 9:
-#line 280 "glslang.y"
- {
- if (!yyvsp[-3].interm.intermTypedNode->isArray() && !yyvsp[-3].interm.intermTypedNode->isMatrix() && !yyvsp[-3].interm.intermTypedNode->isVector()) {
- if (yyvsp[-3].interm.intermTypedNode->getAsSymbolNode())
- parseContext.error(yyvsp[-2].lex.line, " left of '[' is not of type array, matrix, or vector ", yyvsp[-3].interm.intermTypedNode->getAsSymbolNode()->getSymbol().c_str(), "");
- else
- parseContext.error(yyvsp[-2].lex.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
- parseContext.recover();
- }
- if (yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst && !yyvsp[-3].interm.intermTypedNode->isArray() && yyvsp[-1].interm.intermTypedNode->getQualifier() == EvqConst) {
- if (yyvsp[-3].interm.intermTypedNode->isVector()) { // constant folding for vectors
- TVectorFields fields;
- fields.num = 1;
- fields.offsets[0] = yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst; // need to do it this way because v.xy sends fields integer array
- yyval.interm.intermTypedNode = parseContext.addConstVectorNode(fields, yyvsp[-3].interm.intermTypedNode, yyvsp[-2].lex.line);
- } else if (yyvsp[-3].interm.intermTypedNode->isMatrix()) { // constant folding for matrices
- yyval.interm.intermTypedNode = parseContext.addConstMatrixNode(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst, yyvsp[-3].interm.intermTypedNode, yyvsp[-2].lex.line);
- }
- } else {
- if (yyvsp[-1].interm.intermTypedNode->getQualifier() == EvqConst) {
- if ((yyvsp[-3].interm.intermTypedNode->isVector() || yyvsp[-3].interm.intermTypedNode->isMatrix()) && yyvsp[-3].interm.intermTypedNode->getType().getNominalSize() <= yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst && !yyvsp[-3].interm.intermTypedNode->isArray() ) {
- parseContext.error(yyvsp[-2].lex.line, "", "[", "field selection out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
- parseContext.recover();
- } else {
- if (yyvsp[-3].interm.intermTypedNode->isArray()) {
- if (yyvsp[-3].interm.intermTypedNode->getType().getArraySize() == 0) {
- if (yyvsp[-3].interm.intermTypedNode->getType().getMaxArraySize() <= yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst) {
- if (parseContext.arraySetMaxSize(yyvsp[-3].interm.intermTypedNode->getAsSymbolNode(), yyvsp[-3].interm.intermTypedNode->getTypePointer(), yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst, true, yyvsp[-2].lex.line))
- parseContext.recover();
- } else {
- if (parseContext.arraySetMaxSize(yyvsp[-3].interm.intermTypedNode->getAsSymbolNode(), yyvsp[-3].interm.intermTypedNode->getTypePointer(), 0, false, yyvsp[-2].lex.line))
- parseContext.recover();
- }
- } else if ( yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst >= yyvsp[-3].interm.intermTypedNode->getType().getArraySize()) {
- parseContext.error(yyvsp[-2].lex.line, "", "[", "array index out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
- parseContext.recover();
- }
- }
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-3].interm.intermTypedNode, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
- }
- } else {
- if (yyvsp[-3].interm.intermTypedNode->isArray() && yyvsp[-3].interm.intermTypedNode->getType().getArraySize() == 0) {
- parseContext.error(yyvsp[-2].lex.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
- parseContext.recover();
- }
-
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexIndirect, yyvsp[-3].interm.intermTypedNode, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
- }
- }
- if (yyval.interm.intermTypedNode == 0) {
- constUnion *unionArray = new constUnion[1];
- unionArray->fConst = 0.0;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[-2].lex.line);
- } else if (yyvsp[-3].interm.intermTypedNode->isArray()) {
- if (yyvsp[-3].interm.intermTypedNode->getType().getStruct())
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getType().getStruct(), yyvsp[-3].interm.intermTypedNode->getType().getTypeName()));
- else
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-3].interm.intermTypedNode->getNominalSize(), yyvsp[-3].interm.intermTypedNode->isMatrix()));
- } else if (yyvsp[-3].interm.intermTypedNode->isMatrix() && yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst)
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqConst, yyvsp[-3].interm.intermTypedNode->getNominalSize()));
- else if (yyvsp[-3].interm.intermTypedNode->isMatrix())
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-3].interm.intermTypedNode->getNominalSize()));
- else if (yyvsp[-3].interm.intermTypedNode->isVector() && yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst)
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqConst));
- else if (yyvsp[-3].interm.intermTypedNode->isVector())
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary));
- else
- yyval.interm.intermTypedNode->setType(yyvsp[-3].interm.intermTypedNode->getType());
- ;}
- break;
-
- case 10:
-#line 348 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 11:
-#line 351 "glslang.y"
- {
- if (yyvsp[-2].interm.intermTypedNode->isArray()) {
- parseContext.error(yyvsp[0].lex.line, "cannot apply dot operator to an array", ".", "");
- parseContext.recover();
- }
-
- if (yyvsp[-2].interm.intermTypedNode->isVector()) {
- TVectorFields fields;
- if (! parseContext.parseVectorFields(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode->getNominalSize(), fields, yyvsp[0].lex.line)) {
- fields.num = 1;
- fields.offsets[0] = 0;
- parseContext.recover();
- }
-
- if (yyvsp[-2].interm.intermTypedNode->getType().getQualifier() == EvqConst) { // constant folding for vector fields
- yyval.interm.intermTypedNode = parseContext.addConstVectorNode(fields, yyvsp[-2].interm.intermTypedNode, yyvsp[0].lex.line);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- else
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(), EvqConst, (int) (*yyvsp[0].lex.string).size()));
- } else {
- if (fields.num == 1) {
- constUnion *unionArray = new constUnion[1];
- unionArray->iConst = fields.offsets[0];
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType()));
- } else {
- TString vectorString = *yyvsp[0].lex.string;
- TIntermTyped* index = parseContext.intermediate.addSwizzle(fields, yyvsp[0].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpVectorSwizzle, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(),EvqTemporary, (int) vectorString.size()));
- }
- }
- } else if (yyvsp[-2].interm.intermTypedNode->isMatrix()) {
- TMatrixFields fields;
- if (! parseContext.parseMatrixFields(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode->getNominalSize(), fields, yyvsp[0].lex.line)) {
- fields.wholeRow = false;
- fields.wholeCol = false;
- fields.row = 0;
- fields.col = 0;
- parseContext.recover();
- }
-
- if (fields.wholeRow || fields.wholeCol) {
- parseContext.error(yyvsp[-1].lex.line, " non-scalar fields not implemented yet", ".", "");
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->iConst = 0;
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-2].interm.intermTypedNode->getNominalSize()));
- } else {
- constUnion *unionArray = new constUnion[1];
- unionArray->iConst = fields.col * yyvsp[-2].interm.intermTypedNode->getNominalSize() + fields.row;
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType()));
- }
- } else if (yyvsp[-2].interm.intermTypedNode->getBasicType() == EbtStruct) {
- bool fieldFound = false;
- TTypeList* fields = yyvsp[-2].interm.intermTypedNode->getType().getStruct();
- if (fields == 0) {
- parseContext.error(yyvsp[-1].lex.line, "structure has no fields", "Internal Error", "");
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- } else {
- unsigned int i;
- for (i = 0; i < fields->size(); ++i) {
- if ((*fields)[i].type->getFieldName() == *yyvsp[0].lex.string) {
- fieldFound = true;
- break;
- }
- }
- if (fieldFound) {
- if (yyvsp[-2].interm.intermTypedNode->getType().getQualifier() == EvqConst) {
- yyval.interm.intermTypedNode = parseContext.addConstStruct(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode, yyvsp[-1].lex.line);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- else {
- yyval.interm.intermTypedNode->setType(*(*fields)[i].type);
- // change the qualifier of the return type, not of the structure field
- // as the structure definition is shared between various structures.
- yyval.interm.intermTypedNode->getTypePointer()->changeQualifier(EvqConst);
- }
- } else {
- constUnion *unionArray = new constUnion[1];
- unionArray->iConst = i;
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirectStruct, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode->setType(*(*fields)[i].type);
- }
- } else {
- parseContext.error(yyvsp[-1].lex.line, " no such field in structure", yyvsp[0].lex.string->c_str(), "");
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- }
- } else {
- parseContext.error(yyvsp[-1].lex.line, " field selection requires structure, vector, or matrix on left hand side", yyvsp[0].lex.string->c_str(), "");
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- // don't delete $3.string, it's from the pool
- ;}
- break;
-
- case 12:
-#line 460 "glslang.y"
- {
- if (parseContext.lValueErrorCheck(yyvsp[0].lex.line, "++", yyvsp[-1].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPostIncrement, yyvsp[-1].interm.intermTypedNode, yyvsp[0].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.unaryOpError(yyvsp[0].lex.line, "++", yyvsp[-1].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 13:
-#line 470 "glslang.y"
- {
- if (parseContext.lValueErrorCheck(yyvsp[0].lex.line, "--", yyvsp[-1].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPostDecrement, yyvsp[-1].interm.intermTypedNode, yyvsp[0].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.unaryOpError(yyvsp[0].lex.line, "--", yyvsp[-1].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 14:
-#line 483 "glslang.y"
- {
- if (parseContext.integerErrorCheck(yyvsp[0].interm.intermTypedNode, "[]"))
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 15:
-#line 491 "glslang.y"
- {
- TFunction* fnCall = yyvsp[0].interm.function;
- TOperator op = fnCall->getBuiltInOp();
-
- if (op != EOpNull) {
- //
- // Then this should be a constructor.
- //
- TType type(EbtVoid); // use this to get the type back
- if (parseContext.constructorErrorCheck(yyvsp[0].interm.line, yyvsp[0].interm.intermNode, *fnCall, op, &type)) {
- yyval.interm.intermTypedNode = 0;
- } else {
- //
- // It's a constructor, of type 'type'.
- //
- yyval.interm.intermTypedNode = parseContext.addConstructor(yyvsp[0].interm.intermNode, &type, op, fnCall, yyvsp[0].interm.line);
- }
-
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(0, op, yyvsp[0].interm.line);
- }
- yyval.interm.intermTypedNode->setType(type);
- } else {
- //
- // Not a constructor. Find it in the symbol table.
- //
- const TFunction* fnCandidate;
- bool builtIn;
- fnCandidate = parseContext.findFunction(yyvsp[0].interm.line, fnCall, &builtIn);
- if (fnCandidate) {
- //
- // A declared function. But, it might still map to a built-in
- // operation.
- //
- op = fnCandidate->getBuiltInOp();
- if (builtIn && op != EOpNull) {
- //
- // A function call mapped to a built-in operation.
- //
- if (fnCandidate->getParamCount() == 1) {
- //
- // Treat it like a built-in unary operator.
- //
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(op, yyvsp[0].interm.intermNode, 0, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.error(yyvsp[0].interm.intermNode->getLine(), " wrong operand type", "Internal Error",
- "built in unary operator function. Type: %s",
- static_cast<TIntermTyped*>(yyvsp[0].interm.intermNode)->getCompleteString().c_str());
- YYERROR;
- }
- } else {
- yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(yyvsp[0].interm.intermAggregate, op, yyvsp[0].interm.line);
- }
- } else {
- // This is a real function call
-
- yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(yyvsp[0].interm.intermAggregate, EOpFunctionCall, yyvsp[0].interm.line);
- yyval.interm.intermTypedNode->setType(fnCandidate->getReturnType());
-
- // this is how we know whether the given function is a builtIn function or a user defined function
- // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also
- // if builtIn == true, it's definitely a builtIn function with EOpNull
- if (!builtIn)
- yyval.interm.intermTypedNode->getAsAggregate()->setUserDefined();
- yyval.interm.intermTypedNode->getAsAggregate()->setName(fnCandidate->getMangledName());
-
- TQualifier qual;
- TQualifierList& qualifierList = yyval.interm.intermTypedNode->getAsAggregate()->getQualifier();
- for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
- qual = (*fnCandidate)[i].type->getQualifier();
- if (qual == EvqOut || qual == EvqInOut) {
- if (parseContext.lValueErrorCheck(yyval.interm.intermTypedNode->getLine(), "assign", yyval.interm.intermTypedNode->getAsAggregate()->getSequence()[i]->getAsTyped())) {
- parseContext.error(yyvsp[0].interm.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
- parseContext.recover();
- }
- }
- qualifierList.push_back(qual);
- }
- }
- yyval.interm.intermTypedNode->setType(fnCandidate->getReturnType());
- } else {
- // error message was put out by PaFindFunction()
- // Put on a dummy node for error recovery
- constUnion *unionArray = new constUnion[1];
- unionArray->fConst = 0.0;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[0].interm.line);
- parseContext.recover();
- }
- }
- delete fnCall;
- ;}
- break;
-
- case 16:
-#line 586 "glslang.y"
- {
- yyval.interm = yyvsp[-1].interm;
- yyval.interm.line = yyvsp[0].lex.line;
- ;}
- break;
-
- case 17:
-#line 590 "glslang.y"
- {
- yyval.interm = yyvsp[-1].interm;
- yyval.interm.line = yyvsp[0].lex.line;
- ;}
- break;
-
- case 18:
-#line 597 "glslang.y"
- {
- yyval.interm.function = yyvsp[-1].interm.function;
- yyval.interm.intermNode = 0;
- ;}
- break;
-
- case 19:
-#line 601 "glslang.y"
- {
- yyval.interm.function = yyvsp[0].interm.function;
- yyval.interm.intermNode = 0;
- ;}
- break;
-
- case 20:
-#line 608 "glslang.y"
- {
- TParameter param = { 0, new TType(yyvsp[0].interm.intermTypedNode->getType()) };
- yyvsp[-1].interm.function->addParameter(param);
- yyval.interm.function = yyvsp[-1].interm.function;
- yyval.interm.intermNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 21:
-#line 614 "glslang.y"
- {
- TParameter param = { 0, new TType(yyvsp[0].interm.intermTypedNode->getType()) };
- yyvsp[-2].interm.function->addParameter(param);
- yyval.interm.function = yyvsp[-2].interm.function;
- yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-2].interm.intermNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line);
- ;}
- break;
-
- case 22:
-#line 623 "glslang.y"
- {
- yyval.interm.function = yyvsp[-1].interm.function;
- ;}
- break;
-
- case 23:
-#line 629 "glslang.y"
- {
- if (yyvsp[0].interm.op == EOpConstructStruct) {
- TString tempString = "";
- TFunction *function = new TFunction(&tempString, *(yyvsp[0].interm.type.userDef), yyvsp[0].interm.op);
- yyval.interm.function = function;
- }
- else {
- TFunction *function = new TFunction(yyvsp[0].interm.op);
- yyval.interm.function = function;
- }
- ;}
- break;
-
- case 24:
-#line 640 "glslang.y"
- {
- if (parseContext.reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string))
- parseContext.recover();
- TType type(EbtVoid);
- TFunction *function = new TFunction(yyvsp[0].lex.string, type);
- yyval.interm.function = function;
- ;}
- break;
-
- case 25:
-#line 656 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructFloat; ;}
- break;
-
- case 26:
-#line 657 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructInt; ;}
- break;
-
- case 27:
-#line 658 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBool; ;}
- break;
-
- case 28:
-#line 659 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec2; ;}
- break;
-
- case 29:
-#line 660 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec3; ;}
- break;
-
- case 30:
-#line 661 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec4; ;}
- break;
-
- case 31:
-#line 662 "glslang.y"
- { FRAG_VERT_ONLY("bvec2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec2; ;}
- break;
-
- case 32:
-#line 663 "glslang.y"
- { FRAG_VERT_ONLY("bvec3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec3; ;}
- break;
-
- case 33:
-#line 664 "glslang.y"
- { FRAG_VERT_ONLY("bvec4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec4; ;}
- break;
-
- case 34:
-#line 665 "glslang.y"
- { FRAG_VERT_ONLY("ivec2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec2; ;}
- break;
-
- case 35:
-#line 666 "glslang.y"
- { FRAG_VERT_ONLY("ivec3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec3; ;}
- break;
-
- case 36:
-#line 667 "glslang.y"
- { FRAG_VERT_ONLY("ivec4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec4; ;}
- break;
-
- case 37:
-#line 668 "glslang.y"
- { FRAG_VERT_ONLY("mat2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat2; ;}
- break;
-
- case 38:
-#line 669 "glslang.y"
- { FRAG_VERT_ONLY("mat3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat3; ;}
- break;
-
- case 39:
-#line 670 "glslang.y"
- { FRAG_VERT_ONLY("mat4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat4; ;}
- break;
-
- case 40:
-#line 671 "glslang.y"
- {
- TType& structure = static_cast<TVariable*>(yyvsp[0].lex.symbol)->getType();
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtStruct, qual, 1, false, false, &structure, yyvsp[0].lex.line };
- yyval.interm.type = t;
- yyval.interm.line = yyvsp[0].lex.line;
- yyval.interm.op = EOpConstructStruct;
- ;}
- break;
-
- case 41:
-#line 682 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 42:
-#line 685 "glslang.y"
- {
- if (parseContext.lValueErrorCheck(yyvsp[-1].lex.line, "++", yyvsp[0].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPreIncrement, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.unaryOpError(yyvsp[-1].lex.line, "++", yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 43:
-#line 695 "glslang.y"
- {
- if (parseContext.lValueErrorCheck(yyvsp[-1].lex.line, "--", yyvsp[0].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPreDecrement, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.unaryOpError(yyvsp[-1].lex.line, "--", yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 44:
-#line 705 "glslang.y"
- {
- if (yyvsp[-1].interm.op != EOpNull) {
- yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(yyvsp[-1].interm.op, yyvsp[0].interm.intermTypedNode, yyvsp[-1].interm.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- char* errorOp = "";
- switch(yyvsp[-1].interm.op) {
- case EOpNegative: errorOp = "-"; break;
- case EOpLogicalNot: errorOp = "!"; break;
- case EOpBitwiseNot: errorOp = "~"; break;
- default: break;
- }
- parseContext.unaryOpError(yyvsp[-1].interm.line, errorOp, yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- }
- } else
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 45:
-#line 727 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNull; ;}
- break;
-
- case 46:
-#line 728 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNegative; ;}
- break;
-
- case 47:
-#line 729 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpLogicalNot; ;}
- break;
-
- case 48:
-#line 730 "glslang.y"
- { PACK_UNPACK_ONLY("~", yyvsp[0].lex.line);
- yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpBitwiseNot; ;}
- break;
-
- case 49:
-#line 736 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 50:
-#line 737 "glslang.y"
- {
- FRAG_VERT_ONLY("*", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpMul, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "*", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 51:
-#line 746 "glslang.y"
- {
- FRAG_VERT_ONLY("/", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpDiv, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "/", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 52:
-#line 755 "glslang.y"
- {
- PACK_UNPACK_ONLY("%", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpMod, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "%", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 53:
-#line 767 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 54:
-#line 768 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpAdd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "+", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 55:
-#line 776 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpSub, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "-", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 56:
-#line 787 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 57:
-#line 788 "glslang.y"
- {
- PACK_UNPACK_ONLY("<<", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLeftShift, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "<<", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 58:
-#line 797 "glslang.y"
- {
- PACK_UNPACK_ONLY(">>", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpRightShift, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, ">>", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 59:
-#line 809 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 60:
-#line 810 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLessThan, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "<", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 61:
-#line 820 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpGreaterThan, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, ">", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 62:
-#line 830 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "<=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 63:
-#line 840 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, ">=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 64:
-#line 853 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 65:
-#line 854 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "==", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 66:
-#line 864 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpNotEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "!=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 67:
-#line 877 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 68:
-#line 878 "glslang.y"
- {
- PACK_UNPACK_ONLY("&", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpAnd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "&", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 69:
-#line 890 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 70:
-#line 891 "glslang.y"
- {
- PACK_UNPACK_ONLY("^", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpExclusiveOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "^", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 71:
-#line 903 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 72:
-#line 904 "glslang.y"
- {
- PACK_UNPACK_ONLY("|", yyvsp[-1].lex.line);
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpInclusiveOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "|", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 73:
-#line 916 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 74:
-#line 917 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "&&", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 75:
-#line 930 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 76:
-#line 931 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalXor, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "^^", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 77:
-#line 944 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 78:
-#line 945 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, "||", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- constUnion *unionArray = new constUnion[1];
- unionArray->bConst = false;
- yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
- }
- ;}
- break;
-
- case 79:
-#line 958 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 80:
-#line 959 "glslang.y"
- {
- if (parseContext.boolErrorCheck(yyvsp[-3].lex.line, yyvsp[-4].interm.intermTypedNode))
- parseContext.recover();
-
- yyval.interm.intermTypedNode = parseContext.intermediate.addSelection(yyvsp[-4].interm.intermTypedNode, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-3].lex.line);
- if (yyvsp[-2].interm.intermTypedNode->getType() != yyvsp[0].interm.intermTypedNode->getType())
- yyval.interm.intermTypedNode = 0;
-
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-3].lex.line, ":", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 81:
-#line 976 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 82:
-#line 977 "glslang.y"
- {
- if (parseContext.lValueErrorCheck(yyvsp[-1].interm.line, "assign", yyvsp[-2].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = parseContext.intermediate.addAssign(yyvsp[-1].interm.op, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].interm.line);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.assignError(yyvsp[-1].interm.line, "assign", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 83:
-#line 990 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAssign; ;}
- break;
-
- case 84:
-#line 991 "glslang.y"
- { FRAG_VERT_ONLY("*=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpMulAssign; ;}
- break;
-
- case 85:
-#line 992 "glslang.y"
- { FRAG_VERT_ONLY("/=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpDivAssign; ;}
- break;
-
- case 86:
-#line 993 "glslang.y"
- { PACK_UNPACK_ONLY("%=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpModAssign; ;}
- break;
-
- case 87:
-#line 994 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAddAssign; ;}
- break;
-
- case 88:
-#line 995 "glslang.y"
- { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpSubAssign; ;}
- break;
-
- case 89:
-#line 996 "glslang.y"
- { PACK_UNPACK_ONLY("<<=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpLeftShiftAssign; ;}
- break;
-
- case 90:
-#line 997 "glslang.y"
- { PACK_UNPACK_ONLY("<<=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpRightShiftAssign; ;}
- break;
-
- case 91:
-#line 998 "glslang.y"
- { PACK_UNPACK_ONLY("&=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAndAssign; ;}
- break;
-
- case 92:
-#line 999 "glslang.y"
- { PACK_UNPACK_ONLY("^=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpExclusiveOrAssign; ;}
- break;
-
- case 93:
-#line 1000 "glslang.y"
- { PACK_UNPACK_ONLY("|=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpInclusiveOrAssign; ;}
- break;
-
- case 94:
-#line 1004 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 95:
-#line 1007 "glslang.y"
- {
- yyval.interm.intermTypedNode = parseContext.intermediate.addComma(yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line);
- if (yyval.interm.intermTypedNode == 0) {
- parseContext.binaryOpError(yyvsp[-1].lex.line, ",", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- }
- ;}
- break;
-
- case 96:
-#line 1018 "glslang.y"
- {
- if (parseContext.constErrorCheck(yyvsp[0].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 97:
-#line 1026 "glslang.y"
- { yyval.interm.intermNode = 0; ;}
- break;
-
- case 98:
-#line 1027 "glslang.y"
- {
- if (yyvsp[-1].interm.intermAggregate)
- yyvsp[-1].interm.intermAggregate->setOperator(EOpSequence);
- yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate;
- ;}
- break;
-
- case 99:
-#line 1035 "glslang.y"
- {
- //
- // Multiple declarations of the same function are allowed.
- //
- // If this is a definition, the definition production code will check for redefinitions
- // (we don't know at this point if it's a definition or not).
- //
- // Redeclarations are allowed. But, return types and parameter qualifiers must match.
- //
- TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(yyvsp[-1].interm.function->getMangledName()));
- if (prevDec) {
- if (prevDec->getReturnType() != yyvsp[-1].interm.function->getReturnType()) {
- parseContext.error(yyvsp[0].lex.line, "overloaded functions must have the same return type", yyvsp[-1].interm.function->getReturnType().getBasicString(), "");
- parseContext.recover();
- }
- for (int i = 0; i < prevDec->getParamCount(); ++i) {
- if ((*prevDec)[i].type->getQualifier() != (*yyvsp[-1].interm.function)[i].type->getQualifier()) {
- parseContext.error(yyvsp[0].lex.line, "overloaded functions must have the same parameter qualifiers", (*yyvsp[-1].interm.function)[i].type->getQualifierString(), "");
- parseContext.recover();
- }
- }
- }
-
- //
- // If this is a redeclaration, it could also be a definition,
- // in which case, we want to use the variable names from this one, and not the one that's
- // being redeclared. So, pass back up this declaration, not the one in the symbol table.
- //
- yyval.interm.function = yyvsp[-1].interm.function;
- yyval.interm.line = yyvsp[0].lex.line;
-
- parseContext.symbolTable.insert(*yyval.interm.function);
- ;}
- break;
-
- case 100:
-#line 1071 "glslang.y"
- {
- yyval.interm.function = yyvsp[0].interm.function;
- ;}
- break;
-
- case 101:
-#line 1074 "glslang.y"
- {
- yyval.interm.function = yyvsp[0].interm.function;
- ;}
- break;
-
- case 102:
-#line 1081 "glslang.y"
- {
- // Add the parameter
- yyval.interm.function = yyvsp[-1].interm.function;
- if (yyvsp[0].interm.param.type->getBasicType() != EbtVoid)
- yyvsp[-1].interm.function->addParameter(yyvsp[0].interm.param);
- else
- delete yyvsp[0].interm.param.type;
- ;}
- break;
-
- case 103:
-#line 1089 "glslang.y"
- {
- //
- // Only first parameter of one-parameter functions can be void
- // The check for named parameters not being void is done in parameter_declarator
- //
- if (yyvsp[0].interm.param.type->getBasicType() == EbtVoid) {
- //
- // This parameter > first is void
- //
- parseContext.error(yyvsp[-1].lex.line, "cannot be an argument type except for '(void)'", "void", "");
- parseContext.recover();
- delete yyvsp[0].interm.param.type;
- } else {
- // Add the parameter
- yyval.interm.function = yyvsp[-2].interm.function;
- yyvsp[-2].interm.function->addParameter(yyvsp[0].interm.param);
- }
- ;}
- break;
-
- case 104:
-#line 1110 "glslang.y"
- {
- if (yyvsp[-2].interm.type.qualifier != EvqGlobal && yyvsp[-2].interm.type.qualifier != EvqTemporary) {
- parseContext.error(yyvsp[-1].lex.line, "no qualifiers allowed for function return", getQualifierString(yyvsp[-2].interm.type.qualifier), "");
- parseContext.recover();
- }
- // make sure a sampler is not involved as well...
- if (parseContext.structQualifierErrorCheck(yyvsp[-1].lex.line, yyvsp[-2].interm.type))
- parseContext.recover();
-
- // Add the function as a prototype after parsing it (we do not support recursion)
- TFunction *function;
- TType type(yyvsp[-2].interm.type);
- function = new TFunction(yyvsp[-1].lex.string, type);
- yyval.interm.function = function;
- ;}
- break;
-
- case 105:
-#line 1129 "glslang.y"
- {
- if (yyvsp[-1].interm.type.type == EbtVoid) {
- parseContext.error(yyvsp[0].lex.line, "illegal use of type 'void'", yyvsp[0].lex.string->c_str(), "");
- parseContext.recover();
- }
- if (parseContext.reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string))
- parseContext.recover();
- TParameter param = {yyvsp[0].lex.string, new TType(yyvsp[-1].interm.type)};
- yyval.interm.line = yyvsp[0].lex.line;
- yyval.interm.param = param;
- ;}
- break;
-
- case 106:
-#line 1140 "glslang.y"
- {
- // Check that we can make an array out of this type
- if (yyvsp[-4].interm.type.array) {
- parseContext.error(yyvsp[-2].lex.line, "cannot declare arrays of this type", TType(yyvsp[-4].interm.type).getCompleteString().c_str(), "");
- parseContext.recover();
- }
- if (parseContext.reservedErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string))
- parseContext.recover();
- yyvsp[-4].interm.type.array = true;
- TType* type = new TType(yyvsp[-4].interm.type);
- if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion())
- type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
- TParameter param = { yyvsp[-3].lex.string, type };
- yyval.interm.line = yyvsp[-3].lex.line;
- yyval.interm.param = param;
- ;}
- break;
-
- case 107:
-#line 1167 "glslang.y"
- {
- yyval.interm = yyvsp[0].interm;
- if (parseContext.paramErrorCheck(yyvsp[0].interm.line, yyvsp[-2].interm.type.qualifier, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
- parseContext.recover();
- ;}
- break;
-
- case 108:
-#line 1172 "glslang.y"
- {
- yyval.interm = yyvsp[0].interm;
- if (parseContext.parameterSamplerErrorCheck(yyvsp[0].interm.line, yyvsp[-1].interm.qualifier, *yyvsp[0].interm.param.type))
- parseContext.recover();
- if (parseContext.paramErrorCheck(yyvsp[0].interm.line, EvqTemporary, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
- parseContext.recover();
- ;}
- break;
-
- case 109:
-#line 1182 "glslang.y"
- {
- yyval.interm = yyvsp[0].interm;
- if (parseContext.paramErrorCheck(yyvsp[0].interm.line, yyvsp[-2].interm.type.qualifier, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
- parseContext.recover();
- ;}
- break;
-
- case 110:
-#line 1187 "glslang.y"
- {
- yyval.interm = yyvsp[0].interm;
- if (parseContext.parameterSamplerErrorCheck(yyvsp[0].interm.line, yyvsp[-1].interm.qualifier, *yyvsp[0].interm.param.type))
- parseContext.recover();
- if (parseContext.paramErrorCheck(yyvsp[0].interm.line, EvqTemporary, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
- parseContext.recover();
- ;}
- break;
-
- case 111:
-#line 1197 "glslang.y"
- {
- yyval.interm.qualifier = EvqIn;
- ;}
- break;
-
- case 112:
-#line 1200 "glslang.y"
- {
- yyval.interm.qualifier = EvqIn;
- ;}
- break;
-
- case 113:
-#line 1203 "glslang.y"
- {
- yyval.interm.qualifier = EvqOut;
- ;}
- break;
-
- case 114:
-#line 1206 "glslang.y"
- {
- yyval.interm.qualifier = EvqInOut;
- ;}
- break;
-
- case 115:
-#line 1212 "glslang.y"
- {
- TParameter param = { 0, new TType(yyvsp[0].interm.type) };
- yyval.interm.param = param;
-
- ;}
- break;
-
- case 116:
-#line 1217 "glslang.y"
- {
- // Check that we can make an array out of this type
- if (yyvsp[-3].interm.type.array) {
- parseContext.error(yyvsp[-2].lex.line, "cannot declare arrays of this type", TType(yyvsp[-3].interm.type).getCompleteString().c_str(), "");
- parseContext.recover();
- }
- yyvsp[-3].interm.type.array = true;
- TType* type = new TType(yyvsp[-3].interm.type);
- if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion())
- type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
-
- TParameter param = { 0, type };
- yyval.interm.line = yyvsp[-2].lex.line;
- yyval.interm.param = param;
- ;}
- break;
-
- case 117:
-#line 1235 "glslang.y"
- {
- yyval.interm = yyvsp[0].interm;
- ;}
- break;
-
- case 118:
-#line 1238 "glslang.y"
- {
- yyval.interm = yyvsp[-2].interm;
- if (parseContext.structQualifierErrorCheck(yyvsp[0].lex.line, yyvsp[-2].interm.type))
- parseContext.recover();
-
- if (parseContext.nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type))
- parseContext.recover();
- ;}
- break;
-
- case 119:
-#line 1246 "glslang.y"
- {
- yyval.interm = yyvsp[-4].interm;
- if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type))
- parseContext.recover();
-
- if (parseContext.arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyval.interm.type, 0))
- parseContext.recover();
- ;}
- break;
-
- case 120:
-#line 1254 "glslang.y"
- {
- yyval.interm = yyvsp[-5].interm;
- if (parseContext.structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-5].interm.type))
- parseContext.recover();
-
- if (parseContext.arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyval.interm.type, yyvsp[-1].interm.intermTypedNode))
- parseContext.recover();
- ;}
- break;
-
- case 121:
-#line 1262 "glslang.y"
- {
- yyval.interm = yyvsp[-4].interm;
- if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type))
- parseContext.recover();
-
- TIntermNode* intermNode;
- if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-4].interm.type, yyvsp[0].interm.intermTypedNode, intermNode)) {
- //
- // build the intermediate representation
- //
- if (intermNode)
- yyval.interm.intermAggregate = parseContext.intermediate.growAggregate(yyvsp[-4].interm.intermNode, intermNode, yyvsp[-1].lex.line);
- else
- yyval.interm.intermAggregate = yyvsp[-4].interm.intermAggregate;
- } else {
- parseContext.recover();
- yyval.interm.intermAggregate = 0;
- }
- ;}
- break;
-
- case 122:
-#line 1284 "glslang.y"
- {
- yyval.interm.type = yyvsp[0].interm.type;
- yyval.interm.intermAggregate = 0;
- ;}
- break;
-
- case 123:
-#line 1288 "glslang.y"
- {
- yyval.interm.intermAggregate = 0;
- yyval.interm.type = yyvsp[-1].interm.type;
- if (parseContext.structQualifierErrorCheck(yyvsp[0].lex.line, yyvsp[-1].interm.type))
- parseContext.recover();
-
- if (parseContext.nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type))
- parseContext.recover();
- ;}
- break;
-
- case 124:
-#line 1297 "glslang.y"
- {
- yyval.interm.intermAggregate = 0;
- yyval.interm.type = yyvsp[-3].interm.type;
- if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
- parseContext.recover();
-
- if (parseContext.arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyval.interm.type, 0))
- parseContext.recover();
- ;}
- break;
-
- case 125:
-#line 1306 "glslang.y"
- {
- yyval.interm.intermAggregate = 0;
- yyval.interm.type = yyvsp[-4].interm.type;
- if (parseContext.structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-4].interm.type))
- parseContext.recover();
-
- if (parseContext.arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyval.interm.type, yyvsp[-1].interm.intermTypedNode))
- parseContext.recover();
- ;}
- break;
-
- case 126:
-#line 1315 "glslang.y"
- {
- yyval.interm.type = yyvsp[-3].interm.type;
- if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
- parseContext.recover();
-
- TIntermNode* intermNode;
- if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type, yyvsp[0].interm.intermTypedNode, intermNode)) {
- //
- // Build intermediate representation
- //
- if (intermNode)
- yyval.interm.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, yyvsp[-1].lex.line);
- else
- yyval.interm.intermAggregate = 0;
- } else {
- parseContext.recover();
- yyval.interm.intermAggregate = 0;
- }
- ;}
- break;
-
- case 127:
-#line 1405 "glslang.y"
- {
- yyval.interm.type = yyvsp[0].interm.type;
- ;}
- break;
-
- case 128:
-#line 1408 "glslang.y"
- {
- TPublicType t = { yyvsp[0].interm.type.type, yyvsp[-1].interm.type.qualifier, yyvsp[0].interm.type.size, yyvsp[0].interm.type.matrix, false, yyvsp[0].interm.type.userDef, 0 };
- if (yyvsp[-1].interm.type.qualifier == EvqAttribute &&
- (yyvsp[0].interm.type.type == EbtBool || yyvsp[0].interm.type.type == EbtInt)) {
- parseContext.error(yyvsp[0].interm.type.line, "cannot be bool or int", getQualifierString(yyvsp[-1].interm.type.qualifier), "");
- parseContext.recover();
- }
- if ((yyvsp[-1].interm.type.qualifier == EvqVaryingIn || yyvsp[-1].interm.type.qualifier == EvqVaryingOut) &&
- (yyvsp[0].interm.type.type == EbtBool || yyvsp[0].interm.type.type == EbtInt)) {
- parseContext.error(yyvsp[0].interm.type.line, "cannot be bool or int", getQualifierString(yyvsp[-1].interm.type.qualifier), "");
- parseContext.recover();
- }
- yyval.interm.type = t;
- ;}
- break;
-
- case 129:
-#line 1425 "glslang.y"
- {
- TPublicType t = { EbtVoid, EvqConst, 1, false, false, 0 };
- yyval.interm.type = t;
- ;}
- break;
-
- case 130:
-#line 1429 "glslang.y"
- {
- VERTEX_ONLY("attribute", yyvsp[0].lex.line);
- if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "attribute"))
- parseContext.recover();
- TPublicType t = { EbtVoid, EvqAttribute, 1, false, false, 0 };
- yyval.interm.type = t;
- ;}
- break;
-
- case 131:
-#line 1436 "glslang.y"
- {
- if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "varying"))
- parseContext.recover();
- TPublicType t = { EbtVoid, EvqVaryingIn, 1, false, false, 0 };
- if (parseContext.language == EShLangVertex)
- t.qualifier = EvqVaryingOut;
- yyval.interm.type = t;
- ;}
- break;
-
- case 132:
-#line 1444 "glslang.y"
- {
- if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "uniform"))
- parseContext.recover();
- TPublicType t = { EbtVoid, EvqUniform, 1, false, false, 0 };
- yyval.interm.type = t;
- ;}
- break;
-
- case 133:
-#line 1453 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtVoid, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 134:
-#line 1458 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 135:
-#line 1463 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtInt, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 136:
-#line 1468 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtBool, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 137:
-#line 1479 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 2, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 138:
-#line 1484 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 3, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 139:
-#line 1489 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 4, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 140:
-#line 1494 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtBool, qual, 2, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 141:
-#line 1499 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtBool, qual, 3, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 142:
-#line 1504 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtBool, qual, 4, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 143:
-#line 1509 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtInt, qual, 2, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 144:
-#line 1514 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtInt, qual, 3, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 145:
-#line 1519 "glslang.y"
- {
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtInt, qual, 4, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 146:
-#line 1524 "glslang.y"
- {
- FRAG_VERT_ONLY("mat2", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 2, true, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 147:
-#line 1530 "glslang.y"
- {
- FRAG_VERT_ONLY("mat3", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 3, true, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 148:
-#line 1536 "glslang.y"
- {
- FRAG_VERT_ONLY("mat4", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtFloat, qual, 4, true, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 149:
-#line 1542 "glslang.y"
- {
- FRAG_VERT_ONLY("sampler1D", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSampler1D, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 150:
-#line 1548 "glslang.y"
- {
- FRAG_VERT_ONLY("sampler2D", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSampler2D, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 151:
-#line 1554 "glslang.y"
- {
- FRAG_VERT_ONLY("sampler3D", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSampler3D, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 152:
-#line 1560 "glslang.y"
- {
- FRAG_VERT_ONLY("samplerCube", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSamplerCube, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 153:
-#line 1566 "glslang.y"
- {
- FRAG_VERT_ONLY("sampler1DShadow", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSampler1DShadow, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 154:
-#line 1572 "glslang.y"
- {
- FRAG_VERT_ONLY("sampler2DShadow", yyvsp[0].lex.line);
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtSampler2DShadow, qual, 1, false, false, 0, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 155:
-#line 1578 "glslang.y"
- {
- FRAG_VERT_ONLY("struct", yyvsp[0].interm.type.line);
- yyval.interm.type = yyvsp[0].interm.type;
- yyval.interm.type.qualifier = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- ;}
- break;
-
- case 156:
-#line 1583 "glslang.y"
- {
- //
- // This is for user defined type names. The lexical phase looked up the
- // type.
- //
- TType& structure = static_cast<TVariable*>(yyvsp[0].lex.symbol)->getType();
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
- TPublicType t = { EbtStruct, qual, 1, false, false, &structure, yyvsp[0].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 157:
-#line 1596 "glslang.y"
- {
- TType* structure = new TType(yyvsp[-1].interm.typeList, *yyvsp[-3].lex.string);
- TVariable* userTypeDef = new TVariable(yyvsp[-3].lex.string, *structure, true);
- if (! parseContext.symbolTable.insert(*userTypeDef)) {
- parseContext.error(yyvsp[-3].lex.line, "redefinition", yyvsp[-3].lex.string->c_str(), "struct");
- parseContext.recover();
- }
- TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, yyvsp[-4].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 158:
-#line 1606 "glslang.y"
- {
- TType* structure = new TType(yyvsp[-1].interm.typeList, TString(""));
- TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, yyvsp[-3].lex.line };
- yyval.interm.type = t;
- ;}
- break;
-
- case 159:
-#line 1614 "glslang.y"
- {
- yyval.interm.typeList = yyvsp[0].interm.typeList;
- ;}
- break;
-
- case 160:
-#line 1617 "glslang.y"
- {
- yyval.interm.typeList = yyvsp[-1].interm.typeList;
- for (unsigned int i = 0; i < yyvsp[0].interm.typeList->size(); ++i) {
- for (unsigned int j = 0; j < yyval.interm.typeList->size(); ++j) {
- if ((*yyval.interm.typeList)[j].type->getFieldName() == (*yyvsp[0].interm.typeList)[i].type->getFieldName()) {
- parseContext.error((*yyvsp[0].interm.typeList)[i].line, "duplicate field name in structure:", "struct", (*yyvsp[0].interm.typeList)[i].type->getFieldName().c_str());
- parseContext.recover();
- }
- }
- yyval.interm.typeList->push_back((*yyvsp[0].interm.typeList)[i]);
- }
- ;}
- break;
-
- case 161:
-#line 1632 "glslang.y"
- {
- yyval.interm.typeList = yyvsp[-1].interm.typeList;
-
- if (parseContext.voidErrorCheck(yyvsp[-2].interm.type.line, (*yyvsp[-1].interm.typeList)[0].type->getFieldName(), yyvsp[-2].interm.type)) {
- parseContext.recover();
- }
- for (unsigned int i = 0; i < yyval.interm.typeList->size(); ++i) {
- //
- // Careful not to replace already know aspects of type, like array-ness
- //
- (*yyval.interm.typeList)[i].type->setType(yyvsp[-2].interm.type.type, yyvsp[-2].interm.type.size, yyvsp[-2].interm.type.matrix, yyvsp[-2].interm.type.userDef);
- if (yyvsp[-2].interm.type.userDef)
- (*yyval.interm.typeList)[i].type->setTypeName(yyvsp[-2].interm.type.userDef->getTypeName());
- }
- ;}
- break;
-
- case 162:
-#line 1650 "glslang.y"
- {
- yyval.interm.typeList = NewPoolTTypeList();
- yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine);
- ;}
- break;
-
- case 163:
-#line 1654 "glslang.y"
- {
- yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine);
- ;}
- break;
-
- case 164:
-#line 1660 "glslang.y"
- {
- yyval.interm.typeLine.type = new TType(EbtVoid);
- yyval.interm.typeLine.line = yyvsp[0].lex.line;
- yyval.interm.typeLine.type->setFieldName(*yyvsp[0].lex.string);
- ;}
- break;
-
- case 165:
-#line 1665 "glslang.y"
- {
- yyval.interm.typeLine.type = new TType(EbtVoid);
- yyval.interm.typeLine.line = yyvsp[-3].lex.line;
- yyval.interm.typeLine.type->setFieldName(*yyvsp[-3].lex.string);
-
- if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion() == 0 || yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getBasicType() != EbtInt ||
- yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst <= 0) {
- parseContext.error(yyvsp[-2].lex.line, "structure field array size must be a positive integer", yyvsp[-3].lex.string->c_str(), "");
- parseContext.recover();
- } else {
- yyval.interm.typeLine.type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
- }
- ;}
- break;
-
- case 166:
-#line 1681 "glslang.y"
- { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
- break;
-
- case 167:
-#line 1685 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 168:
-#line 1689 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermAggregate; ;}
- break;
-
- case 169:
-#line 1690 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 170:
-#line 1696 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 171:
-#line 1697 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 172:
-#line 1698 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 173:
-#line 1699 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 174:
-#line 1700 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 175:
-#line 1704 "glslang.y"
- { yyval.interm.intermAggregate = 0; ;}
- break;
-
- case 176:
-#line 1705 "glslang.y"
- { parseContext.symbolTable.push(); ;}
- break;
-
- case 177:
-#line 1705 "glslang.y"
- { parseContext.symbolTable.pop(); ;}
- break;
-
- case 178:
-#line 1705 "glslang.y"
- {
- if (yyvsp[-2].interm.intermAggregate != 0)
- yyvsp[-2].interm.intermAggregate->setOperator(EOpSequence);
- yyval.interm.intermAggregate = yyvsp[-2].interm.intermAggregate;
- ;}
- break;
-
- case 179:
-#line 1713 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 180:
-#line 1714 "glslang.y"
- { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
- break;
-
- case 181:
-#line 1719 "glslang.y"
- {
- yyval.interm.intermNode = 0;
- ;}
- break;
-
- case 182:
-#line 1722 "glslang.y"
- {
- if (yyvsp[-1].interm.intermAggregate)
- yyvsp[-1].interm.intermAggregate->setOperator(EOpSequence);
- yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate;
- ;}
- break;
-
- case 183:
-#line 1730 "glslang.y"
- {
- yyval.interm.intermAggregate = parseContext.intermediate.makeAggregate(yyvsp[0].interm.intermNode, 0);
- ;}
- break;
-
- case 184:
-#line 1733 "glslang.y"
- {
- yyval.interm.intermAggregate = parseContext.intermediate.growAggregate(yyvsp[-1].interm.intermAggregate, yyvsp[0].interm.intermNode, 0);
- ;}
- break;
-
- case 185:
-#line 1739 "glslang.y"
- { yyval.interm.intermNode = 0; ;}
- break;
-
- case 186:
-#line 1740 "glslang.y"
- { yyval.interm.intermNode = static_cast<TIntermNode*>(yyvsp[-1].interm.intermTypedNode); ;}
- break;
-
- case 187:
-#line 1744 "glslang.y"
- {
- if (parseContext.boolErrorCheck(yyvsp[-4].lex.line, yyvsp[-2].interm.intermTypedNode))
- parseContext.recover();
- yyval.interm.intermNode = parseContext.intermediate.addSelection(yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.nodePair, yyvsp[-4].lex.line);
- ;}
- break;
-
- case 188:
-#line 1752 "glslang.y"
- {
- yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermNode;
- yyval.interm.nodePair.node2 = yyvsp[0].interm.intermNode;
- ;}
- break;
-
- case 189:
-#line 1756 "glslang.y"
- {
- yyval.interm.nodePair.node1 = yyvsp[0].interm.intermNode;
- yyval.interm.nodePair.node2 = 0;
- ;}
- break;
-
- case 190:
-#line 1766 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- if (parseContext.boolErrorCheck(yyvsp[0].interm.intermTypedNode->getLine(), yyvsp[0].interm.intermTypedNode))
- parseContext.recover();
- ;}
- break;
-
- case 191:
-#line 1771 "glslang.y"
- {
- TIntermNode* intermNode;
- if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
- parseContext.recover();
- if (parseContext.boolErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
- parseContext.recover();
-
- if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type, yyvsp[0].interm.intermTypedNode, intermNode))
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- else {
- parseContext.recover();
- yyval.interm.intermTypedNode = 0;
- }
- ;}
- break;
-
- case 192:
-#line 1788 "glslang.y"
- { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; ;}
- break;
-
- case 193:
-#line 1788 "glslang.y"
- {
- parseContext.symbolTable.pop();
- yyval.interm.intermNode = parseContext.intermediate.addLoop(yyvsp[0].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, true, yyvsp[-5].lex.line);
- --parseContext.loopNestingLevel;
- ;}
- break;
-
- case 194:
-#line 1793 "glslang.y"
- { ++parseContext.loopNestingLevel; ;}
- break;
-
- case 195:
-#line 1793 "glslang.y"
- {
- if (parseContext.boolErrorCheck(yyvsp[0].lex.line, yyvsp[-2].interm.intermTypedNode))
- parseContext.recover();
-
- yyval.interm.intermNode = parseContext.intermediate.addLoop(yyvsp[-5].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, false, yyvsp[-4].lex.line);
- --parseContext.loopNestingLevel;
- ;}
- break;
-
- case 196:
-#line 1800 "glslang.y"
- { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; ;}
- break;
-
- case 197:
-#line 1800 "glslang.y"
- {
- parseContext.symbolTable.pop();
- yyval.interm.intermNode = parseContext.intermediate.makeAggregate(yyvsp[-3].interm.intermNode, yyvsp[-5].lex.line);
- yyval.interm.intermNode = parseContext.intermediate.growAggregate(
- yyval.interm.intermNode,
- parseContext.intermediate.addLoop(yyvsp[0].interm.intermNode, reinterpret_cast<TIntermTyped*>(yyvsp[-2].interm.nodePair.node1), reinterpret_cast<TIntermTyped*>(yyvsp[-2].interm.nodePair.node2), true, yyvsp[-6].lex.line),
- yyvsp[-6].lex.line);
- yyval.interm.intermNode->getAsAggregate()->setOperator(EOpSequence);
- --parseContext.loopNestingLevel;
- ;}
- break;
-
- case 198:
-#line 1813 "glslang.y"
- {
- yyval.interm.intermNode = yyvsp[0].interm.intermNode;
- ;}
- break;
-
- case 199:
-#line 1816 "glslang.y"
- {
- yyval.interm.intermNode = yyvsp[0].interm.intermNode;
- ;}
- break;
-
- case 200:
-#line 1822 "glslang.y"
- {
- yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 201:
-#line 1825 "glslang.y"
- {
- yyval.interm.intermTypedNode = 0;
- ;}
- break;
-
- case 202:
-#line 1831 "glslang.y"
- {
- yyval.interm.nodePair.node1 = yyvsp[-1].interm.intermTypedNode;
- yyval.interm.nodePair.node2 = 0;
- ;}
- break;
-
- case 203:
-#line 1835 "glslang.y"
- {
- yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermTypedNode;
- yyval.interm.nodePair.node2 = yyvsp[0].interm.intermTypedNode;
- ;}
- break;
-
- case 204:
-#line 1842 "glslang.y"
- {
- if (parseContext.loopNestingLevel <= 0) {
- parseContext.error(yyvsp[-1].lex.line, "continue statement only allowed in loops", "", "");
- parseContext.recover();
- }
- yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpContinue, yyvsp[-1].lex.line);
- ;}
- break;
-
- case 205:
-#line 1849 "glslang.y"
- {
- if (parseContext.loopNestingLevel <= 0) {
- parseContext.error(yyvsp[-1].lex.line, "break statement only allowed in loops", "", "");
- parseContext.recover();
- }
- yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpBreak, yyvsp[-1].lex.line);
- ;}
- break;
-
- case 206:
-#line 1856 "glslang.y"
- {
- yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpReturn, yyvsp[-1].lex.line);
- if (parseContext.currentFunctionType->getBasicType() != EbtVoid) {
- parseContext.error(yyvsp[-1].lex.line, "non-void function must return a value", "return", "");
- parseContext.recover();
- }
- ;}
- break;
-
- case 207:
-#line 1863 "glslang.y"
- {
- yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpReturn, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
- parseContext.functionReturnsValue = true;
- if (parseContext.currentFunctionType->getBasicType() == EbtVoid) {
- parseContext.error(yyvsp[-2].lex.line, "void function cannot return a value", "return", "");
- parseContext.recover();
- } else if (*(parseContext.currentFunctionType) != yyvsp[-1].interm.intermTypedNode->getType()) {
- parseContext.error(yyvsp[-2].lex.line, "function return is not matching type:", "return", "");
- parseContext.recover();
- }
- ;}
- break;
-
- case 208:
-#line 1874 "glslang.y"
- {
- FRAG_ONLY("discard", yyvsp[-1].lex.line);
- yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpKill, yyvsp[-1].lex.line);
- ;}
- break;
-
- case 209:
-#line 1883 "glslang.y"
- {
- yyval.interm.intermNode = yyvsp[0].interm.intermNode;
- parseContext.treeRoot = yyval.interm.intermNode;
- ;}
- break;
-
- case 210:
-#line 1887 "glslang.y"
- {
- yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-1].interm.intermNode, yyvsp[0].interm.intermNode, 0);
- parseContext.treeRoot = yyval.interm.intermNode;
- ;}
- break;
-
- case 211:
-#line 1894 "glslang.y"
- {
- yyval.interm.intermNode = yyvsp[0].interm.intermNode;
- ;}
- break;
-
- case 212:
-#line 1897 "glslang.y"
- {
- yyval.interm.intermNode = yyvsp[0].interm.intermNode;
- ;}
- break;
-
- case 213:
-#line 1903 "glslang.y"
- {
- TFunction& function = *(yyvsp[0].interm.function);
- TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(function.getMangledName()));
- //
- // Note: 'prevDec' could be 'function' if this is the first time we've seen function
- // as it would have just been put in the symbol table. Otherwise, we're looking up
- // an earlier occurance.
- //
- if (prevDec->isDefined()) {
- //
- // Then this function already has a body.
- //
- parseContext.error(yyvsp[0].interm.line, "function already has a body", function.getName().c_str(), "");
- parseContext.recover();
- }
- prevDec->setDefined();
-
- //
- // Raise error message if main function takes any parameters or return anything other than void
- //
- if (function.getName() == "main") {
- if (function.getParamCount() > 0) {
- parseContext.error(yyvsp[0].interm.line, "function cannot take any parameter(s)", function.getName().c_str(), "");
- parseContext.recover();
- }
- if (function.getReturnType().getBasicType() != EbtVoid) {
- parseContext.error(yyvsp[0].interm.line, "", function.getReturnType().getBasicString(), "main function cannot return a value" );
- parseContext.recover();
- }
- }
-
- //
- // New symbol table scope for body of function plus its arguments
- //
- parseContext.symbolTable.push();
-
- //
- // Remember the return type for later checking for RETURN statements.
- //
- parseContext.currentFunctionType = &(prevDec->getReturnType());
- parseContext.functionReturnsValue = false;
-
- //
- // Insert parameters into the symbol table.
- // If the parameter has no name, it's not an error, just don't insert it
- // (could be used for unused args).
- //
- // Also, accumulate the list of parameters into the HIL, so lower level code
- // knows where to find parameters.
- //
- TIntermAggregate* paramNodes = new TIntermAggregate;
- for (int i = 0; i < function.getParamCount(); i++) {
- TParameter& param = function[i];
- if (param.name != 0) {
- TVariable *variable = new TVariable(param.name, *param.type);
- //
- // Insert the parameters with name in the symbol table.
- //
- if (! parseContext.symbolTable.insert(*variable)) {
- parseContext.error(yyvsp[0].interm.line, "redefinition", variable->getName().c_str(), "");
- parseContext.recover();
- delete variable;
- }
- //
- // Transfer ownership of name pointer to symbol table.
- //
- param.name = 0;
-
- //
- // Add the parameter to the HIL
- //
- paramNodes = parseContext.intermediate.growAggregate(
- paramNodes,
- parseContext.intermediate.addSymbol(variable->getUniqueId(),
- variable->getName(),
- variable->getType(), yyvsp[0].interm.line),
- yyvsp[0].interm.line);
- } else {
- paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, yyvsp[0].interm.line), yyvsp[0].interm.line);
- }
- }
- parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, yyvsp[0].interm.line);
- yyvsp[0].interm.intermAggregate = paramNodes;
- parseContext.loopNestingLevel = 0;
- ;}
- break;
-
- case 214:
-#line 1988 "glslang.y"
- {
- //?? Check that all paths return a value if return type != void ?
- // May be best done as post process phase on intermediate code
- if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) {
- parseContext.error(yyvsp[-2].interm.line, "function does not return a value:", "", yyvsp[-2].interm.function->getName().c_str());
- parseContext.recover();
- }
- parseContext.symbolTable.pop();
- yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-2].interm.intermAggregate, yyvsp[0].interm.intermNode, 0);
- parseContext.intermediate.setAggregateOperator(yyval.interm.intermNode, EOpFunction, yyvsp[-2].interm.line);
- yyval.interm.intermNode->getAsAggregate()->setName(yyvsp[-2].interm.function->getMangledName().c_str());
- yyval.interm.intermNode->getAsAggregate()->setType(yyvsp[-2].interm.function->getReturnType());
-
- // store the pragma information for debug and optimize and other vendor specific
- // information. This information can be queried from the parse tree
- yyval.interm.intermNode->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
- yyval.interm.intermNode->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
- yyval.interm.intermNode->getAsAggregate()->addToPragmaTable(parseContext.contextPragma.pragmaTable);
- ;}
- break;
-
-
- }
-
-/* Line 999 of yacc.c. */
-#line 4158 "glslang.tab.c"
-\f
- yyvsp -= yylen;
- yyssp -= yylen;
-
-
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (YYPACT_NINF < yyn && yyn < YYLAST)
- {
- YYSIZE_T yysize = 0;
- int yytype = YYTRANSLATE (yychar);
- char *yymsg;
- int yyx, yycount;
-
- yycount = 0;
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- yysize += yystrlen (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("syntax error, unexpected ") + 1;
- yysize += yystrlen (yytname[yytype]);
- yymsg = (char *) YYSTACK_ALLOC (yysize);
- if (yymsg != 0)
- {
- char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
- yyp = yystpcpy (yyp, yytname[yytype]);
-
- if (yycount < 5)
- {
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
- yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
- }
- }
- yyerror (yymsg);
- YYSTACK_FREE (yymsg);
- }
- else
- yyerror ("syntax error; also virtual memory exhausted");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror ("syntax error");
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- {
- /* Pop the error token. */
- YYPOPSTACK;
- /* Pop the rest of the stack. */
- while (yyss < yyssp)
- {
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[*yyssp], yyvsp);
- YYPOPSTACK;
- }
- YYABORT;
- }
-
- YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval);
- yychar = YYEMPTY;
-
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*----------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action. |
-`----------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[yystate], yyvsp);
- yyvsp--;
- yystate = *--yyssp;
-
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- YYDPRINTF ((stderr, "Shifting error token, "));
-
- *++yyvsp = yylval;
-
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*----------------------------------------------.
-| yyoverflowlab -- parser overflow comes here. |
-`----------------------------------------------*/
-yyoverflowlab:
- yyerror ("parser stack overflow");
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
- return yyresult;
-}
-
-
-#line 209 "glslang.y"
-
-
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "Include/InfoSink.h"\r
-\r
-#ifdef _WIN32\r
- #include <windows.h>\r
-#endif\r
-\r
-void TInfoSinkBase::append(const char *s) \r
-{\r
- if (outputStream & EString) {\r
- checkMem(strlen(s)); \r
- sink.append(s); \r
- }\r
-\r
-#ifdef _WIN32\r
- if (outputStream & EDebugger)\r
- OutputDebugString(s);\r
-#endif\r
-\r
- if (outputStream & EStdOut)\r
- fprintf(stdout, "%s", s);\r
-}\r
-\r
-void TInfoSinkBase::append(int count, char c) \r
-{ \r
- if (outputStream & EString) {\r
- checkMem(count); \r
- sink.append(count, c); \r
- }\r
-\r
-#ifdef _WIN32\r
- if (outputStream & EDebugger) {\r
- char str[2];\r
- str[0] = c;\r
- str[1] = '\0';\r
- OutputDebugString(str);\r
- }\r
-#endif\r
-\r
- if (outputStream & EStdOut)\r
- fprintf(stdout, "%c", c);\r
-}\r
-\r
-void TInfoSinkBase::append(const TPersistString& t) \r
-{ \r
- if (outputStream & EString) {\r
- checkMem(t.size()); \r
- sink.append(t); \r
- }\r
-\r
-#ifdef _WIN32\r
- if (outputStream & EDebugger)\r
- OutputDebugString(t.c_str());\r
-#endif\r
-\r
- if (outputStream & EStdOut)\r
- fprintf(stdout, "%s", t.c_str());\r
-}\r
-\r
-void TInfoSinkBase::append(const TString& t)\r
-{ \r
- if (outputStream & EString) {\r
- checkMem(t.size()); \r
- sink.append(t.c_str()); \r
- }\r
-\r
-#ifdef _WIN32\r
- if (outputStream & EDebugger)\r
- OutputDebugString(t.c_str());\r
-#endif\r
-\r
- if (outputStream & EStdOut)\r
- fprintf(stdout, "%s", t.c_str());\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// Create strings that declare built-in definitions, add built-ins that\r
-// cannot be expressed in the files, and establish mappings between \r
-// built-in functions and operators.\r
-//\r
-\r
-#include "../Include/intermediate.h"\r
-#include "Initialize.h"\r
-\r
-void TBuiltIns::initialize()\r
-{\r
- //\r
- // Initialize all the built-in strings for parsing.\r
- //\r
- TString BuiltInFunctions;\r
- TString BuiltInFunctionsVertex;\r
- TString BuiltInFunctionsFragment;\r
- TString StandardVertexVaryings;\r
- TString StandardFragmentVaryings;\r
- TString StandardVertexAttributes;\r
- TString StandardUniforms;\r
-\r
- {\r
- //============================================================================\r
- //\r
- // Prototypes for built-in functions seen by both vertex and fragment shaders.\r
- //\r
- //============================================================================\r
-\r
- TString& s = BuiltInFunctions;\r
-\r
- //\r
- // Angle and Trigonometric Functions.\r
- //\r
- s.append(TString("float radians(float degrees);"));\r
- s.append(TString("vec2 radians(vec2 degrees);"));\r
- s.append(TString("vec3 radians(vec3 degrees);"));\r
- s.append(TString("vec4 radians(vec4 degrees);"));\r
-\r
- s.append(TString("float degrees(float radians);"));\r
- s.append(TString("vec2 degrees(vec2 radians);"));\r
- s.append(TString("vec3 degrees(vec3 radians);"));\r
- s.append(TString("vec4 degrees(vec4 radians);"));\r
-\r
- s.append(TString("float sin(float angle);"));\r
- s.append(TString("vec2 sin(vec2 angle);"));\r
- s.append(TString("vec3 sin(vec3 angle);"));\r
- s.append(TString("vec4 sin(vec4 angle);"));\r
-\r
- s.append(TString("float cos(float angle);"));\r
- s.append(TString("vec2 cos(vec2 angle);"));\r
- s.append(TString("vec3 cos(vec3 angle);"));\r
- s.append(TString("vec4 cos(vec4 angle);"));\r
-\r
- s.append(TString("float tan(float angle);"));\r
- s.append(TString("vec2 tan(vec2 angle);"));\r
- s.append(TString("vec3 tan(vec3 angle);"));\r
- s.append(TString("vec4 tan(vec4 angle);"));\r
-\r
- s.append(TString("float asin(float x);"));\r
- s.append(TString("vec2 asin(vec2 x);"));\r
- s.append(TString("vec3 asin(vec3 x);"));\r
- s.append(TString("vec4 asin(vec4 x);"));\r
-\r
- s.append(TString("float acos(float x);"));\r
- s.append(TString("vec2 acos(vec2 x);"));\r
- s.append(TString("vec3 acos(vec3 x);"));\r
- s.append(TString("vec4 acos(vec4 x);"));\r
-\r
- s.append(TString("float atan(float y, float x);"));\r
- s.append(TString("vec2 atan(vec2 y, vec2 x);"));\r
- s.append(TString("vec3 atan(vec3 y, vec3 x);"));\r
- s.append(TString("vec4 atan(vec4 y, vec4 x);"));\r
-\r
- s.append(TString("float atan(float y_over_x);"));\r
- s.append(TString("vec2 atan(vec2 y_over_x);"));\r
- s.append(TString("vec3 atan(vec3 y_over_x);"));\r
- s.append(TString("vec4 atan(vec4 y_over_x);"));\r
-\r
- //\r
- // Exponential Functions.\r
- //\r
- s.append(TString("float pow(float x, float y);"));\r
- s.append(TString("vec2 pow(vec2 x, vec2 y);"));\r
- s.append(TString("vec3 pow(vec3 x, vec3 y);"));\r
- s.append(TString("vec4 pow(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("float exp(float x);"));\r
- s.append(TString("vec2 exp(vec2 x);"));\r
- s.append(TString("vec3 exp(vec3 x);"));\r
- s.append(TString("vec4 exp(vec4 x);"));\r
-\r
- s.append(TString("float log(float x);"));\r
- s.append(TString("vec2 log(vec2 x);"));\r
- s.append(TString("vec3 log(vec3 x);"));\r
- s.append(TString("vec4 log(vec4 x);"));\r
-\r
- s.append(TString("float exp2(float x);"));\r
- s.append(TString("vec2 exp2(vec2 x);"));\r
- s.append(TString("vec3 exp2(vec3 x);"));\r
- s.append(TString("vec4 exp2(vec4 x);"));\r
-\r
- s.append(TString("float log2(float x);"));\r
- s.append(TString("vec2 log2(vec2 x);"));\r
- s.append(TString("vec3 log2(vec3 x);"));\r
- s.append(TString("vec4 log2(vec4 x);"));\r
-\r
- s.append(TString("float sqrt(float x);"));\r
- s.append(TString("vec2 sqrt(vec2 x);"));\r
- s.append(TString("vec3 sqrt(vec3 x);"));\r
- s.append(TString("vec4 sqrt(vec4 x);"));\r
-\r
- s.append(TString("float inversesqrt(float x);"));\r
- s.append(TString("vec2 inversesqrt(vec2 x);"));\r
- s.append(TString("vec3 inversesqrt(vec3 x);"));\r
- s.append(TString("vec4 inversesqrt(vec4 x);"));\r
-\r
- //\r
- // Common Functions.\r
- //\r
- s.append(TString("float abs(float x);"));\r
- s.append(TString("vec2 abs(vec2 x);"));\r
- s.append(TString("vec3 abs(vec3 x);"));\r
- s.append(TString("vec4 abs(vec4 x);"));\r
-\r
- s.append(TString("float sign(float x);"));\r
- s.append(TString("vec2 sign(vec2 x);"));\r
- s.append(TString("vec3 sign(vec3 x);"));\r
- s.append(TString("vec4 sign(vec4 x);"));\r
-\r
- s.append(TString("float floor(float x);"));\r
- s.append(TString("vec2 floor(vec2 x);"));\r
- s.append(TString("vec3 floor(vec3 x);"));\r
- s.append(TString("vec4 floor(vec4 x);"));\r
-\r
- s.append(TString("float ceil(float x);"));\r
- s.append(TString("vec2 ceil(vec2 x);"));\r
- s.append(TString("vec3 ceil(vec3 x);"));\r
- s.append(TString("vec4 ceil(vec4 x);"));\r
-\r
- s.append(TString("float fract(float x);"));\r
- s.append(TString("vec2 fract(vec2 x);"));\r
- s.append(TString("vec3 fract(vec3 x);"));\r
- s.append(TString("vec4 fract(vec4 x);"));\r
-\r
- s.append(TString("float mod(float x, float y);"));\r
- s.append(TString("vec2 mod(vec2 x, float y);"));\r
- s.append(TString("vec3 mod(vec3 x, float y);"));\r
- s.append(TString("vec4 mod(vec4 x, float y);"));\r
- s.append(TString("vec2 mod(vec2 x, vec2 y);"));\r
- s.append(TString("vec3 mod(vec3 x, vec3 y);"));\r
- s.append(TString("vec4 mod(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("float min(float x, float y);"));\r
- s.append(TString("vec2 min(vec2 x, float y);"));\r
- s.append(TString("vec3 min(vec3 x, float y);"));\r
- s.append(TString("vec4 min(vec4 x, float y);"));\r
- s.append(TString("vec2 min(vec2 x, vec2 y);"));\r
- s.append(TString("vec3 min(vec3 x, vec3 y);"));\r
- s.append(TString("vec4 min(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("float max(float x, float y);"));\r
- s.append(TString("vec2 max(vec2 x, float y);"));\r
- s.append(TString("vec3 max(vec3 x, float y);"));\r
- s.append(TString("vec4 max(vec4 x, float y);"));\r
- s.append(TString("vec2 max(vec2 x, vec2 y);"));\r
- s.append(TString("vec3 max(vec3 x, vec3 y);"));\r
- s.append(TString("vec4 max(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("float clamp(float x, float minVal, float maxVal);"));\r
- s.append(TString("vec2 clamp(vec2 x, float minVal, float maxVal);"));\r
- s.append(TString("vec3 clamp(vec3 x, float minVal, float maxVal);"));\r
- s.append(TString("vec4 clamp(vec4 x, float minVal, float maxVal);"));\r
- s.append(TString("vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);"));\r
- s.append(TString("vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);"));\r
- s.append(TString("vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);"));\r
-\r
- s.append(TString("float mix(float x, float y, float a);"));\r
- s.append(TString("vec2 mix(vec2 x, vec2 y, float a);"));\r
- s.append(TString("vec3 mix(vec3 x, vec3 y, float a);"));\r
- s.append(TString("vec4 mix(vec4 x, vec4 y, float a);"));\r
- s.append(TString("vec2 mix(vec2 x, vec2 y, vec2 a);"));\r
- s.append(TString("vec3 mix(vec3 x, vec3 y, vec3 a);"));\r
- s.append(TString("vec4 mix(vec4 x, vec4 y, vec4 a);"));\r
-\r
- s.append(TString("float step(float edge, float x);"));\r
- s.append(TString("vec2 step(vec2 edge, vec2 x);"));\r
- s.append(TString("vec3 step(vec3 edge, vec3 x);"));\r
- s.append(TString("vec4 step(vec4 edge, vec4 x);"));\r
- s.append(TString("vec2 step(float edge, vec2 x);"));\r
- s.append(TString("vec3 step(float edge, vec3 x);"));\r
- s.append(TString("vec4 step(float edge, vec4 x);"));\r
-\r
- s.append(TString("float smoothstep(float edge0, float edge1, float x);"));\r
- s.append(TString("vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);"));\r
- s.append(TString("vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);"));\r
- s.append(TString("vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);"));\r
- s.append(TString("vec2 smoothstep(float edge0, float edge1, vec2 x);"));\r
- s.append(TString("vec3 smoothstep(float edge0, float edge1, vec3 x);"));\r
- s.append(TString("vec4 smoothstep(float edge0, float edge1, vec4 x);"));\r
-\r
- //\r
- // Geometric Functions.\r
- //\r
- s.append(TString("float length(float x);"));\r
- s.append(TString("float length(vec2 x);"));\r
- s.append(TString("float length(vec3 x);"));\r
- s.append(TString("float length(vec4 x);"));\r
-\r
- s.append(TString("float distance(float p0, float p1);"));\r
- s.append(TString("float distance(vec2 p0, vec2 p1);"));\r
- s.append(TString("float distance(vec3 p0, vec3 p1);"));\r
- s.append(TString("float distance(vec4 p0, vec4 p1);"));\r
-\r
- s.append(TString("float dot(float x, float y);"));\r
- s.append(TString("float dot(vec2 x, vec2 y);"));\r
- s.append(TString("float dot(vec3 x, vec3 y);"));\r
- s.append(TString("float dot(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("vec3 cross(vec3 x, vec3 y);"));\r
- s.append(TString("float normalize(float x);"));\r
- s.append(TString("vec2 normalize(vec2 x);"));\r
- s.append(TString("vec3 normalize(vec3 x);"));\r
- s.append(TString("vec4 normalize(vec4 x);"));\r
-\r
- s.append(TString("float faceforward(float N, float I, float Nref);"));\r
- s.append(TString("vec2 faceforward(vec2 N, vec2 I, vec2 Nref);"));\r
- s.append(TString("vec3 faceforward(vec3 N, vec3 I, vec3 Nref);"));\r
- s.append(TString("vec4 faceforward(vec4 N, vec4 I, vec4 Nref);"));\r
-\r
- s.append(TString("float reflect(float I, float N);"));\r
- s.append(TString("vec2 reflect(vec2 I, vec2 N);"));\r
- s.append(TString("vec3 reflect(vec3 I, vec3 N);"));\r
- s.append(TString("vec4 reflect(vec4 I, vec4 N);"));\r
-\r
- s.append(TString("float refract(float I, float N, float eta);"));\r
- s.append(TString("vec2 refract(vec2 I, vec2 N, float eta);"));\r
- s.append(TString("vec3 refract(vec3 I, vec3 N, float eta);"));\r
- s.append(TString("vec4 refract(vec4 I, vec4 N, float eta);"));\r
-\r
- //\r
- // Matrix Functions.\r
- //\r
- s.append(TString("mat2 matrixCompMult(mat2 x, mat2 y);"));\r
- s.append(TString("mat3 matrixCompMult(mat3 x, mat3 y);"));\r
- s.append(TString("mat4 matrixCompMult(mat4 x, mat4 y);"));\r
-\r
- //\r
- // Vector relational functions.\r
- //\r
- s.append(TString("bvec2 lessThan(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 lessThan(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 lessThan(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 lessThan(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 lessThan(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 lessThan(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 lessThanEqual(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 lessThanEqual(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 lessThanEqual(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 lessThanEqual(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 lessThanEqual(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 lessThanEqual(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 greaterThan(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 greaterThan(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 greaterThan(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 greaterThan(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 greaterThan(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 greaterThan(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 greaterThanEqual(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 greaterThanEqual(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 greaterThanEqual(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 greaterThanEqual(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 greaterThanEqual(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 greaterThanEqual(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 equal(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 equal(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 equal(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 equal(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 equal(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 equal(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 equal(bvec2 x, bvec2 y);"));\r
- s.append(TString("bvec3 equal(bvec3 x, bvec3 y);"));\r
- s.append(TString("bvec4 equal(bvec4 x, bvec4 y);"));\r
-\r
- s.append(TString("bvec2 notEqual(vec2 x, vec2 y);"));\r
- s.append(TString("bvec3 notEqual(vec3 x, vec3 y);"));\r
- s.append(TString("bvec4 notEqual(vec4 x, vec4 y);"));\r
-\r
- s.append(TString("bvec2 notEqual(ivec2 x, ivec2 y);"));\r
- s.append(TString("bvec3 notEqual(ivec3 x, ivec3 y);"));\r
- s.append(TString("bvec4 notEqual(ivec4 x, ivec4 y);"));\r
-\r
- s.append(TString("bvec2 notEqual(bvec2 x, bvec2 y);"));\r
- s.append(TString("bvec3 notEqual(bvec3 x, bvec3 y);"));\r
- s.append(TString("bvec4 notEqual(bvec4 x, bvec4 y);"));\r
-\r
- s.append(TString("bool any(bvec2 x);"));\r
- s.append(TString("bool any(bvec3 x);"));\r
- s.append(TString("bool any(bvec4 x);"));\r
-\r
- s.append(TString("bool all(bvec2 x);"));\r
- s.append(TString("bool all(bvec3 x);"));\r
- s.append(TString("bool all(bvec4 x);"));\r
-\r
- s.append(TString("bvec2 not(bvec2 x);"));\r
- s.append(TString("bvec3 not(bvec3 x);"));\r
- s.append(TString("bvec4 not(bvec4 x);"));\r
-\r
- //\r
- // Texture Functions.\r
- //\r
- s.append(TString("vec4 texture1D(sampler1D sampler, float coord);"));\r
- s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);"));\r
- s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);"));\r
-\r
- s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));\r
- s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));\r
- s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));\r
-\r
- s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);"));\r
- s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);"));\r
-\r
- s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));\r
-\r
- s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);"));\r
-\r
- s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);"));\r
-\r
- s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);"));\r
-\r
- s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);"));\r
-\r
-\r
- //\r
- // Noise functions.\r
- //\r
- s.append(TString("float noise1(float x);"));\r
- s.append(TString("float noise1(vec2 x);"));\r
- s.append(TString("float noise1(vec3 x);"));\r
- s.append(TString("float noise1(vec4 x);"));\r
-\r
- s.append(TString("vec2 noise2(float x);"));\r
- s.append(TString("vec2 noise2(vec2 x);"));\r
- s.append(TString("vec2 noise2(vec3 x);"));\r
- s.append(TString("vec2 noise2(vec4 x);"));\r
-\r
- s.append(TString("vec3 noise3(float x);"));\r
- s.append(TString("vec3 noise3(vec2 x);"));\r
- s.append(TString("vec3 noise3(vec3 x);"));\r
- s.append(TString("vec3 noise3(vec4 x);"));\r
-\r
- s.append(TString("vec4 noise4(float x);"));\r
- s.append(TString("vec4 noise4(vec2 x);"));\r
- s.append(TString("vec4 noise4(vec3 x);"));\r
- s.append(TString("vec4 noise4(vec4 x);"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Prototypes for built-in functions seen by vertex shaders only.\r
- //\r
- //============================================================================\r
-\r
- TString& s = BuiltInFunctionsVertex;\r
-\r
- //\r
- // Geometric Functions.\r
- //\r
- s.append(TString("vec4 ftransform();"));\r
-\r
- //\r
- // Texture Functions.\r
- //\r
- s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));\r
- s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));\r
- s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));\r
-\r
- s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));\r
- s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));\r
- s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));\r
-\r
- s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));\r
- s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));\r
- s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));\r
-\r
- s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));\r
- s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));\r
- s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));\r
- s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Prototypes for built-in functions seen by fragment shaders only.\r
- //\r
- //============================================================================\r
-\r
- TString& s = BuiltInFunctionsFragment;\r
-\r
- //\r
- // Texture Functions.\r
- //\r
- s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));\r
- s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));\r
- s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));\r
-\r
- s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));\r
- s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));\r
- s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));\r
-\r
- s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));\r
- s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));\r
- s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));\r
- \r
- s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));\r
- s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));\r
- s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));\r
- s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));\r
-\r
- s.append(TString("float dFdx(float p);"));\r
- s.append(TString("vec2 dFdx(vec2 p);"));\r
- s.append(TString("vec3 dFdx(vec3 p);"));\r
- s.append(TString("vec4 dFdx(vec4 p);"));\r
-\r
- s.append(TString("float dFdy(float p);"));\r
- s.append(TString("vec2 dFdy(vec2 p);"));\r
- s.append(TString("vec3 dFdy(vec3 p);"));\r
- s.append(TString("vec4 dFdy(vec4 p);"));\r
-\r
- s.append(TString("float fwidth(float p);"));\r
- s.append(TString("vec2 fwidth(vec2 p);"));\r
- s.append(TString("vec3 fwidth(vec3 p);"));\r
- s.append(TString("vec4 fwidth(vec4 p);"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Standard Uniforms\r
- //\r
- //============================================================================\r
-\r
- TString& s = StandardUniforms;\r
- \r
-\r
- //\r
- // OpenGL'uniform' state. Page numbers are in reference to version\r
- // 1.4 of the OpenGL specification.\r
- //\r
-\r
- //\r
- // Matrix state. p. 31, 32, 37, 39, 40.\r
- //\r
- s.append(TString("uniform mat4 gl_ModelViewMatrix;"));\r
- s.append(TString("uniform mat4 gl_ProjectionMatrix;"));\r
- s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;"));\r
-\r
- //\r
- // Derived matrix state that provides inverse and transposed versions\r
- // of the matrices above.\r
- //\r
- s.append(TString("uniform mat3 gl_NormalMatrix;"));\r
-\r
- s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));\r
- s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));\r
- s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;"));\r
-\r
- s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;"));\r
- s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;"));\r
- s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;"));\r
-\r
- s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;"));\r
- s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;"));\r
- s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));\r
-\r
- //\r
- // Normal scaling p. 39.\r
- //\r
- s.append(TString("uniform float gl_NormalScale;"));\r
-\r
- //\r
- // Depth range in window coordinates, p. 33\r
- //\r
- s.append(TString("struct gl_DepthRangeParameters {"));\r
- s.append(TString(" float near;")); // n\r
- s.append(TString(" float far;")); // f\r
- s.append(TString(" float diff;")); // f - n\r
- s.append(TString("};"));\r
- s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));\r
-\r
-\r
- //\r
- // Point Size, p. 66, 67.\r
- //\r
- s.append(TString("struct gl_PointParameters {"));\r
- s.append(TString(" float size;"));\r
- s.append(TString(" float sizeMin;"));\r
- s.append(TString(" float sizeMax;"));\r
- s.append(TString(" float fadeThresholdSize;"));\r
- s.append(TString(" float distanceConstantAttenuation;"));\r
- s.append(TString(" float distanceLinearAttenuation;"));\r
- s.append(TString(" float distanceQuadraticAttenuation;"));\r
- s.append(TString("};"));\r
- \r
- s.append(TString("uniform gl_PointParameters gl_Point;"));\r
-\r
- //\r
- // Material State p. 50, 55.\r
- //\r
- s.append(TString("struct gl_MaterialParameters {"));\r
- s.append(TString(" vec4 emission;")); // Ecm\r
- s.append(TString(" vec4 ambient;")); // Acm\r
- s.append(TString(" vec4 diffuse;")); // Dcm\r
- s.append(TString(" vec4 specular;")); // Scm\r
- s.append(TString(" float shininess;")); // Srm\r
- s.append(TString("};"));\r
- s.append(TString("uniform gl_MaterialParameters gl_FrontMaterial;"));\r
- s.append(TString("uniform gl_MaterialParameters gl_BackMaterial;"));\r
-\r
- //\r
- // Light State p 50, 53, 55.\r
- //\r
-\r
- s.append(TString("struct gl_LightSourceParameters {"));\r
- s.append(TString(" vec4 ambient;")); // Acli\r
- s.append(TString(" vec4 diffuse;")); // Dcli\r
- s.append(TString(" vec4 specular;")); // Scli\r
- s.append(TString(" vec4 position;")); // Ppli\r
- s.append(TString(" vec4 halfVector;")); // Derived: Hi\r
- s.append(TString(" vec3 spotDirection;")); // Sdli\r
- s.append(TString(" float spotExponent;")); // Srli\r
- s.append(TString(" float spotCutoff;")); // Crli\r
- // (range: [0.0,90.0], 180.0)\r
- s.append(TString(" float spotCosCutoff;")); // Derived: cos(Crli)\r
- // (range: [1.0,0.0],-1.0)\r
- s.append(TString(" float constantAttenuation;")); // K0\r
- s.append(TString(" float linearAttenuation;")); // K1\r
- s.append(TString(" float quadraticAttenuation;"));// K2\r
- s.append(TString("};"));\r
-\r
-\r
- s.append(TString("struct gl_LightModelParameters {"));\r
- s.append(TString(" vec4 ambient;")); // Acs\r
- s.append(TString("};"));\r
-\r
- s.append(TString("uniform gl_LightModelParameters gl_LightModel;"));\r
-\r
- //\r
- // Derived state from products of light and material.\r
- //\r
-\r
- s.append(TString("struct gl_LightModelProducts {"));\r
- s.append(TString(" vec4 sceneColor;")); // Derived. Ecm + Acm * Acs\r
- s.append(TString("};"));\r
-\r
- s.append(TString("uniform gl_LightModelProducts gl_FrontLightModelProduct;"));\r
- s.append(TString("uniform gl_LightModelProducts gl_BackLightModelProduct;"));\r
-\r
- s.append(TString("struct gl_LightProducts {"));\r
- s.append(TString(" vec4 ambient;")); // Acm * Acli\r
- s.append(TString(" vec4 diffuse;")); // Dcm * Dcli\r
- s.append(TString(" vec4 specular;")); // Scm * Scli\r
- s.append(TString("};"));\r
-\r
-\r
-\r
-\r
- //\r
- // Fog p. 161\r
- //\r
- s.append(TString("struct gl_FogParameters {"));\r
- s.append(TString(" vec4 color;"));\r
- s.append(TString(" float density;"));\r
- s.append(TString(" float start;"));\r
- s.append(TString(" float end;"));\r
- s.append(TString(" float scale;")); // 1 / (gl_FogEnd - gl_FogStart)\r
- s.append(TString("};"));\r
- \r
- s.append(TString("uniform gl_FogParameters gl_Fog;"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Vertex attributes, p. 19.\r
- //\r
- //============================================================================\r
-\r
- TString& s = StandardVertexAttributes;\r
-\r
- s.append(TString("attribute vec4 gl_Color;"));\r
- s.append(TString("attribute vec4 gl_SecondaryColor;"));\r
- s.append(TString("attribute vec3 gl_Normal;"));\r
- s.append(TString("attribute vec4 gl_Vertex;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord0;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord1;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord2;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord3;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord4;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord5;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord6;"));\r
- s.append(TString("attribute vec4 gl_MultiTexCoord7;"));\r
- s.append(TString("attribute float gl_FogCoord;"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Define the output varying interface from the vertex shader.\r
- //\r
- //============================================================================\r
-\r
- TString& s = StandardVertexVaryings;\r
-\r
- s.append(TString("varying vec4 gl_FrontColor;"));\r
- s.append(TString("varying vec4 gl_BackColor;"));\r
- s.append(TString("varying vec4 gl_FrontSecondaryColor;"));\r
- s.append(TString("varying vec4 gl_BackSecondaryColor;"));\r
- s.append(TString("varying vec4 gl_TexCoord[];"));\r
- s.append(TString("varying float gl_FogFragCoord;"));\r
-\r
- s.append(TString("\n"));\r
- }\r
- {\r
- //============================================================================\r
- //\r
- // Define the input varying interface to the fragment shader.\r
- //\r
- //============================================================================\r
-\r
- TString& s = StandardFragmentVaryings;\r
-\r
- s.append(TString("varying vec4 gl_Color;"));\r
- s.append(TString("varying vec4 gl_SecondaryColor;"));\r
- s.append(TString("varying vec4 gl_TexCoord[];"));\r
- s.append(TString("varying float gl_FogFragCoord;"));\r
-\r
- s.append(TString("\n"));\r
- }\r
-\r
- builtInStrings[EShLangFragment].push_back(BuiltInFunctions.c_str());\r
- builtInStrings[EShLangFragment].push_back(BuiltInFunctionsFragment);\r
- builtInStrings[EShLangFragment].push_back(StandardUniforms);\r
- builtInStrings[EShLangFragment].push_back(StandardFragmentVaryings);\r
-\r
- builtInStrings[EShLangVertex].push_back(BuiltInFunctions);\r
- builtInStrings[EShLangVertex].push_back(BuiltInFunctionsVertex);\r
- builtInStrings[EShLangVertex].push_back(StandardVertexVaryings);\r
- builtInStrings[EShLangVertex].push_back(StandardVertexAttributes);\r
- builtInStrings[EShLangVertex].push_back(StandardUniforms);\r
-}\r
-\r
-\r
-void TBuiltIns::initialize(const TBuiltInResource &resources)\r
-{\r
- //\r
- // Initialize all the built-in strings for parsing.\r
- //\r
- TString StandardUniforms; \r
-\r
- {\r
- //============================================================================\r
- //\r
- // Standard Uniforms\r
- //\r
- //============================================================================\r
-\r
- TString& s = StandardUniforms;\r
- \r
- //\r
- // Implementation dependent constants. The example values below\r
- // are the minimum values allowed for these maximums.\r
- //\r
- char builtInConstant[80];\r
- sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0\r
- s.append(TString(builtInConstant)); \r
- \r
- sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader\r
- s.append(TString(builtInConstant)); \r
- \r
- sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader\r
- s.append(TString(builtInConstant)); \r
- \r
- sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader\r
- s.append(TString(builtInConstant)); \r
- \r
- sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader\r
- s.append(TString(builtInConstant)); \r
- \r
- sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader\r
- s.append(TString(builtInConstant));\r
- \r
- sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers\r
- s.append(TString(builtInConstant));\r
-\r
- //\r
- // OpenGL'uniform' state. Page numbers are in reference to version\r
- // 1.4 of the OpenGL specification.\r
- //\r
-\r
- //\r
- // Matrix state. p. 31, 32, 37, 39, 40.\r
- //\r
- s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));\r
-\r
- //\r
- // Derived matrix state that provides inverse and transposed versions\r
- // of the matrices above.\r
- //\r
- s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));\r
-\r
- s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));\r
-\r
- s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));\r
-\r
- //\r
- // Clip planes p. 42.\r
- //\r
- s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));\r
-\r
- //\r
- // Light State p 50, 53, 55.\r
- //\r
- s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));\r
-\r
- //\r
- // Derived state from products of light.\r
- //\r
- s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));\r
- s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));\r
-\r
- //\r
- // Textureg Environment and Generation, p. 152, p. 40-42.\r
- //\r
- s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));\r
- s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));\r
- s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));\r
-\r
- s.append(TString("\n"));\r
- }\r
-\r
- builtInStrings[EShLangFragment].push_back(StandardUniforms);\r
- builtInStrings[EShLangVertex].push_back(StandardUniforms);\r
-}\r
-\r
-void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)\r
-{\r
- //\r
- // First, insert some special built-in variables that are not in \r
- // the built-in header files.\r
- //\r
- switch(language) {\r
-\r
- case EShLangFragment: {\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EvqFace, 1)));\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EvqFragCoord, 4)));\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4)));\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1)));\r
-\r
- }\r
- break;\r
-\r
- case EShLangVertex:\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EvqPosition, 4)));\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EvqPointSize, 1)));\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_ClipVertex"), TType(EbtFloat, EvqClipVertex, 4)));\r
- break;\r
- default: break;\r
- }\r
-\r
- //\r
- // Next, identify which built-ins from the already loaded headers have\r
- // a mapping to an operator. Those that are not identified as such are\r
- // expected to be resolved through a library of functions, versus as\r
- // operations.\r
- //\r
- symbolTable.relateToOperator("not", EOpVectorLogicalNot);\r
-\r
- symbolTable.relateToOperator("matrixCompMult", EOpMul);\r
- symbolTable.relateToOperator("mod", EOpMod);\r
-\r
- symbolTable.relateToOperator("equal", EOpVectorEqual);\r
- symbolTable.relateToOperator("notEqual", EOpVectorNotEqual);\r
- symbolTable.relateToOperator("lessThan", EOpLessThan);\r
- symbolTable.relateToOperator("greaterThan", EOpGreaterThan);\r
- symbolTable.relateToOperator("lessThanEqual", EOpLessThanEqual);\r
- symbolTable.relateToOperator("greaterThanEqual", EOpGreaterThanEqual);\r
- \r
- symbolTable.relateToOperator("radians", EOpRadians);\r
- symbolTable.relateToOperator("degrees", EOpDegrees);\r
- symbolTable.relateToOperator("sin", EOpSin);\r
- symbolTable.relateToOperator("cos", EOpCos);\r
- symbolTable.relateToOperator("tan", EOpTan);\r
- symbolTable.relateToOperator("asin", EOpAsin);\r
- symbolTable.relateToOperator("acos", EOpAcos);\r
- symbolTable.relateToOperator("atan", EOpAtan);\r
-\r
- symbolTable.relateToOperator("pow", EOpPow);\r
- symbolTable.relateToOperator("exp2", EOpExp2);\r
- symbolTable.relateToOperator("log", EOpLog);\r
- symbolTable.relateToOperator("exp", EOpExp);\r
- symbolTable.relateToOperator("log2", EOpLog2);\r
- symbolTable.relateToOperator("sqrt", EOpSqrt);\r
- symbolTable.relateToOperator("inversesqrt", EOpInverseSqrt);\r
-\r
- symbolTable.relateToOperator("abs", EOpAbs);\r
- symbolTable.relateToOperator("sign", EOpSign);\r
- symbolTable.relateToOperator("floor", EOpFloor);\r
- symbolTable.relateToOperator("ceil", EOpCeil);\r
- symbolTable.relateToOperator("fract", EOpFract);\r
- symbolTable.relateToOperator("min", EOpMin);\r
- symbolTable.relateToOperator("max", EOpMax);\r
- symbolTable.relateToOperator("clamp", EOpClamp);\r
- symbolTable.relateToOperator("mix", EOpMix);\r
- symbolTable.relateToOperator("step", EOpStep);\r
- symbolTable.relateToOperator("smoothstep", EOpSmoothStep);\r
-\r
- symbolTable.relateToOperator("length", EOpLength);\r
- symbolTable.relateToOperator("distance", EOpDistance);\r
- symbolTable.relateToOperator("dot", EOpDot);\r
- symbolTable.relateToOperator("cross", EOpCross);\r
- symbolTable.relateToOperator("normalize", EOpNormalize);\r
- symbolTable.relateToOperator("forward", EOpFaceForward);\r
- symbolTable.relateToOperator("reflect", EOpReflect);\r
- symbolTable.relateToOperator("refract", EOpRefract);\r
- \r
- symbolTable.relateToOperator("any", EOpAny);\r
- symbolTable.relateToOperator("all", EOpAll);\r
-\r
- switch(language) {\r
-\r
- case EShLangVertex:\r
- break;\r
- \r
- case EShLangFragment:\r
- symbolTable.relateToOperator("dFdx", EOpDPdx); \r
- symbolTable.relateToOperator("dFdy", EOpDPdy); \r
- symbolTable.relateToOperator("fwidth", EOpFwidth);\r
-\r
- break;\r
-\r
- case EShLangPack:\r
- case EShLangUnpack:\r
- symbolTable.relateToOperator("itof", EOpItof);\r
- symbolTable.relateToOperator("ftoi", EOpFtoi);\r
- symbolTable.relateToOperator("skipPixels", EOpSkipPixels);\r
- symbolTable.relateToOperator("readInput", EOpReadInput);\r
- symbolTable.relateToOperator("writePixel", EOpWritePixel);\r
- symbolTable.relateToOperator("bitmapLSB", EOpBitmapLsb);\r
- symbolTable.relateToOperator("bitmapMSB", EOpBitmapMsb);\r
- symbolTable.relateToOperator("writeOutput", EOpWriteOutput);\r
- symbolTable.relateToOperator("readPixel", EOpReadPixel);\r
- break;\r
- default: assert (false && "Language not supported");\r
- }\r
-}\r
-\r
-void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)\r
-{\r
- //\r
- // First, insert some special built-in variables that are not in \r
- // the built-in header files.\r
- //\r
- switch(language) {\r
-\r
- case EShLangFragment: {\r
- // Set up gl_FragData. The array size.\r
- TType fragData(EbtFloat, EvqFragColor, 4, false, true);\r
- fragData.setArraySize(resources.maxDrawBuffers);\r
- symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));\r
- }\r
- break;\r
-\r
- default: break;\r
- }\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _INITIALIZE_INCLUDED_\r
-#define _INITIALIZE_INCLUDED_\r
-\r
-#include "Include/ResourceLimits.h"\r
-#include "../Include/Common.h"\r
-#include "../Include/ShHandle.h"\r
-#include "SymbolTable.h"\r
-\r
-typedef TVector<TString> TBuiltInStrings;\r
-\r
-class TBuiltIns {\r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
- void initialize();\r
- void initialize(const TBuiltInResource& resources);\r
- TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }\r
-protected:\r
- TBuiltInStrings builtInStrings[EShLangCount];\r
-};\r
-\r
-void IdentifyBuiltIns(EShLanguage, TSymbolTable&);\r
-void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);\r
-\r
-#endif // _INITIALIZE_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "../Include/intermediate.h"\r
-\r
-//\r
-// Traverse the intermediate representation tree, and\r
-// call a node type specific function for each node.\r
-// Done recursively through the member function Traverse().\r
-// Node types can be skipped if their function to call is 0,\r
-// but their subtree will still be traversed.\r
-// Nodes with children can have their whole subtree skipped\r
-// if preVisit is turned on and the type specific function\r
-// returns false.\r
-//\r
-// preVisit, postVisit, and rightToLeft control what order\r
-// nodes are visited in.\r
-//\r
-\r
-//\r
-// Traversal functions for terminals are straighforward....\r
-//\r
-void TIntermSymbol::traverse(TIntermTraverser* it)\r
-{\r
- if (it->visitSymbol)\r
- it->visitSymbol(this, it);\r
-}\r
-\r
-void TIntermConstantUnion::traverse(TIntermTraverser* it)\r
-{\r
- if (it->visitConstantUnion)\r
- it->visitConstantUnion(this, it);\r
-}\r
-\r
-//\r
-// Traverse a binary node.\r
-//\r
-void TIntermBinary::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
-\r
- //\r
- // visit the node before children if pre-visiting.\r
- //\r
- if (it->preVisit && it->visitBinary)\r
- visit = it->visitBinary(true, this, it);\r
- \r
- //\r
- // Visit the children, in the right order.\r
- //\r
- if (visit) {\r
- ++it->depth;\r
- if (it->rightToLeft) {\r
- if (right)\r
- right->traverse(it);\r
- if (left)\r
- left->traverse(it);\r
- } else {\r
- if (left)\r
- left->traverse(it);\r
- if (right)\r
- right->traverse(it);\r
- }\r
- --it->depth;\r
- }\r
-\r
- //\r
- // Visit the node after the children, if requested and the traversal\r
- // hasn't been cancelled yet.\r
- //\r
- if (visit && it->postVisit && it->visitBinary)\r
- it->visitBinary(false, this, it);\r
-}\r
-\r
-//\r
-// Traverse a unary node. Same comments in binary node apply here.\r
-//\r
-void TIntermUnary::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
-\r
- if (it->preVisit && it->visitUnary)\r
- visit = it->visitUnary(true, this, it);\r
-\r
- if (visit) {\r
- ++it->depth;\r
- operand->traverse(it);\r
- --it->depth;\r
- }\r
- \r
- if (visit && it->postVisit && it->visitUnary)\r
- it->visitUnary(false, this, it);\r
-}\r
-\r
-//\r
-// Traverse an aggregate node. Same comments in binary node apply here.\r
-//\r
-void TIntermAggregate::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
- \r
- if (it->preVisit && it->visitAggregate)\r
- visit = it->visitAggregate(true, this, it);\r
- \r
- if (visit) {\r
- ++it->depth;\r
-\r
- TIntermSequence::iterator sit;\r
- if (it->rightToLeft) {\r
- sit = sequence.end();\r
- while (sit != sequence.begin()) {\r
- --sit;\r
- (*sit)->traverse(it);\r
- }\r
- } else {\r
- for (sit = sequence.begin(); sit != sequence.end(); ++sit)\r
- (*sit)->traverse(it);\r
- }\r
- \r
- --it->depth;\r
- }\r
-\r
- if (visit && it->postVisit && it->visitAggregate)\r
- it->visitAggregate(false, this, it);\r
-}\r
-\r
-//\r
-// Traverse a selection node. Same comments in binary node apply here.\r
-//\r
-void TIntermSelection::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
-\r
- if (it->preVisit && it->visitSelection)\r
- visit = it->visitSelection(true, this, it);\r
- \r
- if (visit) {\r
- ++it->depth;\r
- if (it->rightToLeft) {\r
- if (falseBlock)\r
- falseBlock->traverse(it);\r
- if (trueBlock)\r
- trueBlock->traverse(it);\r
- condition->traverse(it);\r
- } else {\r
- condition->traverse(it);\r
- if (trueBlock)\r
- trueBlock->traverse(it);\r
- if (falseBlock)\r
- falseBlock->traverse(it);\r
- }\r
- --it->depth;\r
- }\r
-\r
- if (visit && it->postVisit && it->visitSelection)\r
- it->visitSelection(false, this, it);\r
-}\r
-\r
-//\r
-// Traverse a loop node. Same comments in binary node apply here.\r
-//\r
-void TIntermLoop::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
-\r
- if (it->preVisit && it->visitLoop)\r
- visit = it->visitLoop(true, this, it);\r
- \r
- if (visit) {\r
- ++it->depth;\r
- if (it->rightToLeft) {\r
- if (terminal)\r
- terminal->traverse(it);\r
- if (body)\r
- body->traverse(it);\r
- if (test)\r
- test->traverse(it);\r
- } else {\r
- if (test)\r
- test->traverse(it);\r
- if (body)\r
- body->traverse(it);\r
- if (terminal)\r
- terminal->traverse(it);\r
- }\r
- --it->depth;\r
- }\r
-\r
- if (visit && it->postVisit && it->visitLoop)\r
- it->visitLoop(false, this, it);\r
-}\r
-\r
-//\r
-// Traverse a branch node. Same comments in binary node apply here.\r
-//\r
-void TIntermBranch::traverse(TIntermTraverser* it)\r
-{\r
- bool visit = true;\r
-\r
- if (it->preVisit && it->visitBranch)\r
- visit = it->visitBranch(true, this, it);\r
- \r
- if (visit && expression) {\r
- ++it->depth;\r
- expression->traverse(it);\r
- --it->depth;\r
- }\r
-\r
- if (visit && it->postVisit && it->visitBranch)\r
- it->visitBranch(false, this, it);\r
-}\r
-\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// Build the intermediate representation.\r
-//\r
-\r
-#include "../Include/ShHandle.h"\r
-#include "localintermediate.h"\r
-#include "QualifierAlive.h"\r
-#include "RemoveTree.h"\r
-#include <float.h>\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-//\r
-// First set of functions are to help build the intermediate representation.\r
-// These functions are not member functions of the nodes.\r
-// They are called from parser productions.\r
-//\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Add a terminal node for an identifier in an expression.\r
-//\r
-// Returns the added node.\r
-//\r
-TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, TSourceLoc line)\r
-{\r
- TIntermSymbol* node = new TIntermSymbol(id, name, type);\r
- node->setLine(line);\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Connect two nodes with a new parent that does a binary operation on the nodes.\r
-//\r
-// Returns the added node.\r
-//\r
-TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TSymbolTable& symbolTable)\r
-{\r
- switch (op) {\r
- case EOpLessThan:\r
- case EOpGreaterThan:\r
- case EOpLessThanEqual:\r
- case EOpGreaterThanEqual:\r
- if (left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector() || left->getType().getBasicType() == EbtStruct) {\r
- return 0;\r
- }\r
- break;\r
- case EOpLogicalOr:\r
- case EOpLogicalXor:\r
- case EOpLogicalAnd:\r
- if (left->getType().getBasicType() != EbtBool || left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector()) {\r
- return 0;\r
- }\r
- break;\r
- case EOpAdd:\r
- case EOpSub:\r
- case EOpDiv:\r
- case EOpMul:\r
- if (left->getType().getBasicType() == EbtStruct || left->getType().getBasicType() == EbtBool)\r
- return 0;\r
- default: break; \r
- }\r
-\r
- // \r
- // First try converting the children to compatible types.\r
- //\r
-\r
- if (!(left->getType().getStruct() && right->getType().getStruct())) {\r
- TIntermTyped* child = addConversion(op, left->getType(), right);\r
- if (child)\r
- right = child;\r
- else {\r
- child = addConversion(op, right->getType(), left);\r
- if (child)\r
- left = child;\r
- else\r
- return 0;\r
- }\r
- } else {\r
- if (left->getType() != right->getType())\r
- return 0;\r
- }\r
-\r
-\r
- //\r
- // Need a new node holding things together then. Make\r
- // one and promote it to the right type.\r
- //\r
- TIntermBinary* node = new TIntermBinary(op);\r
- if (line == 0)\r
- line = right->getLine();\r
- node->setLine(line);\r
-\r
- node->setLeft(left);\r
- node->setRight(right);\r
- if (! node->promote(infoSink))\r
- return 0;\r
-\r
- TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();\r
- TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();\r
- \r
- if (leftTempConstant)\r
- leftTempConstant = copyConstUnion(left->getAsConstantUnion())->getAsConstantUnion();\r
- \r
- if (rightTempConstant)\r
- rightTempConstant = copyConstUnion(right->getAsConstantUnion())->getAsConstantUnion();\r
- \r
- if (right->getType().getQualifier() == EvqConst && left->getType().getQualifier() == EvqConst) {\r
- if (right->getAsAggregate()) {\r
- rightTempConstant = changeAggrToTempConst(right->getAsAggregate(), symbolTable, line); \r
- if (rightTempConstant->getUnionArrayPointer() == 0)\r
- return 0; \r
- }\r
-\r
- if (left->getAsAggregate()) {\r
- leftTempConstant = changeAggrToTempConst(left->getAsAggregate(), symbolTable, line); \r
- if (leftTempConstant->getUnionArrayPointer() == 0)\r
- return 0;\r
- }\r
- }\r
-\r
- //\r
- // See if we can fold constants.\r
- //\r
-\r
- TIntermTyped* typedReturnNode = 0;\r
- if ( leftTempConstant && rightTempConstant) {\r
- if (leftTempConstant->getSize() == 1 && rightTempConstant->getSize() > 1)\r
- typedReturnNode = rightTempConstant->fold(node->getOp(), leftTempConstant, infoSink, false);\r
- else\r
- typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink, true);\r
-\r
- if (typedReturnNode)\r
- return typedReturnNode;\r
- else {\r
- node->setLeft(leftTempConstant);\r
- node->setRight(rightTempConstant);\r
- }\r
- } else if (leftTempConstant) {\r
- node->setLeft(copyConstUnion(leftTempConstant));\r
- } else if (rightTempConstant) {\r
- node->setRight(rightTempConstant);\r
- }\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Connect two nodes through an assignment.\r
-//\r
-// Returns the added node.\r
-//\r
-TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line)\r
-{\r
- //\r
- // Like adding binary math, except the conversion can only go\r
- // from right to left.\r
- //\r
- TIntermBinary* node = new TIntermBinary(op);\r
- if (line == 0)\r
- line = left->getLine();\r
- node->setLine(line);\r
-\r
- if (right->getAsConstantUnion()) { // if the right node of assignment is a TempConstant node, allocate its own new space and remove the pointer to the symbol table value\r
- right = copyConstUnion(right->getAsConstantUnion()) ;\r
- if (right == 0)\r
- return 0;\r
- }\r
-\r
- TIntermTyped* child = addConversion(op, left->getType(), right);\r
- if (child == 0)\r
- return 0;\r
-\r
- node->setLeft(left);\r
- node->setRight(child);\r
- if (! node->promote(infoSink))\r
- return 0;\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Connect two nodes through an index operator, where the left node is the base\r
-// of an array or struct, and the right node is a direct or indirect offset.\r
-//\r
-// Returns the added node.\r
-// The caller should set the type of the returned node.\r
-//\r
-TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc line)\r
-{\r
- TIntermBinary* node = new TIntermBinary(op);\r
- if (line == 0)\r
- line = index->getLine();\r
- node->setLine(line);\r
- node->setLeft(base);\r
- node->setRight(index);\r
-\r
- // caller should set the type\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Add one node as the parent of another that it operates on.\r
-//\r
-// Returns the added node.\r
-//\r
-TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, TSourceLoc line, TSymbolTable& symbolTable)\r
-{\r
- TIntermUnary* node;\r
- TIntermTyped* child = childNode->getAsTyped();\r
-\r
- if (child == 0) {\r
- infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);\r
- return 0;\r
- }\r
-\r
- switch (op) {\r
- case EOpLogicalNot:\r
- if (child->getType().getBasicType() != EbtBool || child->getType().isMatrix() || child->getType().isArray() || child->getType().isVector()) {\r
- return 0;\r
- }\r
- break;\r
-\r
- case EOpPostIncrement:\r
- case EOpPreIncrement:\r
- case EOpPostDecrement:\r
- case EOpPreDecrement:\r
- case EOpNegative:\r
- if (child->getType().getBasicType() == EbtStruct)\r
- return 0;\r
- default: break;\r
- }\r
- \r
- //\r
- // Do we need to promote the operand?\r
- //\r
- // Note: Implicit promotions were removed from the language.\r
- //\r
- TBasicType newType = EbtVoid;\r
- switch (op) {\r
- case EOpConstructInt: newType = EbtInt; break;\r
- case EOpConstructBool: newType = EbtBool; break;\r
- case EOpConstructFloat: newType = EbtFloat; break;\r
- default: break;\r
- }\r
-\r
- if (newType != EbtVoid) {\r
- child = addConversion(op, TType(newType, EvqTemporary, child->getNominalSize(), \r
- child->isMatrix(), \r
- child->isArray()),\r
- child);\r
- if (child == 0)\r
- return 0;\r
- }\r
-\r
- //\r
- // For constructors, we are now done, it's all in the conversion.\r
- //\r
- switch (op) {\r
- case EOpConstructInt:\r
- case EOpConstructBool:\r
- case EOpConstructFloat:\r
- return child;\r
- default: break;\r
- }\r
- \r
- if (child->getAsConstantUnion())\r
- child = copyConstUnion(child->getAsConstantUnion());\r
-\r
- if (child->getAsAggregate() && child->getType().getQualifier() == EvqConst) {\r
- child = changeAggrToTempConst(child->getAsAggregate(), symbolTable, line); \r
- if (child->getAsConstantUnion()->getUnionArrayPointer() == 0)\r
- return 0; \r
- }\r
- \r
- TIntermConstantUnion *childTempConstant = child->getAsConstantUnion();\r
- \r
- //\r
- // Make a new node for the operator.\r
- //\r
- node = new TIntermUnary(op);\r
- if (line == 0)\r
- line = child->getLine();\r
- node->setLine(line);\r
- node->setOperand(child);\r
- \r
- if (! node->promote(infoSink))\r
- return 0;\r
-\r
- if (childTempConstant) {\r
- TIntermTyped* newChild = childTempConstant->fold(op, 0, infoSink, true);\r
- \r
- if (newChild) {\r
- return newChild;\r
- } \r
- } \r
-\r
- return node;\r
-}\r
-\r
-//\r
-// This is the safe way to change the operator on an aggregate, as it\r
-// does lots of error checking and fixing. Especially for establishing\r
-// a function call's operation on it's set of parameters. Sequences\r
-// of instructions are also aggregates, but they just direnctly set\r
-// their operator to EOpSequence.\r
-//\r
-// Returns an aggregate node, which could be the one passed in if\r
-// it was already an aggregate.\r
-//\r
-TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, TSourceLoc line)\r
-{\r
- TIntermAggregate* aggNode;\r
-\r
- //\r
- // Make sure we have an aggregate. If not turn it into one.\r
- //\r
- if (node) {\r
- aggNode = node->getAsAggregate();\r
- if (aggNode == 0 || aggNode->getOp() != EOpNull) {\r
- //\r
- // Make an aggregate containing this node.\r
- //\r
- aggNode = new TIntermAggregate();\r
- aggNode->getSequence().push_back(node);\r
- if (line == 0)\r
- line = node->getLine();\r
- }\r
- } else\r
- aggNode = new TIntermAggregate();\r
-\r
- //\r
- // Set the operator.\r
- //\r
- aggNode->setOperator(op);\r
- if (line != 0)\r
- aggNode->setLine(line);\r
-\r
- return aggNode;\r
-}\r
-\r
-//\r
-// Convert one type to another.\r
-//\r
-// Returns the node representing the conversion, which could be the same\r
-// node passed in if no conversion was needed.\r
-//\r
-// Return 0 if a conversion can't be done.\r
-//\r
-TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TIntermTyped* node)\r
-{\r
- //\r
- // Does the base type allow operation?\r
- //\r
- switch (node->getBasicType()) {\r
- case EbtVoid:\r
- case EbtSampler1D:\r
- case EbtSampler2D:\r
- case EbtSampler3D:\r
- case EbtSamplerCube:\r
- case EbtSampler1DShadow:\r
- case EbtSampler2DShadow:\r
- return 0;\r
- default: break;\r
- }\r
-\r
- //\r
- // Otherwise, if types are identical, no problem\r
- //\r
- if (type == node->getType())\r
- return node;\r
-\r
- //\r
- // If one's a structure, then no conversions.\r
- //\r
- if (type.getStruct() || node->getType().getStruct())\r
- return 0;\r
-\r
- TBasicType promoteTo;\r
- \r
- switch (op) {\r
- //\r
- // Explicit conversions\r
- //\r
- case EOpConstructBool:\r
- promoteTo = EbtBool;\r
- break;\r
- case EOpConstructFloat:\r
- promoteTo = EbtFloat;\r
- break;\r
- case EOpConstructInt:\r
- promoteTo = EbtInt;\r
- break;\r
- default:\r
- //\r
- // implicit conversions were removed from the language.\r
- //\r
- if (type.getBasicType() != node->getType().getBasicType())\r
- return 0;\r
- //\r
- // Size and structure could still differ, but that's\r
- // handled by operator promotion.\r
- //\r
- return node;\r
- }\r
- \r
- //\r
- // Do conversion.\r
- //\r
- bool allConstant = true;\r
- // check to see if there is an aggregate node\r
- if (node->getAsAggregate()) {\r
- if (node->getAsAggregate()->getOp() != EOpFunctionCall) {\r
- // if the aggregate node is a constructor or a comma operator, look at its children, if they are constant\r
- // convert them into the right type\r
- TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;\r
- for (TIntermSequence::iterator p = sequenceVector.begin(); \r
- p != sequenceVector.end(); p++) {\r
- if (!(*p)->getAsTyped()->getAsConstantUnion())\r
- allConstant = false;\r
- }\r
- } else\r
- allConstant = false;\r
- }\r
- if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const\r
- TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;\r
- for (TIntermSequence::iterator p = sequenceVector.begin(); \r
- p != sequenceVector.end(); p++) {\r
- TIntermTyped* newNode = 0;\r
- constUnion *unionArray = new constUnion[1];\r
-\r
- switch (promoteTo) {\r
- case EbtFloat:\r
- switch ((*p)->getAsTyped()->getType().getBasicType()) {\r
- \r
- case EbtInt: \r
- unionArray->fConst = static_cast<float>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
- newNode = addConstantUnion(unionArray, TType(EbtFloat, EvqConst), node->getLine()); break;\r
- case EbtBool: \r
- unionArray->fConst = static_cast<float>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst);\r
- newNode = newNode = addConstantUnion(unionArray, TType(EbtFloat, EvqConst), node->getLine()); break;\r
- default:\r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- break;\r
- case EbtInt:\r
- switch ((*p)->getAsTyped()->getType().getBasicType()) {\r
- case EbtFloat:\r
- unionArray->iConst = static_cast<int>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->fConst);\r
- newNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), node->getLine()); \r
- break;\r
- case EbtBool:\r
- unionArray->iConst = static_cast<int>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst);\r
- newNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), node->getLine()); \r
- break;\r
- default:\r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- break;\r
- case EbtBool:\r
- switch ((*p)->getAsTyped()->getType().getBasicType()) {\r
- case EbtFloat:\r
- unionArray->bConst = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->fConst != 0.0 ;\r
- newNode = addConstantUnion(unionArray, TType(EbtBool, EvqConst), node->getLine()); \r
- break;\r
- case EbtInt:\r
- unionArray->bConst = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst != 0 ;\r
- newNode = addConstantUnion(unionArray, TType(EbtBool, EvqConst), node->getLine()); \r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- } \r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- if (newNode) {\r
- sequenceVector.erase(p); \r
- sequenceVector.insert(p, newNode);\r
- }\r
- }\r
- return node->getAsAggregate();\r
- } else if (node->getAsConstantUnion()) {\r
-\r
- return (promoteConstantUnion(promoteTo, node->getAsConstantUnion()));\r
- } else {\r
- \r
- //\r
- // Add a new newNode for the conversion.\r
- //\r
- TIntermUnary* newNode = 0;\r
-\r
- TOperator newOp = EOpNull;\r
- switch (promoteTo) {\r
- case EbtFloat:\r
- switch (node->getBasicType()) {\r
- case EbtInt: newOp = EOpConvIntToFloat; break;\r
- case EbtBool: newOp = EOpConvBoolToFloat; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- break;\r
- case EbtBool:\r
- switch (node->getBasicType()) {\r
- case EbtInt: newOp = EOpConvIntToBool; break;\r
- case EbtFloat: newOp = EOpConvFloatToBool; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- break;\r
- case EbtInt:\r
- switch (node->getBasicType()) {\r
- case EbtBool: newOp = EOpConvBoolToInt; break;\r
- case EbtFloat: newOp = EOpConvFloatToInt; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());\r
- return 0;\r
- }\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Bad promotion type", node->getLine());\r
- return 0;\r
- }\r
-\r
- TType type(promoteTo, EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());\r
- newNode = new TIntermUnary(newOp, type);\r
- newNode->setLine(node->getLine());\r
- newNode->setOperand(node);\r
-\r
- return newNode;\r
- }\r
-}\r
-\r
-//\r
-// Safe way to combine two nodes into an aggregate. Works with null pointers, \r
-// a node that's not a aggregate yet, etc.\r
-//\r
-// Returns the resulting aggregate, unless 0 was passed in for \r
-// both existing nodes.\r
-//\r
-TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc line)\r
-{\r
- if (left == 0 && right == 0)\r
- return 0;\r
-\r
- TIntermAggregate* aggNode = 0;\r
- if (left)\r
- aggNode = left->getAsAggregate();\r
- if (!aggNode || aggNode->getOp() != EOpNull) {\r
- aggNode = new TIntermAggregate;\r
- if (left)\r
- aggNode->getSequence().push_back(left);\r
- }\r
-\r
- if (right)\r
- aggNode->getSequence().push_back(right);\r
-\r
- if (line != 0)\r
- aggNode->setLine(line);\r
-\r
- return aggNode;\r
-}\r
-\r
-//\r
-// Turn an existing node into an aggregate.\r
-//\r
-// Returns an aggregate, unless 0 was passed in for the existing node.\r
-//\r
-TIntermAggregate* TIntermediate::makeAggregate(TIntermNode* node, TSourceLoc line)\r
-{\r
- if (node == 0)\r
- return 0;\r
-\r
- TIntermAggregate* aggNode = new TIntermAggregate;\r
- aggNode->getSequence().push_back(node);\r
-\r
- if (line != 0)\r
- aggNode->setLine(line);\r
- else\r
- aggNode->setLine(node->getLine());\r
-\r
- return aggNode;\r
-}\r
-\r
-//\r
-// For "if" test nodes. There are three children; a condition,\r
-// a true path, and a false path. The two paths are in the\r
-// nodePair.\r
-//\r
-// Returns the selection node created.\r
-//\r
-TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc line)\r
-{\r
- //\r
- // For compile time constant selections, prune the code and \r
- // test now.\r
- //\r
- \r
- if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) {\r
- if (cond->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst)\r
- return nodePair.node1;\r
- else\r
- return nodePair.node2;\r
- }\r
-\r
- TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);\r
- node->setLine(line);\r
-\r
- return node;\r
-}\r
-\r
-\r
-TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc line)\r
-{\r
- if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) {\r
- return right;\r
- } else {\r
- TIntermTyped *commaAggregate = growAggregate(left, right, line);\r
- commaAggregate->getAsAggregate()->setOperator(EOpComma); \r
- commaAggregate->setType(right->getType());\r
- commaAggregate->getTypePointer()->changeQualifier(EvqTemporary);\r
- return commaAggregate;\r
- }\r
-}\r
-\r
-//\r
-// For "?:" test nodes. There are three children; a condition,\r
-// a true path, and a false path. The two paths are specified\r
-// as separate parameters.\r
-//\r
-// Returns the selection node created, or 0 if one could not be.\r
-//\r
-TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc line)\r
-{\r
- //\r
- // Get compatible types.\r
- //\r
- TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock);\r
- if (child)\r
- falseBlock = child;\r
- else {\r
- child = addConversion(EOpSequence, falseBlock->getType(), trueBlock);\r
- if (child)\r
- trueBlock = child;\r
- else\r
- return 0;\r
- }\r
-\r
- //\r
- // See if condition is constant, and select now.\r
- //\r
-\r
- if (cond->getAsConstantUnion()) {\r
- if (cond->getAsConstantUnion()->getUnionArrayPointer()->bConst)\r
- return trueBlock;\r
- else\r
- return falseBlock;\r
- }\r
-\r
- //\r
- // Make a selection node.\r
- //\r
- TIntermSelection* node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType());\r
- node->setLine(line);\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Constant terminal nodes. Has a union that contains bool, float or int constants\r
-//\r
-// Returns the constant union node created.\r
-//\r
-\r
-TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc line)\r
-{\r
- TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);\r
- node->setLine(line);\r
-\r
- return node;\r
-}\r
-\r
-TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc line)\r
-{\r
- \r
- TIntermAggregate* node = new TIntermAggregate(EOpSequence);\r
-\r
- node->setLine(line);\r
- TIntermConstantUnion* constIntNode;\r
- TIntermSequence &sequenceVector = node->getSequence();\r
- constUnion* unionArray;\r
-\r
- for (int i = 0; i < fields.num; i++) {\r
- unionArray = new constUnion[1];\r
- unionArray->iConst = fields.offsets[i];\r
- constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), line);\r
- sequenceVector.push_back(constIntNode);\r
- }\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// Create loop nodes.\r
-//\r
-TIntermNode* TIntermediate::addLoop(TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line)\r
-{\r
- TIntermNode* node = new TIntermLoop(body, test, terminal, testFirst);\r
- node->setLine(line);\r
- \r
- return node;\r
-}\r
-\r
-//\r
-// Add branches.\r
-//\r
-TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TSourceLoc line)\r
-{\r
- return addBranch(branchOp, 0, line);\r
-}\r
-\r
-TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expression, TSourceLoc line)\r
-{\r
- TIntermBranch* node = new TIntermBranch(branchOp, expression);\r
- node->setLine(line);\r
-\r
- return node;\r
-}\r
-\r
-//\r
-// This is to be executed once the final root is put on top by the parsing\r
-// process.\r
-//\r
-bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)\r
-{\r
- if (root == 0)\r
- return true;\r
-\r
- //\r
- // First, finish off the top level sequence, if any\r
- //\r
- TIntermAggregate* aggRoot = root->getAsAggregate();\r
- if (aggRoot && aggRoot->getOp() == EOpNull)\r
- aggRoot->setOperator(EOpSequence);\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// This deletes the tree.\r
-//\r
-void TIntermediate::remove(TIntermNode* root)\r
-{\r
- if (root)\r
- RemoveAllTreeNodes(root);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////\r
-//\r
-// Member functions of the nodes used for building the tree.\r
-//\r
-////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Say whether or not an operation node changes the value of a variable.\r
-//\r
-// Returns true if state is modified.\r
-//\r
-bool TIntermOperator::modifiesState() const\r
-{\r
- switch (op) { \r
- case EOpPostIncrement: \r
- case EOpPostDecrement: \r
- case EOpPreIncrement: \r
- case EOpPreDecrement: \r
- case EOpAssign: \r
- case EOpAddAssign: \r
- case EOpSubAssign: \r
- case EOpMulAssign: \r
- case EOpVectorTimesMatrixAssign:\r
- case EOpVectorTimesScalarAssign:\r
- case EOpMatrixTimesScalarAssign:\r
- case EOpMatrixTimesMatrixAssign:\r
- case EOpDivAssign: \r
- case EOpModAssign: \r
- case EOpAndAssign: \r
- case EOpInclusiveOrAssign: \r
- case EOpExclusiveOrAssign: \r
- case EOpLeftShiftAssign: \r
- case EOpRightShiftAssign: \r
- return true;\r
- default:\r
- return false;\r
- }\r
-}\r
-\r
-//\r
-// returns true if the operator is for one of the constructors\r
-//\r
-bool TIntermOperator::isConstructor() const\r
-{\r
- switch (op) {\r
- case EOpConstructVec2:\r
- case EOpConstructVec3:\r
- case EOpConstructVec4:\r
- case EOpConstructMat2:\r
- case EOpConstructMat3:\r
- case EOpConstructMat4:\r
- case EOpConstructFloat:\r
- case EOpConstructIVec2:\r
- case EOpConstructIVec3:\r
- case EOpConstructIVec4:\r
- case EOpConstructInt:\r
- case EOpConstructBVec2:\r
- case EOpConstructBVec3:\r
- case EOpConstructBVec4:\r
- case EOpConstructBool:\r
- case EOpConstructStruct:\r
- return true;\r
- default:\r
- return false;\r
- }\r
-}\r
-//\r
-// Make sure the type of a unary operator is appropriate for its \r
-// combination of operation and operand type.\r
-//\r
-// Returns false in nothing makes sense.\r
-//\r
-bool TIntermUnary::promote(TInfoSink&)\r
-{\r
- switch (op) {\r
- case EOpLogicalNot:\r
- if (operand->getBasicType() != EbtBool)\r
- return false;\r
- break;\r
- case EOpBitwiseNot:\r
- if (operand->getBasicType() != EbtInt)\r
- return false;\r
- break;\r
- case EOpNegative:\r
- case EOpPostIncrement:\r
- case EOpPostDecrement:\r
- case EOpPreIncrement:\r
- case EOpPreDecrement:\r
- if (operand->getBasicType() == EbtBool)\r
- return false;\r
- break;\r
-\r
- // operators for built-ins are already type checked against their prototype\r
- case EOpAny:\r
- case EOpAll:\r
- case EOpVectorLogicalNot:\r
- return true;\r
-\r
- default:\r
- if (operand->getBasicType() != EbtFloat)\r
- return false;\r
- }\r
- \r
- setType(operand->getType());\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// Establishes the type of the resultant operation, as well as\r
-// makes the operator the correct one for the operands.\r
-//\r
-// Returns false if operator can't work on operands.\r
-//\r
-bool TIntermBinary::promote(TInfoSink& infoSink)\r
-{\r
- int size = left->getNominalSize();\r
- if (right->getNominalSize() > size)\r
- size = right->getNominalSize();\r
-\r
- TBasicType type = left->getBasicType();\r
-\r
- //\r
- // Don't operate on arrays.\r
- //\r
- if (left->isArray() || right->isArray())\r
- return false;\r
-\r
- //\r
- // Base assumption: just make the type the same as the left\r
- // operand. Then only deviations from this need be coded.\r
- //\r
- setType(TType(type, EvqTemporary, left->getNominalSize(), left->isMatrix()));\r
- \r
- //\r
- // All scalars. Code after this test assumes this case is removed!\r
- //\r
- if (size == 1) {\r
-\r
- switch (op) {\r
-\r
- //\r
- // Promote to conditional\r
- //\r
- case EOpEqual:\r
- case EOpNotEqual:\r
- case EOpLessThan:\r
- case EOpGreaterThan:\r
- case EOpLessThanEqual:\r
- case EOpGreaterThanEqual:\r
- setType(TType(EbtBool));\r
- break;\r
-\r
- //\r
- // And and Or operate on conditionals\r
- //\r
- case EOpLogicalAnd:\r
- case EOpLogicalOr:\r
- if (left->getBasicType() != EbtBool || right->getBasicType() != EbtBool)\r
- return false; \r
- setType(TType(EbtBool));\r
- break;\r
-\r
- //\r
- // Check for integer only operands.\r
- //\r
- case EOpMod:\r
- case EOpRightShift:\r
- case EOpLeftShift:\r
- case EOpAnd:\r
- case EOpInclusiveOr:\r
- case EOpExclusiveOr:\r
- if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)\r
- return false;\r
- break;\r
- case EOpModAssign:\r
- case EOpAndAssign:\r
- case EOpInclusiveOrAssign:\r
- case EOpExclusiveOrAssign:\r
- case EOpLeftShiftAssign:\r
- case EOpRightShiftAssign:\r
- if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)\r
- return false;\r
- // fall through\r
-\r
- //\r
- // Everything else should have matching types\r
- //\r
- default:\r
- if (left->getBasicType() != right->getBasicType() ||\r
- left->isMatrix() != right->isMatrix())\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
- //\r
- // Are the sizes compatible?\r
- //\r
- if ( left->getNominalSize() != size && left->getNominalSize() != 1 ||\r
- right->getNominalSize() != size && right->getNominalSize() != 1)\r
- return false;\r
-\r
- //\r
- // Can these two operands be combined?\r
- //\r
- switch (op) {\r
- case EOpMul:\r
- if (!left->isMatrix() && right->isMatrix()) {\r
- if (left->isVector())\r
- op = EOpVectorTimesMatrix;\r
- else {\r
- op = EOpMatrixTimesScalar;\r
- setType(TType(type, EvqTemporary, size, true));\r
- }\r
- } else if (left->isMatrix() && !right->isMatrix()) {\r
- if (right->isVector()) {\r
- op = EOpMatrixTimesVector;\r
- setType(TType(type, EvqTemporary, size, false));\r
- } else {\r
- op = EOpMatrixTimesScalar;\r
- }\r
- } else if (left->isMatrix() && right->isMatrix()) {\r
- op = EOpMatrixTimesMatrix;\r
- } else if (!left->isMatrix() && !right->isMatrix()) {\r
- if (left->isVector() && right->isVector()) {\r
- // leave as component product\r
- } else if (left->isVector() || right->isVector()) {\r
- op = EOpVectorTimesScalar;\r
- setType(TType(type, EvqTemporary, size, false));\r
- }\r
- } else {\r
- infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());\r
- return false;\r
- }\r
- break;\r
- case EOpMulAssign:\r
- if (!left->isMatrix() && right->isMatrix()) {\r
- if (left->isVector())\r
- op = EOpVectorTimesMatrixAssign;\r
- else {\r
- return false;\r
- }\r
- } else if (left->isMatrix() && !right->isMatrix()) {\r
- if (right->isVector()) {\r
- return false;\r
- } else {\r
- op = EOpMatrixTimesScalarAssign;\r
- }\r
- } else if (left->isMatrix() && right->isMatrix()) {\r
- op = EOpMatrixTimesMatrixAssign;\r
- } else if (!left->isMatrix() && !right->isMatrix()) {\r
- if (left->isVector() && right->isVector()) {\r
- // leave as component product\r
- } else if (left->isVector() || right->isVector()) {\r
- if (! left->isVector())\r
- return false;\r
- op = EOpVectorTimesScalarAssign;\r
- setType(TType(type, EvqTemporary, size, false));\r
- }\r
- } else {\r
- infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());\r
- return false;\r
- }\r
- break; \r
- case EOpAssign:\r
- if (left->getNominalSize() != right->getNominalSize())\r
- return false;\r
- // fall through\r
- case EOpAdd:\r
- case EOpSub:\r
- case EOpDiv:\r
- case EOpMod:\r
- case EOpAddAssign:\r
- case EOpSubAssign:\r
- case EOpDivAssign:\r
- case EOpModAssign:\r
- if (left->isMatrix() && right->isVector() ||\r
- left->isVector() && right->isMatrix() ||\r
- left->getBasicType() != right->getBasicType())\r
- return false;\r
- setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));\r
- break;\r
- \r
- case EOpEqual:\r
- case EOpNotEqual:\r
- case EOpLessThan:\r
- case EOpGreaterThan:\r
- case EOpLessThanEqual:\r
- case EOpGreaterThanEqual:\r
- if (left->isMatrix() && right->isVector() ||\r
- left->isVector() && right->isMatrix() ||\r
- left->getBasicType() != right->getBasicType())\r
- return false;\r
- setType(TType(EbtBool));\r
- break;\r
-\r
-default:\r
- return false;\r
- }\r
-\r
- //\r
- // One more check for assignment. The Resulting type has to match the left operand.\r
- //\r
- switch (op) {\r
- case EOpAssign:\r
- case EOpAddAssign:\r
- case EOpSubAssign:\r
- case EOpMulAssign:\r
- case EOpDivAssign:\r
- case EOpModAssign:\r
- case EOpAndAssign:\r
- case EOpInclusiveOrAssign:\r
- case EOpExclusiveOrAssign:\r
- case EOpLeftShiftAssign:\r
- case EOpRightShiftAssign:\r
- if (getType() != left->getType())\r
- return false;\r
- break;\r
- default: \r
- break;\r
- }\r
- \r
- return true;\r
-}\r
-\r
-bool compareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index)\r
-{\r
- TTypeList* fields = leftNodeType.getStruct();\r
-\r
- size_t structSize = fields->size();\r
-\r
- for (size_t j = 0; j < structSize; j++) {\r
- int size = (*fields)[j].type->getInstanceSize();\r
- for (int i = 0; i < size; i++) {\r
- switch ((*fields)[j].type->getBasicType()) {\r
- case EbtFloat:\r
- if (leftUnionArray[index].fConst != rightUnionArray[index].fConst)\r
- return false;\r
- index++;\r
- break;\r
- case EbtInt:\r
- if (leftUnionArray[index].iConst != rightUnionArray[index].iConst)\r
- return false;\r
- index++;\r
- break;\r
- case EbtBool:\r
- if (leftUnionArray[index].bConst != rightUnionArray[index].bConst)\r
- return false;\r
- index++;\r
- break;\r
- case EbtStruct:\r
- if (!compareStructure(*(*fields)[j].type, rightUnionArray, leftUnionArray, index))\r
- return false;\r
- break;\r
- default: \r
- assert(true && "Cannot compare");\r
- break;\r
- } \r
- \r
- }\r
- }\r
- return true;\r
-} \r
-\r
-//\r
-// The fold functions see if an operation on a constant can be done in place,\r
-// without generating run-time code.\r
-//\r
-// Returns the node to keep using, which may or may not be the node passed in.\r
-//\r
-\r
-TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink, bool leftOperand)\r
-{ \r
- constUnion *unionArray = this->getUnionArrayPointer(); \r
-\r
- if (constantNode) {\r
- if (constantNode->getAsConstantUnion() && constantNode->getSize() == 1 && constantNode->getType().getBasicType() != EbtStruct\r
- && this->getSize() > 1) {\r
- TIntermConstantUnion *node = constantNode->getAsConstantUnion();\r
- TIntermConstantUnion *newNode;\r
- constUnion* tempConstArray;\r
- switch(op) {\r
- case EOpAdd: \r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;\r
- case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
- case EOpMatrixTimesScalar: \r
- case EOpVectorTimesScalar:\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;\r
- case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
- case EOpSub:\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: \r
- if (leftOperand)\r
- tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst; \r
- else\r
- tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst; \r
- break;\r
-\r
- case EbtInt: \r
- if (leftOperand) \r
- tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst; \r
- else\r
- tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst; \r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpDiv:\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: \r
- if (leftOperand) {\r
- if (node->getUnionArrayPointer()->fConst == 0.0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].fConst = FLT_MAX;\r
- } else\r
- tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst; \r
- } else {\r
- if (unionArray[i].fConst == 0.0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].fConst = FLT_MAX;\r
- } else\r
- tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst; \r
- }\r
- break;\r
-\r
- case EbtInt: \r
- if (leftOperand) {\r
- if (node->getUnionArrayPointer()->iConst == 0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].iConst = INT_MAX;\r
- } else\r
- tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst; \r
- } else {\r
- if (unionArray[i].iConst == 0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].iConst = INT_MAX;\r
- } else\r
- tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst; \r
- }\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
- \r
- case EOpLogicalXor: // this code is written for possible future use, will not get executed currently\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpLogicalOr: // this code is written for possible future use, will not get executed currently \r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- default:\r
- infoSink.info.message(EPrefixInternalError, "Invalid operator for constant folding", this->getLine());\r
- return 0;\r
- }\r
- newNode = new TIntermConstantUnion(tempConstArray, this->getType());\r
- newNode->setLine(this->getLine());\r
- \r
- return newNode;\r
- } else if (constantNode->getAsConstantUnion() && (this->getSize() > 1 || this->getType().getBasicType() == EbtStruct)) {\r
- TIntermConstantUnion *node = constantNode->getAsConstantUnion();\r
- constUnion *rightUnionArray = node->getUnionArrayPointer(); \r
- constUnion* tempConstArray = 0;\r
- TIntermConstantUnion *tempNode;\r
- int index = 0;\r
- bool boolNodeFlag = false;\r
- switch(op) {\r
- case EOpAdd: \r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;\r
- case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
- case EOpSub: \r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) { \r
- case EbtFloat: \r
- if (leftOperand)\r
- tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst; \r
- else\r
- tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst; \r
- break;\r
-\r
- case EbtInt: \r
- if (leftOperand) \r
- tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;\r
- else\r
- tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst; \r
- break;\r
- \r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
- case EOpMul: \r
- if (this->isVector()) { // two vectors multiplied together\r
- int size = this->getSize();\r
- tempConstArray = new constUnion[size];\r
- \r
- for (int i = 0; i < size; i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;\r
- case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());\r
- return 0;\r
- }\r
- }\r
- } \r
- break;\r
- case EOpMatrixTimesMatrix: \r
- if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {\r
- infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());\r
- return 0;\r
- }\r
- {// support MSVC++6.0\r
- int size = this->getNominalSize();\r
- tempConstArray = new constUnion[size*size];\r
- for (int row = 0; row < size; row++) {\r
- for (int column = 0; column < size; column++) {\r
- tempConstArray[size * column + row].fConst = 0.0;\r
- for (int i = 0; i < size; i++) {\r
- tempConstArray[size * column + row].fConst += unionArray[i * size + row].fConst * (rightUnionArray[column * size + i].fConst); \r
- }\r
- }\r
- }\r
- }\r
- break;\r
- case EOpDiv: \r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: \r
- if (leftOperand) {\r
- if (rightUnionArray[i].fConst == 0.0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].fConst = FLT_MAX;\r
- } else\r
- tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst; \r
- } else {\r
- if (unionArray[i].fConst == 0.0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].fConst = FLT_MAX;\r
- } else\r
- tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst; \r
- }\r
- break;\r
-\r
- case EbtInt: \r
- if (leftOperand) {\r
- if (rightUnionArray[i].iConst == 0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].iConst = INT_MAX;\r
- } else\r
- tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst; \r
- } else {\r
- if (unionArray[i].iConst == 0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- tempConstArray[i].iConst = INT_MAX;\r
- } else\r
- tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst; \r
- }\r
- break; \r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpMatrixTimesVector: \r
- if (node->getBasicType() != EbtFloat) {\r
- infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", this->getLine());\r
- return 0;\r
- }\r
- tempConstArray = new constUnion[this->getNominalSize()];\r
- \r
- {// support MSVC++6.0 \r
- for (int size = this->getNominalSize(), i = 0; i < size; i++) {\r
- tempConstArray[i].fConst = 0.0;\r
- for (int j = 0; j < size; j++) {\r
- tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst); \r
- }\r
- }\r
- }\r
- \r
- tempNode = new TIntermConstantUnion(tempConstArray, node->getType());\r
- tempNode->setLine(this->getLine());\r
-\r
- return tempNode; \r
-\r
- case EOpVectorTimesMatrix:\r
- if (this->getType().getBasicType() != EbtFloat) {\r
- infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for vector times matrix", this->getLine());\r
- return 0;\r
- } \r
-\r
- tempConstArray = new constUnion[this->getNominalSize()];\r
- {// support MSVC++6.0\r
- for (int size = this->getNominalSize(), i = 0; i < size; i++) {\r
- tempConstArray[i].fConst = 0.0;\r
- for (int j = 0; j < size; j++) {\r
- tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst); \r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpLogicalXor: // this code is written for possible future use, will not get executed currently\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpLogicalOr: // this code is written for possible future use, will not get executed currently\r
- tempConstArray = new constUnion[this->getSize()];\r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());\r
- return 0;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EOpEqual: \r
- \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].fConst != rightUnionArray[i].fConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EbtInt: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].iConst != rightUnionArray[i].iConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
- case EbtBool: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].bConst != rightUnionArray[i].bConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
- case EbtStruct:\r
- if (!compareStructure(node->getType(), node->getUnionArrayPointer(), unionArray, index))\r
- boolNodeFlag = true;\r
- break;\r
- \r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"==\"", this->getLine());\r
- return 0;\r
- }\r
-\r
- tempConstArray = new constUnion[1];\r
- if (!boolNodeFlag) {\r
- tempConstArray->bConst = true;\r
- }\r
- else {\r
- tempConstArray->bConst = false;\r
- }\r
- \r
- tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));\r
- tempNode->setLine(this->getLine());\r
- \r
- return tempNode; \r
-\r
- case EOpNotEqual: \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].fConst == rightUnionArray[i].fConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case EbtInt: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].iConst == rightUnionArray[i].iConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
- case EbtBool: \r
- {// support MSVC++6.0\r
- for (int i = 0; i < this->getSize(); i++) { \r
- if (unionArray[i].bConst == rightUnionArray[i].bConst) {\r
- boolNodeFlag = true;\r
- break; // break out of for loop\r
- }\r
- }\r
- }\r
- break;\r
- case EbtStruct:\r
- if (compareStructure(node->getType(), node->getUnionArrayPointer(), unionArray, index))\r
- boolNodeFlag = true;\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"!=\"", this->getLine());\r
- return 0;\r
- }\r
-\r
- tempConstArray = new constUnion[1];\r
- if (!boolNodeFlag) {\r
- tempConstArray->bConst = true;\r
- }\r
- else {\r
- tempConstArray->bConst = false;\r
- }\r
- \r
- tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));\r
- tempNode->setLine(this->getLine());\r
- \r
- return tempNode; \r
- \r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Invalid operator for constant folding", this->getLine());\r
- return 0;\r
- }\r
- tempNode = new TIntermConstantUnion(tempConstArray, this->getType());\r
- tempNode->setLine(this->getLine());\r
-\r
- return tempNode; \r
- } else if (this->getSize() == 1 && this->getType().getBasicType() != EbtStruct \r
- && constantNode->getSize() == 1 && constantNode->getType().getBasicType() != EbtStruct ) { // scalar constant folding\r
- constUnion *unionArray = new constUnion[1];\r
- TIntermConstantUnion* newNode = 0;\r
-\r
- switch (this->getType().getBasicType()) {\r
- case EbtInt:\r
- {\r
- //\r
- // Dealing with two operands, us and constant.\r
- //\r
- // Do Binary operations.\r
- //\r
- int rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->iConst;\r
- int leftValue = this->getUnionArrayPointer()->iConst;\r
- //int line = this->getLine();\r
-\r
- switch(op) {\r
- //?? add constant intrinsics\r
- case EOpAdd: unionArray->iConst = leftValue + rightValue; break;\r
- case EOpSub: unionArray->iConst = leftValue - rightValue; break;\r
- case EOpMul: unionArray->iConst = leftValue * rightValue; break;\r
- case EOpDiv: \r
- if (rightValue == 0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- unionArray->iConst = INT_MAX;\r
- } else\r
- unionArray->iConst = leftValue / rightValue; break;\r
- \r
- case EOpMod: unionArray->iConst = leftValue % rightValue; break;\r
- \r
- case EOpRightShift: unionArray->iConst = leftValue >> rightValue; break;\r
- case EOpLeftShift: unionArray->iConst = leftValue << rightValue; break;\r
- \r
- case EOpAnd: unionArray->iConst = leftValue & rightValue; break;\r
- case EOpInclusiveOr: unionArray->iConst = leftValue | rightValue; break;\r
- case EOpExclusiveOr: unionArray->iConst = leftValue ^ rightValue; break;\r
-\r
- // the following assume it's okay to have memory leaks\r
- case EOpEqual: \r
- unionArray->bConst = leftValue == rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpNotEqual: \r
- unionArray->bConst = leftValue != rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpLessThan: \r
- unionArray->bConst = leftValue < rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpGreaterThan: \r
- unionArray->bConst = leftValue > rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpLessThanEqual: \r
- unionArray->bConst = leftValue <= rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpGreaterThanEqual: \r
- unionArray->bConst = leftValue >= rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
-\r
- default:\r
- //infoSink.info.message(EPrefixInternalError, "Binary operation not folded into constant int", line);\r
- return 0;\r
- }\r
- if (!newNode) {\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtInt, EvqConst)); \r
- }\r
- newNode->setLine(constantNode->getLine());\r
- return newNode;\r
- }\r
- case EbtFloat:\r
- {\r
- float rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->fConst;\r
- float leftValue = this->getUnionArrayPointer()->fConst;\r
-\r
- switch(op) {\r
- //?? add constant intrinsics\r
- case EOpAdd: unionArray->fConst = leftValue + rightValue; break;\r
- case EOpSub: unionArray->fConst = leftValue - rightValue; break;\r
- case EOpMul: unionArray->fConst = leftValue * rightValue; break;\r
- case EOpDiv: \r
- if (rightValue == 0.0) {\r
- infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());\r
- unionArray->fConst = FLT_MAX;\r
- } else\r
- unionArray->fConst = leftValue / rightValue; break;\r
-\r
- // the following assume it's okay to have memory leaks (cleaned up by pool allocator)\r
- case EOpEqual: \r
- unionArray->bConst = leftValue == rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpNotEqual: \r
- unionArray->bConst = leftValue != rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpLessThan: \r
- unionArray->bConst = leftValue < rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpGreaterThan: \r
- unionArray->bConst = leftValue > rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpLessThanEqual: \r
- unionArray->bConst = leftValue <= rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
- case EOpGreaterThanEqual: \r
- unionArray->bConst = leftValue >= rightValue;\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- break;\r
-\r
- default: \r
- //infoSink.info.message(EPrefixInternalError, "Binary operation not folded into constant float", line);\r
- return 0;\r
- }\r
- if (!newNode) {\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtFloat, EvqConst)); \r
- }\r
- newNode->setLine(constantNode->getLine());\r
- return newNode;\r
- }\r
- case EbtBool:\r
- {\r
- bool rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->bConst;\r
- bool leftValue = this->getUnionArrayPointer()->bConst;\r
-\r
- switch(op) {\r
- //?? add constant intrinsics\r
- case EOpLogicalAnd: unionArray->bConst = leftValue & rightValue; break;\r
- case EOpLogicalXor: unionArray->bConst = leftValue ^ rightValue; break;\r
- case EOpLogicalOr: unionArray->bConst = leftValue | rightValue; break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Binary operator cannot be folded into constant bool", line);\r
- return 0;\r
- }\r
- newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst)); \r
- newNode->setLine(constantNode->getLine());\r
- return newNode;\r
- }\r
- default:\r
- infoSink.info.message(EPrefixInternalError, "Cannot fold constant", this->getLine());\r
- return 0;\r
- }\r
- }\r
- } else { \r
- //\r
- // Do unary operations\r
- //\r
- TIntermConstantUnion *newNode = 0;\r
- constUnion* tempConstArray = new constUnion[this->getSize()];\r
- if (this->getSize() > 1) {\r
- for (int i = 0; i < this->getSize(); i++) {\r
- switch(op) {\r
- case EOpNegative: \r
- switch (this->getType().getBasicType()) {\r
- case EbtFloat: tempConstArray[i].fConst = -(unionArray[i].fConst); break;\r
- case EbtInt: tempConstArray[i].iConst = -(unionArray[i].iConst); break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", this->getLine());\r
- return 0;\r
- }\r
- break;\r
- case EOpLogicalNot: // this code is written for possible future use, will not get executed currently \r
- switch (this->getType().getBasicType()) {\r
- case EbtBool: tempConstArray[i].bConst = !(unionArray[i].bConst); break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", this->getLine());\r
- return 0;\r
- }\r
- break;\r
- default: \r
- return 0;\r
- }\r
- }\r
- newNode = new TIntermConstantUnion(tempConstArray, this->getType());\r
- newNode->setLine(this->getLine());\r
- return newNode; \r
- } else {\r
- switch(op) {\r
- //?? add constant intrinsics\r
- case EOpNegative: \r
- switch (this->getType().getBasicType()) {\r
- case EbtInt:\r
- tempConstArray->iConst = -(this->getUnionArrayPointer()->iConst);\r
- newNode = new TIntermConstantUnion(tempConstArray, TType(EbtInt, EvqConst));\r
- break;\r
- case EbtFloat:\r
- tempConstArray->fConst = -(this->getUnionArrayPointer()->fConst);\r
- newNode = new TIntermConstantUnion(tempConstArray, TType(EbtFloat, EvqConst));\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", line);\r
- return 0;\r
- }\r
- break;\r
- case EOpLogicalNot: \r
- switch (this->getType().getBasicType()) {\r
- case EbtBool:\r
- tempConstArray->bConst = !this->getUnionArrayPointer()->bConst;\r
- newNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", line);\r
- return 0;\r
- }\r
- break;\r
- default: \r
- return 0;\r
- }\r
- newNode->setLine(this->getLine());\r
- return newNode;\r
- \r
- }\r
- }\r
-\r
- return this;\r
-}\r
-\r
-TIntermConstantUnion* TIntermediate::changeAggrToTempConst(TIntermAggregate* node, TSymbolTable& symbolTable, TSourceLoc line) \r
-{\r
- constUnion* unionArray = new constUnion[node->getType().getInstanceSize()]; \r
- bool returnVal;\r
-\r
- if (node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {\r
- returnVal = parseConstTree(line, node, unionArray, node->getOp(), symbolTable, node->getType(), true);\r
- }\r
- else {\r
- returnVal = parseConstTree(line, node, unionArray, node->getOp(), symbolTable, node->getType());\r
- }\r
-\r
- if (returnVal)\r
- unionArray = 0;\r
-\r
- return (addConstantUnion(unionArray, node->getType(), node->getLine())); \r
-}\r
-\r
-TIntermTyped* TIntermediate::copyConstUnion(TIntermConstantUnion* node) \r
-{\r
- constUnion *unionArray = node->getUnionArrayPointer();\r
-\r
- if (!unionArray)\r
- return 0;\r
- \r
- int size;\r
- if (node->getType().getBasicType() == EbtStruct)\r
- //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case\r
- // of nested/embedded structs.\r
- size = node->getType().setStructSize(node->getType().getStruct());\r
- //size = node->getType().getStructSize();\r
- else\r
- size = node->getType().getInstanceSize();\r
- \r
- constUnion *newSpace = new constUnion[size];\r
-\r
- for (int i = 0; i < size; i++)\r
- newSpace[i] = unionArray[i];\r
-\r
- node->setUnionArrayPointer(newSpace);\r
- return node;\r
-}\r
-\r
-TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node) \r
-{\r
- constUnion *rightUnionArray = node->getUnionArrayPointer();\r
- int size = node->getType().getInstanceSize();\r
-\r
- constUnion *leftUnionArray = new constUnion[size];\r
-\r
- for (int i=0; i < size; i++) {\r
- \r
- switch (promoteTo) {\r
- case EbtFloat:\r
- switch (node->getType().getBasicType()) {\r
- case EbtInt:\r
- (leftUnionArray[i]).fConst = static_cast<float>(rightUnionArray[i].iConst);\r
- break;\r
- case EbtBool:\r
- (leftUnionArray[i]).fConst = static_cast<float>(rightUnionArray[i].bConst);\r
- break;\r
- case EbtFloat:\r
- (leftUnionArray[i]).fConst = rightUnionArray[i].fConst;\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());\r
- return 0;\r
- } \r
- break;\r
- case EbtInt:\r
- switch (node->getType().getBasicType()) {\r
- case EbtInt:\r
- (leftUnionArray[i]).iConst = rightUnionArray[i].iConst;\r
- break;\r
- case EbtBool:\r
- (leftUnionArray[i]).iConst = static_cast<int>(rightUnionArray[i].bConst);\r
- break;\r
- case EbtFloat:\r
- (leftUnionArray[i]).iConst = static_cast<int>(rightUnionArray[i].fConst);\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());\r
- return 0;\r
- } \r
- break;\r
- case EbtBool:\r
- switch (node->getType().getBasicType()) {\r
- case EbtInt:\r
- (leftUnionArray[i]).bConst = rightUnionArray[i].iConst != 0;\r
- break;\r
- case EbtBool:\r
- (leftUnionArray[i]).bConst = rightUnionArray[i].bConst;\r
- break;\r
- case EbtFloat:\r
- (leftUnionArray[i]).bConst = rightUnionArray[i].fConst != 0.0;\r
- break;\r
- default: \r
- infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());\r
- return 0;\r
- } \r
- \r
- break;\r
- default:\r
- infoSink.info.message(EPrefixInternalError, "Incorrect data type found", node->getLine());\r
- return 0;\r
- }\r
- \r
- }\r
- \r
- const TType& t = node->getType();\r
- \r
- return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());\r
-}\r
-\r
-//\r
-// This method inserts the child nodes into the parent node at the given location specified\r
-// by parentNodeIter. offset tells the integer offset into the parent vector that points to \r
-// the child node. sequenceVector is the parent vector.\r
-// Returns reference to the last inserted child node\r
-// increments the offset based on the number of child nodes added\r
-//\r
-void TIntermediate::removeChildNode(TIntermSequence &parentSequence, TType& parentType, int& offset, TIntermSequence::iterator& parentNodeIter, TIntermAggregate* child)\r
-{\r
- if (!child)\r
- return;\r
-\r
- parentNodeIter = parentSequence.begin() + offset;\r
-\r
- TIntermSequence& childSequence = child->getSequence();\r
- int oldSize = static_cast<int>(parentSequence.size());\r
- if (childSequence.size() == 1) {\r
- if (!removeMatrixConstNode(parentSequence, parentType, child, offset)) {\r
- for (int i = 0; i < child->getType().getInstanceSize(); i++) {\r
- constUnion* constantUnion = new constUnion[1];\r
- *constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());\r
- TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,\r
- childSequence[0]->getAsConstantUnion()->getType());\r
- constant->setLine(child->getLine());\r
- parentNodeIter = parentSequence.begin() + offset;\r
- parentSequence.insert(parentNodeIter, constant);\r
- }\r
- }\r
- } else \r
- parentSequence.insert(parentNodeIter, childSequence.begin(), childSequence.end());\r
-\r
- int newSize = static_cast<int>(parentSequence.size());\r
- offset = offset + newSize - oldSize;\r
- parentNodeIter = parentSequence.begin() + offset;\r
- parentNodeIter = parentSequence.erase(parentNodeIter);\r
- offset--;\r
- parentNodeIter--;\r
-}\r
-\r
-//\r
-// The parent has only one child node. This method is not implemented\r
-// for parent that is a structure\r
-//\r
-TIntermTyped* TIntermediate::removeChildNode(TIntermTyped* parent, TType* parentType, TIntermAggregate* child)\r
-{\r
- TIntermTyped* resultNode = 0;\r
-\r
- if (parentType->getInstanceSize() == 1) {\r
- resultNode = child->getSequence()[0]->getAsTyped(); \r
- } else {\r
- int size = parentType->getInstanceSize();\r
- TIntermSequence& parentSequence = parent->getAsAggregate()->getSequence();\r
- TIntermSequence& childSequence = child->getSequence();\r
-\r
- if (childSequence.size() == 1) {\r
- if (!removeMatrixConstNode(parentSequence, *parentType, child, 1))\r
- parentSequence.push_back(child->getSequence()[0]);\r
- } else {\r
- for (int i = 0; i < size; i++) {\r
- parentSequence.push_back(child->getSequence()[i]);\r
- }\r
- }\r
- parentSequence.erase(parentSequence.begin());\r
-\r
- return parent;\r
- }\r
-\r
- return resultNode;\r
-}\r
-\r
-bool TIntermediate::removeMatrixConstNode(TIntermSequence &parentSequence, TType& parentType, TIntermAggregate* child, int offset)\r
-{\r
- if (!child)\r
- return false;\r
-\r
- TIntermSequence::iterator parentNodeIter;\r
- TIntermSequence &childSequence = child->getSequence();\r
-\r
- switch (child->getOp()) {\r
- case EOpConstructMat2:\r
- case EOpConstructMat3:\r
- case EOpConstructMat4:\r
- {// support MSVC++6.0\r
- for (int i = 0; i < child->getType().getInstanceSize(); i++) {\r
- constUnion* constantUnion = new constUnion[1];\r
- if (i % (child->getType().getNominalSize() + 1) == 0) {\r
- *constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());\r
- } else {\r
- switch (parentType.getBasicType()) {\r
- case EbtInt: constantUnion->iConst = 0; break;\r
- case EbtFloat: constantUnion->fConst = 0.0; break;\r
- case EbtBool: constantUnion->bConst = false; break;\r
- default: ; /* default added by BrianP */\r
- }\r
- }\r
- TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,\r
- childSequence[0]->getAsConstantUnion()->getType());\r
- constant->setLine(child->getLine());\r
- parentNodeIter = parentSequence.begin() + offset + i;\r
- parentSequence.insert(parentNodeIter, constant);\r
- }\r
- }\r
- return true;\r
- default:\r
- return false;\r
- }\r
-}\r
-\r
-void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)\r
-{\r
- assert (!pragmaTable);\r
- pragmaTable = new TPragmaTable();\r
- *pragmaTable = pTable;\r
-}\r
-\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _MMAP_INCLUDED_\r
-#define _MMAP_INCLUDED_\r
-\r
-//\r
-// Encapsulate memory mapped files\r
-//\r
-\r
-class TMMap {\r
-public:\r
- TMMap(const char* fileName) : \r
- fSize(-1), // -1 is the error value returned by GetFileSize()\r
- fp(NULL),\r
- fBuff(0) // 0 is the error value returned by MapViewOfFile()\r
- {\r
- if ((fp = fopen(fileName, "r")) == NULL)\r
- return;\r
- char c = getc(fp);\r
- fSize = 0;\r
- while (c != EOF) {\r
- fSize++;\r
- c = getc(fp);\r
- }\r
- if (c == EOF)\r
- fSize++;\r
- rewind(fp);\r
- fBuff = (char*)malloc(sizeof(char) * fSize);\r
- int count = 0;\r
- c = getc(fp);\r
- while (c != EOF) {\r
- fBuff[count++] = c;\r
- c = getc(fp);\r
- }\r
- fBuff[count++] = c;\r
- }\r
-\r
- char* getData() { return fBuff; }\r
- int getSize() { return fSize; }\r
-\r
- ~TMMap() {\r
- if (fp != NULL)\r
- fclose(fp);\r
- }\r
- \r
-private:\r
- int fSize; // size of file to map in\r
- FILE *fp;\r
- char* fBuff; // the actual data;\r
-};\r
-\r
-#endif // _MMAP_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "ParseHelper.h"\r
-#include "Include/InitializeParseContext.h"\r
-#include "osinclude.h"\r
-#include <stdarg.h>\r
-///////////////////////////////////////////////////////////////////////\r
-//\r
-// Sub- vector and matrix fields\r
-//\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Look at a '.' field selector string and change it into offsets\r
-// for a vector.\r
-//\r
-bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TVectorFields& fields, int line)\r
-{\r
- fields.num = (int) compString.size();\r
- if (fields.num > 4) {\r
- error(line, "illegal vector field selection", compString.c_str(), "");\r
- return false;\r
- }\r
-\r
- enum {\r
- exyzw,\r
- ergba,\r
- estpq\r
- } fieldSet[4];\r
-\r
- for (int i = 0; i < fields.num; ++i) {\r
- switch (compString[i]) {\r
- case 'x': \r
- fields.offsets[i] = 0;\r
- fieldSet[i] = exyzw;\r
- break;\r
- case 'r': \r
- fields.offsets[i] = 0;\r
- fieldSet[i] = ergba;\r
- break;\r
- case 's':\r
- fields.offsets[i] = 0;\r
- fieldSet[i] = estpq;\r
- break;\r
- case 'y': \r
- fields.offsets[i] = 1;\r
- fieldSet[i] = exyzw;\r
- break;\r
- case 'g': \r
- fields.offsets[i] = 1;\r
- fieldSet[i] = ergba;\r
- break;\r
- case 't':\r
- fields.offsets[i] = 1;\r
- fieldSet[i] = estpq;\r
- break;\r
- case 'z': \r
- fields.offsets[i] = 2;\r
- fieldSet[i] = exyzw;\r
- break;\r
- case 'b': \r
- fields.offsets[i] = 2;\r
- fieldSet[i] = ergba;\r
- break;\r
- case 'p':\r
- fields.offsets[i] = 2;\r
- fieldSet[i] = estpq;\r
- break;\r
- \r
- case 'w': \r
- fields.offsets[i] = 3;\r
- fieldSet[i] = exyzw;\r
- break;\r
- case 'a': \r
- fields.offsets[i] = 3;\r
- fieldSet[i] = ergba;\r
- break;\r
- case 'q':\r
- fields.offsets[i] = 3;\r
- fieldSet[i] = estpq;\r
- break;\r
- default:\r
- error(line, "illegal vector field selection", compString.c_str(), "");\r
- return false;\r
- }\r
- }\r
-\r
- for (int i = 0; i < fields.num; ++i) {\r
- if (fields.offsets[i] >= vecSize) {\r
- error(line, "vector field selection out of range", compString.c_str(), "");\r
- return false;\r
- }\r
-\r
- if (i > 0) {\r
- if (fieldSet[i] != fieldSet[i-1]) {\r
- error(line, "illegal - vector component fields not from the same set", compString.c_str(), "");\r
- return false;\r
- }\r
- }\r
- }\r
-\r
- return true;\r
-}\r
-\r
-\r
-//\r
-// Look at a '.' field selector string and change it into offsets\r
-// for a matrix.\r
-//\r
-bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TMatrixFields& fields, int line)\r
-{\r
- fields.wholeRow = false;\r
- fields.wholeCol = false;\r
- fields.row = -1;\r
- fields.col = -1;\r
-\r
- if (compString.size() != 2) {\r
- error(line, "illegal length of matrix field selection", compString.c_str(), "");\r
- return false;\r
- }\r
-\r
- if (compString[0] == '_') {\r
- if (compString[1] < '0' || compString[1] > '3') {\r
- error(line, "illegal matrix field selection", compString.c_str(), "");\r
- return false;\r
- }\r
- fields.wholeCol = true;\r
- fields.col = compString[1] - '0';\r
- } else if (compString[1] == '_') {\r
- if (compString[0] < '0' || compString[0] > '3') {\r
- error(line, "illegal matrix field selection", compString.c_str(), "");\r
- return false;\r
- }\r
- fields.wholeRow = true;\r
- fields.row = compString[0] - '0';\r
- } else {\r
- if (compString[0] < '0' || compString[0] > '3' ||\r
- compString[1] < '0' || compString[1] > '3') {\r
- error(line, "illegal matrix field selection", compString.c_str(), "");\r
- return false;\r
- }\r
- fields.row = compString[0] - '0';\r
- fields.col = compString[1] - '0';\r
- }\r
-\r
- if (fields.row >= matSize || fields.col >= matSize) {\r
- error(line, "matrix field selection out of range", compString.c_str(), "");\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////\r
-//\r
-// Errors\r
-//\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Track whether errors have occurred.\r
-//\r
-void TParseContext::recover()\r
-{\r
- recoveredFromError = true;\r
-}\r
-\r
-//\r
-// Used by flex/bison to output all syntax and parsing errors.\r
-//\r
-void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, \r
- const char *szExtraInfoFormat, ...)\r
-{\r
- char szExtraInfo[400];\r
- va_list marker;\r
- \r
- va_start(marker, szExtraInfoFormat);\r
- \r
- _vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker);\r
- \r
- /* VC++ format: file(linenum) : error #: 'token' : extrainfo */\r
- infoSink.info.prefix(EPrefixError);\r
- infoSink.info.location(nLine);\r
- infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";\r
- \r
- va_end(marker);\r
-\r
- ++numErrors;\r
-}\r
-\r
-//\r
-// Same error message for all places assignments don't work.\r
-//\r
-void TParseContext::assignError(int line, const char* op, TString left, TString right)\r
-{\r
- error(line, "", op, "cannot convert from '%s' to '%s'",\r
- right.c_str(), left.c_str());\r
-}\r
-\r
-//\r
-// Same error message for all places unary operations don't work.\r
-//\r
-void TParseContext::unaryOpError(int line, char* op, TString operand)\r
-{\r
- error(line, " wrong operand type", op, \r
- "no operation '%s' exists that takes an operand of type %s (or there is no acceptable conversion)",\r
- op, operand.c_str());\r
-}\r
-\r
-//\r
-// Same error message for all binary operations don't work.\r
-//\r
-void TParseContext::binaryOpError(int line, char* op, TString left, TString right)\r
-{\r
- error(line, " wrong operand types ", op, \r
- "no operation '%s' exists that takes a left-hand operand of type '%s' and "\r
- "a right operand of type '%s' (or there is no acceptable conversion)", \r
- op, left.c_str(), right.c_str());\r
-}\r
-\r
-//\r
-// Both test and if necessary, spit out an error, to see if the node is really\r
-// an l-value that can be operated on this way.\r
-//\r
-// Returns true if the was an error.\r
-//\r
-bool TParseContext::lValueErrorCheck(int line, char* op, TIntermTyped* node)\r
-{\r
- TIntermSymbol* symNode = node->getAsSymbolNode();\r
- TIntermBinary* binaryNode = node->getAsBinaryNode();\r
-\r
- if (binaryNode) {\r
- bool errorReturn;\r
-\r
- switch(binaryNode->getOp()) {\r
- case EOpIndexDirect:\r
- case EOpIndexIndirect:\r
- case EOpIndexDirectStruct:\r
- return lValueErrorCheck(line, op, binaryNode->getLeft());\r
- case EOpVectorSwizzle:\r
- errorReturn = lValueErrorCheck(line, op, binaryNode->getLeft());\r
- if (!errorReturn) {\r
- int offset[4] = {0,0,0,0};\r
-\r
- TIntermTyped* rightNode = binaryNode->getRight();\r
- TIntermAggregate *aggrNode = rightNode->getAsAggregate();\r
- \r
- for (TIntermSequence::iterator p = aggrNode->getSequence().begin(); \r
- p != aggrNode->getSequence().end(); p++) {\r
- int value = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst;\r
- offset[value]++; \r
- if (offset[value] > 1) {\r
- error(line, " l-value of swizzle cannot have duplicate components", op, "", "");\r
-\r
- return true;\r
- }\r
- }\r
- } \r
-\r
- return errorReturn;\r
- default: \r
- break;\r
- }\r
- error(line, " l-value required", op, "", "");\r
-\r
- return true;\r
- }\r
-\r
-\r
- const char* symbol = 0;\r
- if (symNode != 0)\r
- symbol = symNode->getSymbol().c_str();\r
-\r
- char* message = 0;\r
- switch (node->getQualifier()) {\r
- case EvqConst: message = "can't modify a const"; break;\r
- case EvqConstReadOnly: message = "can't modify a const"; break;\r
- case EvqAttribute: message = "can't modify an attribute"; break;\r
- case EvqUniform: message = "can't modify a uniform"; break;\r
- case EvqVaryingIn: message = "can't modify a varying"; break;\r
- case EvqInput: message = "can't modify an input"; break;\r
- case EvqFace: message = "can't modify gl_FrontFace"; break;\r
- case EvqFragCoord: message = "can't modify gl_FragCoord"; break;\r
- default:\r
-\r
- //\r
- // Type that can't be written to?\r
- //\r
- switch (node->getBasicType()) {\r
- case EbtSampler1D:\r
- case EbtSampler2D:\r
- case EbtSampler3D:\r
- case EbtSamplerCube:\r
- case EbtSampler1DShadow:\r
- case EbtSampler2DShadow:\r
- message = "can't modify a sampler";\r
- break;\r
- case EbtVoid:\r
- message = "can't modify void";\r
- break;\r
- default: \r
- break;\r
- }\r
- }\r
-\r
- if (message == 0 && binaryNode == 0 && symNode == 0) {\r
- error(line, " l-value required", op, "", "");\r
-\r
- return true;\r
- }\r
-\r
-\r
- //\r
- // Everything else is okay, no error.\r
- //\r
- if (message == 0)\r
- return false;\r
-\r
- //\r
- // If we get here, we have an error and a message.\r
- //\r
- if (symNode)\r
- error(line, " l-value required", op, "\"%s\" (%s)", symbol, message);\r
- else\r
- error(line, " l-value required", op, "(%s)", message);\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// Both test, and if necessary spit out an error, to see if the node is really\r
-// a constant.\r
-//\r
-// Returns true if the was an error.\r
-//\r
-bool TParseContext::constErrorCheck(TIntermTyped* node)\r
-{\r
- if (node->getQualifier() == EvqConst)\r
- return false;\r
-\r
- error(node->getLine(), "constant expression required", "", "");\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// Both test, and if necessary spit out an error, to see if the node is really\r
-// an integer.\r
-//\r
-// Returns true if the was an error.\r
-//\r
-bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)\r
-{\r
- if (node->getBasicType() == EbtInt && node->getNominalSize() == 1)\r
- return false;\r
-\r
- error(node->getLine(), "integer expression required", token, "");\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// Both test, and if necessary spit out an error, to see if we are currently\r
-// globally scoped.\r
-//\r
-// Returns true if the was an error.\r
-//\r
-bool TParseContext::globalErrorCheck(int line, bool global, char* token)\r
-{\r
- if (global)\r
- return false;\r
-\r
- error(line, "only allowed at global scope", token, "");\r
-\r
- return true;\r
-}\r
-\r
-//\r
-// For now, keep it simple: if it starts "gl_", it's reserved, independent\r
-// of scope. Except, if the symbol table is at the built-in push-level,\r
-// which is when we are parsing built-ins.\r
-//\r
-// Returns true if there was an error.\r
-//\r
-bool TParseContext::reservedErrorCheck(int line, const TString& identifier)\r
-{\r
- if (symbolTable.atBuiltInLevel() ||\r
- identifier.substr(0, 3) != TString("gl_"))\r
- return false;\r
-\r
- error(line, "reserved built-in name", "gl_", "");\r
-\r
- return true; \r
-}\r
-\r
-//\r
-// Make sure there is enough data provided to the constructor to build\r
-// something of the type of the constructor. Also returns the type of\r
-// the constructor.\r
-//\r
-// Returns true if there was an error in construction.\r
-//\r
-bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction& function, TOperator op, TType* type)\r
-{\r
- switch(op) {\r
- case EOpConstructInt: *type = TType(EbtInt); break;\r
- case EOpConstructBool: *type = TType(EbtBool); break;\r
- case EOpConstructFloat: *type = TType(EbtFloat); break;\r
- case EOpConstructVec2: *type = TType(EbtFloat, EvqTemporary, 2); break;\r
- case EOpConstructVec3: *type = TType(EbtFloat, EvqTemporary, 3); break;\r
- case EOpConstructVec4: *type = TType(EbtFloat, EvqTemporary, 4); break;\r
- case EOpConstructBVec2: *type = TType(EbtBool, EvqTemporary, 2); break;\r
- case EOpConstructBVec3: *type = TType(EbtBool, EvqTemporary, 3); break;\r
- case EOpConstructBVec4: *type = TType(EbtBool, EvqTemporary, 4); break;\r
- case EOpConstructIVec2: *type = TType(EbtInt, EvqTemporary, 2); break;\r
- case EOpConstructIVec3: *type = TType(EbtInt, EvqTemporary, 3); break;\r
- case EOpConstructIVec4: *type = TType(EbtInt, EvqTemporary, 4); break;\r
- case EOpConstructMat2: *type = TType(EbtFloat, EvqTemporary, 2, true); break;\r
- case EOpConstructMat3: *type = TType(EbtFloat, EvqTemporary, 3, true); break;\r
- case EOpConstructMat4: *type = TType(EbtFloat, EvqTemporary, 4, true); break;\r
- case EOpConstructStruct: *type = TType(function.getReturnType().getStruct(), function.getReturnType().getTypeName()); break;\r
- default:\r
- error(line, "expected constructor", "Internal Error", "");\r
- return true;\r
- }\r
-\r
- bool constructingMatrix = false;\r
- switch(op) {\r
- case EOpConstructMat2:\r
- case EOpConstructMat3:\r
- case EOpConstructMat4:\r
- constructingMatrix = true;\r
- break;\r
- default: \r
- break;\r
- }\r
-\r
- //\r
- // Note: It's okay to have too many components available, but not okay to have unused\r
- // arguments. 'full' will go to true when enough args have been seen. If we loop\r
- // again, there is an extra argument, so 'overfull' will become true.\r
- //\r
-\r
- int size = 0;\r
- bool constType = true;\r
- bool full = false;\r
- bool overFull = false;\r
- bool matrixInMatrix = false;\r
- for (int i = 0; i < function.getParamCount(); ++i) {\r
- size += function[i].type->getInstanceSize();\r
- if (constructingMatrix && function[i].type->isMatrix())\r
- matrixInMatrix = true;\r
- if (full)\r
- overFull = true;\r
- if (op != EOpConstructStruct && size >= type->getInstanceSize())\r
- full = true;\r
- if (function[i].type->getQualifier() != EvqConst)\r
- constType = false;\r
- }\r
- \r
- if (constType)\r
- type->changeQualifier(EvqConst);\r
-\r
- if (matrixInMatrix) {\r
- error(line, "constructing matrix from matrix", "constructor", "(reserved)");\r
- return true;\r
- }\r
-\r
- if (overFull) {\r
- error(line, "too many arguments", "constructor", "");\r
- return true;\r
- }\r
-\r
- if (size != 1 && size < type->getInstanceSize() || (size < 1) && op == EOpConstructStruct) {\r
- error(line, "not enough data provided for construction", "constructor", "");\r
- return true;\r
- }\r
-\r
- TIntermTyped* typed = node->getAsTyped();\r
- if (typed == 0) {\r
- error(line, "constructor argument does not have a type", "constructor", "");\r
- return true;\r
- }\r
- if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) {\r
- error(line, "cannot convert a sampler", "constructor", "");\r
- return true;\r
- }\r
- if (typed->getBasicType() == EbtVoid) {\r
- error(line, "cannot convert a void", "constructor", "");\r
- return true;\r
- }\r
-\r
- return false;\r
-}\r
-\r
-// This function checks to see if a void variable has been declared and raise an error message for such a case\r
-//\r
-// returns true in case of an error\r
-//\r
-bool TParseContext::voidErrorCheck(int line, const TString& identifier, const TPublicType& pubType)\r
-{\r
- if (pubType.type == EbtVoid) {\r
- error(line, "illegal use of type 'void'", identifier.c_str(), "");\r
- return true;\r
- } \r
-\r
- return false;\r
-}\r
-\r
-// This function checks to see if the node (for the expression) contains a scalar boolean expression or not\r
-//\r
-// returns true in case of an error\r
-//\r
-bool TParseContext::boolErrorCheck(int line, const TIntermTyped* type)\r
-{\r
- if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector()) {\r
- error(line, "boolean expression expected", "", "");\r
- return true;\r
- } \r
-\r
- return false;\r
-}\r
-\r
-// This function checks to see if the node (for the expression) contains a scalar boolean expression or not\r
-//\r
-// returns true in case of an error\r
-//\r
-bool TParseContext::boolErrorCheck(int line, const TPublicType& pType)\r
-{\r
- if (pType.type != EbtBool || pType.array || pType.matrix || (pType.size > 1)) {\r
- error(line, "boolean expression expected", "", "");\r
- return true;\r
- } \r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const char* reason)\r
-{\r
- if (pType.type == EbtStruct) {\r
- if (containsSampler(*pType.userDef)) {\r
- error(line, reason, TType::getBasicString(pType.type), "(structure contains a sampler)");\r
- \r
- return true;\r
- }\r
- \r
- return false;\r
- } else if (IsSampler(pType.type)) {\r
- error(line, reason, TType::getBasicString(pType.type), "");\r
-\r
- return true;\r
- }\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType)\r
-{\r
- if ((pType.qualifier == EvqVaryingIn || pType.qualifier == EvqVaryingOut || pType.qualifier == EvqAttribute) &&\r
- pType.type == EbtStruct) {\r
- error(line, "cannot be used with a structure", getQualifierString(pType.qualifier), "");\r
- \r
- return true;\r
- }\r
-\r
- if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform"))\r
- return true;\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type)\r
-{\r
- if ((qualifier == EvqOut || qualifier == EvqInOut) && \r
- type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) {\r
- error(line, "samplers cannot be output parameters", type.getBasicString(), "");\r
- return true;\r
- }\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::containsSampler(TType& type)\r
-{\r
- if (IsSampler(type.getBasicType()))\r
- return true;\r
-\r
- if (type.getBasicType() == EbtStruct) {\r
- TTypeList& structure = *type.getStruct();\r
- for (unsigned int i = 0; i < structure.size(); ++i) {\r
- if (containsSampler(*structure[i].type))\r
- return true;\r
- }\r
- }\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::insertBuiltInArrayAtGlobalLevel()\r
-{\r
- TString *name = NewPoolTString("gl_TexCoord");\r
- TSymbol* symbol = symbolTable.find(*name);\r
- if (!symbol) {\r
- error(0, "INTERNAL ERROR finding symbol", name->c_str(), "");\r
- return true;\r
- }\r
- TVariable* variable = static_cast<TVariable*>(symbol);\r
-\r
- TVariable* newVariable = new TVariable(name, variable->getType());\r
-\r
- if (! symbolTable.insert(*newVariable)) {\r
- delete newVariable;\r
- error(0, "INTERNAL ERROR inserting new symbol", name->c_str(), "");\r
- return true;\r
- }\r
-\r
- return false;\r
-}\r
-\r
-//\r
-// Do all the semantic checking for declaring an array, with and \r
-// without a size, and make the right changes to the symbol table.\r
-//\r
-// size == 0 means no specified size.\r
-//\r
-// Returns true if there was an error.\r
-//\r
-bool TParseContext::arrayErrorCheck(int line, TString& identifier, TPublicType type, TIntermTyped* size)\r
-{\r
- //\r
- // Don't check for reserved word use until after we know it's not in the symbol table,\r
- // because reserved arrays can be redeclared.\r
- //\r
-\r
- //\r
- // Can the type be an array?\r
- //\r
- if (type.array || type.qualifier == EvqAttribute || type.qualifier == EvqConst) {\r
- error(line, "cannot declare arrays of this type", TType(type).getCompleteString().c_str(), "");\r
- return true;\r
- }\r
- type.array = true;\r
-\r
- //\r
- // size will be 0 if there is no size declared, otherwise it contains the size\r
- // declared.\r
- //\r
- TIntermConstantUnion* constant = 0;\r
- if (size) {\r
- constant = size->getAsConstantUnion();\r
- if (constant == 0 || constant->getBasicType() != EbtInt || constant->getUnionArrayPointer()->iConst <= 0) {\r
- error(line, "array size must be a positive integer", identifier.c_str(), "");\r
- return true;\r
- }\r
- }\r
-\r
- bool builtIn = false; \r
- bool sameScope = false;\r
- TSymbol* symbol = symbolTable.find(identifier, &builtIn, &sameScope);\r
- if (symbol == 0 || !sameScope) {\r
- if (reservedErrorCheck(line, identifier))\r
- return true;\r
- \r
- TVariable* variable = new TVariable(&identifier, TType(type));\r
-\r
- if (size)\r
- variable->getType().setArraySize(constant->getUnionArrayPointer()->iConst);\r
-\r
- if (! symbolTable.insert(*variable)) {\r
- delete variable;\r
- error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str(), "");\r
- return true;\r
- }\r
- } else {\r
- if (! symbol->isVariable()) {\r
- error(line, "variable expected", identifier.c_str(), "");\r
- return true;\r
- }\r
-\r
- TVariable* variable = static_cast<TVariable*>(symbol);\r
- if (! variable->getType().isArray()) {\r
- error(line, "redeclaring non-array as array", identifier.c_str(), "");\r
- return true;\r
- }\r
- if (variable->getType().getArraySize() > 0) {\r
- error(line, "redeclaration of array with size", identifier.c_str(), "");\r
- return true;\r
- }\r
- \r
- if (variable->getType() != TType(type)) {\r
- error(line, "redeclaration of array with a different type", identifier.c_str(), "");\r
- return true;\r
- }\r
-\r
- TType* t = variable->getArrayInformationType();\r
- while (t != 0) {\r
- if (t->getMaxArraySize() > constant->getUnionArrayPointer()->iConst) {\r
- error(line, "higher index value already used for the array", identifier.c_str(), "");\r
- return true;\r
- }\r
- t->setArraySize(constant->getUnionArrayPointer()->iConst);\r
- t = t->getArrayInformationType();\r
- }\r
-\r
- if (size)\r
- variable->getType().setArraySize(constant->getUnionArrayPointer()->iConst);\r
- } \r
-\r
- if (voidErrorCheck(line, identifier, type))\r
- return true;\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, TSourceLoc line)\r
-{\r
- bool builtIn = false;\r
- TSymbol* symbol = symbolTable.find(node->getSymbol(), &builtIn);\r
- if (symbol == 0) {\r
- error(line, " undeclared identifier", node->getSymbol().c_str(), "");\r
- return true;\r
- }\r
- TVariable* variable = static_cast<TVariable*>(symbol);\r
-\r
- type->setArrayInformationType(variable->getArrayInformationType());\r
- variable->updateArrayInformationType(type);\r
-\r
- // we dont want to update the maxArraySize when this flag is not set, we just want to include this \r
- // node type in the chain of node types so that its updated when a higher maxArraySize comes in.\r
- if (!updateFlag)\r
- return false;\r
-\r
- size++;\r
- variable->getType().setMaxArraySize(size);\r
- type->setMaxArraySize(size);\r
- TType* tt = type;\r
-\r
- while(tt->getArrayInformationType() != 0) {\r
- tt = tt->getArrayInformationType();\r
- tt->setMaxArraySize(size);\r
- }\r
-\r
- return false;\r
-}\r
-\r
-//\r
-// Do semantic checking for a variable declaration that has no initializer,\r
-// and update the symbol table.\r
-//\r
-// Returns true if there was an error.\r
-//\r
-bool TParseContext::nonInitErrorCheck(int line, TString& identifier, TPublicType& type)\r
-{\r
- if (reservedErrorCheck(line, identifier))\r
- recover();\r
-\r
- //\r
- // Make the qualifier make sense, error is issued in a little bit.\r
- //\r
- bool constError = false;\r
- if (type.qualifier == EvqConst) {\r
- type.qualifier = EvqTemporary;\r
- constError = true;\r
- }\r
-\r
- TVariable* variable = new TVariable(&identifier, TType(type));\r
-\r
- if (! symbolTable.insert(*variable)) {\r
- error(line, "redefinition", variable->getName().c_str(), "");\r
- delete variable;\r
- return true;\r
- }\r
- if (constError) {\r
- error(line, "variables with qualifier 'const' must be initialized", identifier.c_str(), "");\r
- return true;\r
- }\r
-\r
- if (voidErrorCheck(line, identifier, type))\r
- return true;\r
-\r
- return false;\r
-}\r
-\r
-bool TParseContext::paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type)\r
-{ \r
- if (qualifier != EvqConst && qualifier != EvqTemporary) {\r
- error(line, "qualifier not allowed on function parameter", getQualifierString(qualifier), "");\r
- return true;\r
- }\r
- if (qualifier == EvqConst && paramQualifier != EvqIn) {\r
- error(line, "qualifier not allowed with ", getQualifierString(qualifier), getQualifierString(paramQualifier));\r
- return true;\r
- }\r
-\r
- if (qualifier == EvqConst)\r
- type->changeQualifier(EvqConstReadOnly);\r
- else\r
- type->changeQualifier(paramQualifier);\r
-\r
- return false;\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Non-Errors.\r
-//\r
-/////////////////////////////////////////////////////////////////////////////////\r
-\r
-//\r
-// Look up a function name in the symbol table, and make sure it is a function.\r
-//\r
-// Return the function symbol if found, otherwise 0.\r
-//\r
-const TFunction* TParseContext::findFunction(int line, TFunction* call, bool *builtIn)\r
-{\r
- const TSymbol* symbol = symbolTable.find(call->getMangledName(), builtIn);\r
-\r
- if (symbol == 0) { \r
- error(line, "no matching overloaded function found", call->getName().c_str(), "");\r
- return 0;\r
- }\r
-\r
- if (! symbol->isFunction()) {\r
- error(line, "function name expected", call->getName().c_str(), "");\r
- return 0;\r
- }\r
- \r
- const TFunction* function = static_cast<const TFunction*>(symbol);\r
- \r
- return function;\r
-}\r
-//\r
-// Initializers show up in several places in the grammar. Have one set of\r
-// code to handle them here.\r
-//\r
-bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, \r
- TIntermTyped* initializer, TIntermNode*& intermNode)\r
-{\r
- if (reservedErrorCheck(line, identifier))\r
- return true;\r
-\r
- if (voidErrorCheck(line, identifier, pType))\r
- return true;\r
-\r
- //\r
- // add variable to symbol table\r
- //\r
- TVariable* variable = new TVariable(&identifier, TType(pType));\r
- if (! symbolTable.insert(*variable)) {\r
- error(line, "redefinition", variable->getName().c_str(), "");\r
- return true;\r
- // don't delete variable, it's used by error recovery, and the pool \r
- // pop will take care of the memory\r
- }\r
-\r
- //\r
- // identifier must be of type constant, a global, or a temporary\r
- //\r
- TQualifier qualifier = variable->getType().getQualifier();\r
- if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConst)) {\r
- error(line, " cannot initialize this type of qualifier ", variable->getType().getQualifierString(), "");\r
- return true;\r
- }\r
- //\r
- // test for and propagate constant\r
- //\r
-\r
- if (qualifier == EvqConst) {\r
- if (qualifier != initializer->getType().getQualifier()) {\r
- error(line, " assigning non-constant to", "=", "'%s'", variable->getType().getCompleteString().c_str());\r
- variable->getType().changeQualifier(EvqTemporary);\r
- return true;\r
- }\r
- if (TType(pType) != initializer->getType()) {\r
- error(line, " non-matching types for const initializer ", \r
- variable->getType().getQualifierString(), "");\r
- variable->getType().changeQualifier(EvqTemporary);\r
- return true;\r
- }\r
- if (initializer->getAsConstantUnion()) { \r
- constUnion* unionArray = variable->getConstPointer(); \r
-\r
- if (pType.size == 1 && TType(pType).getBasicType() != EbtStruct) {\r
- switch (pType.type ) {\r
- case EbtInt:\r
- unionArray->iConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].iConst;\r
- break;\r
- case EbtFloat:\r
- unionArray->fConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].fConst;\r
- break;\r
- case EbtBool:\r
- unionArray->bConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].bConst;\r
- break;\r
- default:\r
- error(line, " cannot initialize constant of this type", "", "");\r
- return true;\r
- }\r
- } else {\r
- variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer());\r
- }\r
- } else if (initializer->getAsAggregate()) {\r
- bool returnVal = false;\r
- constUnion* unionArray = variable->getConstPointer();\r
- if (initializer->getAsAggregate()->getSequence().size() == 1 && initializer->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {\r
- returnVal = intermediate.parseConstTree(line, initializer, unionArray, initializer->getAsAggregate()->getOp(), symbolTable, variable->getType(), true);\r
- }\r
- else {\r
- returnVal = intermediate.parseConstTree(line, initializer, unionArray, initializer->getAsAggregate()->getOp(), symbolTable, variable->getType());\r
- }\r
- intermNode = 0;\r
- constUnion *arrayUnion = unionArray;\r
- if (returnVal) {\r
- arrayUnion = 0;\r
- variable->getType().changeQualifier(EvqTemporary);\r
- } \r
- return returnVal;\r
- } else if (initializer->getAsSymbolNode()) {\r
- const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol());\r
- const TVariable* tVar = static_cast<const TVariable*>(symbol);\r
-\r
- constUnion* constArray = tVar->getConstPointer();\r
- variable->shareConstPointer(constArray);\r
- } else {\r
- error(line, " assigning non-constant to", "=", "'%s'", variable->getType().getCompleteString().c_str());\r
- variable->getType().changeQualifier(EvqTemporary);\r
- return true;\r
- }\r
- }\r
- \r
- if (qualifier != EvqConst) {\r
- TIntermSymbol* intermSymbol = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), line);\r
- intermNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, line);\r
- if (intermNode == 0) {\r
- assignError(line, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());\r
- return true;\r
- }\r
- } else \r
- intermNode = 0;\r
-\r
- return false;\r
-}\r
-\r
-//\r
-// This method checks to see if the given aggregate node has all its children nodes as constants\r
-// This method does not test if structure members are constant\r
-//\r
-bool TParseContext::canNodeBeRemoved(TIntermNode* childNode)\r
-{\r
- TIntermAggregate *aggrNode = childNode->getAsAggregate();\r
- if (!aggrNode)\r
- return false;\r
-\r
- if (!aggrNode->isConstructor() || aggrNode->getOp() == EOpConstructStruct)\r
- return false;\r
-\r
- bool allConstant = true;\r
-\r
- // check if all the child nodes are constants so that they can be inserted into \r
- // the parent node\r
- if (aggrNode) {\r
- TIntermSequence &childSequenceVector = aggrNode->getSequence() ;\r
- for (TIntermSequence::iterator p = childSequenceVector.begin(); \r
- p != childSequenceVector.end(); p++) {\r
- if (!(*p)->getAsTyped()->getAsConstantUnion())\r
- return false;\r
- }\r
- }\r
-\r
- return allConstant;\r
-}\r
-\r
-// This function is used to test for the correctness of the parameters passed to various constructor functions\r
-// and also convert them to the right datatype if it is allowed and required. \r
-//\r
-// Returns 0 for an error or the constructed node (aggregate or typed) for no error.\r
-//\r
-TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOperator op, TFunction* fnCall, TSourceLoc line)\r
-{\r
- if (node == 0)\r
- return 0;\r
-\r
- TIntermAggregate* aggrNode = node->getAsAggregate();\r
- \r
- TTypeList::iterator list;\r
- TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.\r
- if (op == EOpConstructStruct) {\r
- const TType& ttype = fnCall->getReturnType();\r
- structure = ttype.getStruct();\r
- list = (*structure).begin();\r
- }\r
-\r
- bool singleArg;\r
- if (aggrNode) {\r
- if (aggrNode->getOp() != EOpNull || aggrNode->getSequence().size() == 1)\r
- singleArg = true;\r
- else\r
- singleArg = false;\r
- } else\r
- singleArg = true;\r
-\r
- TIntermTyped *newNode;\r
- if (singleArg) {\r
- if (op == EOpConstructStruct) { \r
- // If structure constructor is being called for only one parameter inside the structure,\r
- // we need to call constructStruct function once.\r
- if (structure->size() != 1) {\r
- error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");\r
- \r
- return 0;\r
- } else\r
- return constructStruct(node, (*list).type, 1, node->getLine(), false);\r
- } else {\r
- newNode = constructBuiltIn(type, op, node, node->getLine(), false);\r
- if (newNode && newNode->getAsAggregate()) {\r
- if (canNodeBeRemoved(newNode->getAsAggregate()->getSequence()[0])) {\r
- TIntermAggregate* returnAggNode = newNode->getAsAggregate()->getSequence()[0]->getAsAggregate();\r
- newNode = intermediate.removeChildNode(newNode, type, returnAggNode);\r
- }\r
- }\r
- return newNode;\r
- }\r
- }\r
- \r
- //\r
- // Handle list of arguments.\r
- //\r
- TIntermSequence &sequenceVector = aggrNode->getSequence() ; // Stores the information about the parameter to the constructor\r
- // if the structure constructor contains more than one parameter, then construct\r
- // each parameter\r
- if (op == EOpConstructStruct) {\r
- if (structure->size() != sequenceVector.size()) { // If the number of parameters to the constructor does not match the expected number of parameters\r
- error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");\r
- \r
- return 0;\r
- }\r
- }\r
- \r
- int paramCount = 0; // keeps a track of the constructor parameter number being checked \r
- \r
- // for each parameter to the constructor call, check to see if the right type is passed or convert them \r
- // to the right type if possible (and allowed).\r
- // for structure constructors, just check if the right type is passed, no conversion is allowed.\r
- \r
- for (TIntermSequence::iterator p = sequenceVector.begin(); \r
- p != sequenceVector.end(); p++, paramCount++) {\r
- bool move = false;\r
- if (op == EOpConstructStruct) {\r
- newNode = constructStruct(*p, (list[paramCount]).type, paramCount+1, node->getLine(), true);\r
- if (newNode)\r
- move = true;\r
- } else {\r
- newNode = constructBuiltIn(type, op, *p, node->getLine(), true);\r
-\r
- if (newNode) {\r
- if (canNodeBeRemoved(newNode))\r
- intermediate.removeChildNode(sequenceVector, *type, paramCount, p, newNode->getAsAggregate());\r
- else\r
- move = true; \r
- } \r
- }\r
- if (move) {\r
- sequenceVector.erase(p); \r
- sequenceVector.insert(p, newNode);\r
- }\r
- }\r
-\r
- return intermediate.setAggregateOperator(aggrNode, op, line);\r
-}\r
-\r
-// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value\r
-// for the parameter to the constructor (passed to this function). Essentially, it converts\r
-// the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a \r
-// float, then float is converted to int.\r
-//\r
-// Returns 0 for an error or the constructed node.\r
-//\r
-TIntermTyped* TParseContext::constructBuiltIn(TType* type, TOperator op, TIntermNode* node, TSourceLoc line, bool subset)\r
-{\r
- TIntermTyped* newNode;\r
- TOperator basicOp;\r
-\r
- //\r
- // First, convert types as needed.\r
- //\r
- switch (op) {\r
- case EOpConstructVec2:\r
- case EOpConstructVec3:\r
- case EOpConstructVec4:\r
- case EOpConstructMat2:\r
- case EOpConstructMat3:\r
- case EOpConstructMat4:\r
- case EOpConstructFloat:\r
- basicOp = EOpConstructFloat;\r
- break;\r
-\r
- case EOpConstructIVec2:\r
- case EOpConstructIVec3:\r
- case EOpConstructIVec4:\r
- case EOpConstructInt:\r
- basicOp = EOpConstructInt;\r
- break;\r
-\r
- case EOpConstructBVec2:\r
- case EOpConstructBVec3:\r
- case EOpConstructBVec4:\r
- case EOpConstructBool:\r
- basicOp = EOpConstructBool;\r
- break;\r
-\r
- default:\r
- error(line, "unsupported construction", "", "");\r
- recover();\r
-\r
- return 0;\r
- }\r
- newNode = intermediate.addUnaryMath(basicOp, node, node->getLine(), symbolTable);\r
- if (newNode == 0) {\r
- error(line, "can't convert", "constructor", "");\r
- return 0;\r
- }\r
-\r
- //\r
- // Now, if there still isn't an operation to do the construction, and we need one, add one.\r
- //\r
- \r
- // Otherwise, skip out early.\r
- if (subset || newNode != node && newNode->getType() == *type)\r
- return newNode;\r
-\r
- // setAggregateOperator will insert a new node for the constructor, as needed.\r
- return intermediate.setAggregateOperator(newNode, op, line);\r
-}\r
-\r
-// This function tests for the type of the parameters to the structures constructors. Raises\r
-// an error message if the expected type does not match the parameter passed to the constructor.\r
-//\r
-// Returns 0 for an error or the input node itself if the expected and the given parameter types match.\r
-//\r
-TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int paramCount, TSourceLoc line, bool subset)\r
-{\r
- if (*type == node->getAsTyped()->getType()) {\r
- if (subset)\r
- return node->getAsTyped();\r
- else\r
- return intermediate.setAggregateOperator(node->getAsTyped(), EOpConstructStruct, line);\r
- } else {\r
- error(line, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount,\r
- node->getAsTyped()->getType().getBasicString(), type->getBasicString());\r
- recover();\r
- }\r
-\r
- return 0;\r
-}\r
-\r
-//\r
-// This function returns the tree representation for the vector field(s) being accessed from contant vector.\r
-// If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is\r
-// returned, else an aggregate node is returned (for v.xy). The input to this function could either be the symbol\r
-// node or it could be the intermediate tree representation of accessing fields in a constant structure or column of \r
-// a constant matrix.\r
-//\r
-TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTyped* node, TSourceLoc line)\r
-{\r
- TIntermTyped* typedNode;\r
- TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();\r
- TIntermAggregate* aggregateNode = node->getAsAggregate();\r
-\r
- constUnion *unionArray;\r
- if (tempConstantNode) {\r
- unionArray = tempConstantNode->getUnionArrayPointer();\r
-\r
- if (!unionArray) { // this error message should never be raised\r
- infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", line);\r
- recover();\r
-\r
- return node;\r
- }\r
- } else if (aggregateNode) { // if an aggregate node is present, the value has to be taken from the parse tree \r
- // for a case like vec(4).xz\r
- unionArray = new constUnion[aggregateNode->getType().getInstanceSize()]; \r
- \r
- bool returnVal = false;\r
- if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);\r
- }\r
- else {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());\r
- }\r
-\r
- if (returnVal)\r
- return 0;\r
-\r
- } else { // The node has to be either a symbol node or an aggregate node or a tempConstant node, else, its an error\r
- error(line, "No aggregate or constant union node available", "Internal Error", "");\r
- recover();\r
-\r
- return 0;\r
- }\r
-\r
- constUnion* constArray = new constUnion[fields.num];\r
-\r
- for (int i = 0; i < fields.num; i++) {\r
- if (fields.offsets[i] >= node->getType().getInstanceSize()) {\r
- error(line, "", "[", "vector field selection out of range '%d'", fields.offsets[i]);\r
- recover();\r
- fields.offsets[i] = 0;\r
- }\r
- \r
- constArray[i] = unionArray[fields.offsets[i]];\r
-\r
- } \r
- typedNode = intermediate.addConstantUnion(constArray, node->getType(), line);\r
- return typedNode;\r
-}\r
-\r
-//\r
-// This function returns the column being accessed from a constant matrix. The values are retrieved from\r
-// the symbol table and parse-tree is built for a vector (each column of a matrix is a vector). The input \r
-// to the function could either be a symbol node (m[0] where m is a constant matrix)that represents a \r
-// constant matrix or it could be the tree representation of the constant matrix (s.m1[0] where s is a constant structure)\r
-//\r
-TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, TSourceLoc line)\r
-{\r
- TIntermTyped* typedNode;\r
- TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();\r
- TIntermAggregate* aggregateNode = node->getAsAggregate();\r
-\r
- if (index >= node->getType().getNominalSize()) {\r
- error(line, "", "[", "matrix field selection out of range '%d'", index);\r
- recover();\r
- index = 0;\r
- }\r
-\r
- if (tempConstantNode) {\r
- constUnion* unionArray = tempConstantNode->getUnionArrayPointer();\r
- int size = tempConstantNode->getType().getNominalSize();\r
- typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);\r
- } else if (aggregateNode) {\r
- // for a case like mat4(5)[0]\r
- constUnion* unionArray = new constUnion[aggregateNode->getType().getInstanceSize()]; \r
- int size = aggregateNode->getType().getNominalSize();\r
- \r
- bool returnVal = false;\r
- if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);\r
- }\r
- else {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());\r
- }\r
-\r
- if (!returnVal)\r
- typedNode = intermediate.addConstantUnion(&unionArray[size*index], aggregateNode->getType(), line);\r
- else \r
- return 0;\r
-\r
- } else {\r
- error(line, "No Aggregate or Constant Union node available", "Internal Error", "");\r
- recover();\r
-\r
- return 0;\r
- }\r
-\r
- return typedNode;\r
-}\r
-\r
-//\r
-// This function returns the value of a particular field inside a constant structure from the symbol table. \r
-// If there is an embedded/nested struct, it appropriately calls addConstStructNested or addConstStructFromAggr\r
-// function and returns the parse-tree with the values of the embedded/nested struct.\r
-//\r
-TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* node, TSourceLoc line)\r
-{\r
- TTypeList* fields = node->getType().getStruct();\r
- TIntermTyped *typedNode;\r
- int instanceSize = 0;\r
- unsigned int index = 0;\r
- TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();\r
- TIntermAggregate* aggregateNode = node->getAsAggregate();\r
-\r
- for ( index = 0; index < fields->size(); ++index) {\r
- if ((*fields)[index].type->getFieldName() == identifier) {\r
- break;\r
- } else {\r
- if ((*fields)[index].type->getStruct())\r
- //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case\r
- // of nested/embedded structs. \r
- instanceSize += (*fields)[index].type->setStructSize((*fields)[index].type->getStruct());\r
- else\r
- instanceSize += (*fields)[index].type->getInstanceSize();\r
- }\r
- }\r
-\r
- if (tempConstantNode) {\r
- constUnion* constArray = tempConstantNode->getUnionArrayPointer();\r
-\r
- typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function\r
- } else if (aggregateNode) {\r
- // for a case like constStruct(1,v3).i where structure fields is int i and vec3 v3.\r
-\r
- constUnion* unionArray = new constUnion[aggregateNode->getType().getStructSize()]; \r
- \r
- bool returnVal = false;\r
- if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);\r
- }\r
- else {\r
- returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());\r
- }\r
-\r
- if (!returnVal)\r
- typedNode = intermediate.addConstantUnion(unionArray+instanceSize, aggregateNode->getType(), line);\r
- else\r
- return 0;\r
-\r
- } else {\r
- error(line, "No Aggregate or Constant Union node available", "Internal Error", "");\r
- recover();\r
-\r
- return 0;\r
- }\r
-\r
- return typedNode;\r
-}\r
-\r
-//\r
-// Initialize all supported extensions to disable\r
-//\r
-void TParseContext::initializeExtensionBehavior()\r
-{\r
- //\r
- // example code: extensionBehavior["test"] = EDisable; // where "test" is the name of \r
- // supported extension\r
- //\r
-}\r
-\r
-OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;\r
-\r
-bool InitializeParseContextIndex()\r
-{\r
- if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) {\r
- assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");\r
- return false;\r
- }\r
-\r
- //\r
- // Allocate a TLS index.\r
- //\r
- GlobalParseContextIndex = OS_AllocTLSIndex();\r
- \r
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool InitializeGlobalParseContext()\r
-{\r
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "InitializeGlobalParseContext(): Parse Context index not initalised");\r
- return false;\r
- }\r
-\r
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));\r
- if (lpParseContext != 0) {\r
- assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");\r
- return false;\r
- }\r
-\r
- TThreadParseContext *lpThreadData = new TThreadParseContext();\r
- if (lpThreadData == 0) {\r
- assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context");\r
- return false;\r
- }\r
-\r
- lpThreadData->lpGlobalParseContext = 0;\r
- OS_SetTLSValue(GlobalParseContextIndex, lpThreadData);\r
-\r
- return true;\r
-}\r
-\r
-TParseContextPointer& GetGlobalParseContext()\r
-{\r
- //\r
- // Minimal error checking for speed\r
- //\r
-\r
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));\r
-\r
- return lpParseContext->lpGlobalParseContext;\r
-}\r
-\r
-bool FreeParseContext()\r
-{\r
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "FreeParseContext(): Parse Context index not initalised");\r
- return false;\r
- }\r
-\r
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));\r
- if (lpParseContext)\r
- delete lpParseContext;\r
-\r
- return true;\r
-}\r
-\r
-bool FreeParseContextIndex()\r
-{\r
- OS_TLSIndex tlsiIndex = GlobalParseContextIndex;\r
-\r
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "FreeParseContextIndex(): Parse Context index not initalised");\r
- return false;\r
- }\r
-\r
- GlobalParseContextIndex = OS_INVALID_TLS_INDEX;\r
-\r
- return OS_FreeTLSIndex(tlsiIndex);\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-#ifndef _PARSER_HELPER_INCLUDED_\r
-#define _PARSER_HELPER_INCLUDED_\r
-\r
-#include "../Include/ShHandle.h"\r
-#include "SymbolTable.h"\r
-#include "localintermediate.h"\r
-\r
-struct TMatrixFields {\r
- bool wholeRow;\r
- bool wholeCol;\r
- int row;\r
- int col; \r
-};\r
-\r
-typedef enum {\r
- EBhRequire,\r
- EBhEnable,\r
- EBhWarn,\r
- EBhDisable\r
-} TBehavior;\r
-\r
-struct TPragma {\r
- TPragma(bool o, bool d) : optimize(o), debug(d) { }\r
- bool optimize;\r
- bool debug;\r
- TPragmaTable pragmaTable;\r
-};\r
-\r
-//\r
-// The following are extra variables needed during parsing, grouped together so\r
-// they can be passed to the parser without needing a global.\r
-//\r
-struct TParseContext {\r
- TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) : \r
- intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),\r
- recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), \r
- inTypeParen(false), contextPragma(true, false) { }\r
- TIntermediate& intermediate; // to hold and build a parse tree\r
- TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed\r
- TInfoSink& infoSink;\r
- EShLanguage language; // vertex or fragment language (future: pack or unpack)\r
- TIntermNode* treeRoot; // root of parse tree being created\r
- bool recoveredFromError; // true if a parse error has occurred, but we continue to parse\r
- int numErrors;\r
- bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier\r
- int loopNestingLevel; // 0 if outside all loops\r
- bool inTypeParen; // true if in parentheses, looking only for an identifier\r
- const TType* currentFunctionType; // the return type of the function that's currently being parsed\r
- bool functionReturnsValue; // true if a non-void function has a return\r
- TMap<TString, TBehavior> extensionBehavior;\r
- void initializeExtensionBehavior();\r
-\r
- void C_DECL error(TSourceLoc, const char *szReason, const char *szToken, \r
- const char *szExtraInfoFormat, ...);\r
- bool reservedErrorCheck(int line, const TString& identifier);\r
- void recover();\r
- \r
- bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);\r
- bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);\r
- void assignError(int line, const char* op, TString left, TString right);\r
- void unaryOpError(int line, char* op, TString operand);\r
- void binaryOpError(int line, char* op, TString left, TString right);\r
- bool lValueErrorCheck(int line, char* op, TIntermTyped*);\r
- bool constErrorCheck(TIntermTyped* node);\r
- bool integerErrorCheck(TIntermTyped* node, char* token);\r
- bool globalErrorCheck(int line, bool global, char* token);\r
- bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);\r
- bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TIntermTyped* size);\r
- bool insertBuiltInArrayAtGlobalLevel();\r
- bool voidErrorCheck(int, const TString&, const TPublicType&);\r
- bool boolErrorCheck(int, const TIntermTyped*);\r
- bool boolErrorCheck(int, const TPublicType&);\r
- bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);\r
- bool structQualifierErrorCheck(int line, const TPublicType& pType);\r
- bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);\r
- bool containsSampler(TType& type);\r
- bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);\r
- bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);\r
- const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);\r
- bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, \r
- TIntermTyped* initializer, TIntermNode*& intermNode);\r
- bool canNodeBeRemoved(TIntermNode*);\r
- TIntermTyped* addConstructor(TIntermNode*, TType*, TOperator, TFunction*, TSourceLoc);\r
- TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);\r
- TIntermTyped* constructBuiltIn(TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);\r
- TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);\r
- TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);\r
- TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);\r
- bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);\r
- struct TPragma contextPragma;\r
- TString HashErrMsg; \r
- bool AfterEOF;\r
-};\r
-\r
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);\r
-void PaReservedWord();\r
-int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);\r
-int PaParseComment(int &lineno, TParseContext&);\r
-void setInitialState();\r
-\r
-typedef TParseContext* TParseContextPointer;\r
-extern TParseContextPointer& GetGlobalParseContext();\r
-#define GlobalParseContext GetGlobalParseContext()\r
-\r
-typedef struct TThreadParseContextRec\r
-{\r
- TParseContext *lpGlobalParseContext;\r
-} TThreadParseContext;\r
-\r
-#endif // _PARSER_HELPER_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "../Include/PoolAlloc.h"\r
-#include "../Include/Common.h"\r
-\r
-#include "Include/InitializeGlobals.h"\r
-#include "osinclude.h"\r
-\r
-OS_TLSIndex PoolIndex;\r
-\r
-void InitializeGlobalPools()\r
-{\r
- TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); \r
- if (globalPools)\r
- return;\r
-\r
- TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true);\r
-\r
- TThreadGlobalPools* threadData = new TThreadGlobalPools();\r
- \r
- threadData->globalPoolAllocator = globalPoolAllocator;\r
- \r
- OS_SetTLSValue(PoolIndex, threadData); \r
- globalPoolAllocator->push();\r
-}\r
-\r
-void FreeGlobalPools()\r
-{\r
- // Release the allocated memory for this thread.\r
- TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); \r
- if (!globalPools)\r
- return;\r
- \r
- GlobalPoolAllocator.popAll();\r
- delete &GlobalPoolAllocator; \r
- delete globalPools;\r
-}\r
-\r
-bool InitializePoolIndex()\r
-{\r
- // Allocate a TLS index.\r
- if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-void FreePoolIndex()\r
-{\r
- // Release the TLS index.\r
- OS_FreeTLSIndex(PoolIndex);\r
-}\r
-\r
-TPoolAllocator& GetGlobalPoolAllocator()\r
-{\r
- TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));\r
-\r
- return *threadData->globalPoolAllocator;\r
-}\r
-\r
-void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)\r
-{\r
- TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));\r
-\r
- threadData->globalPoolAllocator = poolAllocator;\r
-}\r
-\r
-//\r
-// Implement the functionality of the TPoolAllocator class, which\r
-// is documented in PoolAlloc.h.\r
-//\r
-TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) : \r
- global(g),\r
- pageSize(growthIncrement),\r
- alignment(allocationAlignment),\r
- freeList(0),\r
- inUseList(0),\r
- numCalls(0)\r
-{\r
- //\r
- // Don't allow page sizes we know are smaller than all common\r
- // OS page sizes.\r
- //\r
- if (pageSize < 4*1024)\r
- pageSize = 4*1024;\r
-\r
- //\r
- // A large currentPageOffset indicates a new page needs to\r
- // be obtained to allocate memory.\r
- //\r
- currentPageOffset = pageSize;\r
-\r
- //\r
- // Adjust alignment to be at least pointer aligned and\r
- // power of 2.\r
- //\r
- size_t minAlign = sizeof(void*);\r
- alignment &= ~(minAlign - 1);\r
- if (alignment < minAlign)\r
- alignment = minAlign;\r
- size_t a = 1;\r
- while (a < alignment)\r
- a <<= 1;\r
- alignment = a;\r
- alignmentMask = a - 1;\r
-\r
- //\r
- // Align header skip\r
- //\r
- headerSkip = minAlign;\r
- if (headerSkip < sizeof(tHeader)) {\r
- headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask;\r
- }\r
-\r
- //\r
- // Put a marker at the beginning of the stack. We won't \r
- // pop() past this.\r
- //\r
- tAllocState start = { currentPageOffset, 0 };\r
- stack.push_back(start);\r
-}\r
-\r
-TPoolAllocator::~TPoolAllocator()\r
-{\r
- if (!global) {\r
- //\r
- // Then we know that this object is not being \r
- // allocated after other, globally scoped objects\r
- // that depend on it. So we can delete the "in use" memory.\r
- //\r
- while (inUseList) {\r
- tHeader* next = inUseList->nextPage;\r
- inUseList->~tHeader();\r
- delete [] reinterpret_cast<char*>(inUseList);\r
- inUseList = next;\r
- }\r
- }\r
-\r
- //\r
- // Always delete the free list memory - it can't be being\r
- // (correctly) referenced, whether the pool allocator was\r
- // global or not. We should not check the guard blocks\r
- // here, because we did it already when the block was\r
- // placed into the free list.\r
- //\r
- while (freeList) {\r
- tHeader* next = freeList->nextPage;\r
- delete [] reinterpret_cast<char*>(freeList);\r
- freeList = next;\r
- }\r
-}\r
-\r
-// Support MSVC++ 6.0\r
-const unsigned char TAllocation::guardBlockBeginVal = 0xfb;\r
-const unsigned char TAllocation::guardBlockEndVal = 0xfe;\r
-const unsigned char TAllocation::userDataFill = 0xcd;\r
-\r
-# ifdef GUARD_BLOCKS\r
- const size_t TAllocation::guardBlockSize = 16;\r
-# else\r
- const size_t TAllocation::guardBlockSize = 0;\r
-# endif\r
-\r
-//\r
-// Check a single guard block for damage\r
-//\r
-void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const\r
-{\r
- for (int x = 0; x < guardBlockSize; x++) {\r
- if (blockMem[x] != val) {\r
- char assertMsg[80];\r
-\r
- // We don't print the assert message. It's here just to be helpful.\r
- sprintf(assertMsg, "PoolAlloc: Damage %s %u byte allocation at 0x%p\n",\r
- locText, size, data());\r
- assert(0 && "PoolAlloc: Damage in guard block");\r
- }\r
- }\r
-}\r
-\r
-\r
-void TPoolAllocator::push()\r
-{\r
- tAllocState state = { currentPageOffset, inUseList };\r
-\r
- stack.push_back(state);\r
- \r
- //\r
- // Indicate there is no current page to allocate from.\r
- //\r
- currentPageOffset = pageSize;\r
-}\r
-\r
-//\r
-// Do a mass-deallocation of all the individual allocations\r
-// that have occurred since the last push(), or since the\r
-// last pop(), or since the object's creation.\r
-//\r
-// The deallocated pages are saved for future allocations.\r
-//\r
-void TPoolAllocator::pop()\r
-{\r
- if (stack.size() < 1)\r
- return;\r
-\r
- tHeader* page = stack.back().page;\r
- currentPageOffset = stack.back().offset;\r
-\r
- while (inUseList != page) {\r
- // invoke destructor to free allocation list\r
- inUseList->~tHeader();\r
- \r
- tHeader* nextInUse = inUseList->nextPage;\r
- if (inUseList->pageCount > 1)\r
- delete [] reinterpret_cast<char*>(inUseList);\r
- else {\r
- inUseList->nextPage = freeList;\r
- freeList = inUseList;\r
- }\r
- inUseList = nextInUse;\r
- }\r
-\r
- stack.pop_back();\r
-}\r
-\r
-//\r
-// Do a mass-deallocation of all the individual allocations\r
-// that have occurred.\r
-//\r
-void TPoolAllocator::popAll()\r
-{\r
- while (stack.size() > 0)\r
- pop();\r
-}\r
-\r
-void* TPoolAllocator::allocate(size_t numBytes)\r
-{\r
- // If we are using guard blocks, all allocations are bracketed by\r
- // them: [guardblock][allocation][guardblock]. numBytes is how\r
- // much memory the caller asked for. allocationSize is the total\r
- // size including guard blocks. In release build,\r
- // guardBlockSize=0 and this all gets optimized away.\r
- size_t allocationSize = TAllocation::allocationSize(numBytes);\r
- \r
- //\r
- // Just keep some interesting statistics.\r
- //\r
- ++numCalls;\r
- totalBytes += numBytes;\r
-\r
- //\r
- // Do the allocation, most likely case first, for efficiency.\r
- // This step could be moved to be inline sometime.\r
- //\r
- if (currentPageOffset + allocationSize <= pageSize) {\r
- //\r
- // Safe to allocate from currentPageOffset.\r
- //\r
- unsigned char* memory = reinterpret_cast<unsigned char *>(inUseList) + currentPageOffset;\r
- currentPageOffset += allocationSize;\r
- currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask;\r
-\r
- return initializeAllocation(inUseList, memory, numBytes);\r
- }\r
-\r
- if (allocationSize + headerSkip > pageSize) {\r
- //\r
- // Do a multi-page allocation. Don't mix these with the others.\r
- // The OS is efficient and allocating and free-ing multiple pages.\r
- //\r
- size_t numBytesToAlloc = allocationSize + headerSkip;\r
- tHeader* memory = reinterpret_cast<tHeader*>(::new char[numBytesToAlloc]);\r
- if (memory == 0)\r
- return 0;\r
-\r
- // Use placement-new to initialize header\r
- new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize);\r
- inUseList = memory;\r
-\r
- currentPageOffset = pageSize; // make next allocation come from a new page\r
-\r
- // No guard blocks for multi-page allocations (yet)\r
- return reinterpret_cast<void*>(reinterpret_cast<UINT_PTR>(memory) + headerSkip);\r
- }\r
-\r
- //\r
- // Need a simple page to allocate from.\r
- //\r
- tHeader* memory;\r
- if (freeList) {\r
- memory = freeList;\r
- freeList = freeList->nextPage;\r
- } else {\r
- memory = reinterpret_cast<tHeader*>(::new char[pageSize]);\r
- if (memory == 0)\r
- return 0;\r
- }\r
-\r
- // Use placement-new to initialize header\r
- new(memory) tHeader(inUseList, 1);\r
- inUseList = memory;\r
- \r
- unsigned char* ret = reinterpret_cast<unsigned char *>(inUseList) + headerSkip;\r
- currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;\r
-\r
- return initializeAllocation(inUseList, ret, numBytes);\r
-}\r
-\r
-\r
-//\r
-// Check all allocations in a list for damage by calling check on each.\r
-//\r
-void TAllocation::checkAllocList() const\r
-{\r
- for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)\r
- alloc->check();\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "../Include/intermediate.h"\r
-\r
-class TAliveTraverser : public TIntermTraverser {\r
-public:\r
- TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)\r
- {\r
- visitSymbol = AliveSymbol;\r
- visitSelection = AliveSelection;\r
- rightToLeft = true;\r
- }\r
- bool wasFound() { return found; }\r
-protected:\r
- bool found;\r
- TQualifier qualifier;\r
-\r
- friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);\r
- friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);\r
-};\r
-\r
-//\r
-// Report whether or not a variable of the given qualifier type\r
-// is guaranteed written. Not always possible to determine if\r
-// it is written conditionally.\r
-//\r
-// ?? It does not do this well yet, this is just a place holder\r
-// that simply determines if it was reference at all, anywhere.\r
-//\r
-bool QualifierWritten(TIntermNode* node, TQualifier qualifier)\r
-{\r
- TAliveTraverser it(qualifier);\r
-\r
- if (node)\r
- node->traverse(&it);\r
-\r
- return it.wasFound();\r
-}\r
-\r
-void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)\r
-{\r
- TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);\r
-\r
- //\r
- // If it's what we're looking for, record it.\r
- //\r
- if (node->getQualifier() == lit->qualifier)\r
- lit->found = true;\r
-}\r
-\r
-bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)\r
-{\r
- TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);\r
-\r
- if (lit->wasFound())\r
- return false;\r
-\r
- return true;\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-bool QualifierWritten(TIntermNode* root, TQualifier);\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "../Include/intermediate.h"\r
-#include "RemoveTree.h"\r
-//\r
-// Code to recursively delete the intermediate tree.\r
-//\r
-\r
-void RemoveSymbol(TIntermSymbol* node, TIntermTraverser* it)\r
-{\r
- delete node;\r
-}\r
-\r
-bool RemoveBinary(bool /*preVisit*/ , TIntermBinary* node, TIntermTraverser*)\r
-{\r
- delete node;\r
-\r
- return true;\r
-}\r
-\r
-bool RemoveUnary(bool /*preVisit */, TIntermUnary* node, TIntermTraverser*)\r
-{\r
- delete node;\r
-\r
- return true;\r
-}\r
-\r
-bool RemoveAggregate(bool /*preVisit*/ , TIntermAggregate* node, TIntermTraverser*)\r
-{\r
- delete node;\r
-\r
- return true;\r
-}\r
-\r
-bool RemoveSelection(bool /*preVisit*/ , TIntermSelection* node, TIntermTraverser*)\r
-{\r
- delete node;\r
-\r
- return true;\r
-}\r
-\r
-void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)\r
-{\r
- delete node;\r
-}\r
-\r
-//\r
-// Entry point.\r
-//\r
-void RemoveAllTreeNodes(TIntermNode* root)\r
-{\r
- TIntermTraverser it;\r
-\r
- it.visitAggregate = RemoveAggregate;\r
- it.visitBinary = RemoveBinary;\r
- it.visitConstantUnion = RemoveConstantUnion;\r
- it.visitSelection = RemoveSelection;\r
- it.visitSymbol = RemoveSymbol;\r
- it.visitUnary = RemoveUnary;\r
-\r
- it.preVisit = false;\r
- it.postVisit = true;\r
-\r
- root->traverse(&it);\r
-}\r
-\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-void RemoveAllTreeNodes(TIntermNode*);\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// Implement the top-level of interface to the compiler/linker,\r
-// as defined in ShaderLang.h\r
-//\r
-#include "SymbolTable.h"\r
-#include "ParseHelper.h"\r
-#include "../Include/ShHandle.h"\r
-#include "Initialisation.h"\r
-\r
-#define SH_EXPORTING\r
-#include "../Public/ShaderLangExt.h"\r
-\r
-#include "Include/ResourceLimits.h"\r
-#include "Initialize.h"\r
-\r
-extern "C" int InitPreprocessor(void);\r
-extern "C" int FinalizePreprocessor(void);\r
-extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);\r
-\r
-bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);\r
-bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);\r
-\r
-//\r
-// A symbol table for each language. Each has a different\r
-// set of built-ins, and we want to preserve that from\r
-// compile to compile.\r
-//\r
-TSymbolTable SymbolTables[EShLangCount];\r
-\r
-TPoolAllocator* PerProcessGPA = 0;\r
-//\r
-// This is the platform independent interface between an OGL driver\r
-// and the shading language compiler/linker.\r
-//\r
-\r
-//\r
-// Driver must call this first, once, before doing any other\r
-// compiler/linker operations.\r
-//\r
-int ShInitialize()\r
-{\r
- TInfoSink infoSink;\r
- bool ret = true;\r
-\r
- if (!InitProcess())\r
- return 0;\r
-\r
- // This method should be called once per process. If its called by multiple threads, then \r
- // we need to have thread synchronization code around the initialization of per process\r
- // global pool allocator\r
- if (!PerProcessGPA) { \r
- TPoolAllocator *builtInPoolAllocator = new TPoolAllocator(true);\r
- builtInPoolAllocator->push();\r
- TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;\r
- SetGlobalPoolAllocatorPtr(builtInPoolAllocator);\r
-\r
- TSymbolTable symTables[EShLangCount];\r
- generateBuiltInSymbolTable(0, infoSink, symTables);\r
-\r
- PerProcessGPA = new TPoolAllocator(true);\r
- PerProcessGPA->push();\r
- SetGlobalPoolAllocatorPtr(PerProcessGPA);\r
-\r
- SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);\r
- SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);\r
-\r
- SetGlobalPoolAllocatorPtr(gPoolAllocator);\r
-\r
- symTables[EShLangVertex].pop();\r
- symTables[EShLangFragment].pop();\r
-\r
- builtInPoolAllocator->popAll();\r
- delete builtInPoolAllocator; \r
-\r
- }\r
-\r
- return ret ? 1 : 0;\r
-}\r
-\r
-//\r
-// Driver calls these to create and destroy compiler/linker\r
-// objects.\r
-//\r
-\r
-ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions));\r
- \r
- return reinterpret_cast<void*>(base);\r
-}\r
-\r
-ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions));\r
-\r
- return reinterpret_cast<void*>(base);\r
-}\r
-\r
-ShHandle ShConstructUniformMap()\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap());\r
-\r
- return reinterpret_cast<void*>(base);\r
-}\r
-\r
-void ShDestruct(ShHandle handle)\r
-{\r
- if (handle == 0)\r
- return;\r
-\r
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);\r
-\r
- if (base->getAsCompiler())\r
- DeleteCompiler(base->getAsCompiler());\r
- else if (base->getAsLinker())\r
- DeleteLinker(base->getAsLinker());\r
- else if (base->getAsUniformMap())\r
- DeleteUniformMap(base->getAsUniformMap());\r
-}\r
-\r
-//\r
-// Cleanup symbol tables\r
-//\r
-int __fastcall ShFinalize()\r
-{ \r
- if (PerProcessGPA) {\r
- PerProcessGPA->popAll();\r
- delete PerProcessGPA;\r
- }\r
- return 1;\r
-}\r
-\r
-//\r
-// This function should be called only once by the Master Dll. Currently, this is being called for each thread \r
-// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called \r
-// from master dll once.\r
-//\r
-bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable* symbolTables, EShLanguage language)\r
-{\r
- TBuiltIns builtIns;\r
- \r
- if (resources) {\r
- builtIns.initialize(*resources);\r
- initializeSymbolTable(builtIns.getBuiltInStrings(), language, infoSink, resources, symbolTables);\r
- } else {\r
- builtIns.initialize();\r
- initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources, symbolTables);\r
- initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources, symbolTables);\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource* resources, TSymbolTable* symbolTables)\r
-{\r
- TIntermediate intermediate(infoSink);\r
- TSymbolTable* symbolTable;\r
- \r
- if (resources)\r
- symbolTable = symbolTables;\r
- else\r
- symbolTable = &symbolTables[language];\r
-\r
- TParseContext parseContext(*symbolTable, intermediate, language, infoSink);\r
-\r
- GlobalParseContext = &parseContext;\r
- \r
- setInitialState();\r
-\r
- assert (symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());\r
- \r
- //\r
- // Parse the built-ins. This should only happen once per\r
- // language symbol table.\r
- //\r
- // Push the symbol table to give it an initial scope. This\r
- // push should not have a corresponding pop, so that built-ins\r
- // are preserved, and the test for an empty table fails.\r
- //\r
-\r
- symbolTable->push();\r
- \r
- //Initialize the Preprocessor\r
- int ret = InitPreprocessor();\r
- if (ret) {\r
- infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");\r
- return false;\r
- }\r
- \r
- for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();\r
- i != BuiltInStrings[parseContext.language].end();\r
- ++i) {\r
- const char* builtInShaders[1];\r
- int builtInLengths[1];\r
-\r
- builtInShaders[0] = (*i).c_str();\r
- builtInLengths[0] = (int) (*i).size();\r
-\r
- if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {\r
- infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");\r
- return false;\r
- }\r
- }\r
-\r
- if (resources) {\r
- IdentifyBuiltIns(parseContext.language, *symbolTable, *resources);\r
- } else { \r
- IdentifyBuiltIns(parseContext.language, *symbolTable);\r
- }\r
-\r
- FinalizePreprocessor();\r
-\r
- return true;\r
-}\r
-\r
-\r
-//\r
-// Do an actual compile on the given strings. The result is left \r
-// in the given compile object.\r
-//\r
-// Return: The return value of ShCompile is really boolean, indicating\r
-// success or failure.\r
-//\r
-int ShCompile(\r
- const ShHandle handle,\r
- const char* const shaderStrings[],\r
- const int numStrings,\r
- const EShOptimizationLevel optLevel,\r
- const TBuiltInResource* resources,\r
- int debugOptions\r
- )\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- TCompiler* compiler = base->getAsCompiler();\r
- if (compiler == 0)\r
- return 0;\r
- \r
- GlobalPoolAllocator.push();\r
- compiler->infoSink.info.erase();\r
- compiler->infoSink.debug.erase();\r
-\r
- if (numStrings == 0)\r
- return 1;\r
-\r
- TIntermediate intermediate(compiler->infoSink);\r
- TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);\r
- \r
- generateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());\r
-\r
- TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);\r
- parseContext.initializeExtensionBehavior();\r
-\r
- GlobalParseContext = &parseContext;\r
- \r
- setInitialState();\r
-\r
- InitPreprocessor(); \r
- //\r
- // Parse the application's shaders. All the following symbol table\r
- // work will be throw-away, so push a new allocation scope that can\r
- // be thrown away, then push a scope for the current shader's globals.\r
- //\r
- bool success = true;\r
- \r
- symbolTable.push();\r
- if (!symbolTable.atGlobalLevel())\r
- parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");\r
-\r
- if (parseContext.insertBuiltInArrayAtGlobalLevel())\r
- success = false;\r
-\r
- int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext);\r
- if (ret)\r
- success = false;\r
-\r
- if (success && parseContext.treeRoot) {\r
- if (optLevel == EShOptNoGeneration)\r
- parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");\r
- else {\r
- success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);\r
-\r
- if (success) {\r
-\r
- if (debugOptions & EDebugOpIntermediate)\r
- intermediate.outputTree(parseContext.treeRoot);\r
-\r
- //\r
- // Call the machine dependent compiler\r
- //\r
- if (! compiler->compile(parseContext.treeRoot))\r
- success = false;\r
- }\r
- }\r
- } else if (!success) {\r
- parseContext.infoSink.info.prefix(EPrefixError);\r
- parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n";\r
- success = false;\r
- if (debugOptions & EDebugOpIntermediate)\r
- intermediate.outputTree(parseContext.treeRoot);\r
- }\r
-\r
- intermediate.remove(parseContext.treeRoot);\r
-\r
- //\r
- // Ensure symbol table is returned to the built-in level,\r
- // throwing away all but the built-ins.\r
- //\r
- while (! symbolTable.atSharedBuiltInLevel())\r
- symbolTable.pop();\r
-\r
- FinalizePreprocessor();\r
- //\r
- // Throw away all the temporary memory used by the compilation process.\r
- //\r
- GlobalPoolAllocator.pop();\r
-\r
- return success ? 1 : 0;\r
-}\r
-\r
-//\r
-// Do an actual link on the given compile objects.\r
-//\r
-// Return: The return value of is really boolean, indicating\r
-// success or failure.\r
-//\r
-int ShLink(\r
- const ShHandle linkHandle,\r
- const ShHandle compHandles[],\r
- const int numHandles,\r
- ShHandle uniformMapHandle,\r
- short int** uniformsAccessed,\r
- int* numUniformsAccessed)\r
-\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);\r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
- if (linker == 0)\r
- return 0;\r
-\r
- int returnValue;\r
- GlobalPoolAllocator.push();\r
- returnValue = ShLinkExt(linkHandle, compHandles, numHandles);\r
- GlobalPoolAllocator.pop();\r
-\r
- if (returnValue)\r
- return 1;\r
-\r
- return 0;\r
-}\r
-//\r
-// This link method will be eventually used once the ICD supports the new linker interface\r
-//\r
-int ShLinkExt(\r
- const ShHandle linkHandle,\r
- const ShHandle compHandles[],\r
- const int numHandles)\r
-{\r
- if (linkHandle == 0 || numHandles == 0)\r
- return 0;\r
-\r
- THandleList cObjects;\r
-\r
- {// support MSVC++6.0\r
- for (int i = 0; i < numHandles; ++i) {\r
- if (compHandles[i] == 0)\r
- return 0;\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);\r
- if (base->getAsLinker()) {\r
- cObjects.push_back(base->getAsLinker());\r
- }\r
- if (base->getAsCompiler())\r
- cObjects.push_back(base->getAsCompiler());\r
- \r
- \r
- if (cObjects[i] == 0)\r
- return 0;\r
- }\r
- }\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);\r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
-\r
- if (linker == 0)\r
- return 0;\r
-\r
- linker->infoSink.info.erase();\r
-\r
- {// support MSVC++6.0\r
- for (int i = 0; i < numHandles; ++i) {\r
- if (cObjects[i]->getAsCompiler()) {\r
- if (! cObjects[i]->getAsCompiler()->linkable()) {\r
- linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code."); \r
- return 0;\r
- }\r
- }\r
- }\r
- }\r
-\r
- bool ret = linker->link(cObjects);\r
-\r
- return ret ? 1 : 0;\r
-}\r
-\r
-//\r
-// ShSetEncrpytionMethod is a place-holder for specifying\r
-// how source code is encrypted.\r
-//\r
-void ShSetEncryptionMethod(ShHandle handle)\r
-{\r
- if (handle == 0)\r
- return;\r
-}\r
-\r
-//\r
-// Return any compiler/linker/uniformmap log of messages for the application.\r
-//\r
-const char* ShGetInfoLog(const ShHandle handle)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = static_cast<TShHandleBase*>(handle);\r
- TInfoSink* infoSink;\r
-\r
- if (base->getAsCompiler())\r
- infoSink = &(base->getAsCompiler()->getInfoSink());\r
- else if (base->getAsLinker())\r
- infoSink = &(base->getAsLinker()->getInfoSink());\r
-\r
- infoSink->info << infoSink->debug.c_str();\r
- return infoSink->info.c_str();\r
-}\r
-\r
-//\r
-// Return the resulting binary code from the link process. Structure\r
-// is machine dependent.\r
-//\r
-const void* ShGetExecutable(const ShHandle handle)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- \r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
- if (linker == 0)\r
- return 0;\r
-\r
- return linker->getObjectCode();\r
-}\r
-\r
-//\r
-// Let the linker know where the application said it's attributes are bound.\r
-// The linker does not use these values, they are remapped by the ICD or\r
-// hardware. It just needs them to know what's aliased.\r
-//\r
-// Return: The return value of is really boolean, indicating\r
-// success or failure.\r
-//\r
-// This is to preserve the old linker API, P20 code can use the generic \r
-// ShConstructBinding() and ShAddBinding() APIs\r
-//\r
-int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)\r
-{ \r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
-\r
- if (linker == 0)\r
- return 0;\r
- \r
- linker->setAppAttributeBindings(table);\r
-\r
- return 1;\r
-}\r
-\r
-//\r
-// Let the linker know where the predefined attributes have to live.\r
-// This is to preserve the old linker API, P20 code can use the generic \r
-// ShConstructBinding() and ShAddBinding() APIs\r
-//\r
-int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
-\r
- if (linker == 0)\r
- return 0;\r
-\r
- linker->setFixedAttributeBindings(table);\r
- return 1;\r
-}\r
-\r
-//\r
-// Some attribute locations are off-limits to the linker...\r
-//\r
-int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return 0;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- TLinker* linker = static_cast<TLinker*>(base->getAsLinker());\r
- if (linker == 0)\r
- return 0;\r
-\r
- linker->setExcludedAttributes(attributes, count);\r
-\r
- return 1;\r
-}\r
-\r
-//\r
-// Return the index for OpenGL to use for knowing where a uniform lives.\r
-//\r
-// Return: The return value of is really boolean, indicating\r
-// success or failure.\r
-//\r
-// We dont have to change this code for now since the TUniformMap being\r
-// passed back to ICD by the linker is the same as being used for the old P10 linker\r
-//\r
-int ShGetUniformLocation(const ShHandle handle, const char* name)\r
-{\r
- if (!InitThread())\r
- return 0;\r
-\r
- if (handle == 0)\r
- return -1;\r
-\r
- TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);\r
- TUniformMap* uniformMap= base->getAsUniformMap();\r
- if (uniformMap == 0)\r
- return -1;\r
-\r
- return uniformMap->getLocation(name);\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-//\r
-// Symbol table for parsing. Most functionaliy and main ideas \r
-// are documented in the header file.\r
-//\r
-\r
-#include "SymbolTable.h"\r
-\r
-//\r
-// TType helper function needs a place to live.\r
-//\r
-\r
-//\r
-// Recursively generate mangled names.\r
-//\r
-void TType::buildMangledName(TString& mangledName)\r
-{\r
- if (isMatrix())\r
- mangledName += 'm';\r
- else if (isVector())\r
- mangledName += 'v';\r
-\r
- switch (type) {\r
- case EbtFloat: mangledName += 'f'; break;\r
- case EbtInt: mangledName += 'i'; break;\r
- case EbtBool: mangledName += 'b'; break;\r
- case EbtSampler1D: mangledName += "s1"; break;\r
- case EbtSampler2D: mangledName += "s2"; break;\r
- case EbtSampler3D: mangledName += "s3"; break;\r
- case EbtSamplerCube: mangledName += "sC"; break;\r
- case EbtSampler1DShadow: mangledName += "sS1"; break;\r
- case EbtSampler2DShadow: mangledName += "sS2"; break;\r
- case EbtStruct: \r
- mangledName += "struct-";\r
- if (typeName)\r
- mangledName += *typeName;\r
- {// support MSVC++6.0\r
- for (unsigned int i = 0; i < structure->size(); ++i) {\r
- mangledName += '-';\r
- (*structure)[i].type->buildMangledName(mangledName);\r
- }\r
- }\r
- default: \r
- break;\r
- }\r
-\r
- mangledName += static_cast<char>('0' + getNominalSize());\r
- if (isArray()) {\r
- char buf[10];\r
- sprintf(buf, "%d", arraySize);\r
- mangledName += '[';\r
- mangledName += buf;\r
- mangledName += ']';\r
- }\r
-}\r
-\r
-//\r
-// Dump functions.\r
-//\r
-\r
-void TVariable::dump(TInfoSink& infoSink) const \r
-{\r
- infoSink.debug << getName().c_str() << ": " << type.getQualifierString() << " " << type.getBasicString();\r
- if (type.isArray()) {\r
- infoSink.debug << "[0]";\r
- }\r
- infoSink.debug << "\n";\r
-}\r
-\r
-void TFunction::dump(TInfoSink &infoSink) const\r
-{\r
- infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n";\r
-}\r
-\r
-void TSymbolTableLevel::dump(TInfoSink &infoSink) const \r
-{\r
- tLevel::const_iterator it;\r
- for (it = level.begin(); it != level.end(); ++it)\r
- (*it).second->dump(infoSink);\r
-}\r
-\r
-void TSymbolTable::dump(TInfoSink &infoSink) const\r
-{\r
- for (int level = currentLevel(); level >= 0; --level) {\r
- infoSink.debug << "LEVEL " << level << "\n";\r
- table[level]->dump(infoSink);\r
- }\r
-}\r
-\r
-//\r
-// Functions have buried pointers to delete.\r
-//\r
-TFunction::~TFunction()\r
-{\r
- for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)\r
- delete (*i).type;\r
-}\r
-\r
-//\r
-// Symbol table levels are a map of pointers to symbols that have to be deleted.\r
-//\r
-TSymbolTableLevel::~TSymbolTableLevel()\r
-{\r
- for (tLevel::iterator it = level.begin(); it != level.end(); ++it)\r
- delete (*it).second;\r
-}\r
-\r
-//\r
-// Change all function entries in the table with the non-mangled name\r
-// to be related to the provided built-in operation. This is a low\r
-// performance operation, and only intended for symbol tables that\r
-// live across a large number of compiles.\r
-//\r
-void TSymbolTableLevel::relateToOperator(const char* name, TOperator op) \r
-{\r
- tLevel::iterator it;\r
- for (it = level.begin(); it != level.end(); ++it) {\r
- if ((*it).second->isFunction()) {\r
- TFunction* function = static_cast<TFunction*>((*it).second);\r
- if (function->getName() == name)\r
- function->relateToOperator(op);\r
- }\r
- }\r
-} \r
-\r
-\r
-TSymbol::TSymbol(const TSymbol& copyOf)\r
-{\r
- name = NewPoolTString(copyOf.name->c_str());\r
- uniqueId = copyOf.uniqueId;\r
-}\r
-\r
-TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)\r
-{ \r
- type.copyType(copyOf.type, remapper);\r
- userType = copyOf.userType;\r
- // for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL\r
- assert(copyOf.arrayInformationType == 0); \r
- arrayInformationType = 0;\r
-\r
- if (copyOf.unionArray) { \r
- assert(!copyOf.type.getStruct()); \r
- assert(copyOf.type.getInstanceSize() == 1);\r
- unionArray = new constUnion[1];\r
- switch (type.getBasicType()) {\r
- case EbtFloat: unionArray[0].fConst = copyOf.unionArray[0].fConst; break;\r
- case EbtInt: unionArray[0].iConst = copyOf.unionArray[0].iConst; break;\r
- case EbtBool: unionArray[0].bConst = copyOf.unionArray[0].bConst; break;\r
- default:\r
- assert (false && "Unknown type");\r
- }\r
- } else\r
- unionArray = 0;\r
-}\r
-\r
-TVariable* TVariable::clone(TStructureMap& remapper) \r
-{\r
- TVariable *variable = new TVariable(*this, remapper);\r
-\r
- return variable;\r
-}\r
-\r
-TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)\r
-{ \r
- for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {\r
- TParameter param;\r
- parameters.push_back(param);\r
- parameters.back().copyParam(copyOf.parameters[i], remapper);\r
- }\r
-\r
- returnType.copyType(copyOf.returnType, remapper);\r
- mangledName = copyOf.mangledName;\r
- op = copyOf.op;\r
- defined = copyOf.defined;\r
-}\r
-\r
-TFunction* TFunction::clone(TStructureMap& remapper) \r
-{\r
- TFunction *function = new TFunction(*this, remapper);\r
-\r
- return function;\r
-}\r
-\r
-TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)\r
-{\r
- TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();\r
- tLevel::iterator iter;\r
- for (iter = level.begin(); iter != level.end(); ++iter) {\r
- symTableLevel->insert(*iter->second->clone(remapper));\r
- }\r
-\r
- return symTableLevel;\r
-}\r
-\r
-void TSymbolTable::copyTable(const TSymbolTable& copyOf)\r
-{\r
- TStructureMap remapper;\r
- uniqueId = copyOf.uniqueId;\r
- for (unsigned int i = 0; i < copyOf.table.size(); ++i) {\r
- table.push_back(copyOf.table[i]->clone(remapper));\r
- }\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _SYMBOL_TABLE_INCLUDED_\r
-#define _SYMBOL_TABLE_INCLUDED_\r
-\r
-//\r
-// Symbol table for parsing. Has these design characteristics:\r
-//\r
-// * Same symbol table can be used to compile many shaders, to preserve\r
-// effort of creating and loading with the large numbers of built-in\r
-// symbols.\r
-//\r
-// * Name mangling will be used to give each function a unique name\r
-// so that symbol table lookups are never ambiguous. This allows\r
-// a simpler symbol table structure.\r
-//\r
-// * Pushing and popping of scope, so symbol table will really be a stack \r
-// of symbol tables. Searched from the top, with new inserts going into\r
-// the top.\r
-//\r
-// * Constants: Compile time constant symbols will keep their values\r
-// in the symbol table. The parser can substitute constants at parse\r
-// time, including doing constant folding and constant propagation.\r
-//\r
-// * No temporaries: Temporaries made from operations (+, --, .xy, etc.)\r
-// are tracked in the intermediate representation, not the symbol table.\r
-//\r
-\r
-#include "Include/Common.h"\r
-#include "Include/intermediate.h"\r
-#include "Include/InfoSink.h"\r
- \r
-//\r
-// Symbol base class. (Can build functions or variables out of these...)\r
-//\r
-class TSymbol { \r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
- TSymbol(const TString *n) : name(n) { }\r
- virtual ~TSymbol() { /* don't delete name, it's from the pool */ }\r
- const TString& getName() const { return *name; }\r
- virtual const TString& getMangledName() const { return getName(); }\r
- virtual bool isFunction() const { return false; }\r
- virtual bool isVariable() const { return false; }\r
- void setUniqueId(int id) { uniqueId = id; }\r
- int getUniqueId() const { return uniqueId; }\r
- virtual void dump(TInfoSink &infoSink) const = 0;\r
- TSymbol(const TSymbol&);\r
- virtual TSymbol* clone(TStructureMap& remapper) = 0;\r
-\r
-protected:\r
- const TString *name;\r
- unsigned int uniqueId; // For real comparing during code generation\r
-};\r
-\r
-//\r
-// Variable class, meaning a symbol that's not a function.\r
-// \r
-// There could be a separate class heirarchy for Constant variables;\r
-// Only one of int, bool, or float, (or none) is correct for\r
-// any particular use, but it's easy to do this way, and doesn't\r
-// seem worth having separate classes, and "getConst" can't simply return\r
-// different values for different types polymorphically, so this is \r
-// just simple and pragmatic.\r
-//\r
-class TVariable : public TSymbol {\r
-public:\r
- TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }\r
- virtual ~TVariable() { }\r
- virtual bool isVariable() const { return true; } \r
- TType& getType() { return type; } \r
- const TType& getType() const { return type; }\r
- bool isUserType() const { return userType; }\r
- void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }\r
- void updateArrayInformationType(TType *t) { arrayInformationType = t; }\r
- TType* getArrayInformationType() { return arrayInformationType; }\r
-\r
- virtual void dump(TInfoSink &infoSink) const;\r
-\r
- constUnion* getConstPointer() { \r
- if (!unionArray) {\r
- if (!type.getStruct())\r
- unionArray = new constUnion[type.getInstanceSize()];\r
- else\r
- unionArray = new constUnion[type.getStructSize()];\r
- }\r
- return unionArray;\r
- }\r
-\r
- constUnion* getConstPointer() const { return unionArray; }\r
-\r
- void shareConstPointer( constUnion *constArray)\r
- {\r
- delete unionArray;\r
- unionArray = constArray; \r
- }\r
- TVariable(const TVariable&, TStructureMap& remapper); // copy constructor\r
- virtual TVariable* clone(TStructureMap& remapper);\r
- \r
-protected:\r
- TType type;\r
- bool userType;\r
- // we are assuming that Pool Allocator will free the memory allocated to unionArray\r
- // when this object is destroyed\r
- constUnion *unionArray;\r
- TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol\r
-};\r
-\r
-//\r
-// The function sub-class of symbols and the parser will need to\r
-// share this definition of a function parameter.\r
-//\r
-struct TParameter {\r
- TString *name;\r
- TType* type;\r
- void copyParam(const TParameter& param, TStructureMap& remapper) {\r
- name = NewPoolTString(param.name->c_str());\r
- type = param.type->clone(remapper);\r
- }\r
-};\r
-\r
-//\r
-// The function sub-class of a symbol. \r
-//\r
-class TFunction : public TSymbol {\r
-public:\r
- TFunction(TOperator o) :\r
- TSymbol(0),\r
- returnType(TType(EbtVoid)),\r
- op(o),\r
- defined(false) { }\r
- TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) : \r
- TSymbol(name), \r
- returnType(retType),\r
- mangledName(*name + '('),\r
- op(tOp),\r
- defined(false) { }\r
- virtual ~TFunction();\r
- virtual bool isFunction() const { return true; } \r
- \r
- void addParameter(TParameter& p) \r
- { \r
- parameters.push_back(p);\r
- mangledName = mangledName + p.type->getMangledName();\r
- }\r
- \r
- const TString& getMangledName() const { return mangledName; }\r
- const TType& getReturnType() const { return returnType; }\r
- void relateToOperator(TOperator o) { op = o; }\r
- TOperator getBuiltInOp() const { return op; }\r
- void setDefined() { defined = true; }\r
- bool isDefined() { return defined; }\r
-\r
- int getParamCount() const { return static_cast<int>(parameters.size()); } \r
- TParameter& operator [](int i) { return parameters[i]; }\r
- const TParameter& operator [](int i) const { return parameters[i]; }\r
- \r
- virtual void dump(TInfoSink &infoSink) const;\r
- TFunction(const TFunction&, TStructureMap& remapper);\r
- virtual TFunction* clone(TStructureMap& remapper);\r
- \r
-protected:\r
- typedef TVector<TParameter> TParamList;\r
- TParamList parameters;\r
- TType returnType;\r
- TString mangledName;\r
- TOperator op;\r
- bool defined;\r
-};\r
-\r
-\r
-class TSymbolTableLevel {\r
-public:\r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
- TSymbolTableLevel() { }\r
- ~TSymbolTableLevel();\r
- \r
- bool insert(TSymbol& symbol) \r
- {\r
- //\r
- // returning true means symbol was added to the table\r
- //\r
- tInsertResult result;\r
- result = level.insert(tLevelPair(symbol.getMangledName(), &symbol));\r
- \r
- return result.second;\r
- }\r
-\r
- TSymbol* find(const TString& name) const\r
- {\r
- tLevel::const_iterator it = level.find(name);\r
- if (it == level.end())\r
- return 0;\r
- else\r
- return (*it).second;\r
- }\r
-\r
- void relateToOperator(const char* name, TOperator op);\r
- void dump(TInfoSink &infoSink) const; \r
- TSymbolTableLevel* clone(TStructureMap& remapper);\r
- \r
-protected:\r
- typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;\r
- typedef const tLevel::value_type tLevelPair;\r
- typedef std::pair<tLevel::iterator, bool> tInsertResult;\r
-\r
- tLevel level;\r
-};\r
-\r
-class TSymbolTable {\r
-public:\r
- TSymbolTable() : uniqueId(0)\r
- {\r
- //\r
- // The symbol table cannot be used until push() is called, but\r
- // the lack of an initial call to push() can be used to detect\r
- // that the symbol table has not been preloaded with built-ins.\r
- //\r
- }\r
-\r
- TSymbolTable(TSymbolTable& symTable)\r
- {\r
- table.push_back(symTable.table[0]);\r
- uniqueId = symTable.uniqueId;\r
- }\r
-\r
- ~TSymbolTable()\r
- {\r
- // level 0 is always built In symbols, so we never pop that out\r
- while (table.size() > 1)\r
- pop();\r
- }\r
-\r
- //\r
- // When the symbol table is initialized with the built-ins, there should\r
- // 'push' calls, so that built-ins are at level 0 and the shader\r
- // globals are at level 1.\r
- //\r
- bool isEmpty() { return table.size() == 0; }\r
- bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }\r
- bool atSharedBuiltInLevel() { return table.size() == 1; } \r
- bool atGlobalLevel() { return table.size() <= 3; }\r
- void push() { \r
- table.push_back(new TSymbolTableLevel);\r
- }\r
-\r
- void pop() { \r
- delete table[currentLevel()]; \r
- table.pop_back(); \r
- }\r
-\r
- bool insert(TSymbol& symbol)\r
- {\r
- symbol.setUniqueId(++uniqueId);\r
- return table[currentLevel()]->insert(symbol);\r
- }\r
- \r
- TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0) \r
- {\r
- int level = currentLevel();\r
- TSymbol* symbol;\r
- do {\r
- symbol = table[level]->find(name);\r
- --level;\r
- } while (symbol == 0 && level >= 0);\r
- level++;\r
- if (builtIn)\r
- *builtIn = level == 0;\r
- if (sameScope)\r
- *sameScope = level == currentLevel();\r
- return symbol;\r
- }\r
-\r
- TSymbolTableLevel* getGlobalLevel() { assert (table.size() >= 3); return table[2]; }\r
- void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }\r
- int getMaxSymbolId() { return uniqueId; }\r
- void dump(TInfoSink &infoSink) const; \r
- void copyTable(const TSymbolTable& copyOf);\r
-\r
-protected: \r
- int currentLevel() const { return static_cast<int>(table.size()) - 1; }\r
- bool atDynamicBuiltInLevel() { return table.size() == 2; }\r
-\r
- std::vector<TSymbolTableLevel*> table;\r
- int uniqueId; // for unique identification in code generation\r
-};\r
-\r
-#endif // _SYMBOL_TABLE_INCLUDED_\r
+++ /dev/null
-/*\r
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-*/\r
-/* Based on\r
-ANSI C grammar, Lex specification\r
-\r
-In 1985, Jeff Lee published this Lex specification together with a Yacc \r
-grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted \r
-both to net.sources in 1987; that original, as mentioned in the answer \r
-to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net, \r
-file usenet/net.sources/ansi.c.grammar.Z. \r
-\r
-I intend to keep this version as close to the current C Standard grammar \r
-as possible; please let me know if you discover discrepancies. \r
-\r
-Jutta Degener, 1995 \r
-*/\r
-\r
-D [0-9]\r
-L [a-zA-Z_]\r
-H [a-fA-F0-9]\r
-E [Ee][+-]?{D}+\r
-O [0-7]\r
-\r
-%option nounput \r
-%{\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include "ParseHelper.h"\r
-#include "glslang_tab.h"\r
-\r
-/* windows only pragma */\r
-#ifdef _MSC_VER\r
-#pragma warning(disable : 4102)\r
-#endif\r
-\r
-int yy_input(char* buf, int max_size);\r
-TSourceLoc yylineno;\r
-\r
-#ifdef _WIN32\r
- extern int yyparse(TParseContext&);\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext) \r
-#else\r
- extern int yyparse(void*);\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)\r
- #define parseContext (*((TParseContext*)(parseContextLocal)))\r
-#endif\r
- \r
-#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))\r
-\r
-%}\r
-\r
-%option noyywrap\r
-%option never-interactive\r
-%option outfile="Gen_glslang.cpp"\r
-%x FIELDS\r
-\r
-\r
-%%\r
-<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };\r
-\r
-"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }\r
-"const" { pyylval->lex.line = yylineno; return(CONST_QUAL); }\r
-"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }\r
-"varying" { pyylval->lex.line = yylineno; return(VARYING); }\r
-\r
-"break" { pyylval->lex.line = yylineno; return(BREAK); }\r
-"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }\r
-"do" { pyylval->lex.line = yylineno; return(DO); }\r
-"for" { pyylval->lex.line = yylineno; return(FOR); }\r
-"while" { pyylval->lex.line = yylineno; return(WHILE); }\r
-\r
-"if" { pyylval->lex.line = yylineno; return(IF); }\r
-"else" { pyylval->lex.line = yylineno; return(ELSE); }\r
-\r
-"in" { pyylval->lex.line = yylineno; return(IN_QUAL); }\r
-"out" { pyylval->lex.line = yylineno; return(OUT_QUAL); }\r
-"inout" { pyylval->lex.line = yylineno; return(INOUT_QUAL); }\r
-\r
-"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }\r
-"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }\r
-"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }\r
-"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }\r
-"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }\r
-"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }\r
-\r
-"discard" { pyylval->lex.line = yylineno; return(DISCARD); }\r
-"return" { pyylval->lex.line = yylineno; return(RETURN); }\r
-\r
-"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }\r
-"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }\r
-"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }\r
-\r
-"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }\r
-"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }\r
-"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }\r
-"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }\r
-"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }\r
-"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }\r
-"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }\r
-"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }\r
-"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }\r
-\r
-"sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }\r
-"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }\r
-"sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }\r
-"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }\r
-"sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }\r
-"sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }\r
-\r
-"struct" { pyylval->lex.line = yylineno; return(STRUCT); }\r
-\r
-"asm" { PaReservedWord(); return 0; }\r
-\r
-"class" { PaReservedWord(); return 0; }\r
-"union" { PaReservedWord(); return 0; }\r
-"enum" { PaReservedWord(); return 0; }\r
-"typedef" { PaReservedWord(); return 0; }\r
-"template" { PaReservedWord(); return 0; }\r
-"this" { PaReservedWord(); return 0; }\r
-"packed" { PaReservedWord(); return 0; }\r
-\r
-"goto" { PaReservedWord(); return 0; }\r
-"switch" { PaReservedWord(); return 0; }\r
-"default" { PaReservedWord(); return 0; }\r
-\r
-"inline" { PaReservedWord(); return 0; }\r
-"noinline" { PaReservedWord(); return 0; }\r
-"volatile" { PaReservedWord(); return 0; }\r
-"public" { PaReservedWord(); return 0; }\r
-"static" { PaReservedWord(); return 0; }\r
-"extern" { PaReservedWord(); return 0; }\r
-"external" { PaReservedWord(); return 0; }\r
-"interface" { PaReservedWord(); return 0; }\r
-\r
-"long" { PaReservedWord(); return 0; }\r
-"short" { PaReservedWord(); return 0; }\r
-"double" { PaReservedWord(); return 0; }\r
-"half" { PaReservedWord(); return 0; }\r
-"fixed" { PaReservedWord(); return 0; }\r
-"unsigned" { PaReservedWord(); return 0; }\r
-\r
-"input" { PaReservedWord(); return 0; }\r
-"output" { PaReservedWord(); return 0; }\r
-\r
-"hvec2" { PaReservedWord(); return 0; }\r
-"hvec3" { PaReservedWord(); return 0; }\r
-"hvec4" { PaReservedWord(); return 0; }\r
-"fvec2" { PaReservedWord(); return 0; }\r
-"fvec3" { PaReservedWord(); return 0; }\r
-"fvec4" { PaReservedWord(); return 0; }\r
-"dvec2" { PaReservedWord(); return 0; }\r
-"dvec3" { PaReservedWord(); return 0; }\r
-"dvec4" { PaReservedWord(); return 0; }\r
-\r
-"sampler2DRect" { PaReservedWord(); return 0; }\r
-"sampler3DRect" { PaReservedWord(); return 0; }\r
-"sampler2DRectShadow" { PaReservedWord(); return 0; }\r
-\r
-"sizeof" { PaReservedWord(); return 0; }\r
-"cast" { PaReservedWord(); return 0; }\r
-\r
-"namespace" { PaReservedWord(); return 0; }\r
-"using" { PaReservedWord(); return 0; }\r
-\r
-{L}({L}|{D})* { \r
- pyylval->lex.line = yylineno; \r
- pyylval->lex.string = NewPoolTString(yytext); \r
- return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); \r
-}\r
-\r
-0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
-0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
-0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}\r
-{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }\r
-\r
-{D}+{E} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
-{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
-"."{D}+({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }\r
-\r
-"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; } \r
-\r
-"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }\r
-"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }\r
-"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }\r
-"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }\r
-"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }\r
-"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }\r
-">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }\r
-"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }\r
-"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }\r
-"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }\r
-\r
-"++" { pyylval->lex.line = yylineno; return(INC_OP); }\r
-"--" { pyylval->lex.line = yylineno; return(DEC_OP); }\r
-"&&" { pyylval->lex.line = yylineno; return(AND_OP); }\r
-"||" { pyylval->lex.line = yylineno; return(OR_OP); }\r
-"^^" { pyylval->lex.line = yylineno; return(XOR_OP); }\r
-"<=" { pyylval->lex.line = yylineno; return(LE_OP); }\r
-">=" { pyylval->lex.line = yylineno; return(GE_OP); }\r
-"==" { pyylval->lex.line = yylineno; return(EQ_OP); }\r
-"!=" { pyylval->lex.line = yylineno; return(NE_OP); }\r
-"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }\r
-">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }\r
-";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }\r
-("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }\r
-("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }\r
-"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }\r
-":" { pyylval->lex.line = yylineno; return(COLON); }\r
-"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }\r
-"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }\r
-")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }\r
-("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }\r
-("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }\r
-"." { BEGIN(FIELDS); return(DOT); }\r
-"!" { pyylval->lex.line = yylineno; return(BANG); }\r
-"-" { pyylval->lex.line = yylineno; return(DASH); }\r
-"~" { pyylval->lex.line = yylineno; return(TILDE); }\r
-"+" { pyylval->lex.line = yylineno; return(PLUS); }\r
-"*" { pyylval->lex.line = yylineno; return(STAR); }\r
-"/" { pyylval->lex.line = yylineno; return(SLASH); }\r
-"%" { pyylval->lex.line = yylineno; return(PERCENT); }\r
-"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }\r
-">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }\r
-"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }\r
-"^" { pyylval->lex.line = yylineno; return(CARET); }\r
-"&" { pyylval->lex.line = yylineno; return(AMPERSAND); }\r
-"?" { pyylval->lex.line = yylineno; return(QUESTION); }\r
-\r
-<FIELDS>{L}({L}|{D})* { \r
-BEGIN(INITIAL); \r
- pyylval->lex.line = yylineno; \r
- pyylval->lex.string = NewPoolTString(yytext); \r
- return FIELD_SELECTION; }\r
-<FIELDS>[ \t\v\f\r] {}\r
-\r
-[ \t\v\n\f\r] { }\r
-<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}\r
-<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";\r
- return 0; }\r
-\r
-%%\r
-\r
-\r
-//Including Pre-processor.\r
-extern "C" {\r
- #include "./preprocessor/preprocess.h"\r
-} \r
-\r
-//\r
-// The YY_INPUT macro just calls this. Maybe this could be just put into\r
-// the macro directly.\r
-//\r
-\r
-int yy_input(char* buf, int max_size)\r
-{\r
- char *char_token =NULL;\r
- int len;\r
-\r
- if ((len = yylex_CPP(buf, max_size)) == 0)\r
- return 0;\r
- if (len >= max_size) \r
- YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );\r
-\r
- buf[len] = ' ';\r
- return len+1;\r
-}\r
-\r
-\r
-//\r
-// Parse an array of strings using yyparse. We set up globals used by\r
-// yywrap.\r
-//\r
-// Returns 0 for success, as per yyparse().\r
-//\r
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)\r
-{\r
- int argv0len;\r
- ScanFromString(argv[0]); \r
- \r
- //Storing the Current Compiler Parse context into the cpp structure.\r
- cpp->pC = (void*)&parseContextLocal;\r
- \r
- if (!argv || argc == 0 || !argv[0])\r
- return 1;\r
- \r
- if (!strLen) {\r
- argv0len = (int) strlen(argv[0]);\r
- strLen = &argv0len;\r
- }\r
- yyrestart(0);\r
- (&parseContextLocal)->AfterEOF = false;\r
- cpp->PaWhichStr = 0;\r
- cpp->PaArgv = argv;\r
- cpp->PaArgc = argc;\r
- cpp->PaStrLen = strLen;\r
- yylineno = 1;\r
- \r
- if (*cpp->PaStrLen >= 0) { \r
- int ret;\r
- #ifdef _WIN32\r
- ret = yyparse(parseContextLocal);\r
- #else\r
- ret = yyparse((void*)(&parseContextLocal));\r
- #endif\r
- if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)\r
- return 1;\r
- else\r
- return 0;\r
- }\r
- else\r
- return 0;\r
-}\r
-\r
-void yyerror(char *s) \r
-{\r
- if (((TParseContext *)cpp->pC)->AfterEOF) {\r
- if (cpp->tokensBeforeEOF == 1) {\r
- GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");\r
- GlobalParseContext->recover();\r
- }\r
- } else {\r
- GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");\r
- GlobalParseContext->recover();\r
- } \r
-}\r
-\r
-void PaReservedWord()\r
-{\r
- GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)\r
-{\r
- symbol = parseContextLocal.symbolTable.find(id);\r
- if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {\r
- TVariable* variable = static_cast<TVariable*>(symbol);\r
- if (variable->isUserType()) {\r
- parseContextLocal.lexAfterType = true;\r
- return TYPE_NAME;\r
- }\r
- }\r
- \r
- return IDENTIFIER;\r
-}\r
-\r
-int PaParseComment(int &lineno, TParseContext& parseContextLocal)\r
-{\r
- int transitionFlag = 0;\r
- int nextChar;\r
- \r
- while (transitionFlag != 2) {\r
- nextChar = yyinput();\r
- if (nextChar == '\n')\r
- lineno++;\r
- switch (nextChar) {\r
- case '*' :\r
- transitionFlag = 1;\r
- break;\r
- case '/' : /* if star is the previous character, then it is the end of comment */\r
- if (transitionFlag == 1) {\r
- return 1 ;\r
- }\r
- break;\r
- case EOF :\r
- /* Raise error message here */\r
- parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");\r
- GlobalParseContext->recover();\r
- return YY_NULL; \r
- default : /* Any other character will be a part of the comment */\r
- transitionFlag = 0;\r
- }\r
- }\r
- return 1;\r
-}\r
-\r
-extern "C" {\r
-\r
-void CPPDebugLogMsg(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);\r
-}\r
-\r
-void CPPWarningToInfoLog(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); \r
-}\r
-\r
-void CPPShInfoLogMsg(const char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-void CPPErrorToInfoLog(char *msg)\r
-{\r
- ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");\r
- GlobalParseContext->recover();\r
-}\r
-\r
-void SetLineNumber(int line)\r
-{\r
- yylineno &= ~SourceLocLineMask;\r
- yylineno |= line;\r
-}\r
-\r
-void SetStringNumber(int string)\r
-{\r
- yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);\r
-}\r
-\r
-int GetStringNumber(void)\r
-{\r
- return yylineno >> 16;\r
-}\r
-\r
-int GetLineNumber(void)\r
-{\r
- return yylineno & SourceLocLineMask;\r
-}\r
-\r
-void IncLineNumber(void)\r
-{\r
- if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)\r
- ++yylineno;\r
-}\r
-\r
-void DecLineNumber(void)\r
-{\r
- if ((yylineno & SourceLocLineMask) > 0)\r
- --yylineno;\r
-}\r
-\r
-void HandlePragma(const char **tokens, int numTokens)\r
-{\r
- if (!strcmp(tokens[0], "optimize")) {\r
- if (numTokens != 4) {\r
- CPPShInfoLogMsg("optimize pragma syntax is incorrect");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");\r
- return;\r
- }\r
- \r
- if (!strcmp(tokens[2], "on"))\r
- ((TParseContext *)cpp->pC)->contextPragma.optimize = true;\r
- else if (!strcmp(tokens[2], "off"))\r
- ((TParseContext *)cpp->pC)->contextPragma.optimize = false;\r
- else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");\r
- return;\r
- }\r
- } else if (!strcmp(tokens[0], "debug")) {\r
- if (numTokens != 4) {\r
- CPPShInfoLogMsg("debug pragma syntax is incorrect");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");\r
- return;\r
- }\r
- \r
- if (!strcmp(tokens[2], "on"))\r
- ((TParseContext *)cpp->pC)->contextPragma.debug = true;\r
- else if (!strcmp(tokens[2], "off"))\r
- ((TParseContext *)cpp->pC)->contextPragma.debug = false;\r
- else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");\r
- return;\r
- }\r
- \r
- if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");\r
- return;\r
- }\r
- } else {\r
- /*\r
- // implementation specific pragma\r
- // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma\r
- // For now, just ignore the pragma that the implementation cannot recognize\r
- // An Example of one such implementation for a pragma that has a syntax like\r
- // #pragma pragmaname(pragmavalue)\r
- // This implementation stores the current pragmavalue against the pragma name in pragmaTable.\r
- if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { \r
- TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;\r
- TPragmaTable::iterator iter;\r
- iter = pragmaTable.find(TString(tokens[0]));\r
- if (iter != pragmaTable.end()) {\r
- iter->second = tokens[2];\r
- } else {\r
- pragmaTable[tokens[0]] = tokens[2];\r
- } \r
- }\r
- */\r
- }\r
-}\r
-\r
-void StoreStr(char *string)\r
-{\r
- TString strSrc;\r
- strSrc = TString(string);\r
-\r
- ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;\r
-}\r
-\r
-const char* GetStrfromTStr(void)\r
-{\r
- cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();\r
- return cpp->ErrMsg;\r
-}\r
-\r
-void ResetTString(void)\r
-{\r
- ((TParseContext *)cpp->pC)->HashErrMsg = "";\r
-}\r
-\r
-TBehavior GetBehavior(const char* behavior)\r
-{\r
- if (!strcmp("require", behavior))\r
- return EBhRequire;\r
- else if (!strcmp("enable", behavior))\r
- return EBhEnable;\r
- else if (!strcmp("disable", behavior))\r
- return EBhDisable;\r
- else if (!strcmp("warn", behavior))\r
- return EBhWarn;\r
- else {\r
- CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());\r
- return EBhDisable;\r
- } \r
-}\r
-\r
-void updateExtensionBehavior(const char* extName, const char* behavior)\r
-{\r
- TBehavior behaviorVal = GetBehavior(behavior);\r
- TMap<TString, TBehavior>:: iterator iter;\r
- TString msg;\r
- \r
- // special cased for all extension\r
- if (!strcmp(extName, "all")) {\r
- if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {\r
- CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); \r
- return;\r
- } else {\r
- for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)\r
- iter->second = behaviorVal;\r
- } \r
- } else {\r
- iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));\r
- if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {\r
- switch (behaviorVal) {\r
- case EBhRequire:\r
- CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); \r
- break;\r
- case EBhEnable:\r
- case EBhWarn:\r
- case EBhDisable:\r
- msg = TString("extension '") + extName + "' is not supported";\r
- ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); \r
- break;\r
- }\r
- return;\r
- } else\r
- iter->second = behaviorVal;\r
- }\r
-}\r
- \r
-}\r
-\r
-void setInitialState()\r
-{\r
- yy_start = 1;\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-/**\r
- * This is bison grammar and production code for parsing the OpenGL 2.0 shading\r
- * languages.\r
- */\r
-%{\r
-\r
-/* Based on:\r
-ANSI C Yacc grammar\r
-\r
-In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a \r
-matching Lex specification) for the April 30, 1985 draft version of the \r
-ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that\r
-original, as mentioned in the answer to question 17.25 of the comp.lang.c\r
-FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.\r
- \r
-I intend to keep this version as close to the current C Standard grammar as \r
-possible; please let me know if you discover discrepancies. \r
-\r
-Jutta Degener, 1995 \r
-*/\r
-\r
-#include "SymbolTable.h"\r
-#include "ParseHelper.h"\r
-#include "../Public/ShaderLang.h"\r
-\r
-#ifdef _WIN32\r
- #define YYPARSE_PARAM parseContext\r
- #define YYPARSE_PARAM_DECL TParseContext&\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)\r
- #define YYLEX_PARAM parseContext\r
-#else\r
- #define YYPARSE_PARAM parseContextLocal\r
- #define parseContext (*((TParseContext*)(parseContextLocal)))\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)\r
- #define YYLEX_PARAM (void*)(parseContextLocal)\r
- extern void yyerror(char*); \r
-#endif\r
-\r
-#define FRAG_VERT_ONLY(S, L) { \\r
- if (parseContext.language != EShLangFragment && \\r
- parseContext.language != EShLangVertex) { \\r
- parseContext.error(L, " supported in vertex/fragment shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-\r
-#define VERTEX_ONLY(S, L) { \\r
- if (parseContext.language != EShLangVertex) { \\r
- parseContext.error(L, " supported in vertex shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-\r
-#define FRAG_ONLY(S, L) { \\r
- if (parseContext.language != EShLangFragment) { \\r
- parseContext.error(L, " supported in fragment shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-\r
-#define PACK_ONLY(S, L) { \\r
- if (parseContext.language != EShLangPack) { \\r
- parseContext.error(L, " supported in pack shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-\r
-#define UNPACK_ONLY(S, L) { \\r
- if (parseContext.language != EShLangUnpack) { \\r
- parseContext.error(L, " supported in unpack shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-\r
-#define PACK_UNPACK_ONLY(S, L) { \\r
- if (parseContext.language != EShLangUnpack && \\r
- parseContext.language != EShLangPack) { \\r
- parseContext.error(L, " supported in pack/unpack shaders only ", S, "", ""); \\r
- parseContext.recover(); \\r
- } \\r
-}\r
-%}\r
-%union {\r
- struct {\r
- TSourceLoc line;\r
- union {\r
- TString *string;\r
- float f;\r
- int i;\r
- bool b;\r
- };\r
- TSymbol* symbol;\r
- } lex;\r
- struct {\r
- TSourceLoc line;\r
- TOperator op;\r
- union {\r
- TIntermNode* intermNode;\r
- TIntermNodePair nodePair;\r
- TIntermTyped* intermTypedNode;\r
- TIntermAggregate* intermAggregate;\r
- };\r
- union {\r
- TPublicType type;\r
- TQualifier qualifier;\r
- TFunction* function;\r
- TParameter param;\r
- TTypeLine typeLine;\r
- TTypeList* typeList;\r
- };\r
- } interm;\r
-}\r
-\r
-%{\r
-#ifndef _WIN32\r
- extern int yylex(YYSTYPE*, void*);\r
-#endif\r
-%}\r
-\r
-%pure_parser /* Just in case is called from multiple threads */\r
-%expect 1 /* One shift reduce conflict because of if | else */\r
-%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE\r
-%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN\r
-%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4\r
-%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING\r
-%token <lex> STRUCT VOID_TYPE WHILE\r
-%token <lex> SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW\r
-\r
-%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT\r
-%token <lex> FIELD_SELECTION\r
-%token <lex> LEFT_OP RIGHT_OP\r
-%token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP\r
-%token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN\r
-%token <lex> MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN\r
-%token <lex> SUB_ASSIGN\r
-\r
-%token <lex> LEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT\r
-%token <lex> COMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT\r
-%token <lex> LEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION\r
-\r
-%type <interm> assignment_operator constructor_identifier unary_operator\r
-%type <interm.intermTypedNode> variable_identifier primary_expression postfix_expression\r
-%type <interm.intermTypedNode> expression integer_expression assignment_expression\r
-%type <interm.intermTypedNode> unary_expression multiplicative_expression additive_expression\r
-%type <interm.intermTypedNode> relational_expression equality_expression \r
-%type <interm.intermTypedNode> conditional_expression constant_expression\r
-%type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression\r
-%type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression\r
-%type <interm.intermTypedNode> function_call initializer condition conditionopt\r
-\r
-%type <interm.intermNode> translation_unit function_definition\r
-%type <interm.intermNode> statement simple_statement\r
-%type <interm.intermAggregate> statement_list compound_statement \r
-%type <interm.intermNode> declaration_statement selection_statement expression_statement\r
-%type <interm.intermNode> declaration external_declaration\r
-%type <interm.intermNode> for_init_statement compound_statement_no_new_scope\r
-%type <interm.nodePair> selection_rest_statement for_rest_statement\r
-%type <interm.intermNode> iteration_statement jump_statement statement_no_new_scope\r
-%type <interm> single_declaration init_declarator_list\r
-\r
-%type <interm> parameter_declaration parameter_declarator parameter_type_specifier\r
-%type <interm.qualifier> parameter_qualifier\r
-\r
-%type <interm.type> type_qualifier fully_specified_type type_specifier \r
-%type <interm.type> struct_specifier \r
-%type <interm.typeLine> struct_declarator \r
-%type <interm.typeList> struct_declarator_list struct_declaration struct_declaration_list\r
-%type <interm.function> function_header function_declarator function_identifier\r
-%type <interm.function> function_header_with_parameters function_call_header \r
-%type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype\r
-\r
-%start translation_unit \r
-%%\r
-\r
-variable_identifier \r
- : IDENTIFIER {\r
- // The symbol table search was done in the lexical phase\r
- const TSymbol* symbol = $1.symbol;\r
- const TVariable* variable;\r
- if (symbol == 0) {\r
- parseContext.error($1.line, "undeclared identifier", $1.string->c_str(), "");\r
- parseContext.recover();\r
- TType type(EbtFloat);\r
- TVariable* fakeVariable = new TVariable($1.string, type);\r
- parseContext.symbolTable.insert(*fakeVariable);\r
- variable = fakeVariable;\r
- } else {\r
- // This identifier can only be a variable type symbol \r
- if (! symbol->isVariable()) {\r
- parseContext.error($1.line, "variable expected", $1.string->c_str(), "");\r
- parseContext.recover();\r
- }\r
- variable = static_cast<const TVariable*>(symbol);\r
- }\r
-\r
- // don't delete $1.string, it's used by error recovery, and the pool\r
- // pop will reclaim the memory\r
-\r
- if (variable->getType().getQualifier() == EvqConst ) {\r
- constUnion* constArray = variable->getConstPointer();\r
- TType t(variable->getType());\r
- $$ = parseContext.intermediate.addConstantUnion(constArray, t, $1.line); \r
- } else\r
- $$ = parseContext.intermediate.addSymbol(variable->getUniqueId(), \r
- variable->getName(), \r
- variable->getType(), $1.line);\r
- }\r
- ;\r
-\r
-primary_expression\r
- : variable_identifier {\r
- $$ = $1;\r
- }\r
- | INTCONSTANT {\r
- //\r
- // INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders, \r
- // check for overflow for constants\r
- //\r
- if (abs($1.i) >= (1 << 16)) {\r
- parseContext.error($1.line, " integer constant overflow", "", "");\r
- parseContext.recover();\r
- }\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->iConst = $1.i;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.line);\r
- }\r
- | FLOATCONSTANT {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->fConst = $1.f;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);\r
- }\r
- | BOOLCONSTANT {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = $1.b;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.line);\r
- }\r
- | LEFT_PAREN expression RIGHT_PAREN {\r
- $$ = $2;\r
- }\r
- ;\r
-\r
-postfix_expression\r
- : primary_expression { \r
- $$ = $1;\r
- } \r
- | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {\r
- if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {\r
- if ($1->getAsSymbolNode())\r
- parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");\r
- else\r
- parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");\r
- parseContext.recover();\r
- }\r
- if ($1->getType().getQualifier() == EvqConst && !$1->isArray() && $3->getQualifier() == EvqConst) {\r
- if ($1->isVector()) { // constant folding for vectors\r
- TVectorFields fields;\r
- fields.num = 1;\r
- fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->iConst; // need to do it this way because v.xy sends fields integer array\r
- $$ = parseContext.addConstVectorNode(fields, $1, $2.line);\r
- } else if ($1->isMatrix()) { // constant folding for matrices\r
- $$ = parseContext.addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->iConst, $1, $2.line);\r
- }\r
- } else {\r
- if ($3->getQualifier() == EvqConst) {\r
- if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->iConst && !$1->isArray() ) {\r
- parseContext.error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
- parseContext.recover();\r
- } else {\r
- if ($1->isArray()) {\r
- if ($1->getType().getArraySize() == 0) {\r
- if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->iConst) {\r
- if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->iConst, true, $2.line))\r
- parseContext.recover(); \r
- } else {\r
- if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))\r
- parseContext.recover(); \r
- }\r
- } else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->iConst >= $1->getType().getArraySize()) {\r
- parseContext.error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
- parseContext.recover();\r
- }\r
- }\r
- $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);\r
- }\r
- } else {\r
- if ($1->isArray() && $1->getType().getArraySize() == 0) {\r
- parseContext.error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");\r
- parseContext.recover();\r
- }\r
- \r
- $$ = parseContext.intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);\r
- }\r
- } \r
- if ($$ == 0) {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->fConst = 0.0;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line);\r
- } else if ($1->isArray()) {\r
- if ($1->getType().getStruct())\r
- $$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName()));\r
- else\r
- $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize(), $1->isMatrix()));\r
- } else if ($1->isMatrix() && $1->getType().getQualifier() == EvqConst) \r
- $$->setType(TType($1->getBasicType(), EvqConst, $1->getNominalSize())); \r
- else if ($1->isMatrix()) \r
- $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize())); \r
- else if ($1->isVector() && $1->getType().getQualifier() == EvqConst) \r
- $$->setType(TType($1->getBasicType(), EvqConst)); \r
- else if ($1->isVector()) \r
- $$->setType(TType($1->getBasicType(), EvqTemporary));\r
- else\r
- $$->setType($1->getType()); \r
- }\r
- | function_call {\r
- $$ = $1;\r
- }\r
- | postfix_expression DOT FIELD_SELECTION { \r
- if ($1->isArray()) {\r
- parseContext.error($3.line, "cannot apply dot operator to an array", ".", "");\r
- parseContext.recover();\r
- }\r
-\r
- if ($1->isVector()) {\r
- TVectorFields fields;\r
- if (! parseContext.parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {\r
- fields.num = 1;\r
- fields.offsets[0] = 0;\r
- parseContext.recover();\r
- }\r
-\r
- if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields\r
- $$ = parseContext.addConstVectorNode(fields, $1, $3.line);\r
- if ($$ == 0) {\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- else\r
- $$->setType(TType($1->getBasicType(), EvqConst, (int) (*$3.string).size()));\r
- } else {\r
- if (fields.num == 1) {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->iConst = fields.offsets[0];\r
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);\r
- $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);\r
- $$->setType(TType($1->getBasicType()));\r
- } else {\r
- TString vectorString = *$3.string;\r
- TIntermTyped* index = parseContext.intermediate.addSwizzle(fields, $3.line); \r
- $$ = parseContext.intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);\r
- $$->setType(TType($1->getBasicType(),EvqTemporary, (int) vectorString.size())); \r
- }\r
- }\r
- } else if ($1->isMatrix()) {\r
- TMatrixFields fields;\r
- if (! parseContext.parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {\r
- fields.wholeRow = false;\r
- fields.wholeCol = false;\r
- fields.row = 0;\r
- fields.col = 0;\r
- parseContext.recover();\r
- }\r
-\r
- if (fields.wholeRow || fields.wholeCol) {\r
- parseContext.error($2.line, " non-scalar fields not implemented yet", ".", "");\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->iConst = 0;\r
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);\r
- $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); \r
- $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize()));\r
- } else {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->iConst = fields.col * $1->getNominalSize() + fields.row;\r
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);\r
- $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); \r
- $$->setType(TType($1->getBasicType()));\r
- }\r
- } else if ($1->getBasicType() == EbtStruct) {\r
- bool fieldFound = false;\r
- TTypeList* fields = $1->getType().getStruct();\r
- if (fields == 0) {\r
- parseContext.error($2.line, "structure has no fields", "Internal Error", "");\r
- parseContext.recover();\r
- $$ = $1;\r
- } else {\r
- unsigned int i;\r
- for (i = 0; i < fields->size(); ++i) {\r
- if ((*fields)[i].type->getFieldName() == *$3.string) {\r
- fieldFound = true;\r
- break;\r
- } \r
- }\r
- if (fieldFound) {\r
- if ($1->getType().getQualifier() == EvqConst) {\r
- $$ = parseContext.addConstStruct(*$3.string, $1, $2.line);\r
- if ($$ == 0) {\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- else {\r
- $$->setType(*(*fields)[i].type);\r
- // change the qualifier of the return type, not of the structure field\r
- // as the structure definition is shared between various structures.\r
- $$->getTypePointer()->changeQualifier(EvqConst);\r
- }\r
- } else {\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->iConst = i;\r
- TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);\r
- $$ = parseContext.intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line); \r
- $$->setType(*(*fields)[i].type);\r
- }\r
- } else {\r
- parseContext.error($2.line, " no such field in structure", $3.string->c_str(), "");\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- } else {\r
- parseContext.error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- // don't delete $3.string, it's from the pool\r
- }\r
- | postfix_expression INC_OP {\r
- if (parseContext.lValueErrorCheck($2.line, "++", $1))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.unaryOpError($2.line, "++", $1->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- | postfix_expression DEC_OP {\r
- if (parseContext.lValueErrorCheck($2.line, "--", $1))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.unaryOpError($2.line, "--", $1->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-integer_expression \r
- : expression {\r
- if (parseContext.integerErrorCheck($1, "[]"))\r
- parseContext.recover();\r
- $$ = $1; \r
- }\r
- ;\r
-\r
-function_call \r
- : function_call_generic {\r
- TFunction* fnCall = $1.function;\r
- TOperator op = fnCall->getBuiltInOp();\r
- \r
- if (op != EOpNull) {\r
- //\r
- // Then this should be a constructor.\r
- //\r
- TType type(EbtVoid); // use this to get the type back\r
- if (parseContext.constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {\r
- $$ = 0;\r
- } else {\r
- //\r
- // It's a constructor, of type 'type'.\r
- //\r
- $$ = parseContext.addConstructor($1.intermNode, &type, op, fnCall, $1.line);\r
- }\r
- \r
- if ($$ == 0) { \r
- parseContext.recover();\r
- $$ = parseContext.intermediate.setAggregateOperator(0, op, $1.line);\r
- }\r
- $$->setType(type);\r
- } else {\r
- //\r
- // Not a constructor. Find it in the symbol table.\r
- //\r
- const TFunction* fnCandidate;\r
- bool builtIn;\r
- fnCandidate = parseContext.findFunction($1.line, fnCall, &builtIn);\r
- if (fnCandidate) {\r
- //\r
- // A declared function. But, it might still map to a built-in\r
- // operation.\r
- //\r
- op = fnCandidate->getBuiltInOp();\r
- if (builtIn && op != EOpNull) {\r
- //\r
- // A function call mapped to a built-in operation.\r
- //\r
- if (fnCandidate->getParamCount() == 1) {\r
- //\r
- // Treat it like a built-in unary operator.\r
- //\r
- $$ = parseContext.intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.error($1.intermNode->getLine(), " wrong operand type", "Internal Error", \r
- "built in unary operator function. Type: %s",\r
- static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str());\r
- YYERROR;\r
- }\r
- } else {\r
- $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);\r
- }\r
- } else {\r
- // This is a real function call\r
- \r
- $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);\r
- $$->setType(fnCandidate->getReturnType()); \r
- \r
- // this is how we know whether the given function is a builtIn function or a user defined function\r
- // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also\r
- // if builtIn == true, it's definitely a builtIn function with EOpNull\r
- if (!builtIn) \r
- $$->getAsAggregate()->setUserDefined(); \r
- $$->getAsAggregate()->setName(fnCandidate->getMangledName());\r
-\r
- TQualifier qual;\r
- TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier();\r
- for (int i = 0; i < fnCandidate->getParamCount(); ++i) {\r
- qual = (*fnCandidate)[i].type->getQualifier();\r
- if (qual == EvqOut || qual == EvqInOut) {\r
- if (parseContext.lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {\r
- parseContext.error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");\r
- parseContext.recover();\r
- }\r
- }\r
- qualifierList.push_back(qual);\r
- }\r
- }\r
- $$->setType(fnCandidate->getReturnType());\r
- } else {\r
- // error message was put out by PaFindFunction()\r
- // Put on a dummy node for error recovery\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->fConst = 0.0;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);\r
- parseContext.recover();\r
- }\r
- }\r
- delete fnCall;\r
- }\r
- ;\r
-\r
-function_call_generic\r
- : function_call_header_with_parameters RIGHT_PAREN {\r
- $$ = $1;\r
- $$.line = $2.line;\r
- }\r
- | function_call_header_no_parameters RIGHT_PAREN {\r
- $$ = $1;\r
- $$.line = $2.line;\r
- }\r
- ;\r
- \r
-function_call_header_no_parameters \r
- : function_call_header VOID_TYPE {\r
- $$.function = $1;\r
- $$.intermNode = 0;\r
- }\r
- | function_call_header {\r
- $$.function = $1;\r
- $$.intermNode = 0;\r
- }\r
- ;\r
-\r
-function_call_header_with_parameters\r
- : function_call_header assignment_expression {\r
- TParameter param = { 0, new TType($2->getType()) };\r
- $1->addParameter(param);\r
- $$.function = $1;\r
- $$.intermNode = $2;\r
- }\r
- | function_call_header_with_parameters COMMA assignment_expression {\r
- TParameter param = { 0, new TType($3->getType()) };\r
- $1.function->addParameter(param);\r
- $$.function = $1.function;\r
- $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.line);\r
- }\r
- ;\r
-\r
-function_call_header \r
- : function_identifier LEFT_PAREN {\r
- $$ = $1;\r
- }\r
- ;\r
-\r
-function_identifier\r
- : constructor_identifier {\r
- if ($1.op == EOpConstructStruct) {\r
- TString tempString = "";\r
- TFunction *function = new TFunction(&tempString, *($1.type.userDef), $1.op);\r
- $$ = function;\r
- }\r
- else {\r
- TFunction *function = new TFunction($1.op);\r
- $$ = function;\r
- }\r
- }\r
- | IDENTIFIER {\r
- if (parseContext.reservedErrorCheck($1.line, *$1.string)) \r
- parseContext.recover();\r
- TType type(EbtVoid);\r
- TFunction *function = new TFunction($1.string, type);\r
- $$ = function; \r
- }\r
- ;\r
-\r
-// Grammar Note: Constructors look like functions, but lexical anaylsis recognized most of them as keywords.\r
-\r
-//\r
-// Don't go through the symbol table for constructors. \r
-// Their parameters will be verified algorithmically.\r
-//\r
-constructor_identifier\r
- : FLOAT_TYPE { $$.line = $1.line; $$.op = EOpConstructFloat; }\r
- | INT_TYPE { $$.line = $1.line; $$.op = EOpConstructInt; }\r
- | BOOL_TYPE { $$.line = $1.line; $$.op = EOpConstructBool; }\r
- | VEC2 { $$.line = $1.line; $$.op = EOpConstructVec2; }\r
- | VEC3 { $$.line = $1.line; $$.op = EOpConstructVec3; }\r
- | VEC4 { $$.line = $1.line; $$.op = EOpConstructVec4; }\r
- | BVEC2 { FRAG_VERT_ONLY("bvec2", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec2; }\r
- | BVEC3 { FRAG_VERT_ONLY("bvec3", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec3; }\r
- | BVEC4 { FRAG_VERT_ONLY("bvec4", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec4; }\r
- | IVEC2 { FRAG_VERT_ONLY("ivec2", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec2; }\r
- | IVEC3 { FRAG_VERT_ONLY("ivec3", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec3; }\r
- | IVEC4 { FRAG_VERT_ONLY("ivec4", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec4; }\r
- | MATRIX2 { FRAG_VERT_ONLY("mat2", $1.line); $$.line = $1.line; $$.op = EOpConstructMat2; }\r
- | MATRIX3 { FRAG_VERT_ONLY("mat3", $1.line); $$.line = $1.line; $$.op = EOpConstructMat3; }\r
- | MATRIX4 { FRAG_VERT_ONLY("mat4", $1.line); $$.line = $1.line; $$.op = EOpConstructMat4; }\r
- | TYPE_NAME { \r
- TType& structure = static_cast<TVariable*>($1.symbol)->getType();\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtStruct, qual, 1, false, false, &structure, $1.line }; \r
- $$.type = t;\r
- $$.line = $1.line; \r
- $$.op = EOpConstructStruct; \r
- } \r
- ;\r
-\r
-unary_expression\r
- : postfix_expression {\r
- $$ = $1;\r
- }\r
- | INC_OP unary_expression {\r
- if (parseContext.lValueErrorCheck($1.line, "++", $2))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.unaryOpError($1.line, "++", $2->getCompleteString());\r
- parseContext.recover();\r
- $$ = $2;\r
- }\r
- }\r
- | DEC_OP unary_expression {\r
- if (parseContext.lValueErrorCheck($1.line, "--", $2))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.unaryOpError($1.line, "--", $2->getCompleteString());\r
- parseContext.recover();\r
- $$ = $2;\r
- }\r
- }\r
- | unary_operator unary_expression {\r
- if ($1.op != EOpNull) {\r
- $$ = parseContext.intermediate.addUnaryMath($1.op, $2, $1.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- char* errorOp = "";\r
- switch($1.op) {\r
- case EOpNegative: errorOp = "-"; break;\r
- case EOpLogicalNot: errorOp = "!"; break;\r
- case EOpBitwiseNot: errorOp = "~"; break;\r
- default: break;\r
- }\r
- parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString());\r
- parseContext.recover();\r
- $$ = $2;\r
- }\r
- } else\r
- $$ = $2;\r
- }\r
- ;\r
-// Grammar Note: No traditional style type casts.\r
-\r
-unary_operator\r
- : PLUS { $$.line = $1.line; $$.op = EOpNull; }\r
- | DASH { $$.line = $1.line; $$.op = EOpNegative; }\r
- | BANG { $$.line = $1.line; $$.op = EOpLogicalNot; }\r
- | TILDE { PACK_UNPACK_ONLY("~", $1.line); \r
- $$.line = $1.line; $$.op = EOpBitwiseNot; }\r
- ;\r
-// Grammar Note: No '*' or '&' unary ops. Pointers are not supported.\r
-\r
-multiplicative_expression\r
- : unary_expression { $$ = $1; }\r
- | multiplicative_expression STAR unary_expression {\r
- FRAG_VERT_ONLY("*", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- | multiplicative_expression SLASH unary_expression {\r
- FRAG_VERT_ONLY("/", $2.line); \r
- $$ = parseContext.intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- | multiplicative_expression PERCENT unary_expression {\r
- PACK_UNPACK_ONLY("%", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpMod, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "%", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-additive_expression\r
- : multiplicative_expression { $$ = $1; }\r
- | additive_expression PLUS multiplicative_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- | additive_expression DASH multiplicative_expression {\r
- $$ = parseContext.intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- } \r
- }\r
- ;\r
-\r
-shift_expression\r
- : additive_expression { $$ = $1; }\r
- | shift_expression LEFT_OP additive_expression {\r
- PACK_UNPACK_ONLY("<<", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpLeftShift, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "<<", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- | shift_expression RIGHT_OP additive_expression {\r
- PACK_UNPACK_ONLY(">>", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpRightShift, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, ">>", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-relational_expression\r
- : shift_expression { $$ = $1; }\r
- | relational_expression LEFT_ANGLE shift_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- | relational_expression RIGHT_ANGLE shift_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- | relational_expression LE_OP shift_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- | relational_expression GE_OP shift_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- ;\r
-\r
-equality_expression\r
- : relational_expression { $$ = $1; }\r
- | equality_expression EQ_OP relational_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- | equality_expression NE_OP relational_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- ;\r
-\r
-and_expression\r
- : equality_expression { $$ = $1; }\r
- | and_expression AMPERSAND equality_expression {\r
- PACK_UNPACK_ONLY("&", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpAnd, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "&", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-exclusive_or_expression\r
- : and_expression { $$ = $1; }\r
- | exclusive_or_expression CARET and_expression {\r
- PACK_UNPACK_ONLY("^", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpExclusiveOr, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "^", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-inclusive_or_expression\r
- : exclusive_or_expression { $$ = $1; }\r
- | inclusive_or_expression VERTICAL_BAR exclusive_or_expression {\r
- PACK_UNPACK_ONLY("|", $2.line);\r
- $$ = parseContext.intermediate.addBinaryMath(EOpInclusiveOr, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "|", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-logical_and_expression\r
- : inclusive_or_expression { $$ = $1; }\r
- | logical_and_expression AND_OP inclusive_or_expression {\r
- $$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- ;\r
-\r
-logical_xor_expression\r
- : logical_and_expression { $$ = $1; }\r
- | logical_xor_expression XOR_OP logical_and_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- ;\r
-\r
-logical_or_expression\r
- : logical_xor_expression { $$ = $1; }\r
- | logical_or_expression OR_OP logical_xor_expression { \r
- $$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext.symbolTable);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- constUnion *unionArray = new constUnion[1];\r
- unionArray->bConst = false;\r
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);\r
- }\r
- }\r
- ;\r
-\r
-conditional_expression\r
- : logical_or_expression { $$ = $1; }\r
- | logical_or_expression QUESTION expression COLON assignment_expression {\r
- if (parseContext.boolErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- $$ = parseContext.intermediate.addSelection($1, $3, $5, $2.line);\r
- if ($3->getType() != $5->getType())\r
- $$ = 0;\r
- \r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());\r
- parseContext.recover();\r
- $$ = $5;\r
- }\r
- }\r
- ;\r
-\r
-assignment_expression\r
- : conditional_expression { $$ = $1; }\r
- | unary_expression assignment_operator assignment_expression {\r
- if (parseContext.lValueErrorCheck($2.line, "assign", $1))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.line);\r
- if ($$ == 0) {\r
- parseContext.assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- }\r
- ;\r
-\r
-assignment_operator\r
- : EQUAL { $$.line = $1.line; $$.op = EOpAssign; }\r
- | MUL_ASSIGN { FRAG_VERT_ONLY("*=", $1.line); $$.line = $1.line; $$.op = EOpMulAssign; }\r
- | DIV_ASSIGN { FRAG_VERT_ONLY("/=", $1.line); $$.line = $1.line; $$.op = EOpDivAssign; }\r
- | MOD_ASSIGN { PACK_UNPACK_ONLY("%=", $1.line); $$.line = $1.line; $$.op = EOpModAssign; }\r
- | ADD_ASSIGN { $$.line = $1.line; $$.op = EOpAddAssign; }\r
- | SUB_ASSIGN { $$.line = $1.line; $$.op = EOpSubAssign; }\r
- | LEFT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpLeftShiftAssign; }\r
- | RIGHT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpRightShiftAssign; }\r
- | AND_ASSIGN { PACK_UNPACK_ONLY("&=", $1.line); $$.line = $1.line; $$.op = EOpAndAssign; }\r
- | XOR_ASSIGN { PACK_UNPACK_ONLY("^=", $1.line); $$.line = $1.line; $$.op = EOpExclusiveOrAssign; }\r
- | OR_ASSIGN { PACK_UNPACK_ONLY("|=", $1.line); $$.line = $1.line; $$.op = EOpInclusiveOrAssign; }\r
- ;\r
-\r
-expression\r
- : assignment_expression {\r
- $$ = $1;\r
- }\r
- | expression COMMA assignment_expression {\r
- $$ = parseContext.intermediate.addComma($1, $3, $2.line);\r
- if ($$ == 0) {\r
- parseContext.binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());\r
- parseContext.recover();\r
- $$ = $3;\r
- }\r
- }\r
- ;\r
-\r
-constant_expression\r
- : conditional_expression {\r
- if (parseContext.constErrorCheck($1))\r
- parseContext.recover();\r
- $$ = $1;\r
- }\r
- ;\r
-\r
-declaration\r
- : function_prototype SEMICOLON { $$ = 0; }\r
- | init_declarator_list SEMICOLON { \r
- if ($1.intermAggregate)\r
- $1.intermAggregate->setOperator(EOpSequence); \r
- $$ = $1.intermAggregate; \r
- }\r
- ;\r
-\r
-function_prototype \r
- : function_declarator RIGHT_PAREN {\r
- //\r
- // Multiple declarations of the same function are allowed.\r
- //\r
- // If this is a definition, the definition production code will check for redefinitions \r
- // (we don't know at this point if it's a definition or not).\r
- //\r
- // Redeclarations are allowed. But, return types and parameter qualifiers must match.\r
- // \r
- TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find($1->getMangledName()));\r
- if (prevDec) {\r
- if (prevDec->getReturnType() != $1->getReturnType()) {\r
- parseContext.error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");\r
- parseContext.recover();\r
- }\r
- for (int i = 0; i < prevDec->getParamCount(); ++i) {\r
- if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) {\r
- parseContext.error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), "");\r
- parseContext.recover();\r
- }\r
- }\r
- }\r
- \r
- //\r
- // If this is a redeclaration, it could also be a definition,\r
- // in which case, we want to use the variable names from this one, and not the one that's\r
- // being redeclared. So, pass back up this declaration, not the one in the symbol table.\r
- //\r
- $$.function = $1;\r
- $$.line = $2.line;\r
-\r
- parseContext.symbolTable.insert(*$$.function);\r
- }\r
- ;\r
-\r
-function_declarator \r
- : function_header {\r
- $$ = $1;\r
- }\r
- | function_header_with_parameters { \r
- $$ = $1; \r
- }\r
- ;\r
-\r
-\r
-function_header_with_parameters\r
- : function_header parameter_declaration {\r
- // Add the parameter \r
- $$ = $1;\r
- if ($2.param.type->getBasicType() != EbtVoid)\r
- $1->addParameter($2.param);\r
- else\r
- delete $2.param.type;\r
- }\r
- | function_header_with_parameters COMMA parameter_declaration { \r
- //\r
- // Only first parameter of one-parameter functions can be void\r
- // The check for named parameters not being void is done in parameter_declarator \r
- //\r
- if ($3.param.type->getBasicType() == EbtVoid) {\r
- //\r
- // This parameter > first is void\r
- //\r
- parseContext.error($2.line, "cannot be an argument type except for '(void)'", "void", "");\r
- parseContext.recover();\r
- delete $3.param.type;\r
- } else {\r
- // Add the parameter \r
- $$ = $1; \r
- $1->addParameter($3.param);\r
- }\r
- }\r
- ;\r
-\r
-function_header \r
- : fully_specified_type IDENTIFIER LEFT_PAREN {\r
- if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) {\r
- parseContext.error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");\r
- parseContext.recover();\r
- }\r
- // make sure a sampler is not involved as well...\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- // Add the function as a prototype after parsing it (we do not support recursion) \r
- TFunction *function;\r
- TType type($1);\r
- function = new TFunction($2.string, type);\r
- $$ = function;\r
- }\r
- ;\r
-\r
-parameter_declarator\r
- // Type + name \r
- : type_specifier IDENTIFIER {\r
- if ($1.type == EbtVoid) {\r
- parseContext.error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");\r
- parseContext.recover();\r
- }\r
- if (parseContext.reservedErrorCheck($2.line, *$2.string))\r
- parseContext.recover();\r
- TParameter param = {$2.string, new TType($1)};\r
- $$.line = $2.line;\r
- $$.param = param;\r
- }\r
- | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {\r
- // Check that we can make an array out of this type\r
- if ($1.array) {\r
- parseContext.error($3.line, "cannot declare arrays of this type", TType($1).getCompleteString().c_str(), "");\r
- parseContext.recover();\r
- }\r
- if (parseContext.reservedErrorCheck($2.line, *$2.string))\r
- parseContext.recover();\r
- $1.array = true;\r
- TType* type = new TType($1); \r
- if ($4->getAsConstantUnion())\r
- type->setArraySize($4->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
- TParameter param = { $2.string, type };\r
- $$.line = $2.line;\r
- $$.param = param;\r
- }\r
- ;\r
-\r
-parameter_declaration \r
- // \r
- // The only parameter qualifier a parameter can have are \r
- // IN_QUAL, OUT_QUAL, INOUT_QUAL, or CONST.\r
- //\r
- \r
- //\r
- // Type + name \r
- //\r
- : type_qualifier parameter_qualifier parameter_declarator {\r
- $$ = $3;\r
- if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))\r
- parseContext.recover();\r
- }\r
- | parameter_qualifier parameter_declarator {\r
- $$ = $2;\r
- if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type))\r
- parseContext.recover();\r
- if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))\r
- parseContext.recover();\r
- }\r
- //\r
- // Only type \r
- //\r
- | type_qualifier parameter_qualifier parameter_type_specifier {\r
- $$ = $3;\r
- if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))\r
- parseContext.recover();\r
- }\r
- | parameter_qualifier parameter_type_specifier {\r
- $$ = $2;\r
- if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type))\r
- parseContext.recover();\r
- if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))\r
- parseContext.recover();\r
- }\r
- ;\r
- \r
-parameter_qualifier\r
- : /* empty */ {\r
- $$ = EvqIn;\r
- }\r
- | IN_QUAL {\r
- $$ = EvqIn;\r
- }\r
- | OUT_QUAL {\r
- $$ = EvqOut;\r
- }\r
- | INOUT_QUAL {\r
- $$ = EvqInOut;\r
- }\r
- ;\r
-\r
-parameter_type_specifier \r
- : type_specifier {\r
- TParameter param = { 0, new TType($1) };\r
- $$.param = param;\r
- \r
- }\r
- | type_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET {\r
- // Check that we can make an array out of this type \r
- if ($1.array) {\r
- parseContext.error($2.line, "cannot declare arrays of this type", TType($1).getCompleteString().c_str(), "");\r
- parseContext.recover();\r
- }\r
- $1.array = true;\r
- TType* type = new TType($1); \r
- if ($3->getAsConstantUnion())\r
- type->setArraySize($3->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
-\r
- TParameter param = { 0, type };\r
- $$.line = $2.line;\r
- $$.param = param;\r
- }\r
- ;\r
-\r
-init_declarator_list\r
- : single_declaration {\r
- $$ = $1;\r
- } \r
- | init_declarator_list COMMA IDENTIFIER {\r
- $$ = $1;\r
- if (parseContext.structQualifierErrorCheck($3.line, $1.type))\r
- parseContext.recover();\r
- \r
- if (parseContext.nonInitErrorCheck($3.line, *$3.string, $$.type))\r
- parseContext.recover();\r
- }\r
- | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {\r
- $$ = $1;\r
- if (parseContext.structQualifierErrorCheck($3.line, $1.type))\r
- parseContext.recover();\r
- \r
- if (parseContext.arrayErrorCheck($4.line, *$3.string, $$.type, 0))\r
- parseContext.recover();\r
- }\r
- | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {\r
- $$ = $1;\r
- if (parseContext.structQualifierErrorCheck($3.line, $1.type))\r
- parseContext.recover();\r
- \r
- if (parseContext.arrayErrorCheck($4.line, *$3.string, $$.type, $5))\r
- parseContext.recover();\r
- }\r
- | init_declarator_list COMMA IDENTIFIER EQUAL initializer {\r
- $$ = $1;\r
- if (parseContext.structQualifierErrorCheck($3.line, $1.type))\r
- parseContext.recover();\r
- \r
- TIntermNode* intermNode;\r
- if (!parseContext.executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) {\r
- //\r
- // build the intermediate representation\r
- //\r
- if (intermNode)\r
- $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $4.line);\r
- else\r
- $$.intermAggregate = $1.intermAggregate;\r
- } else {\r
- parseContext.recover();\r
- $$.intermAggregate = 0;\r
- }\r
- }\r
- ;\r
-\r
-single_declaration \r
- : fully_specified_type {\r
- $$.type = $1;\r
- $$.intermAggregate = 0;\r
- } \r
- | fully_specified_type IDENTIFIER {\r
- $$.intermAggregate = 0;\r
- $$.type = $1;\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- if (parseContext.nonInitErrorCheck($2.line, *$2.string, $$.type))\r
- parseContext.recover();\r
- }\r
- | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {\r
- $$.intermAggregate = 0;\r
- $$.type = $1;\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- if (parseContext.arrayErrorCheck($3.line, *$2.string, $$.type, 0))\r
- parseContext.recover();\r
- }\r
- | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {\r
- $$.intermAggregate = 0;\r
- $$.type = $1;\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- if (parseContext.arrayErrorCheck($3.line, *$2.string, $$.type, $4))\r
- parseContext.recover();\r
- }\r
- | fully_specified_type IDENTIFIER EQUAL initializer {\r
- $$.type = $1;\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- TIntermNode* intermNode;\r
- if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {\r
- //\r
- // Build intermediate representation\r
- //\r
- if (intermNode)\r
- $$.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, $3.line);\r
- else\r
- $$.intermAggregate = 0;\r
- } else {\r
- parseContext.recover();\r
- $$.intermAggregate = 0;\r
- }\r
- }\r
- \r
-//\r
-// Place holder for the pack/unpack languages.\r
-//\r
-// | buffer_specifier {\r
-// $$.intermAggregate = 0;\r
-// }\r
- ;\r
-\r
-// Grammar Note: No 'enum', or 'typedef'.\r
-\r
-//\r
-// Place holder for the pack/unpack languages.\r
-//\r
-//%type <interm> buffer_declaration\r
-//%type <interm.type> buffer_specifier input_or_output buffer_declaration_list \r
-//buffer_specifier\r
-// : input_or_output LEFT_BRACE buffer_declaration_list RIGHT_BRACE {\r
-// }\r
-// ;\r
-//\r
-//input_or_output\r
-// : INPUT {\r
-// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "input"))\r
-// parseContext.recover();\r
-// UNPACK_ONLY("input", $1.line);\r
-// $$.qualifier = EvqInput; \r
-// }\r
-// | OUTPUT {\r
-// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "output"))\r
-// parseContext.recover();\r
-// PACK_ONLY("output", $1.line);\r
-// $$.qualifier = EvqOutput;\r
-// }\r
-// ;\r
-\r
-//\r
-// Place holder for the pack/unpack languages.\r
-//\r
-//buffer_declaration_list\r
-// : buffer_declaration {\r
-// }\r
-// | buffer_declaration_list buffer_declaration {\r
-// }\r
-// ;\r
-\r
-//\r
-// Input/output semantics:\r
-// float must be 16 or 32 bits\r
-// float alignment restrictions?\r
-// check for only one input and only one output\r
-// sum of bitfields has to be multiple of 32\r
-//\r
-\r
-//\r
-// Place holder for the pack/unpack languages.\r
-//\r
-//buffer_declaration\r
-// : type_specifier IDENTIFIER COLON constant_expression SEMICOLON {\r
-// if (parseContext.reservedErrorCheck($2.line, *$2.string, parseContext))\r
-// parseContext.recover();\r
-// $$.variable = new TVariable($2.string, $1);\r
-// if (! parseContext.symbolTable.insert(*$$.variable)) {\r
-// parseContext.error($2.line, "redefinition", $$.variable->getName().c_str(), "");\r
-// parseContext.recover();\r
-// // don't have to delete $$.variable, the pool pop will take care of it\r
-// }\r
-// }\r
-// ;\r
-\r
-fully_specified_type\r
- : type_specifier {\r
- $$ = $1;\r
- }\r
- | type_qualifier type_specifier { \r
- TPublicType t = { $2.type, $1.qualifier, $2.size, $2.matrix, false, $2.userDef, 0 };\r
- if ($1.qualifier == EvqAttribute &&\r
- ($2.type == EbtBool || $2.type == EbtInt)) {\r
- parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");\r
- parseContext.recover();\r
- }\r
- if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &&\r
- ($2.type == EbtBool || $2.type == EbtInt)) {\r
- parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");\r
- parseContext.recover();\r
- }\r
- $$ = t;\r
- }\r
- ;\r
-\r
-type_qualifier\r
- : CONST_QUAL { \r
- TPublicType t = { EbtVoid, EvqConst, 1, false, false, 0 }; \r
- $$ = t; \r
- }\r
- | ATTRIBUTE { \r
- VERTEX_ONLY("attribute", $1.line);\r
- if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "attribute"))\r
- parseContext.recover();\r
- TPublicType t = { EbtVoid, EvqAttribute, 1, false, false, 0 }; \r
- $$ = t; \r
- }\r
- | VARYING {\r
- if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "varying"))\r
- parseContext.recover();\r
- TPublicType t = { EbtVoid, EvqVaryingIn, 1, false, false, 0 };\r
- if (parseContext.language == EShLangVertex)\r
- t.qualifier = EvqVaryingOut;\r
- $$ = t; \r
- }\r
- | UNIFORM {\r
- if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "uniform"))\r
- parseContext.recover();\r
- TPublicType t = { EbtVoid, EvqUniform, 1, false, false, 0 }; \r
- $$ = t;\r
- }\r
- ;\r
-\r
-type_specifier\r
- : VOID_TYPE {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtVoid, qual, 1, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | FLOAT_TYPE {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 1, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | INT_TYPE {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtInt, qual, 1, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | BOOL_TYPE {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtBool, qual, 1, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
-// | UNSIGNED INT_TYPE { \r
-// PACK_UNPACK_ONLY("unsigned", $1.line); \r
-// TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
-// TPublicType t = { EbtInt, qual, 1, false, false, 0, $1.line }; \r
-// $$ = t; \r
-// }\r
- | VEC2 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 2, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | VEC3 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 3, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | VEC4 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 4, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | BVEC2 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtBool, qual, 2, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | BVEC3 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtBool, qual, 3, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | BVEC4 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtBool, qual, 4, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | IVEC2 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtInt, qual, 2, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | IVEC3 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtInt, qual, 3, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | IVEC4 {\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtInt, qual, 4, false, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | MATRIX2 {\r
- FRAG_VERT_ONLY("mat2", $1.line); \r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 2, true, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | MATRIX3 { \r
- FRAG_VERT_ONLY("mat3", $1.line); \r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 3, true, false, 0, $1.line }; \r
- $$ = t; \r
- }\r
- | MATRIX4 { \r
- FRAG_VERT_ONLY("mat4", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtFloat, qual, 4, true, false, 0, $1.line }; \r
- $$ = t; \r
- } \r
- | SAMPLER1D {\r
- FRAG_VERT_ONLY("sampler1D", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSampler1D, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- } \r
- | SAMPLER2D {\r
- FRAG_VERT_ONLY("sampler2D", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSampler2D, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- } \r
- | SAMPLER3D {\r
- FRAG_VERT_ONLY("sampler3D", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSampler3D, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- } \r
- | SAMPLERCUBE {\r
- FRAG_VERT_ONLY("samplerCube", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSamplerCube, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- } \r
- | SAMPLER1DSHADOW {\r
- FRAG_VERT_ONLY("sampler1DShadow", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSampler1DShadow, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- } \r
- | SAMPLER2DSHADOW {\r
- FRAG_VERT_ONLY("sampler2DShadow", $1.line);\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtSampler2DShadow, qual, 1, false, false, 0, $1.line }; \r
- $$ = t;\r
- }\r
- | struct_specifier {\r
- FRAG_VERT_ONLY("struct", $1.line);\r
- $$ = $1;\r
- $$.qualifier = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- }\r
- | TYPE_NAME { \r
- //\r
- // This is for user defined type names. The lexical phase looked up the \r
- // type.\r
- //\r
- TType& structure = static_cast<TVariable*>($1.symbol)->getType();\r
- TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r
- TPublicType t = { EbtStruct, qual, 1, false, false, &structure, $1.line }; \r
- $$ = t;\r
- }\r
- ;\r
-\r
-struct_specifier\r
- : STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE {\r
- TType* structure = new TType($4, *$2.string);\r
- TVariable* userTypeDef = new TVariable($2.string, *structure, true);\r
- if (! parseContext.symbolTable.insert(*userTypeDef)) {\r
- parseContext.error($2.line, "redefinition", $2.string->c_str(), "struct");\r
- parseContext.recover();\r
- }\r
- TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, $1.line };\r
- $$ = t;\r
- }\r
- | STRUCT LEFT_BRACE struct_declaration_list RIGHT_BRACE {\r
- TType* structure = new TType($3, TString(""));\r
- TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, $1.line };\r
- $$ = t;\r
- }\r
- ;\r
- \r
-struct_declaration_list\r
- : struct_declaration {\r
- $$ = $1;\r
- }\r
- | struct_declaration_list struct_declaration {\r
- $$ = $1;\r
- for (unsigned int i = 0; i < $2->size(); ++i) {\r
- for (unsigned int j = 0; j < $$->size(); ++j) {\r
- if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) {\r
- parseContext.error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());\r
- parseContext.recover();\r
- }\r
- }\r
- $$->push_back((*$2)[i]);\r
- }\r
- }\r
- ;\r
- \r
-struct_declaration\r
- : type_specifier struct_declarator_list SEMICOLON {\r
- $$ = $2;\r
- \r
- if (parseContext.voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {\r
- parseContext.recover();\r
- }\r
- for (unsigned int i = 0; i < $$->size(); ++i) {\r
- //\r
- // Careful not to replace already know aspects of type, like array-ness\r
- //\r
- (*$$)[i].type->setType($1.type, $1.size, $1.matrix, $1.userDef);\r
- if ($1.userDef)\r
- (*$$)[i].type->setTypeName($1.userDef->getTypeName());\r
- }\r
- }\r
- ;\r
- \r
-struct_declarator_list\r
- : struct_declarator {\r
- $$ = NewPoolTTypeList();\r
- $$->push_back($1);\r
- }\r
- | struct_declarator_list COMMA struct_declarator {\r
- $$->push_back($3);\r
- }\r
- ;\r
- \r
-struct_declarator\r
- : IDENTIFIER {\r
- $$.type = new TType(EbtVoid);\r
- $$.line = $1.line;\r
- $$.type->setFieldName(*$1.string);\r
- }\r
- | IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {\r
- $$.type = new TType(EbtVoid);\r
- $$.line = $1.line;\r
- $$.type->setFieldName(*$1.string);\r
- \r
- if ($3->getAsConstantUnion() == 0 || $3->getAsConstantUnion()->getBasicType() != EbtInt ||\r
- $3->getAsConstantUnion()->getUnionArrayPointer()->iConst <= 0) {\r
- parseContext.error($2.line, "structure field array size must be a positive integer", $1.string->c_str(), "");\r
- parseContext.recover();\r
- } else { \r
- $$.type->setArraySize($3->getAsConstantUnion()->getUnionArrayPointer()->iConst);\r
- }\r
- }\r
- ;\r
-\r
-initializer\r
- : assignment_expression { $$ = $1; }\r
- ;\r
-\r
-declaration_statement \r
- : declaration { $$ = $1; }\r
- ;\r
-\r
-statement\r
- : compound_statement { $$ = $1; }\r
- | simple_statement { $$ = $1; }\r
- ;\r
-\r
-// Grammar Note: No labeled statements; 'goto' is not supported.\r
-\r
-simple_statement \r
- : declaration_statement { $$ = $1; }\r
- | expression_statement { $$ = $1; } \r
- | selection_statement { $$ = $1; }\r
- | iteration_statement { $$ = $1; }\r
- | jump_statement { $$ = $1; }\r
- ;\r
-\r
-compound_statement\r
- : LEFT_BRACE RIGHT_BRACE { $$ = 0; }\r
- | LEFT_BRACE { parseContext.symbolTable.push(); } statement_list { parseContext.symbolTable.pop(); } RIGHT_BRACE {\r
- if ($3 != 0) \r
- $3->setOperator(EOpSequence); \r
- $$ = $3;\r
- }\r
- ;\r
-\r
-statement_no_new_scope \r
- : compound_statement_no_new_scope { $$ = $1; }\r
- | simple_statement { $$ = $1; }\r
- ;\r
-\r
-compound_statement_no_new_scope \r
- // Statement that doesn't create a new scope, for selection_statement, iteration_statement \r
- : LEFT_BRACE RIGHT_BRACE { \r
- $$ = 0; \r
- }\r
- | LEFT_BRACE statement_list RIGHT_BRACE { \r
- if ($2)\r
- $2->setOperator(EOpSequence); \r
- $$ = $2; \r
- }\r
- ;\r
-\r
-statement_list\r
- : statement {\r
- $$ = parseContext.intermediate.makeAggregate($1, 0); \r
- }\r
- | statement_list statement { \r
- $$ = parseContext.intermediate.growAggregate($1, $2, 0);\r
- }\r
- ;\r
-\r
-expression_statement\r
- : SEMICOLON { $$ = 0; }\r
- | expression SEMICOLON { $$ = static_cast<TIntermNode*>($1); }\r
- ;\r
-\r
-selection_statement\r
- : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { \r
- if (parseContext.boolErrorCheck($1.line, $3))\r
- parseContext.recover();\r
- $$ = parseContext.intermediate.addSelection($3, $5, $1.line);\r
- }\r
- ;\r
-\r
-selection_rest_statement \r
- : statement ELSE statement {\r
- $$.node1 = $1;\r
- $$.node2 = $3;\r
- }\r
- | statement { \r
- $$.node1 = $1;\r
- $$.node2 = 0;\r
- }\r
- ;\r
-\r
-// Grammar Note: No 'switch'. Switch statements not supported.\r
-\r
-condition\r
- // In 1996 c++ draft, conditions can include single declarations \r
- : expression {\r
- $$ = $1;\r
- if (parseContext.boolErrorCheck($1->getLine(), $1))\r
- parseContext.recover(); \r
- }\r
- | fully_specified_type IDENTIFIER EQUAL initializer {\r
- TIntermNode* intermNode;\r
- if (parseContext.structQualifierErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- if (parseContext.boolErrorCheck($2.line, $1))\r
- parseContext.recover();\r
- \r
- if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode))\r
- $$ = $4;\r
- else {\r
- parseContext.recover();\r
- $$ = 0;\r
- }\r
- }\r
- ;\r
-\r
-iteration_statement\r
- : WHILE LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope { \r
- parseContext.symbolTable.pop();\r
- $$ = parseContext.intermediate.addLoop($6, $4, 0, true, $1.line);\r
- --parseContext.loopNestingLevel;\r
- }\r
- | DO { ++parseContext.loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {\r
- if (parseContext.boolErrorCheck($8.line, $6))\r
- parseContext.recover();\r
- \r
- $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.line);\r
- --parseContext.loopNestingLevel;\r
- }\r
- | FOR LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {\r
- parseContext.symbolTable.pop();\r
- $$ = parseContext.intermediate.makeAggregate($4, $2.line);\r
- $$ = parseContext.intermediate.growAggregate(\r
- $$,\r
- parseContext.intermediate.addLoop($7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line),\r
- $1.line);\r
- $$->getAsAggregate()->setOperator(EOpSequence);\r
- --parseContext.loopNestingLevel;\r
- }\r
- ;\r
-\r
-for_init_statement \r
- : expression_statement {\r
- $$ = $1; \r
- } \r
- | declaration_statement {\r
- $$ = $1;\r
- }\r
- ;\r
-\r
-conditionopt \r
- : condition { \r
- $$ = $1; \r
- }\r
- | /* May be null */ { \r
- $$ = 0; \r
- }\r
- ;\r
-\r
-for_rest_statement \r
- : conditionopt SEMICOLON { \r
- $$.node1 = $1;\r
- $$.node2 = 0;\r
- }\r
- | conditionopt SEMICOLON expression {\r
- $$.node1 = $1;\r
- $$.node2 = $3;\r
- }\r
- ;\r
-\r
-jump_statement\r
- : CONTINUE SEMICOLON {\r
- if (parseContext.loopNestingLevel <= 0) {\r
- parseContext.error($1.line, "continue statement only allowed in loops", "", "");\r
- parseContext.recover();\r
- } \r
- $$ = parseContext.intermediate.addBranch(EOpContinue, $1.line);\r
- }\r
- | BREAK SEMICOLON {\r
- if (parseContext.loopNestingLevel <= 0) {\r
- parseContext.error($1.line, "break statement only allowed in loops", "", "");\r
- parseContext.recover();\r
- } \r
- $$ = parseContext.intermediate.addBranch(EOpBreak, $1.line);\r
- }\r
- | RETURN SEMICOLON {\r
- $$ = parseContext.intermediate.addBranch(EOpReturn, $1.line);\r
- if (parseContext.currentFunctionType->getBasicType() != EbtVoid) {\r
- parseContext.error($1.line, "non-void function must return a value", "return", "");\r
- parseContext.recover();\r
- }\r
- }\r
- | RETURN expression SEMICOLON { \r
- $$ = parseContext.intermediate.addBranch(EOpReturn, $2, $1.line);\r
- parseContext.functionReturnsValue = true;\r
- if (parseContext.currentFunctionType->getBasicType() == EbtVoid) {\r
- parseContext.error($1.line, "void function cannot return a value", "return", "");\r
- parseContext.recover();\r
- } else if (*(parseContext.currentFunctionType) != $2->getType()) {\r
- parseContext.error($1.line, "function return is not matching type:", "return", "");\r
- parseContext.recover();\r
- }\r
- }\r
- | DISCARD SEMICOLON {\r
- FRAG_ONLY("discard", $1.line);\r
- $$ = parseContext.intermediate.addBranch(EOpKill, $1.line);\r
- } \r
- ;\r
-\r
-// Grammar Note: No 'goto'. Gotos are not supported.\r
-\r
-translation_unit\r
- : external_declaration { \r
- $$ = $1; \r
- parseContext.treeRoot = $$; \r
- }\r
- | translation_unit external_declaration {\r
- $$ = parseContext.intermediate.growAggregate($1, $2, 0);\r
- parseContext.treeRoot = $$;\r
- }\r
- ;\r
-\r
-external_declaration\r
- : function_definition { \r
- $$ = $1; \r
- }\r
- | declaration { \r
- $$ = $1; \r
- }\r
- ;\r
-\r
-function_definition\r
- : function_prototype {\r
- TFunction& function = *($1.function);\r
- TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(function.getMangledName()));\r
- //\r
- // Note: 'prevDec' could be 'function' if this is the first time we've seen function\r
- // as it would have just been put in the symbol table. Otherwise, we're looking up\r
- // an earlier occurance.\r
- //\r
- if (prevDec->isDefined()) {\r
- //\r
- // Then this function already has a body.\r
- //\r
- parseContext.error($1.line, "function already has a body", function.getName().c_str(), "");\r
- parseContext.recover();\r
- }\r
- prevDec->setDefined();\r
- \r
- //\r
- // Raise error message if main function takes any parameters or return anything other than void\r
- //\r
- if (function.getName() == "main") {\r
- if (function.getParamCount() > 0) {\r
- parseContext.error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), "");\r
- parseContext.recover();\r
- }\r
- if (function.getReturnType().getBasicType() != EbtVoid) {\r
- parseContext.error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value" );\r
- parseContext.recover();\r
- } \r
- }\r
- \r
- //\r
- // New symbol table scope for body of function plus its arguments\r
- //\r
- parseContext.symbolTable.push();\r
- \r
- //\r
- // Remember the return type for later checking for RETURN statements.\r
- //\r
- parseContext.currentFunctionType = &(prevDec->getReturnType());\r
- parseContext.functionReturnsValue = false;\r
- \r
- // \r
- // Insert parameters into the symbol table.\r
- // If the parameter has no name, it's not an error, just don't insert it \r
- // (could be used for unused args).\r
- //\r
- // Also, accumulate the list of parameters into the HIL, so lower level code\r
- // knows where to find parameters.\r
- //\r
- TIntermAggregate* paramNodes = new TIntermAggregate;\r
- for (int i = 0; i < function.getParamCount(); i++) {\r
- TParameter& param = function[i];\r
- if (param.name != 0) {\r
- TVariable *variable = new TVariable(param.name, *param.type);\r
- // \r
- // Insert the parameters with name in the symbol table.\r
- //\r
- if (! parseContext.symbolTable.insert(*variable)) {\r
- parseContext.error($1.line, "redefinition", variable->getName().c_str(), "");\r
- parseContext.recover();\r
- delete variable;\r
- }\r
- //\r
- // Transfer ownership of name pointer to symbol table.\r
- //\r
- param.name = 0;\r
- \r
- //\r
- // Add the parameter to the HIL\r
- // \r
- paramNodes = parseContext.intermediate.growAggregate(\r
- paramNodes, \r
- parseContext.intermediate.addSymbol(variable->getUniqueId(),\r
- variable->getName(),\r
- variable->getType(), $1.line), \r
- $1.line);\r
- } else {\r
- paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);\r
- }\r
- }\r
- parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line);\r
- $1.intermAggregate = paramNodes;\r
- parseContext.loopNestingLevel = 0;\r
- }\r
- compound_statement_no_new_scope {\r
- //?? Check that all paths return a value if return type != void ?\r
- // May be best done as post process phase on intermediate code\r
- if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) {\r
- parseContext.error($1.line, "function does not return a value:", "", $1.function->getName().c_str());\r
- parseContext.recover();\r
- }\r
- parseContext.symbolTable.pop();\r
- $$ = parseContext.intermediate.growAggregate($1.intermAggregate, $3, 0);\r
- parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.line);\r
- $$->getAsAggregate()->setName($1.function->getMangledName().c_str());\r
- $$->getAsAggregate()->setType($1.function->getReturnType());\r
- \r
- // store the pragma information for debug and optimize and other vendor specific \r
- // information. This information can be queried from the parse tree\r
- $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);\r
- $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);\r
- $$->getAsAggregate()->addToPragmaTable(parseContext.contextPragma.pragmaTable);\r
- }\r
- ;\r
-\r
-%%\r
+++ /dev/null
-/* A Bison parser, made by GNU Bison 1.875. */
-
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- ATTRIBUTE = 258,
- CONST_QUAL = 259,
- BOOL_TYPE = 260,
- FLOAT_TYPE = 261,
- INT_TYPE = 262,
- BREAK = 263,
- CONTINUE = 264,
- DO = 265,
- ELSE = 266,
- FOR = 267,
- IF = 268,
- DISCARD = 269,
- RETURN = 270,
- BVEC2 = 271,
- BVEC3 = 272,
- BVEC4 = 273,
- IVEC2 = 274,
- IVEC3 = 275,
- IVEC4 = 276,
- VEC2 = 277,
- VEC3 = 278,
- VEC4 = 279,
- MATRIX2 = 280,
- MATRIX3 = 281,
- MATRIX4 = 282,
- IN_QUAL = 283,
- OUT_QUAL = 284,
- INOUT_QUAL = 285,
- UNIFORM = 286,
- VARYING = 287,
- STRUCT = 288,
- VOID_TYPE = 289,
- WHILE = 290,
- SAMPLER1D = 291,
- SAMPLER2D = 292,
- SAMPLER3D = 293,
- SAMPLERCUBE = 294,
- SAMPLER1DSHADOW = 295,
- SAMPLER2DSHADOW = 296,
- IDENTIFIER = 297,
- TYPE_NAME = 298,
- FLOATCONSTANT = 299,
- INTCONSTANT = 300,
- BOOLCONSTANT = 301,
- FIELD_SELECTION = 302,
- LEFT_OP = 303,
- RIGHT_OP = 304,
- INC_OP = 305,
- DEC_OP = 306,
- LE_OP = 307,
- GE_OP = 308,
- EQ_OP = 309,
- NE_OP = 310,
- AND_OP = 311,
- OR_OP = 312,
- XOR_OP = 313,
- MUL_ASSIGN = 314,
- DIV_ASSIGN = 315,
- ADD_ASSIGN = 316,
- MOD_ASSIGN = 317,
- LEFT_ASSIGN = 318,
- RIGHT_ASSIGN = 319,
- AND_ASSIGN = 320,
- XOR_ASSIGN = 321,
- OR_ASSIGN = 322,
- SUB_ASSIGN = 323,
- LEFT_PAREN = 324,
- RIGHT_PAREN = 325,
- LEFT_BRACKET = 326,
- RIGHT_BRACKET = 327,
- LEFT_BRACE = 328,
- RIGHT_BRACE = 329,
- DOT = 330,
- COMMA = 331,
- COLON = 332,
- EQUAL = 333,
- SEMICOLON = 334,
- BANG = 335,
- DASH = 336,
- TILDE = 337,
- PLUS = 338,
- STAR = 339,
- SLASH = 340,
- PERCENT = 341,
- LEFT_ANGLE = 342,
- RIGHT_ANGLE = 343,
- VERTICAL_BAR = 344,
- CARET = 345,
- AMPERSAND = 346,
- QUESTION = 347
- };
-#endif
-#define ATTRIBUTE 258
-#define CONST_QUAL 259
-#define BOOL_TYPE 260
-#define FLOAT_TYPE 261
-#define INT_TYPE 262
-#define BREAK 263
-#define CONTINUE 264
-#define DO 265
-#define ELSE 266
-#define FOR 267
-#define IF 268
-#define DISCARD 269
-#define RETURN 270
-#define BVEC2 271
-#define BVEC3 272
-#define BVEC4 273
-#define IVEC2 274
-#define IVEC3 275
-#define IVEC4 276
-#define VEC2 277
-#define VEC3 278
-#define VEC4 279
-#define MATRIX2 280
-#define MATRIX3 281
-#define MATRIX4 282
-#define IN_QUAL 283
-#define OUT_QUAL 284
-#define INOUT_QUAL 285
-#define UNIFORM 286
-#define VARYING 287
-#define STRUCT 288
-#define VOID_TYPE 289
-#define WHILE 290
-#define SAMPLER1D 291
-#define SAMPLER2D 292
-#define SAMPLER3D 293
-#define SAMPLERCUBE 294
-#define SAMPLER1DSHADOW 295
-#define SAMPLER2DSHADOW 296
-#define IDENTIFIER 297
-#define TYPE_NAME 298
-#define FLOATCONSTANT 299
-#define INTCONSTANT 300
-#define BOOLCONSTANT 301
-#define FIELD_SELECTION 302
-#define LEFT_OP 303
-#define RIGHT_OP 304
-#define INC_OP 305
-#define DEC_OP 306
-#define LE_OP 307
-#define GE_OP 308
-#define EQ_OP 309
-#define NE_OP 310
-#define AND_OP 311
-#define OR_OP 312
-#define XOR_OP 313
-#define MUL_ASSIGN 314
-#define DIV_ASSIGN 315
-#define ADD_ASSIGN 316
-#define MOD_ASSIGN 317
-#define LEFT_ASSIGN 318
-#define RIGHT_ASSIGN 319
-#define AND_ASSIGN 320
-#define XOR_ASSIGN 321
-#define OR_ASSIGN 322
-#define SUB_ASSIGN 323
-#define LEFT_PAREN 324
-#define RIGHT_PAREN 325
-#define LEFT_BRACKET 326
-#define RIGHT_BRACKET 327
-#define LEFT_BRACE 328
-#define RIGHT_BRACE 329
-#define DOT 330
-#define COMMA 331
-#define COLON 332
-#define EQUAL 333
-#define SEMICOLON 334
-#define BANG 335
-#define DASH 336
-#define TILDE 337
-#define PLUS 338
-#define STAR 339
-#define SLASH 340
-#define PERCENT 341
-#define LEFT_ANGLE 342
-#define RIGHT_ANGLE 343
-#define VERTICAL_BAR 344
-#define CARET 345
-#define AMPERSAND 346
-#define QUESTION 347
-
-
-
-
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 117 "glslang.y"
-typedef union YYSTYPE {
- struct {
- TSourceLoc line;
- union {
- TString *string;
- float f;
- int i;
- bool b;
- };
- TSymbol* symbol;
- } lex;
- struct {
- TSourceLoc line;
- TOperator op;
- union {
- TIntermNode* intermNode;
- TIntermNodePair nodePair;
- TIntermTyped* intermTypedNode;
- TIntermAggregate* intermAggregate;
- };
- union {
- TPublicType type;
- TQualifier qualifier;
- TFunction* function;
- TParameter param;
- TTypeLine typeLine;
- TTypeList* typeList;
- };
- } interm;
-} YYSTYPE;
-/* Line 1240 of yacc.c. */
-#line 251 "glslang.tab.h"
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-
-
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "localintermediate.h"\r
-#include "../Include/ShHandle.h"\r
-\r
-//\r
-// Two purposes:\r
-// 1. Show an example of how to iterate tree. Functions can\r
-// also directly call Traverse() on children themselves to\r
-// have finer grained control over the process than shown here.\r
-// See the last function for how to get started.\r
-// 2. Print out a text based description of the tree.\r
-//\r
-\r
-//\r
-// Use this class to carry along data from node to node in \r
-// the traversal\r
-//\r
-class TOutputTraverser : public TIntermTraverser {\r
-public:\r
- TOutputTraverser(TInfoSink& i) : infoSink(i) { }\r
- TInfoSink& infoSink;\r
-};\r
-\r
-TString TType::getCompleteString() const\r
-{\r
- char buf[100];\r
- char *p = &buf[0];\r
-\r
- if (qualifier != EvqTemporary && qualifier != EvqGlobal)\r
- p += sprintf(p, "%s ", getQualifierString());\r
- if (array)\r
- p += sprintf(p, "array of ");\r
- if (matrix)\r
- p += sprintf(p, "%dX%d matrix of ", size, size);\r
- else if (size > 1)\r
- p += sprintf(p, "%d-component vector of ", size);\r
-\r
- sprintf(p, "%s", getBasicString());\r
-\r
- return TString(buf);\r
-} \r
-\r
-//\r
-// Helper functions for printing, not part of traversing.\r
-//\r
-\r
-void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth)\r
-{\r
- int i;\r
-\r
- infoSink.debug << FormatSourceLoc(node->getLine());\r
- \r
- for (i = 0; i < depth; ++i)\r
- infoSink.debug << " ";\r
-}\r
-\r
-//\r
-// The rest of the file are the traversal functions. The last one\r
-// is the one that starts the traversal.\r
-//\r
-// Return true from interior nodes to have the external traversal\r
-// continue on to children. If you process children yourself,\r
-// return false.\r
-//\r
-\r
-void OutputSymbol(TIntermSymbol* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
-\r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
-\r
- char buf[100];\r
- sprintf(buf, "'%s' (%s)\n",\r
- node->getSymbol().c_str(),\r
- node->getCompleteString().c_str());\r
-\r
- oit->infoSink.debug << buf;\r
-}\r
-\r
-bool OutputBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- OutputTreeText(out, node, oit->depth);\r
-\r
- switch (node->getOp()) {\r
- case EOpAssign: out.debug << "move second child to first child"; break;\r
- case EOpAddAssign: out.debug << "add second child into first child"; break;\r
- case EOpSubAssign: out.debug << "subtract second child into first child"; break;\r
- case EOpMulAssign: out.debug << "multiply second child into first child"; break;\r
- case EOpVectorTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;\r
- case EOpVectorTimesScalarAssign: out.debug << "vector scale second child into first child"; break;\r
- case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break;\r
- case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;\r
- case EOpDivAssign: out.debug << "divide second child into first child"; break;\r
- case EOpModAssign: out.debug << "mod second child into first child"; break;\r
- case EOpAndAssign: out.debug << "and second child into first child"; break;\r
- case EOpInclusiveOrAssign: out.debug << "or second child into first child"; break;\r
- case EOpExclusiveOrAssign: out.debug << "exclusive or second child into first child"; break;\r
- case EOpLeftShiftAssign: out.debug << "left shift second child into first child"; break;\r
- case EOpRightShiftAssign: out.debug << "right shift second child into first child"; break;\r
-\r
- case EOpIndexDirect: out.debug << "direct index"; break;\r
- case EOpIndexIndirect: out.debug << "indirect index"; break;\r
- case EOpIndexDirectStruct: out.debug << "direct index for structure"; break;\r
- case EOpVectorSwizzle: out.debug << "vector swizzle"; break;\r
-\r
- case EOpAdd: out.debug << "add"; break;\r
- case EOpSub: out.debug << "subtract"; break;\r
- case EOpMul: out.debug << "component-wise multiply"; break;\r
- case EOpDiv: out.debug << "divide"; break;\r
- case EOpMod: out.debug << "mod"; break;\r
- case EOpRightShift: out.debug << "right-shift"; break;\r
- case EOpLeftShift: out.debug << "left-shift"; break;\r
- case EOpAnd: out.debug << "bitwise and"; break;\r
- case EOpInclusiveOr: out.debug << "inclusive-or"; break;\r
- case EOpExclusiveOr: out.debug << "exclusive-or"; break;\r
- case EOpEqual: out.debug << "Compare Equal"; break;\r
- case EOpNotEqual: out.debug << "Compare Not Equal"; break;\r
- case EOpLessThan: out.debug << "Compare Less Than"; break;\r
- case EOpGreaterThan: out.debug << "Compare Greater Than"; break;\r
- case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;\r
- case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;\r
-\r
- case EOpVectorTimesScalar: out.debug << "vector-scale"; break;\r
- case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;\r
- case EOpMatrixTimesVector: out.debug << "matrix-times-vector"; break;\r
- case EOpMatrixTimesScalar: out.debug << "matrix-scale"; break;\r
- case EOpMatrixTimesMatrix: out.debug << "matrix-multiply"; break;\r
-\r
- case EOpLogicalOr: out.debug << "logical-or"; break;\r
- case EOpLogicalXor: out.debug << "logical-xor"; break;\r
- case EOpLogicalAnd: out.debug << "logical-and"; break;\r
- default: out.debug << "<unknown op>";\r
- }\r
-\r
- out.debug << " (" << node->getCompleteString() << ")";\r
-\r
- out.debug << "\n";\r
-\r
- return true;\r
-}\r
-\r
-bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- OutputTreeText(out, node, oit->depth);\r
-\r
- switch (node->getOp()) { \r
- case EOpNegative: out.debug << "Negate value"; break;\r
- case EOpVectorLogicalNot:\r
- case EOpLogicalNot: out.debug << "Negate conditional"; break;\r
- case EOpBitwiseNot: out.debug << "Bitwise not"; break;\r
-\r
- case EOpPostIncrement: out.debug << "Post-Increment"; break;\r
- case EOpPostDecrement: out.debug << "Post-Decrement"; break;\r
- case EOpPreIncrement: out.debug << "Pre-Increment"; break;\r
- case EOpPreDecrement: out.debug << "Pre-Decrement"; break;\r
-\r
- case EOpConvIntToBool: out.debug << "Convert int to bool"; break;\r
- case EOpConvFloatToBool:out.debug << "Convert float to bool";break;\r
- case EOpConvBoolToFloat:out.debug << "Convert bool to float";break;\r
- case EOpConvIntToFloat: out.debug << "Convert int to float"; break;\r
- case EOpConvFloatToInt: out.debug << "Convert float to int"; break;\r
- case EOpConvBoolToInt: out.debug << "Convert bool to int"; break;\r
-\r
- case EOpRadians: out.debug << "radians"; break;\r
- case EOpDegrees: out.debug << "degrees"; break;\r
- case EOpSin: out.debug << "sine"; break;\r
- case EOpCos: out.debug << "cosine"; break;\r
- case EOpTan: out.debug << "tangent"; break;\r
- case EOpAsin: out.debug << "arc sine"; break;\r
- case EOpAcos: out.debug << "arc cosine"; break;\r
- case EOpAtan: out.debug << "arc tangent"; break;\r
-\r
- case EOpExp: out.debug << "exp"; break;\r
- case EOpLog: out.debug << "log"; break;\r
- case EOpExp2: out.debug << "exp2"; break;\r
- case EOpLog2: out.debug << "log2"; break;\r
- case EOpSqrt: out.debug << "sqrt"; break;\r
- case EOpInverseSqrt: out.debug << "inverse sqrt"; break;\r
-\r
- case EOpAbs: out.debug << "Absolute value"; break;\r
- case EOpSign: out.debug << "Sign"; break;\r
- case EOpFloor: out.debug << "Floor"; break;\r
- case EOpCeil: out.debug << "Ceiling"; break;\r
- case EOpFract: out.debug << "Fraction"; break;\r
-\r
- case EOpLength: out.debug << "length"; break;\r
- case EOpNormalize: out.debug << "normalize"; break;\r
- case EOpDPdx: out.debug << "dPdx"; break; \r
- case EOpDPdy: out.debug << "dPdy"; break; \r
- case EOpFwidth: out.debug << "fwidth"; break; \r
- \r
- case EOpAny: out.debug << "any"; break;\r
- case EOpAll: out.debug << "all"; break;\r
-\r
- default: out.debug.message(EPrefixError, "Bad unary op");\r
- }\r
-\r
- out.debug << " (" << node->getCompleteString() << ")";\r
-\r
- out.debug << "\n";\r
-\r
- return true;\r
-}\r
-\r
-bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- if (node->getOp() == EOpNull) {\r
- out.debug.message(EPrefixError, "node is still EOpNull!");\r
- return true;\r
- }\r
-\r
- OutputTreeText(out, node, oit->depth);\r
-\r
- switch (node->getOp()) {\r
- case EOpSequence: out.debug << "Sequence\n"; return true;\r
- case EOpComma: out.debug << "Comma\n"; return true;\r
- case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;\r
- case EOpFunctionCall: out.debug << "Function Call: " << node->getName(); break;\r
- case EOpParameters: out.debug << "Function Parameters: "; break;\r
- \r
- case EOpConstructFloat: out.debug << "Construct float"; break;\r
- case EOpConstructVec2: out.debug << "Construct vec2"; break;\r
- case EOpConstructVec3: out.debug << "Construct vec3"; break;\r
- case EOpConstructVec4: out.debug << "Construct vec4"; break;\r
- case EOpConstructBool: out.debug << "Construct bool"; break;\r
- case EOpConstructBVec2: out.debug << "Construct bvec2"; break;\r
- case EOpConstructBVec3: out.debug << "Construct bvec3"; break;\r
- case EOpConstructBVec4: out.debug << "Construct bvec4"; break;\r
- case EOpConstructInt: out.debug << "Construct int"; break;\r
- case EOpConstructIVec2: out.debug << "Construct ivec2"; break;\r
- case EOpConstructIVec3: out.debug << "Construct ivec3"; break;\r
- case EOpConstructIVec4: out.debug << "Construct ivec4"; break;\r
- case EOpConstructMat2: out.debug << "Construct mat2"; break;\r
- case EOpConstructMat3: out.debug << "Construct mat3"; break;\r
- case EOpConstructMat4: out.debug << "Construct mat4"; break;\r
- case EOpConstructStruct: out.debug << "Construct structure"; break;\r
- \r
- case EOpLessThan: out.debug << "Compare Less Than"; break;\r
- case EOpGreaterThan: out.debug << "Compare Greater Than"; break;\r
- case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;\r
- case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;\r
- case EOpVectorEqual: out.debug << "Equal"; break;\r
- case EOpVectorNotEqual: out.debug << "NotEqual"; break;\r
-\r
- case EOpMod: out.debug << "mod"; break;\r
- case EOpPow: out.debug << "pow"; break;\r
-\r
- case EOpAtan: out.debug << "arc tangent"; break;\r
-\r
- case EOpMin: out.debug << "min"; break;\r
- case EOpMax: out.debug << "max"; break;\r
- case EOpClamp: out.debug << "clamp"; break;\r
- case EOpMix: out.debug << "mix"; break;\r
- case EOpStep: out.debug << "step"; break;\r
- case EOpSmoothStep: out.debug << "smoothstep"; break;\r
-\r
- case EOpDistance: out.debug << "distance"; break;\r
- case EOpDot: out.debug << "dot-product"; break;\r
- case EOpCross: out.debug << "cross-product"; break;\r
- case EOpFaceForward: out.debug << "face-forward"; break;\r
- case EOpReflect: out.debug << "reflect"; break;\r
- case EOpRefract: out.debug << "refract"; break;\r
- case EOpMul: out.debug << "component-wise multiply"; break;\r
-\r
- case EOpItof: out.debug << "itof"; break;\r
- case EOpFtoi: out.debug << "ftoi"; break;\r
- case EOpSkipPixels: out.debug << "skipPixels"; break;\r
- case EOpReadInput: out.debug << "readInput"; break;\r
- case EOpWritePixel: out.debug << "writePixel"; break;\r
- case EOpBitmapLsb: out.debug << "bitmapLSB"; break;\r
- case EOpBitmapMsb: out.debug << "bitmapMSB"; break;\r
- case EOpWriteOutput: out.debug << "writeOutput"; break;\r
- case EOpReadPixel: out.debug << "readPixel"; break;\r
-\r
- default: out.debug.message(EPrefixError, "Bad aggregation op");\r
- }\r
-\r
- if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)\r
- out.debug << " (" << node->getCompleteString() << ")";\r
- \r
- out.debug << "\n";\r
-\r
- return true;\r
-}\r
-\r
-bool OutputSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- OutputTreeText(out, node, oit->depth);\r
-\r
- out.debug << "Test condition and select";\r
- out.debug << " (" << node->getCompleteString() << ")\n";\r
- \r
- ++oit->depth;\r
- \r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- out.debug << "Condition\n";\r
- node->getCondition()->traverse(it);\r
-\r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- if (node->getTrueBlock()) {\r
- out.debug << "true case\n";\r
- node->getTrueBlock()->traverse(it);\r
- } else\r
- out.debug << "true case is null\n";\r
- \r
- if (node->getFalseBlock()) {\r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- out.debug << "false case\n";\r
- node->getFalseBlock()->traverse(it);\r
- }\r
- \r
- --oit->depth;\r
-\r
- return false;\r
-}\r
-\r
-void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
- \r
- int size = 0;\r
- if (node->getType().getBasicType() == EbtStruct)\r
- size = node->getType().getStructSize();\r
- else\r
- size = node->getType().getInstanceSize();\r
-\r
- for (int i = 0; i < size; i++) {\r
- OutputTreeText(out, node, oit->depth);\r
- switch (node->getType().getBasicType()) {\r
- case EbtBool:\r
- if (node->getUnionArrayPointer()[i].bConst)\r
- out.debug << "true";\r
- else\r
- out.debug << "false";\r
-\r
- out.debug << " (" << "const bool" << ")";\r
-\r
- out.debug << "\n";\r
- break;\r
- case EbtFloat:\r
- {\r
- char buf[300];\r
- sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].fConst, "const float");\r
-\r
- out.debug << buf << "\n"; \r
- }\r
- break;\r
- case EbtInt:\r
- {\r
- char buf[300];\r
- sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].iConst, "const int");\r
-\r
- out.debug << buf << "\n";\r
- break;\r
- }\r
- default: \r
- out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());\r
- break;\r
- }\r
- }\r
-}\r
-\r
-bool OutputLoop(bool /* preVisit */, TIntermLoop* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- OutputTreeText(out, node, oit->depth);\r
- \r
- out.debug << "Loop with condition ";\r
- if (! node->testFirst())\r
- out.debug << "not ";\r
- out.debug << "tested first\n";\r
- \r
- ++oit->depth;\r
- \r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- if (node->getTest()) {\r
- out.debug << "Loop Condition\n";\r
- node->getTest()->traverse(it);\r
- } else\r
- out.debug << "No loop condition\n";\r
- \r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- if (node->getBody()) {\r
- out.debug << "Loop Body\n";\r
- node->getBody()->traverse(it);\r
- } else\r
- out.debug << "No loop body\n";\r
-\r
- if (node->getTerminal()) {\r
- OutputTreeText(oit->infoSink, node, oit->depth);\r
- out.debug << "Loop Terminal Expression\n";\r
- node->getTerminal()->traverse(it);\r
- }\r
-\r
- --oit->depth;\r
-\r
- return false;\r
-}\r
-\r
-bool OutputBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)\r
-{\r
- TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);\r
- TInfoSink& out = oit->infoSink;\r
-\r
- OutputTreeText(out, node, oit->depth);\r
-\r
- switch (node->getFlowOp()) {\r
- case EOpKill: out.debug << "Branch: Kill"; break;\r
- case EOpBreak: out.debug << "Branch: Break"; break;\r
- case EOpContinue: out.debug << "Branch: Continue"; break;\r
- case EOpReturn: out.debug << "Branch: Return"; break;\r
- default: out.debug << "Branch: Unknown Branch"; break;\r
- }\r
-\r
- if (node->getExpression()) {\r
- out.debug << " with expression\n";\r
- ++oit->depth;\r
- node->getExpression()->traverse(it);\r
- --oit->depth;\r
- } else\r
- out.debug << "\n";\r
-\r
- return false;\r
-}\r
-\r
-//\r
-// This function is the one to call externally to start the traversal.\r
-// Individual functions can be initialized to 0 to skip processing of that\r
-// type of node. It's children will still be processed.\r
-//\r
-void TIntermediate::outputTree(TIntermNode* root)\r
-{\r
- if (root == 0)\r
- return;\r
-\r
- TOutputTraverser it(infoSink);\r
-\r
- it.visitAggregate = OutputAggregate;\r
- it.visitBinary = OutputBinary;\r
- it.visitConstantUnion = OutputConstantUnion;\r
- it.visitSelection = OutputSelection;\r
- it.visitSymbol = OutputSymbol;\r
- it.visitUnary = OutputUnary;\r
- it.visitLoop = OutputLoop;\r
- it.visitBranch = OutputBranch;\r
-\r
- root->traverse(&it);\r
-}\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#ifndef _LOCAL_INTERMEDIATE_INCLUDED_\r
-#define _LOCAL_INTERMEDIATE_INCLUDED_\r
-\r
-#include "../Include/intermediate.h"\r
-#include "../Public/ShaderLang.h"\r
-#include "SymbolTable.h"\r
-\r
-struct TVectorFields {\r
- int offsets[4];\r
- int num;\r
-};\r
-\r
-//\r
-// Set of helper functions to help parse and build the tree.\r
-//\r
-class TInfoSink;\r
-class TIntermediate {\r
-public: \r
- POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)\r
-\r
- TIntermediate(TInfoSink& i) : infoSink(i) { }\r
- TIntermSymbol* addSymbol(int Id, const TString&, const TType&, TSourceLoc);\r
- TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);\r
- TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);\r
- TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);\r
- TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);\r
- TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, TSourceLoc, TSymbolTable&);\r
- TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);\r
- TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);\r
- TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);\r
- TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);\r
- TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);\r
- TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);\r
- TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);\r
- TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;\r
- TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;\r
- TIntermConstantUnion* changeAggrToTempConst(TIntermAggregate*, TSymbolTable&, TSourceLoc ); \r
- bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false); \r
- TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);\r
- TIntermBranch* addBranch(TOperator, TSourceLoc);\r
- TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);\r
- TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc);\r
- bool postProcess(TIntermNode*, EShLanguage);\r
- void remove(TIntermNode*);\r
- void outputTree(TIntermNode*);\r
- void removeChildNode(TIntermSequence&, TType&, int&, TIntermSequence::iterator&, TIntermAggregate*);\r
- TIntermTyped* removeChildNode(TIntermTyped*, TType*, TIntermAggregate*);\r
- bool removeMatrixConstNode(TIntermSequence&, TType&, TIntermAggregate*, int);\r
- \r
-protected:\r
- TInfoSink& infoSink;\r
-\r
-private:\r
- void operator=(TIntermediate&); // prevent assignments\r
-};\r
-\r
-#endif // _LOCAL_INTERMEDIATE_INCLUDED_\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#include "ParseHelper.h"\r
-\r
-//\r
-// Use this class to carry along data from node to node in \r
-// the traversal\r
-//\r
-class TConstTraverser : public TIntermTraverser {\r
-public:\r
- TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),\r
- constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;}\r
- int index ;\r
- constUnion *unionArray;\r
- TOperator tOp;\r
- TType type;\r
- TOperator constructorType;\r
- bool singleConstantParam;\r
- TInfoSink& infoSink;\r
- TSymbolTable& symbolTable;\r
- bool error;\r
- int size; // size of the constructor ( 4 for vec4)\r
- bool isMatrix;\r
- int matrixSize; // dimension of the matrix (nominal size and not the instance size)\r
-};\r
-\r
-//\r
-// The rest of the file are the traversal functions. The last one\r
-// is the one that starts the traversal.\r
-//\r
-// Return true from interior nodes to have the external traversal\r
-// continue on to children. If you process children yourself,\r
-// return false.\r
-//\r
-\r
-void ParseSymbol(TIntermSymbol* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- TQualifier qualifier = node->getType().getQualifier();\r
- constUnion* unionArray = oit->unionArray;\r
- int instanceSize;\r
- if (oit->type.getBasicType() == EbtStruct)\r
- instanceSize = oit->type.getStructSize();\r
- else\r
- instanceSize = oit->type.getInstanceSize();\r
-\r
- if (oit->index >= instanceSize)\r
- return;\r
-\r
- if (qualifier != EvqConst) {\r
- char buf[200];\r
- sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());\r
- oit->infoSink.info.message(EPrefixError, buf, node->getLine());\r
- oit->error = true;\r
- return ; \r
- }\r
- TSymbol* symbol = oit->symbolTable.find(node->getSymbol());\r
- TVariable* tVar = static_cast<TVariable*>(symbol);\r
-\r
- constUnion* constArray = tVar->getConstPointer();\r
- if (!constArray) {\r
- char buf[200];\r
- sprintf(buf, "'constructor' : constant '%s' has not been initialized correctly", node->getSymbol().c_str());\r
- oit->infoSink.info.message(EPrefixError, buf, node->getLine());\r
- oit->error = true;\r
- return;\r
- }\r
- int symbolSize;\r
-\r
- if (tVar->getType().getBasicType() == EbtStruct)\r
- symbolSize = tVar->getType().getStructSize();\r
- else \r
- symbolSize = tVar->getType().getInstanceSize();\r
- \r
- // for constructors such as ivec4(vec4), if vec4 is a symbol node, then the appropriate conversion is required as the\r
- // types do not match\r
- for (int i = 0; i < symbolSize; i++) {\r
- if (oit->index >= instanceSize)\r
- return;\r
- if (tVar->getType().getBasicType() == oit->type.getBasicType() || oit->type.getBasicType() == EbtStruct)\r
- (unionArray[oit->index]) = constArray[i];\r
- else {\r
- switch (tVar->getType().getBasicType()) {\r
- case EbtFloat:\r
- switch (oit->type.getBasicType()) {\r
- case EbtInt: unionArray[oit->index].iConst = static_cast<int> (constArray[i].fConst); break;\r
- case EbtBool: unionArray[oit->index].bConst = constArray[i].fConst != 0.0; break; \r
- default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;\r
- }\r
- break;\r
- case EbtInt:\r
- switch (oit->type.getBasicType()) {\r
- case EbtFloat: unionArray[oit->index].fConst = static_cast<float>(constArray[i].iConst); break;\r
- case EbtBool: unionArray[oit->index].bConst = constArray[i].iConst != 0 ; break; \r
- default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;\r
- }\r
- break;\r
- case EbtBool:\r
- switch (oit->type.getBasicType()) {\r
- case EbtFloat: unionArray[oit->index].fConst = static_cast<float>(constArray[i].bConst); break;\r
- case EbtInt: unionArray[oit->index].iConst = static_cast<int> (constArray[i].bConst); break; \r
- default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;\r
- }\r
- break;\r
- default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;\r
- } \r
- }\r
- (oit->index)++;\r
- }\r
-}\r
-\r
-bool ParseBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- \r
- TQualifier qualifier = node->getType().getQualifier();\r
- \r
- if (qualifier != EvqConst) {\r
- char buf[200];\r
- sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());\r
- oit->infoSink.info.message(EPrefixError, buf, node->getLine());\r
- oit->error = true;\r
- return false; \r
- }\r
-\r
- oit->infoSink.info.message(EPrefixInternalError, "Binary Node found in constant constructor", node->getLine());\r
- \r
- return false;\r
-}\r
-\r
-bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
-\r
- char buf[200];\r
- sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());\r
- oit->infoSink.info.message(EPrefixError, buf, node->getLine());\r
- oit->error = true;\r
- return false; \r
-}\r
-\r
-bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
-\r
- if (!node->isConstructor() && node->getOp() != EOpComma) {\r
- char buf[200];\r
- sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());\r
- oit->infoSink.info.message(EPrefixError, buf, node->getLine());\r
- oit->error = true;\r
- return false; \r
- }\r
-\r
- if (node->getSequence().size() == 0) {\r
- oit->error = true;\r
- return false;\r
- }\r
-\r
- bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();\r
- if (flag) \r
- {\r
- oit->singleConstantParam = true; \r
- oit->constructorType = node->getOp();\r
- if (node->getType().getBasicType() == EbtStruct)\r
- oit->size = node->getType().getStructSize();\r
- else\r
- oit->size = node->getType().getInstanceSize();\r
- if (node->getType().isMatrix()) {\r
- oit->isMatrix = true;\r
- oit->matrixSize = node->getType().getNominalSize();\r
- }\r
- } \r
-\r
- for (TIntermSequence::iterator p = node->getSequence().begin(); \r
- p != node->getSequence().end(); p++) {\r
-\r
- if (node->getOp() == EOpComma)\r
- oit->index = 0; \r
-\r
- (*p)->traverse(oit);\r
- } \r
- if (flag) \r
- {\r
- oit->singleConstantParam = false; \r
- oit->constructorType = EOpNull;\r
- oit->size = 0;\r
- oit->isMatrix = false;\r
- oit->matrixSize = 0;\r
- }\r
- return false;\r
-}\r
-\r
-bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- oit->infoSink.info.message(EPrefixInternalError, "Selection Node found in constant constructor", node->getLine());\r
- oit->error = true;\r
- return false;\r
-}\r
-\r
-void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- constUnion* leftUnionArray = oit->unionArray;\r
- int instanceSize;\r
- if (oit->type.getBasicType() == EbtStruct)\r
- instanceSize = oit->type.getStructSize();\r
- else\r
- instanceSize = oit->type.getInstanceSize();\r
-\r
- if (oit->index >= instanceSize)\r
- return;\r
-\r
- if (!oit->singleConstantParam) {\r
- int size;\r
- if (node->getType().getBasicType() == EbtStruct)\r
- size = node->getType().getStructSize();\r
- else\r
- size = node->getType().getInstanceSize();\r
- \r
- constUnion *rightUnionArray = node->getUnionArrayPointer();\r
- for (int i=0; i < size; i++) {\r
- if (oit->index >= instanceSize)\r
- return;\r
- leftUnionArray[oit->index] = rightUnionArray[i];\r
-\r
- (oit->index)++;\r
- }\r
- } else {\r
- int size, totalSize, matrixSize;\r
- bool isMatrix = false;\r
- size = oit->size;\r
- matrixSize = oit->matrixSize;\r
- isMatrix = oit->isMatrix;\r
- totalSize = oit->index + size ;\r
- constUnion *rightUnionArray = node->getUnionArrayPointer();\r
- if (!isMatrix) {\r
- int count = 0;\r
- for (int i = oit->index; i < totalSize; i++) {\r
- if (i >= instanceSize)\r
- return;\r
-\r
- leftUnionArray[i] = rightUnionArray[count];\r
-\r
- (oit->index)++;\r
- if (node->getType().getBasicType() == EbtStruct && node->getType().getStructSize() > 1 ||\r
- node->getType().getBasicType() != EbtStruct && node->getType().getInstanceSize() > 1)\r
- count++; \r
- }\r
- } else { // for matrix constructors\r
- int count = 0;\r
- int index = oit->index;\r
- for (int i = index; i < totalSize; i++) {\r
- if (i >= instanceSize)\r
- return;\r
- if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 )\r
- leftUnionArray[i] = rightUnionArray[count];\r
- else \r
- leftUnionArray[i].fConst = 0.0;\r
-\r
- (oit->index)++;\r
- if (node->getType().getBasicType() == EbtStruct && node->getType().getStructSize() > 1 ||\r
- node->getType().getBasicType() != EbtStruct && node->getType().getInstanceSize() > 1)\r
- count++; \r
- }\r
- }\r
- }\r
-}\r
-\r
-bool ParseLoop(bool /* preVisit */, TIntermLoop* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- oit->infoSink.info.message(EPrefixInternalError, "Loop Node found in constant constructor", node->getLine());\r
- oit->error = true;\r
- return false;\r
-}\r
-\r
-bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)\r
-{\r
- TConstTraverser* oit = static_cast<TConstTraverser*>(it);\r
- oit->infoSink.info.message(EPrefixInternalError, "Branch Node found in constant constructor", node->getLine());\r
- oit->error = true;\r
- return false;\r
-}\r
-\r
-//\r
-// This function is the one to call externally to start the traversal.\r
-// Individual functions can be initialized to 0 to skip processing of that\r
-// type of node. It's children will still be processed.\r
-//\r
-bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)\r
-{\r
- if (root == 0)\r
- return false;\r
-\r
- TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t);\r
- \r
- it.visitAggregate = ParseAggregate;\r
- it.visitBinary = ParseBinary;\r
- it.visitConstantUnion = ParseConstantUnion;\r
- it.visitSelection = ParseSelection;\r
- it.visitSymbol = ParseSymbol;\r
- it.visitUnary = ParseUnary;\r
- it.visitLoop = ParseLoop;\r
- it.visitBranch = ParseBranch;\r
-\r
- root->traverse(&it);\r
- if (it.error)\r
- return true;\r
- else\r
- return false;\r
-}\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-/* */
-/* atom.c */
-/* */
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include "slglobals.h"\r
-\r
-#undef malloc\r
-#undef realloc\r
-#undef free\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*//////////////////////////////////////// String table: ////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-static const struct {\r
- int val;\r
- const char *str;\r
-} tokens[] = {\r
- { CPP_AND_OP, "&&" },\r
- { CPP_AND_ASSIGN, "&=" },\r
- { CPP_SUB_ASSIGN, "-=" },\r
- { CPP_MOD_ASSIGN, "%=" },\r
- { CPP_ADD_ASSIGN, "+=" },\r
- { CPP_DIV_ASSIGN, "/=" },\r
- { CPP_MUL_ASSIGN, "*=" },\r
- { CPP_RIGHT_BRACKET, ":>" },\r
- { CPP_EQ_OP, "==" },\r
- { CPP_XOR_OP, "^^" }, \r
- { CPP_XOR_ASSIGN, "^=" }, \r
- { CPP_FLOATCONSTANT, "<float-const>" },\r
- { CPP_GE_OP, ">=" },\r
- { CPP_RIGHT_OP, ">>" },\r
- { CPP_RIGHT_ASSIGN, ">>=" }, \r
- { CPP_IDENTIFIER, "<ident>" },\r
- { CPP_INTCONSTANT, "<int-const>" },\r
- { CPP_LE_OP, "<=" },\r
- { CPP_LEFT_OP, "<<" },\r
- { CPP_LEFT_ASSIGN, "<<=" },\r
- { CPP_LEFT_BRACKET, "<:" },\r
- { CPP_LEFT_BRACE, "<%" }, \r
- { CPP_DEC_OP, "--" },\r
- { CPP_RIGHT_BRACE, "%>" }, \r
- { CPP_NE_OP, "!=" },\r
- { CPP_OR_OP, "||" },\r
- { CPP_OR_ASSIGN, "|=" }, \r
- { CPP_INC_OP, "++" },\r
- { CPP_STRCONSTANT, "<string-const>" },\r
- { CPP_TYPEIDENTIFIER, "<type-ident>" },\r
-};\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*//////////////////////////////////////// String table: ////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-#define INIT_STRING_TABLE_SIZE 16384\r
-\r
-typedef struct StringTable_Rec {\r
- char *strings;\r
- int nextFree;\r
- int size;\r
-} StringTable;\r
-\r
-/*\r
- * InitStringTable() - Initialize the string table.\r
- *\r
- */\r
-\r
-static int InitStringTable(StringTable *stable)\r
-{\r
- stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);\r
- if (!stable->strings)\r
- return 0;\r
- /* Zero-th offset means "empty" so don't use it. */
- stable->nextFree = 1;\r
- stable->size = INIT_STRING_TABLE_SIZE;\r
- return 1;\r
-} /* InitStringTable */
-\r
-/*\r
- * FreeStringTable() - Free the string table.\r
- *\r
- */\r
-\r
-static void FreeStringTable(StringTable *stable)\r
-{\r
- if (stable->strings)\r
- free(stable->strings);\r
- stable->strings = NULL;\r
- stable->nextFree = 0;\r
- stable->size = 0;\r
-} /* FreeStringTable */
-\r
-/*\r
- * HashString() - Hash a string with the base hash function.\r
- *\r
- */\r
-\r
-static int HashString(const char *s)\r
-{\r
- int hval = 0;\r
-\r
- while (*s) {\r
- hval = (hval*13507 + *s*197) ^ (hval >> 2);\r
- s++;\r
- }\r
- return hval & 0x7fffffff;\r
-} /* HashString */
-\r
-/*\r
- * HashString2() - Hash a string with the incrimenting hash function.\r
- *\r
- */\r
-\r
-static int HashString2(const char *s)\r
-{\r
- int hval = 0;\r
-\r
- while (*s) {\r
- hval = (hval*729 + *s*37) ^ (hval >> 1);\r
- s++;\r
- }\r
- return hval;\r
-} /* HashString2 */
-\r
-/*\r
- * AddString() - Add a string to a string table. Return it's offset.\r
- *\r
- */\r
-\r
-static int AddString(StringTable *stable, const char *s)\r
-{\r
- int len, loc;\r
- char *str;\r
-\r
- len = (int) strlen(s);\r
- if (stable->nextFree + len + 1 >= stable->size) {\r
- assert(stable->size < 1000000);\r
- str = (char *) malloc(stable->size*2);\r
- memcpy(str, stable->strings, stable->size);\r
- free(stable->strings);\r
- stable->strings = str;\r
- }\r
- loc = stable->nextFree;\r
- strcpy(&stable->strings[loc], s);\r
- stable->nextFree += len + 1;\r
- return loc;\r
-} /* AddString */
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////////////// Hash table: /////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-#define INIT_HASH_TABLE_SIZE 2047\r
-#define HASH_TABLE_MAX_COLLISIONS 3\r
-\r
-typedef struct HashEntry_Rec {\r
- int index; /* String table offset of string representation */
- int value; /* Atom (symbol) value */
-} HashEntry;\r
-\r
-typedef struct HashTable_Rec {\r
- HashEntry *entry;\r
- int size;\r
- int entries;\r
- int counts[HASH_TABLE_MAX_COLLISIONS + 1];\r
-} HashTable;\r
-\r
-/*\r
- * InitHashTable() - Initialize the hash table.\r
- *\r
- */\r
-\r
-static int InitHashTable(HashTable *htable, int fsize)\r
-{\r
- int ii;\r
-\r
- htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize);\r
- if (!htable->entry)\r
- return 0;\r
- htable->size = fsize;\r
- for (ii = 0; ii < fsize; ii++) {\r
- htable->entry[ii].index = 0;\r
- htable->entry[ii].value = 0;\r
- }\r
- htable->entries = 0;\r
- for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++)\r
- htable->counts[ii] = 0;\r
- return 1;\r
-} /* InitHashTable */
-\r
-/*\r
- * FreeHashTable() - Free the hash table.\r
- *\r
- */\r
-\r
-static void FreeHashTable(HashTable *htable)\r
-{\r
- if (htable->entry)\r
- free(htable->entry);\r
- htable->entry = NULL;\r
- htable->size = 0;\r
- htable->entries = 0;\r
-} /* FreeHashTable */
-\r
-/*\r
- * Empty() - See if a hash table entry is empty.\r
- *\r
- */\r
-\r
-static int Empty(HashTable *htable, int hashloc)\r
-{\r
- assert(hashloc >= 0 && hashloc < htable->size);\r
- if (htable->entry[hashloc].index == 0) {\r
- return 1;\r
- } else {\r
- return 0;\r
- }\r
-} /* Empty */
-\r
-/*\r
- * Match() - See if a hash table entry is matches a string.\r
- *\r
- */\r
-\r
-static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc)\r
-{\r
- int strloc;\r
-\r
- strloc = htable->entry[hashloc].index;\r
- if (!strcmp(s, &stable->strings[strloc])) {\r
- return 1;\r
- } else {\r
- return 0;\r
- }\r
-} /* Match */
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////////////// Atom table: /////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-#define INIT_ATOM_TABLE_SIZE 1024\r
-\r
-\r
-struct AtomTable_Rec {\r
- StringTable stable; /* String table. */
- HashTable htable; /* Hashes string to atom number and token value. Multiple strings can */
- /* have the same token value but each unique string is a unique atom. */
- int *amap; /* Maps atom value to offset in string table. Atoms all map to unique */
- /* strings except for some undefined values in the lower, fixed part */
- /* of the atom table that map to "<undefined>". The lowest 256 atoms */
- /* correspond to single character ASCII values except for alphanumeric */
- /* characters and '_', which can be other tokens. Next come the */
- /* language tokens with their atom values equal to the token value. */
- /* Then come predefined atoms, followed by user specified identifiers. */
- int *arev; /* Reversed atom for symbol table use. */
- int nextFree;\r
- int size;\r
-};\r
-\r
-static AtomTable latable = { { 0 } };\r
-AtomTable *atable = &latable;\r
-\r
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom);\r
-\r
-/*\r
- * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.\r
- *\r
- */\r
-\r
-static int GrowAtomTable(AtomTable *atable, int size)\r
-{\r
- int *newmap, *newrev;\r
-\r
- if (atable->size < size) {\r
- if (atable->amap) {\r
- newmap = realloc(atable->amap, sizeof(int)*size);\r
- newrev = realloc(atable->arev, sizeof(int)*size);\r
- } else {\r
- newmap = malloc(sizeof(int)*size);\r
- newrev = malloc(sizeof(int)*size);\r
- atable->size = 0;\r
- }\r
- if (!newmap || !newrev) {\r
- /* failed to grow -- error */\r
- if (newmap)\r
- atable->amap = newmap;\r
- if (newrev)\r
- atable->amap = newrev;\r
- return -1;\r
- }\r
- memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));\r
- memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));\r
- atable->amap = newmap;\r
- atable->arev = newrev;\r
- atable->size = size;\r
- }\r
- return 0;\r
-} /* GrowAtomTable */
-\r
-/*\r
- * lReverse() - Reverse the bottom 20 bits of a 32 bit int.\r
- *\r
- */\r
-\r
-static int lReverse(int fval)\r
-{\r
- unsigned int in = fval;\r
- int result = 0, cnt = 0;\r
-\r
- while(in) {\r
- result <<= 1;\r
- result |= in&1;\r
- in >>= 1;\r
- cnt++;\r
- }\r
-\r
- /* Don't use all 31 bits. One million atoms is plenty and sometimes the */
- /* upper bits are used for other things. */
-\r
- if (cnt < 20)\r
- result <<= 20 - cnt;\r
- return result;\r
-} /* lReverse */
-\r
-/*\r
- * AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.\r
- *\r
- */\r
-\r
-static int AllocateAtom(AtomTable *atable)\r
-{\r
- if (atable->nextFree >= atable->size)\r
- GrowAtomTable(atable, atable->nextFree*2);\r
- atable->amap[atable->nextFree] = -1;\r
- atable->arev[atable->nextFree] = lReverse(atable->nextFree);\r
- atable->nextFree++;\r
- return atable->nextFree - 1;\r
-} /* AllocateAtom */
-\r
-/*\r
- * SetAtomValue() - Allocate a new atom associated with "hashindex".\r
- *\r
- */\r
-\r
-static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex)\r
-{\r
- atable->amap[atomnumber] = atable->htable.entry[hashindex].index;\r
- atable->htable.entry[hashindex].value = atomnumber;\r
-} /* SetAtomValue */
-\r
-/*\r
- * FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.\r
- *\r
- */\r
-\r
-static int FindHashLoc(AtomTable *atable, const char *s)\r
-{\r
- int hashloc, hashdelta, count;\r
- int FoundEmptySlot = 0;\r
- int collision[HASH_TABLE_MAX_COLLISIONS + 1];\r
-\r
- hashloc = HashString(s) % atable->htable.size;\r
- if (!Empty(&atable->htable, hashloc)) {\r
- if (Match(&atable->htable, &atable->stable, s, hashloc))\r
- return hashloc;\r
- collision[0] = hashloc;\r
- hashdelta = HashString2(s);\r
- count = 0;\r
- while (count < HASH_TABLE_MAX_COLLISIONS) {\r
- hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size;\r
- if (!Empty(&atable->htable, hashloc)) {\r
- if (Match(&atable->htable, &atable->stable, s, hashloc)) {\r
- return hashloc;\r
- }\r
- } else {\r
- FoundEmptySlot = 1;\r
- break;\r
- }\r
- count++;\r
- collision[count] = hashloc;\r
- }\r
-\r
- if (!FoundEmptySlot) {\r
- if (cpp->options.DumpAtomTable) {\r
- int ii;\r
- char str[200];\r
- sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",\r
- HASH_TABLE_MAX_COLLISIONS);\r
- CPPShInfoLogMsg(str);\r
-\r
- sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);\r
- CPPShInfoLogMsg(str);\r
- for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {\r
- sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",\r
- ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));\r
- CPPShInfoLogMsg(str);\r
- }\r
- }\r
- return -1;\r
- } else {\r
- atable->htable.counts[count]++;\r
- }\r
- }\r
- return hashloc;\r
-} /* FindHashLoc */
-\r
-/*\r
- * IncreaseHashTableSize()\r
- *\r
- */\r
-\r
-static int IncreaseHashTableSize(AtomTable *atable)\r
-{\r
- int ii, strloc, oldhashloc, value, size;\r
- AtomTable oldtable;\r
- char *s;\r
-\r
- /* Save the old atom table and create a new one: */
-\r
- oldtable = *atable;\r
- size = oldtable.htable.size*2 + 1;\r
- if (!InitAtomTable(atable, size))\r
- return 0;\r
-\r
- /* Add all the existing values to the new atom table preserving their atom values: */
-\r
- for (ii = atable->nextFree; ii < oldtable.nextFree; ii++) {\r
- strloc = oldtable.amap[ii];\r
- s = &oldtable.stable.strings[strloc];\r
- oldhashloc = FindHashLoc(&oldtable, s);\r
- assert(oldhashloc >= 0);\r
- value = oldtable.htable.entry[oldhashloc].value;\r
- AddAtomFixed(atable, s, value);\r
- }\r
- FreeAtomTable(&oldtable);\r
- return 1;\r
-} /* IncreaseHashTableSize */
-\r
-/*\r
- * LookUpAddStringHash() - Lookup a string in the hash table. If it's not there, add it and\r
- * initialize the atom value in the hash table to 0. Return the hash table index.\r
- */\r
-\r
-static int LookUpAddStringHash(AtomTable *atable, const char *s)\r
-{\r
- int hashloc, strloc;\r
-\r
- while(1) {\r
- hashloc = FindHashLoc(atable, s);\r
- if (hashloc >= 0)\r
- break;\r
- IncreaseHashTableSize(atable);\r
- }\r
-\r
- if (Empty(&atable->htable, hashloc)) {\r
- atable->htable.entries++;\r
- strloc = AddString(&atable->stable, s);\r
- atable->htable.entry[hashloc].index = strloc;\r
- atable->htable.entry[hashloc].value = 0;\r
- }\r
- return hashloc;\r
-} /* LookUpAddStringHash */
-\r
-/*\r
- * LookUpAddString() - Lookup a string in the hash table. If it's not there, add it and\r
- * initialize the atom value in the hash table to the next atom number.\r
- * Return the atom value of string.\r
- */\r
-\r
-int LookUpAddString(AtomTable *atable, const char *s)\r
-{\r
- int hashindex, atom;\r
-\r
- hashindex = LookUpAddStringHash(atable, s);\r
- atom = atable->htable.entry[hashindex].value;\r
- if (atom == 0) {\r
- atom = AllocateAtom(atable);\r
- SetAtomValue(atable, atom, hashindex);\r
- }\r
- return atom;\r
-} /* LookUpAddString */
-\r
-/*\r
- * GetAtomString()\r
- *\r
- */\r
-\r
-const char *GetAtomString(AtomTable *atable, int atom)\r
-{\r
- int soffset;\r
-\r
- if (atom > 0 && atom < atable->nextFree) {\r
- soffset = atable->amap[atom];\r
- if (soffset > 0 && soffset < atable->stable.nextFree) {\r
- return &atable->stable.strings[soffset];\r
- } else {\r
- return "<internal error: bad soffset>";\r
- }\r
- } else {\r
- if (atom == 0) {\r
- return "<null atom>";\r
- } else {\r
- if (atom == EOF) {\r
- return "<EOF>";\r
- } else {\r
- return "<invalid atom>";\r
- }\r
- }\r
- }\r
-} /* GetAtomString */
-\r
-/*\r
- * GetReversedAtom()\r
- *\r
- */\r
-\r
-int GetReversedAtom(AtomTable *atable, int atom)\r
-{\r
- if (atom > 0 && atom < atable->nextFree) {\r
- return atable->arev[atom];\r
- } else {\r
- return 0;\r
- }\r
-} /* GetReversedAtom */
-\r
-/*\r
- * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.\r
- * Return it's atom index.\r
- */\r
-\r
-int AddAtom(AtomTable *atable, const char *s)\r
-{\r
- int atom;\r
-\r
- atom = LookUpAddString(atable, s);\r
- return atom;\r
-} /* AddAtom */
-\r
-/*\r
- * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.\r
- * Assign it the atom value of "atom".\r
- */\r
-\r
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom)\r
-{\r
- int hashindex, lsize;\r
-\r
- hashindex = LookUpAddStringHash(atable, s);\r
- if (atable->nextFree >= atable->size || atom >= atable->size) {\r
- lsize = atable->size*2;\r
- if (lsize <= atom)\r
- lsize = atom + 1;\r
- GrowAtomTable(atable, lsize);\r
- }\r
- atable->amap[atom] = atable->htable.entry[hashindex].index;\r
- atable->htable.entry[hashindex].value = atom;\r
- /*if (atom >= atable->nextFree) */
- /* atable->nextFree = atom + 1; */
- while (atom >= atable->nextFree) {\r
- atable->arev[atable->nextFree] = lReverse(atable->nextFree);\r
- atable->nextFree++;\r
- }\r
- return atom;\r
-} /* AddAtomFixed */
-\r
-/*\r
- * InitAtomTable() - Initialize the atom table.\r
- *\r
- */\r
-\r
-int InitAtomTable(AtomTable *atable, int htsize)\r
-{\r
- int ii;\r
-\r
- htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize;\r
- if (!InitStringTable(&atable->stable))\r
- return 0;\r
- if (!InitHashTable(&atable->htable, htsize))\r
- return 0;\r
-\r
- atable->nextFree = 0;\r
- atable->amap = NULL;\r
- atable->size = 0;\r
- GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE);\r
- if (!atable->amap)\r
- return 0;\r
-\r
- /* Initialize lower part of atom table to "<undefined>" atom: */
-\r
- AddAtomFixed(atable, "<undefined>", 0);\r
- for (ii = 0; ii < FIRST_USER_TOKEN_SY; ii++)\r
- atable->amap[ii] = atable->amap[0];\r
-\r
- /* Add single character tokens to the atom table: */
-\r
- {\r
- const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";\r
- char t[2];\r
-\r
- t[1] = '\0';\r
- while (*s) {\r
- t[0] = *s;\r
- AddAtomFixed(atable, t, s[0]);\r
- s++;\r
- }\r
- }\r
-\r
- /* Add multiple character scanner tokens : */
-\r
- for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++)\r
- AddAtomFixed(atable, tokens[ii].str, tokens[ii].val);\r
-\r
- /* Add error symbol if running in error mode: */
-\r
- if (cpp->options.ErrorMode)\r
- AddAtomFixed(atable, "error", ERROR_SY);\r
-\r
- AddAtom(atable, "<*** end fixed atoms ***>");\r
-\r
- return 1;\r
-} /* InitAtomTable */
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*//////////////////////////////// Debug Printing Functions: ////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-/*\r
- * PrintAtomTable()\r
- *\r
- */\r
-\r
-void PrintAtomTable(AtomTable *atable)\r
-{\r
- int ii;\r
- char str[200];\r
-\r
- for (ii = 0; ii < atable->nextFree; ii++) {\r
- sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);\r
- CPPDebugLogMsg(str);\r
- }\r
- sprintf(str, "Hash table: size=%d, entries=%d, collisions=",\r
- atable->htable.size, atable->htable.entries);\r
- CPPDebugLogMsg(str);\r
- for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {\r
- sprintf(str, " %d", atable->htable.counts[ii]);\r
- CPPDebugLogMsg(str);\r
- }\r
-\r
-} /* PrintAtomTable */
-\r
-\r
-/*\r
- * GetStringOfAtom()\r
- *\r
- */\r
-\r
-char* GetStringOfAtom(AtomTable *atable, int atom)\r
-{\r
- char* chr_str;\r
- chr_str=&atable->stable.strings[atable->amap[atom]];\r
- return chr_str;\r
-} /* GetStringOfAtom */
-\r
-/*\r
- * FreeAtomTable() - Free the atom table and associated memory\r
- *\r
- */\r
-\r
-void FreeAtomTable(AtomTable *atable)\r
-{\r
- FreeStringTable(&atable->stable);\r
- FreeHashTable(&atable->htable);\r
- if (atable->amap)\r
- free(atable->amap);\r
- if (atable->arev)\r
- free(atable->arev);\r
- atable->amap = NULL;\r
- atable->arev = NULL;\r
- atable->nextFree = 0;\r
- atable->size = 0;\r
-} /* FreeAtomTable */
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*/////////////////////////////////////// End of atom.c /////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* atom.h */
-/* */
-\r
-#if !defined(__ATOM_H)\r
-#define __ATOM_H 1\r
-\r
-typedef struct AtomTable_Rec AtomTable;\r
-\r
-extern AtomTable *atable;\r
-\r
-int InitAtomTable(AtomTable *atable, int htsize);\r
-void FreeAtomTable(AtomTable *atable);\r
-int AddAtom(AtomTable *atable, const char *s);\r
-void PrintAtomTable(AtomTable *atable);\r
-int LookUpAddString(AtomTable *atable, const char *s);\r
-const char *GetAtomString(AtomTable *atable, int atom);\r
-int GetReversedAtom(AtomTable *atable, int atom);\r
-char* GetStringOfAtom(AtomTable *atable, int atom);\r
-#endif /* !defined(__ATOM_H) */
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* compile.h */
-/* */
-\r
-#if !defined(__COMPILE_H)\r
-#define __COMPILE_H 1\r
-\r
-int InitCPPStruct(void);\r
-\r
-typedef struct Options_Rec{\r
- const char *profileString;\r
- int ErrorMode;\r
- int Quiet;\r
- \r
- /* Debug The Compiler options: */
- int DumpAtomTable;\r
-} Options;\r
-\r
-struct CPPStruct_Rec {\r
- /* Public members */
- SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
- Options options; /* Compile options and parameters */
-\r
- /* Private members */
- SourceLoc lastSourceLoc;\r
-\r
- /* Scanner data: */
-\r
- SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
- int mostRecentToken; /* Most recent token seen by the scanner */
- InputSrc *currentInput;\r
- int previous_token;\r
- int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
- \r
- void *pC; /* storing the parseContext of the compile object in cpp. */
- \r
- /* Private members: */
- SourceLoc ltokenLoc;\r
- int ifdepth; /*current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
- int elsedepth[64]; /*Keep a track of #if depth..Max allowed is 64. */
- int elsetracker; /*#if-#else and #endif constructs...Counter. */
- const char *ErrMsg;\r
- int CompileError; /*Indicate compile error when #error, #else,#elif mismatch. */
-\r
- /* */
- /* Globals used to communicate between PaParseStrings() and yy_input()and */
- /* also across the files.(gen_glslang.cpp and scanner.c) */
- /* */
- int PaWhichStr; /* which string we're parsing */
- int* PaStrLen; /* array of lengths of the PaArgv strings */
- int PaArgc; /* count of strings in the array */
- char** PaArgv; /* our array of strings to parse */
- unsigned int tokensBeforeEOF : 1;\r
-};\r
-\r
-#endif /* !defined(__COMPILE_H) */
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* cpp.c */
-/* */
-\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-\r
-#include "slglobals.h"\r
-\r
-static int CPPif(yystypepp * yylvalpp);\r
-\r
-/* Don't use memory.c's replacements, as we clean up properly here */\r
-#undef malloc\r
-#undef free\r
-\r
-static int bindAtom = 0;\r
-static int constAtom = 0;\r
-static int defaultAtom = 0;\r
-static int defineAtom = 0;\r
-static int definedAtom = 0;\r
-static int elseAtom = 0;\r
-static int elifAtom = 0;\r
-static int endifAtom = 0;\r
-static int ifAtom = 0;\r
-static int ifdefAtom = 0;\r
-static int ifndefAtom = 0;\r
-static int includeAtom = 0;\r
-static int lineAtom = 0;\r
-static int pragmaAtom = 0;\r
-static int texunitAtom = 0;\r
-static int undefAtom = 0;\r
-static int errorAtom = 0;\r
-static int __LINE__Atom = 0;\r
-static int __FILE__Atom = 0;\r
-static int __VERSION__Atom = 0;\r
-static int versionAtom = 0;\r
-static int extensionAtom = 0;\r
-\r
-static Scope *macros = 0;\r
-#define MAX_MACRO_ARGS 64\r
-#define MAX_IF_NESTING 64\r
-\r
-static SourceLoc ifloc; /* outermost #if */\r
-\r
-int InitCPP(void)\r
-{\r
- char buffer[64], *t;\r
- const char *f;\r
- /* Add various atoms needed by the CPP line scanner: */
- bindAtom = LookUpAddString(atable, "bind");\r
- constAtom = LookUpAddString(atable, "const");\r
- defaultAtom = LookUpAddString(atable, "default");\r
- defineAtom = LookUpAddString(atable, "define");\r
- definedAtom = LookUpAddString(atable, "defined");\r
- elifAtom = LookUpAddString(atable, "elif");\r
- elseAtom = LookUpAddString(atable, "else");\r
- endifAtom = LookUpAddString(atable, "endif");\r
- ifAtom = LookUpAddString(atable, "if");\r
- ifdefAtom = LookUpAddString(atable, "ifdef");\r
- ifndefAtom = LookUpAddString(atable, "ifndef");\r
- includeAtom = LookUpAddString(atable, "include");\r
- lineAtom = LookUpAddString(atable, "line");\r
- pragmaAtom = LookUpAddString(atable, "pragma");\r
- texunitAtom = LookUpAddString(atable, "texunit");\r
- undefAtom = LookUpAddString(atable, "undef");\r
- errorAtom = LookUpAddString(atable, "error");\r
- __LINE__Atom = LookUpAddString(atable, "__LINE__");\r
- __FILE__Atom = LookUpAddString(atable, "__FILE__");\r
- __VERSION__Atom = LookUpAddString(atable, "__VERSION__");\r
- versionAtom = LookUpAddString(atable, "version");\r
- extensionAtom = LookUpAddString(atable, "extension");\r
- macros = NewScopeInPool(mem_CreatePool(0, 0));\r
- strcpy(buffer, "PROFILE_");\r
- t = buffer + strlen(buffer);\r
- f = cpp->options.profileString;\r
- while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)\r
- *t++ = toupper(*f++);\r
- *t = 0;\r
- return 1;\r
-} /* InitCPP */
-\r
-int FreeCPP(void)\r
-{\r
- if (macros)\r
- {\r
- mem_FreePool(macros->pool);\r
- macros = 0;\r
- }\r
-\r
- return 1;\r
-}\r
-\r
-int FinalCPP(void)\r
-{\r
- if (cpp->ifdepth)\r
- CPPErrorToInfoLog("#if mismatch");\r
- return 1;\r
-}\r
-\r
-static int CPPdefine(yystypepp * yylvalpp)\r
-{\r
- int token, name, args[MAX_MACRO_ARGS], argc;\r
- const char *message;\r
- MacroSymbol mac;\r
- Symbol *symb;\r
- SourceLoc dummyLoc;\r
- memset(&mac, 0, sizeof(mac));\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != CPP_IDENTIFIER) {\r
- CPPErrorToInfoLog("#define");\r
- return token;\r
- }\r
- name = yylvalpp->sc_ident;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token == '(' && !yylvalpp->sc_int) {\r
- /* gather arguments */
- argc = 0;\r
- do {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (argc == 0 && token == ')') break;\r
- if (token != CPP_IDENTIFIER) {\r
- CPPErrorToInfoLog("#define");\r
- return token;\r
- }\r
- if (argc < MAX_MACRO_ARGS)\r
- args[argc++] = yylvalpp->sc_ident;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- } while (token == ',');\r
- if (token != ')') {\r
- CPPErrorToInfoLog("#define");\r
- return token;\r
- }\r
- mac.argc = argc;\r
- mac.args = mem_Alloc(macros->pool, argc * sizeof(int));\r
- memcpy(mac.args, args, argc * sizeof(int));\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- mac.body = NewTokenStream(GetAtomString(atable, name));\r
- while (token != '\n') {\r
- while (token == '\\') {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token == '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- else\r
- RecordToken(mac.body, '\\', yylvalpp);\r
- }\r
- RecordToken(mac.body, token, yylvalpp);\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- };\r
-\r
- symb = LookUpSymbol(macros, name);\r
- if (symb) {\r
- if (!symb->details.mac.undef) {\r
- /* already defined -- need to make sure they are identical */
- if (symb->details.mac.argc != mac.argc) goto error;\r
- for (argc=0; argc < mac.argc; argc++)\r
- if (symb->details.mac.args[argc] != mac.args[argc])\r
- goto error;\r
- RewindTokenStream(symb->details.mac.body);\r
- RewindTokenStream(mac.body);\r
- do {\r
- int old_lval, old_token;\r
- old_token = ReadToken(symb->details.mac.body, yylvalpp);\r
- old_lval = yylvalpp->sc_int;\r
- token = ReadToken(mac.body, yylvalpp);\r
- if (token != old_token || yylvalpp->sc_int != old_lval) { \r
- error:\r
- StoreStr("Macro Redefined");\r
- StoreStr(GetStringOfAtom(atable,name));\r
- message=GetStrfromTStr();\r
- DecLineNumber();\r
- CPPShInfoLogMsg(message);\r
- IncLineNumber();\r
- ResetTString();\r
- break; }\r
- } while (token > 0);\r
- }\r
- FreeMacro(&symb->details.mac);\r
- } else {\r
- dummyLoc.file = 0;\r
- dummyLoc.line = 0;\r
- symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);\r
- }\r
- symb->details.mac = mac;\r
- return '\n';\r
-} /* CPPdefine */
-\r
-static int CPPundef(yystypepp * yylvalpp)\r
-{\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- Symbol *symb;\r
- if(token == '\n'){\r
- CPPErrorToInfoLog("#undef");\r
- return token;\r
- }\r
- if (token != CPP_IDENTIFIER)\r
- goto error;\r
- symb = LookUpSymbol(macros, yylvalpp->sc_ident);\r
- if (symb) {\r
- symb->details.mac.undef = 1;\r
- }\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != '\n') {\r
- error:\r
- CPPErrorToInfoLog("#undef");\r
- }\r
- return token;\r
-} /* CPPundef */
-\r
-/* CPPelse -- skip forward to appropriate spot. This is actually used\r
-** to skip to and #endif after seeing an #else, AND to skip to a #else,\r
-** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false\r
-*/\r
-\r
-static int CPPelse(int matchelse, yystypepp * yylvalpp)\r
-{\r
- int atom,depth=0;\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- while (token > 0) {\r
- if (token != '#') {\r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- continue;\r
- }\r
- if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)\r
- continue;\r
- atom = yylvalpp->sc_ident;\r
- if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){\r
- depth++; cpp->ifdepth++; cpp->elsetracker++;\r
- }\r
- else if (atom == endifAtom) {\r
- if(--depth<=0){\r
- cpp->elsedepth[cpp->elsetracker]=0;\r
- --cpp->elsetracker;\r
- if (cpp->ifdepth) \r
- --cpp->ifdepth;\r
- break;\r
- } \r
- --cpp->elsetracker;\r
- --cpp->ifdepth;\r
- }\r
- else if (((int)(matchelse) != 0)&& depth==0) {\r
- if (atom == elseAtom ) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != '\n') {\r
- CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");\r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- } \r
- break;\r
- } \r
- else if (atom == elifAtom) {\r
- /* we decrement cpp->ifdepth here, because CPPif will increment\r
- * it and we really want to leave it alone */\r
- if (cpp->ifdepth){\r
- --cpp->ifdepth;\r
- --cpp->elsetracker;\r
- }\r
- return CPPif(yylvalpp);\r
- }\r
- }\r
- else if((atom==elseAtom) && (!ChkCorrectElseNesting())){\r
- CPPErrorToInfoLog("#else after a #else");\r
- cpp->CompileError=1;\r
- }\r
- };\r
- return token;\r
-}\r
-\r
-enum eval_prec {\r
- MIN_PREC,\r
- COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,\r
- MAX_PREC\r
-};\r
-\r
-static int op_logor(int a, int b) { return a || b; }\r
-static int op_logand(int a, int b) { return a && b; }\r
-static int op_or(int a, int b) { return a | b; }\r
-static int op_xor(int a, int b) { return a ^ b; }\r
-static int op_and(int a, int b) { return a & b; }\r
-static int op_eq(int a, int b) { return a == b; }\r
-static int op_ne(int a, int b) { return a != b; }\r
-static int op_ge(int a, int b) { return a >= b; }\r
-static int op_le(int a, int b) { return a <= b; }\r
-static int op_gt(int a, int b) { return a > b; }\r
-static int op_lt(int a, int b) { return a < b; }\r
-static int op_shl(int a, int b) { return a << b; }\r
-static int op_shr(int a, int b) { return a >> b; }\r
-static int op_add(int a, int b) { return a + b; }\r
-static int op_sub(int a, int b) { return a - b; }\r
-static int op_mul(int a, int b) { return a * b; }\r
-static int op_div(int a, int b) { return a / b; }\r
-static int op_mod(int a, int b) { return a % b; }\r
-static int op_pos(int a) { return a; }\r
-static int op_neg(int a) { return -a; }\r
-static int op_cmpl(int a) { return ~a; }\r
-static int op_not(int a) { return !a; }\r
-\r
-struct {\r
- int token, prec, (*op)(int, int);\r
-} binop[] = {\r
- { CPP_OR_OP, LOGOR, op_logor },\r
- { CPP_AND_OP, LOGAND, op_logand },\r
- { '|', OR, op_or },\r
- { '^', XOR, op_xor },\r
- { '&', AND, op_and },\r
- { CPP_EQ_OP, EQUAL, op_eq },\r
- { CPP_NE_OP, EQUAL, op_ne },\r
- { '>', RELATION, op_gt },\r
- { CPP_GE_OP, RELATION, op_ge },\r
- { '<', RELATION, op_lt },\r
- { CPP_LE_OP, RELATION, op_le },\r
- { CPP_LEFT_OP, SHIFT, op_shl },\r
- { CPP_RIGHT_OP, SHIFT, op_shr },\r
- { '+', ADD, op_add },\r
- { '-', ADD, op_sub },\r
- { '*', MUL, op_mul },\r
- { '/', MUL, op_div },\r
- { '%', MUL, op_mod },\r
-};\r
-\r
-struct {\r
- int token, (*op)(int);\r
-} unop[] = {\r
- { '+', op_pos },\r
- { '-', op_neg },\r
- { '~', op_cmpl },\r
- { '!', op_not },\r
-};\r
-\r
-#define ALEN(A) (sizeof(A)/sizeof(A[0]))\r
-\r
-static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)\r
-{\r
- int i, val;\r
- Symbol *s;\r
- if (token == CPP_IDENTIFIER) {\r
- if (yylvalpp->sc_ident == definedAtom) {\r
- int needclose = 0;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token == '(') {\r
- needclose = 1;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- if (token != CPP_IDENTIFIER)\r
- goto error;\r
- *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))\r
- ? !s->details.mac.undef : 0;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (needclose) {\r
- if (token != ')')\r
- goto error;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- return eval(token, prec, res, err, yylvalpp);\r
- } else {\r
- goto error;\r
- }\r
- } else if (token == CPP_INTCONSTANT) {\r
- *res = yylvalpp->sc_int;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- } else if (token == '(') {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- token = eval(token, MIN_PREC, res, err, yylvalpp);\r
- if (!*err) {\r
- if (token != ')')\r
- goto error;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- } else {\r
- for (i = ALEN(unop) - 1; i >= 0; i--) {\r
- if (unop[i].token == token)\r
- break;\r
- }\r
- if (i >= 0) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- token = eval(token, UNARY, res, err, yylvalpp);\r
- *res = unop[i].op(*res);\r
- } else {\r
- goto error;\r
- }\r
- }\r
- while (!*err) {\r
- if (token == ')' || token == '\n') break;\r
- for (i = ALEN(binop) - 1; i >= 0; i--) {\r
- if (binop[i].token == token)\r
- break;\r
- }\r
- if (i < 0 || binop[i].prec <= prec)\r
- break;\r
- val = *res;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- token = eval(token, binop[i].prec, res, err, yylvalpp);\r
- *res = binop[i].op(val, *res);\r
- }\r
- return token;\r
-error:\r
- CPPErrorToInfoLog("incorrect preprocessor directive");\r
- *err = 1;\r
- *res = 0;\r
- return token;\r
-} /* eval */
-\r
-static int CPPif(yystypepp * yylvalpp) {\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- int res = 0, err = 0;\r
- cpp->elsetracker++;\r
- if (!cpp->ifdepth++)\r
- ifloc = *cpp->tokenLoc;\r
- if(cpp->ifdepth >MAX_IF_NESTING){\r
- CPPErrorToInfoLog("max #if nesting depth exceeded");\r
- return 0;\r
- }\r
- token = eval(token, MIN_PREC, &res, &err, yylvalpp);\r
- if (token != '\n') {\r
- CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");\r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- } \r
- if (!res && !err) {\r
- token = CPPelse(1, yylvalpp);\r
- }\r
-\r
- return token;\r
-} /* CPPif */
-\r
-static int CPPifdef(int defined, yystypepp * yylvalpp)\r
-{\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- int name = yylvalpp->sc_ident;\r
- if(++cpp->ifdepth >MAX_IF_NESTING){\r
- CPPErrorToInfoLog("max #if nesting depth exceeded");\r
- return 0;\r
- }\r
- cpp->elsetracker++;\r
- if (token != CPP_IDENTIFIER) {\r
- defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");\r
- } else {\r
- Symbol *s = LookUpSymbol(macros, name);\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != '\n') {\r
- CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");\r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- if (((s && !s->details.mac.undef) ? 1 : 0) != defined)\r
- token = CPPelse(1, yylvalpp);\r
- }\r
- return token;\r
-} /* CPPifdef */
-\r
-static int CPPline(yystypepp * yylvalpp) \r
-{\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if(token=='\n'){\r
- DecLineNumber();\r
- CPPErrorToInfoLog("#line");\r
- IncLineNumber();\r
- return token;\r
- }\r
- else if (token == CPP_INTCONSTANT) {\r
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
- SetLineNumber(yylvalpp->sc_int);\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- if (token == CPP_INTCONSTANT) {\r
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
- SetStringNumber(yylvalpp->sc_int);\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if(token!='\n')\r
- CPPErrorToInfoLog("#line");\r
- }\r
- else if (token == '\n'){\r
- return token;\r
- }\r
- else{\r
- CPPErrorToInfoLog("#line");\r
- }\r
- }\r
- else{\r
- CPPErrorToInfoLog("#line");\r
- }\r
- return token;\r
-}\r
-\r
-static int CPPerror(yystypepp * yylvalpp) {\r
-\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- const char *message;\r
- \r
- while (token != '\n') {\r
- if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){\r
- StoreStr(yylvalpp->symbol_name);\r
- }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){\r
- StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));\r
- }else {\r
- StoreStr(GetStringOfAtom(atable,token));\r
- }\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- DecLineNumber();\r
- /*store this msg into the shader's information log..set the Compile Error flag!!!! */
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- cpp->CompileError=1;\r
- IncLineNumber();\r
- return '\n';\r
-}/*CPPerror */
-\r
-static int CPPpragma(yystypepp * yylvalpp)\r
-{\r
- char SrcStrName[2];\r
- char** allTokens;\r
- int tokenCount = 0;\r
- int maxTokenCount = 10;\r
- const char* SrcStr;\r
- int i;\r
-\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- if (token=='\n') {\r
- DecLineNumber();\r
- CPPErrorToInfoLog("#pragma");\r
- IncLineNumber();\r
- return token;\r
- }\r
- \r
- allTokens = (char**)malloc(sizeof(char*) * maxTokenCount); \r
-\r
- while (token != '\n') {\r
- if (tokenCount >= maxTokenCount) {\r
- maxTokenCount *= 2;\r
- allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount);\r
- }\r
- switch (token) {\r
- case CPP_IDENTIFIER:\r
- SrcStr = GetAtomString(atable, yylvalpp->sc_ident);\r
- allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);\r
- strcpy(allTokens[tokenCount++], SrcStr);\r
- break;\r
- case CPP_INTCONSTANT:\r
- SrcStr = yylvalpp->symbol_name;\r
- allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);\r
- strcpy(allTokens[tokenCount++], SrcStr);\r
- break;\r
- case CPP_FLOATCONSTANT:\r
- SrcStr = yylvalpp->symbol_name;\r
- allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);\r
- strcpy(allTokens[tokenCount++], SrcStr);\r
- break;\r
- case -1:\r
- /* EOF */
- CPPShInfoLogMsg("#pragma directive must end with a newline"); \r
- return token;\r
- default:\r
- SrcStrName[0] = token;\r
- SrcStrName[1] = '\0';\r
- allTokens[tokenCount] = (char*)malloc(2);\r
- strcpy(allTokens[tokenCount++], SrcStrName);\r
- }\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
-\r
- cpp->currentInput->ungetch(cpp->currentInput, token, yylvalpp);\r
- HandlePragma(allTokens, tokenCount);\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- for (i = 0; i < tokenCount; ++i) {\r
- free (allTokens[i]);\r
- }\r
- free (allTokens); \r
-\r
- return token;\r
-} /* CPPpragma */
-\r
-#define GL2_VERSION_NUMBER 110\r
-\r
-static int CPPversion(yystypepp * yylvalpp)\r
-{\r
-\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-\r
- if (cpp->notAVersionToken == 1)\r
- CPPShInfoLogMsg("#version must occur before any other statement in the program");\r
-\r
- if(token=='\n'){\r
- DecLineNumber();\r
- CPPErrorToInfoLog("#version");\r
- IncLineNumber();\r
- return token;\r
- }\r
- if (token != CPP_INTCONSTANT)\r
- CPPErrorToInfoLog("#version");\r
- \r
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
- /*SetVersionNumber(yylvalpp->sc_int); */
- \r
- if (yylvalpp->sc_int != GL2_VERSION_NUMBER)\r
- CPPShInfoLogMsg("Version number not supported by GL2");\r
-\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- \r
- if (token == '\n'){\r
- return token;\r
- }\r
- else{\r
- CPPErrorToInfoLog("#version");\r
- }\r
- return token;\r
-} /* CPPversion */
-\r
-static int CPPextension(yystypepp * yylvalpp)\r
-{\r
-\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- char extensionName[80];\r
-\r
- if(token=='\n'){\r
- DecLineNumber();\r
- CPPShInfoLogMsg("extension name not specified");\r
- IncLineNumber();\r
- return token;\r
- }\r
-\r
- if (token != CPP_IDENTIFIER)\r
- CPPErrorToInfoLog("#extension");\r
- \r
- strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));\r
- \r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != ':') {\r
- CPPShInfoLogMsg("':' missing after extension name");\r
- return token;\r
- }\r
- \r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != CPP_IDENTIFIER) {\r
- CPPShInfoLogMsg("behavior for extension not specified");\r
- return token;\r
- }\r
-\r
- updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident));\r
-\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token == '\n'){\r
- return token;\r
- }\r
- else{\r
- CPPErrorToInfoLog("#extension");\r
- }\r
- return token;\r
-} /* CPPextension */
-\r
-int readCPPline(yystypepp * yylvalpp)\r
-{\r
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- const char *message;\r
- int isVersion = 0;\r
-\r
- if (token == CPP_IDENTIFIER) {\r
- if (yylvalpp->sc_ident == defineAtom) {\r
- token = CPPdefine(yylvalpp);\r
- } else if (yylvalpp->sc_ident == elseAtom) {\r
- if(ChkCorrectElseNesting()){\r
- if (!cpp->ifdepth ){\r
- CPPErrorToInfoLog("#else mismatch");\r
- cpp->CompileError=1;\r
- }\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != '\n') {\r
- CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");\r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- token = CPPelse(0, yylvalpp);\r
- }else{\r
- CPPErrorToInfoLog("#else after a #else");\r
- cpp->ifdepth=0;\r
- cpp->notAVersionToken = 1;\r
- return 0;\r
- }\r
- } else if (yylvalpp->sc_ident == elifAtom) {\r
- if (!cpp->ifdepth){\r
- CPPErrorToInfoLog("#elif mismatch");\r
- cpp->CompileError=1;\r
- } \r
- /* this token is really a dont care, but we still need to eat the tokens */
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); \r
- while (token != '\n')\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- token = CPPelse(0, yylvalpp);\r
- } else if (yylvalpp->sc_ident == endifAtom) {\r
- cpp->elsedepth[cpp->elsetracker]=0;\r
- --cpp->elsetracker;\r
- if (!cpp->ifdepth){\r
- CPPErrorToInfoLog("#endif mismatch");\r
- cpp->CompileError=1;\r
- }\r
- else\r
- --cpp->ifdepth;\r
- } else if (yylvalpp->sc_ident == ifAtom) {\r
- token = CPPif(yylvalpp);\r
- } else if (yylvalpp->sc_ident == ifdefAtom) {\r
- token = CPPifdef(1, yylvalpp);\r
- } else if (yylvalpp->sc_ident == ifndefAtom) {\r
- token = CPPifdef(0, yylvalpp);\r
- } else if (yylvalpp->sc_ident == lineAtom) {\r
- token = CPPline(yylvalpp);\r
- } else if (yylvalpp->sc_ident == pragmaAtom) {\r
- token = CPPpragma(yylvalpp);\r
- } else if (yylvalpp->sc_ident == undefAtom) {\r
- token = CPPundef(yylvalpp);\r
- } else if (yylvalpp->sc_ident == errorAtom) {\r
- token = CPPerror(yylvalpp);\r
- } else if (yylvalpp->sc_ident == versionAtom) {\r
- token = CPPversion(yylvalpp);\r
- isVersion = 1;\r
- } else if (yylvalpp->sc_ident == extensionAtom) {\r
- token = CPPextension(yylvalpp);\r
- } else {\r
- StoreStr("Invalid Directive");\r
- StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));\r
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- }\r
- }\r
- while (token != '\n' && token != 0 && token != EOF) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- \r
- cpp->notAVersionToken = !isVersion;\r
-\r
- return token;\r
-} /* readCPPline */
-\r
-void FreeMacro(MacroSymbol *s) {\r
- DeleteTokenStream(s->body);\r
-}\r
-\r
-static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; }\r
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { }\r
-\r
-static void PushEofSrc() {\r
- InputSrc *in = malloc(sizeof(InputSrc));\r
- memset(in, 0, sizeof(InputSrc));\r
- in->scan = eof_scan;\r
- in->getch = eof_scan;\r
- in->ungetch = noop;\r
- in->prev = cpp->currentInput;\r
- cpp->currentInput = in;\r
-}\r
-\r
-static void PopEofSrc() {\r
- if (cpp->currentInput->scan == eof_scan) {\r
- InputSrc *in = cpp->currentInput;\r
- cpp->currentInput = in->prev;\r
- free(in);\r
- }\r
-}\r
-\r
-static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) {\r
- int token;\r
- TokenStream *n;\r
- RewindTokenStream(a);\r
- do {\r
- token = ReadToken(a, yylvalpp);\r
- if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))\r
- break;\r
- } while (token > 0);\r
- if (token <= 0) return a;\r
- n = NewTokenStream("macro arg");\r
- PushEofSrc();\r
- ReadFromTokenStream(a, 0, 0);\r
- while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {\r
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp))\r
- continue;\r
- RecordToken(n, token, yylvalpp);\r
- }\r
- PopEofSrc();\r
- DeleteTokenStream(a);\r
- return n;\r
-} /* PrescanMacroArg */
-\r
-typedef struct MacroInputSrc {\r
- InputSrc base;\r
- MacroSymbol *mac;\r
- TokenStream **args;\r
-} MacroInputSrc;\r
-\r
-/* macro_scan ---\r
-** return the next token for a macro expanion, handling macro args \r
-*/\r
-static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) {\r
- int i;\r
- int token = ReadToken(in->mac->body, yylvalpp);\r
- if (token == CPP_IDENTIFIER) {\r
- for (i = in->mac->argc-1; i>=0; i--)\r
- if (in->mac->args[i] == yylvalpp->sc_ident) break;\r
- if (i >= 0) {\r
- ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);\r
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- }\r
- }\r
- if (token > 0) return token;\r
- in->mac->busy = 0;\r
- cpp->currentInput = in->base.prev;\r
- if (in->args) {\r
- for (i=in->mac->argc-1; i>=0; i--)\r
- DeleteTokenStream(in->args[i]);\r
- free(in->args);\r
- }\r
- free(in);\r
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-} /* macro_scan */
-\r
-/* MacroExpand\r
-** check an identifier (atom) to see if it a macro that should be expanded.\r
-** If it is, push an InputSrc that will produce the appropriate expansion\r
-** and return TRUE. If not, return FALSE.\r
-*/\r
-\r
-int MacroExpand(int atom, yystypepp * yylvalpp)\r
-{\r
- Symbol *sym = LookUpSymbol(macros, atom);\r
- MacroInputSrc *in;\r
- int i,j, token, depth=0;\r
- const char *message;\r
- if (atom == __LINE__Atom) {\r
- yylvalpp->sc_int = GetLineNumber();\r
- sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);\r
- UngetToken(CPP_INTCONSTANT, yylvalpp);\r
- return 1;\r
- }\r
- if (atom == __FILE__Atom) {\r
- yylvalpp->sc_int = GetStringNumber();\r
- sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);\r
- UngetToken(CPP_INTCONSTANT, yylvalpp);\r
- return 1;\r
- }\r
- if (atom == __VERSION__Atom) {\r
- strcpy(yylvalpp->symbol_name,"100");\r
- yylvalpp->sc_int = atoi(yylvalpp->symbol_name);\r
- UngetToken(CPP_INTCONSTANT, yylvalpp);\r
- return 1;\r
- }\r
- if (!sym || sym->details.mac.undef) return 0;\r
- if (sym->details.mac.busy) return 0; /* no recursive expansions */
- in = malloc(sizeof(*in));\r
- memset(in, 0, sizeof(*in));\r
- in->base.scan = (void *)macro_scan;\r
- in->base.line = cpp->currentInput->line;\r
- in->base.name = cpp->currentInput->name;\r
- in->mac = &sym->details.mac;\r
- if (sym->details.mac.args) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token != '(') {\r
- UngetToken(token, yylvalpp);\r
- yylvalpp->sc_ident = atom;\r
- return 0;\r
- }\r
- in->args = malloc(in->mac->argc * sizeof(TokenStream *));\r
- for (i=0; i<in->mac->argc; i++)\r
- in->args[i] = NewTokenStream("macro arg");\r
- i=0;j=0;\r
- do{\r
- depth = 0;\r
- while(1) {\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token <= 0) {\r
- StoreStr("EOF in Macro ");\r
- StoreStr(GetStringOfAtom(atable,atom));\r
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- return 1;\r
- }\r
- if((in->mac->argc==0) && (token!=')')) break;\r
- if (depth == 0 && (token == ',' || token == ')')) break;\r
- if (token == '(') depth++;\r
- if (token == ')') depth--;\r
- RecordToken(in->args[i], token, yylvalpp);\r
- j=1;\r
- }\r
- if (token == ')') {\r
- if((in->mac->argc==1) &&j==0)\r
- break;\r
- i++;\r
- break;\r
- }\r
- i++;\r
- }while(i < in->mac->argc);\r
-\r
- if (i < in->mac->argc) {\r
- StoreStr("Too few args in Macro ");\r
- StoreStr(GetStringOfAtom(atable,atom));\r
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- } else if (token != ')') {\r
- depth=0;\r
- while (token >= 0 && (depth > 0 || token != ')')) {\r
- if (token == ')') depth--;\r
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
- if (token == '(') depth++;\r
- }\r
- \r
- if (token <= 0) {\r
- StoreStr("EOF in Macro ");\r
- StoreStr(GetStringOfAtom(atable,atom));\r
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- return 1;\r
- }\r
- StoreStr("Too many args in Macro ");\r
- StoreStr(GetStringOfAtom(atable,atom));\r
- message=GetStrfromTStr();\r
- CPPShInfoLogMsg(message);\r
- ResetTString();\r
- }\r
- for (i=0; i<in->mac->argc; i++) {\r
- in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);\r
- }\r
- }\r
-#if 0\r
- printf(" <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),\r
- loc.line, GetAtomString(atable, atom));\r
- for (i=0; i<in->mac->argc; i++) {\r
- printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));\r
- DumpTokenStream(stdout, in->args[i]);\r
- printf("'\n");\r
- }\r
-#endif\r
- /*retain the input source*/\r
- in->base.prev = cpp->currentInput;\r
- sym->details.mac.busy = 1;\r
- RewindTokenStream(sym->details.mac.body);\r
- cpp->currentInput = &in->base;\r
- return 1;\r
-} /* MacroExpand */
-\r
-int ChkCorrectElseNesting(void)\r
-{\r
- if(cpp->elsedepth[cpp->elsetracker]==0){\r
- cpp->elsedepth[cpp->elsetracker]=1;\r
- return 1; \r
- }\r
- return 0;\r
-}\r
-\r
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* cpp.h */
-/* */
-\r
-#if !defined(__CPP_H)\r
-#define __CPP_H 1\r
-\r
-#include "parser.h"\r
-#include "tokens.h"\r
-\r
-int InitCPP(void);\r
-int FinalCPP(void);\r
-int readCPPline(yystypepp * yylvalpp);\r
-int MacroExpand(int atom, yystypepp * yylvalpp);\r
-int ChkCorrectElseNesting(void);\r
-\r
-typedef struct MacroSymbol {\r
- int argc;\r
- int *args;\r
- TokenStream *body;\r
- unsigned busy:1;\r
- unsigned undef:1;\r
-} MacroSymbol;\r
-\r
-void FreeMacro(MacroSymbol *);\r
-int PredefineMacro(char *);\r
-\r
-void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
-void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
-void CPPWarningToInfoLog(const char *msg); /* Prints warning messages into info log */
-void HandlePragma(const char**, int numTokens); /* #pragma directive container. */
-void ResetTString(void); /* #error Message as TString. */
-void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log . */
-void StoreStr(char*); /* Store the TString in Parse Context. */
-void SetLineNumber(int); /* Set line number. */
-void SetStringNumber(int); /* Set string number. */
-int GetLineNumber(void); /* Get the current String Number. */
-int GetStringNumber(void); /* Get the current String Number. */
-const char* GetStrfromTStr(void); /* Convert TString to String. */
-void updateExtensionBehavior(const char* extName, const char* behavior);\r
-int FreeCPP(void);\r
-\r
-#endif /* !(defined(__CPP_H) */
+++ /dev/null
-/* converts c++ to c comments */
-/* usage: ./cpp_comment_fix source */
-
-#include <stdio.h>
-
-int main (int argc, char *argv[])
-{
- FILE *f;
- int c;
- char *buf = NULL;
- int size = 0, i = 0;
-
- f = fopen (argv[1], "r");
- while ((c = fgetc (f)) != EOF)
- {
- buf = (void *) realloc (buf, size + 1);
- buf[size] = c;
- size++;
- }
- fclose (f);
-
- f = fopen (argv[1], "w");
-
- while (i < size)
- {
- if (buf[i] == '/')
- {
- if (buf[i+1] == '/')
- {
- fprintf (f, "/*");
- i+=2;
- while (buf[i] != '\n' && buf[i] != '\r' && i < size)
- fprintf (f, "%c", buf[i++]);
- fprintf (f, " */\n");
- if (i < size && buf[i] == '\n')
- i++;
- else if (i < size && buf[i] == '\r')
- i+=2;
- }
- else
- {
- fprintf (f, "/");
- i++;
-
- if (buf[i] == '*')
- {
- fprintf (f, "*");
- i++;
-
- for (;;)
- {
- if (buf[i] == '*' && buf[i+1] == '/')
- {
- fprintf (f, "*/");
- i+=2;
- break;
- }
- else
- {
- fprintf (f, "%c", buf[i]);
- i++;
- }
- }
- }
- }
- }
- else
- {
- fprintf (f, "%c", buf[i]);
- i++;
- }
- }
- fclose (f);
- return 0;
-}
-
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* cppstruct.c */
-/* */
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include "slglobals.h"\r
-\r
-CPPStruct *cpp = NULL;\r
-static int refCount = 0;\r
-\r
-int InitPreprocessor(void);\r
-int ResetPreprocessor(void);\r
-int FreeCPPStruct(void);\r
-int FinalizePreprocessor(void);\r
-\r
-/*\r
- * InitCPPStruct() - Initilaize the CPP structure.\r
- *\r
- */\r
-\r
-int InitCPPStruct(void)\r
-{\r
- int len;\r
- char *p;\r
-\r
- cpp = (CPPStruct *) malloc(sizeof(CPPStruct));\r
- if (cpp == NULL)\r
- return 0;\r
-\r
- refCount++;\r
-\r
- /* Initialize public members: */
- cpp->pLastSourceLoc = &cpp->lastSourceLoc;\r
- \r
- p = (char *) &cpp->options;\r
- len = sizeof(cpp->options);\r
- while (--len >= 0)\r
- p[len] = 0;\r
- \r
- ResetPreprocessor();\r
- return 1;\r
-} /* InitCPPStruct */
-\r
-int ResetPreprocessor(void)\r
-{\r
- /* Initialize private members: */
-\r
- cpp->lastSourceLoc.file = 0;\r
- cpp->lastSourceLoc.line = 0;\r
- cpp->pC=0;\r
- cpp->CompileError=0; \r
- cpp->ifdepth=0;\r
- for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)\r
- cpp->elsedepth[cpp->elsetracker]=0; \r
- cpp->elsetracker=0;\r
- cpp->tokensBeforeEOF = 0;\r
- return 1;\r
-}\r
-\r
-/*Intializing the Preprocessor. */
-\r
-int InitPreprocessor(void)\r
-{\r
- # define CPP_STUFF true\r
- # ifdef CPP_STUFF\r
- FreeCPPStruct();\r
- InitCPPStruct();\r
- cpp->options.Quiet = 1;\r
- cpp->options.profileString = "generic";\r
- if (!InitAtomTable(atable, 0))\r
- return 1;\r
- if (!InitScanner(cpp))\r
- return 1;\r
- # endif\r
- return 0; \r
-}\r
-\r
-/*FreeCPPStruct() - Free the CPP structure. */
-\r
-int FreeCPPStruct(void)\r
-{\r
- if (refCount)\r
- {\r
- free(cpp);\r
- refCount--;\r
- }\r
- \r
- return 1;\r
-}\r
-\r
-/*Finalizing the Preprocessor. */
-\r
-int FinalizePreprocessor(void)\r
-{\r
- # define CPP_STUFF true\r
- # ifdef CPP_STUFF\r
- FreeAtomTable(atable);\r
- FreeCPPStruct();\r
- FreeScanner();\r
- # endif\r
- return 0; \r
-}\r
-\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*//////////////////////////////////// End of cppstruct.c ////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-#include <stddef.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#ifdef __STDC99__\r
-#include <stdint.h>\r
-#elif defined (_WIN64)\r
-typedef unsigned __int64 uintptr_t;\r
-#else \r
-typedef unsigned int uintptr_t;\r
-#endif\r
-\r
-#include "memory.h"\r
-\r
-/* default alignment and chunksize, if called with 0 arguments */
-#define CHUNKSIZE (64*1024)\r
-#define ALIGN 8\r
-\r
-/* we need to call the `real' malloc and free, not our replacements */
-#undef malloc\r
-#undef free\r
-\r
-struct chunk {\r
- struct chunk *next;\r
-};\r
-\r
-struct cleanup {\r
- struct cleanup *next;\r
- void (*fn)(void *);\r
- void *arg;\r
-};\r
-\r
-struct MemoryPool_rec {\r
- struct chunk *next;\r
- uintptr_t free, end;\r
- size_t chunksize;\r
- uintptr_t alignmask;\r
- struct cleanup *cleanup;\r
-};\r
-\r
-MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)\r
-{\r
- MemoryPool *pool;\r
-\r
- if (align == 0) align = ALIGN;\r
- if (chunksize == 0) chunksize = CHUNKSIZE;\r
- if (align & (align-1)) return 0;\r
- if (chunksize < sizeof(MemoryPool)) return 0;\r
- if (chunksize & (align-1)) return 0;\r
- if (!(pool = malloc(chunksize))) return 0;\r
- pool->next = 0;\r
- pool->chunksize = chunksize;\r
- pool->alignmask = (uintptr_t)(align)-1; \r
- pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;\r
- pool->end = (uintptr_t)pool + chunksize;\r
- pool->cleanup = 0;\r
- return pool;\r
-}\r
-\r
-void mem_FreePool(MemoryPool *pool)\r
-{\r
- struct cleanup *cleanup;\r
- struct chunk *p, *next;\r
-\r
- for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {\r
- cleanup->fn(cleanup->arg);\r
- }\r
- for (p = (struct chunk *)pool; p; p = next) {\r
- next = p->next;\r
- free(p);\r
- }\r
-}\r
-\r
-void *mem_Alloc(MemoryPool *pool, size_t size)\r
-{\r
- struct chunk *ch;\r
- void *rv = (void *)pool->free;\r
- size = (size + pool->alignmask) & ~pool->alignmask;\r
- if (size <= 0) size = pool->alignmask;\r
- pool->free += size;\r
- if (pool->free > pool->end || pool->free < (uintptr_t)rv) {\r
- size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)\r
- & ~pool->alignmask;\r
- pool->free = (uintptr_t)rv;\r
- if (minreq >= pool->chunksize) {\r
- /* request size is too big for the chunksize, so allocate it as */
- /* a single chunk of the right size */
- ch = malloc(minreq);\r
- if (!ch) return 0;\r
- } else {\r
- ch = malloc(pool->chunksize);\r
- if (!ch) return 0;\r
- pool->free = (uintptr_t)ch + minreq;\r
- pool->end = (uintptr_t)ch + pool->chunksize;\r
- }\r
- ch->next = pool->next;\r
- pool->next = ch;\r
- rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);\r
- }\r
- return rv;\r
-}\r
-\r
-int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {\r
- struct cleanup *cleanup;\r
-\r
- pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);\r
- cleanup = mem_Alloc(pool, sizeof(struct cleanup));\r
- if (!cleanup) return -1;\r
- cleanup->next = pool->cleanup;\r
- cleanup->fn = fn;\r
- cleanup->arg = arg;\r
- pool->cleanup = cleanup;\r
- return 0;\r
-}\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-#ifndef __MEMORY_H\r
-#define __MEMORY_H\r
-\r
-typedef struct MemoryPool_rec MemoryPool;\r
-\r
-extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);\r
-extern void mem_FreePool(MemoryPool *);\r
-extern void *mem_Alloc(MemoryPool *p, size_t size);\r
-extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);\r
-extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);\r
-\r
-#endif /* __MEMORY_H */\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-#ifndef BISON_PARSER_H\r
-# define BISON_PARSER_H\r
-\r
-#ifndef yystypepp\r
-typedef struct {\r
- int sc_int;\r
- float sc_fval;\r
- int sc_ident;\r
- char symbol_name[MAX_SYMBOL_NAME_LEN+1];\r
-} yystypepp;\r
-\r
-# define YYSTYPE_IS_TRIVIAL 1\r
-#endif\r
-# define CPP_AND_OP 257\r
-# define CPP_SUB_ASSIGN 259\r
-# define CPP_MOD_ASSIGN 260\r
-# define CPP_ADD_ASSIGN 261\r
-# define CPP_DIV_ASSIGN 262\r
-# define CPP_MUL_ASSIGN 263\r
-# define CPP_EQ_OP 264\r
-# define CPP_XOR_OP 265 \r
-# define ERROR_SY 266\r
-# define CPP_FLOATCONSTANT 267\r
-# define CPP_GE_OP 268\r
-# define CPP_RIGHT_OP 269\r
-# define CPP_IDENTIFIER 270\r
-# define CPP_INTCONSTANT 271\r
-# define CPP_LE_OP 272\r
-# define CPP_LEFT_OP 273\r
-# define CPP_DEC_OP 274\r
-# define CPP_NE_OP 275\r
-# define CPP_OR_OP 276\r
-# define CPP_INC_OP 277\r
-# define CPP_STRCONSTANT 278\r
-# define CPP_TYPEIDENTIFIER 279\r
-\r
-# define FIRST_USER_TOKEN_SY 289\r
-\r
-# define CPP_RIGHT_ASSIGN 280\r
-# define CPP_LEFT_ASSIGN 281\r
-# define CPP_AND_ASSIGN 282\r
-# define CPP_OR_ASSIGN 283\r
-# define CPP_XOR_ASSIGN 284\r
-# define CPP_LEFT_BRACKET 285\r
-# define CPP_RIGHT_BRACKET 286\r
-# define CPP_LEFT_BRACE 287\r
-# define CPP_RIGHT_BRACE 288\r
-\r
-#endif /* not BISON_PARSER_H */\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-# include "slglobals.h"\r
-extern CPPStruct *cpp;\r
-int InitCPPStruct(void);\r
-int InitScanner(CPPStruct *cpp);\r
-int InitAtomTable(AtomTable *atable, int htsize);\r
-int ScanFromString(char *s);\r
-char* GetStringOfAtom(AtomTable *atable, int atom);\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* scanner.c */
-/* */
-\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#if 0\r
- #include <ieeefp.h>\r
- #else\r
- #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \\r
- ((*(long *)&(x) & 0x007fffffL)==0000000000L))\r
-#endif\r
-\r
-#include "slglobals.h"\r
-\r
-\r
-typedef struct StringInputSrc {\r
- InputSrc base;\r
- char *p;\r
-} StringInputSrc;\r
-\r
-static int eof_scan(InputSrc *is, yystypepp * yylvalpp)\r
-{\r
- return EOF;\r
-} /* eof_scan */
-\r
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}\r
-\r
-static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };\r
-\r
-static int byte_scan(InputSrc *, yystypepp * yylvalpp);\r
-\r
-#define EOL_SY '\n'\r
-\r
-#if defined(_WIN32)\r
- #define DBG_BREAKPOINT() __asm int 3\r
- #elif defined(_M_AMD64)\r
- #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");\r
- #else\r
- #define DBG_BREAKPOINT()\r
- #endif\r
-\r
- #if defined(_WIN32) && !defined(_M_AMD64)\r
- __int64 RDTSC ( void ) {\r
-\r
- __int64 v;\r
- \r
- __asm __emit 0x0f\r
- __asm __emit 0x31\r
- __asm mov dword ptr v, eax\r
- __asm mov dword ptr v+4, edx\r
- \r
- return v;\r
- }\r
-#endif\r
-\r
-\r
-int InitScanner(CPPStruct *cpp)\r
-{\r
- /* Add various atoms needed by the CPP line scanner: */
- if (!InitCPP())\r
- return 0;\r
-\r
- cpp->mostRecentToken = 0;\r
- cpp->tokenLoc = &cpp->ltokenLoc;\r
-\r
- cpp->ltokenLoc.file = 0;\r
- cpp->ltokenLoc.line = 0;\r
-\r
- cpp->currentInput = &eof_inputsrc;\r
- cpp->previous_token = '\n';\r
- cpp->notAVersionToken = 0;\r
-\r
- return 1;\r
-} /* InitScanner */
-\r
-int FreeScanner(void)\r
-{\r
- return (FreeCPP());\r
-}\r
-\r
-/*\r
- * str_getch()\r
- * takes care of reading from multiple strings.\r
- * returns the next-char from the input stream.\r
- * returns EOF when the complete shader is parsed.\r
- */\r
-static int str_getch(StringInputSrc *in)\r
-{\r
- for(;;){\r
- if (*in->p){\r
- if (*in->p == '\n') {\r
- in->base.line++;\r
- IncLineNumber();\r
- }\r
- return *in->p++;\r
- }\r
- if(++(cpp->PaWhichStr) < cpp->PaArgc){\r
- free(in);\r
- SetStringNumber(cpp->PaWhichStr);\r
- SetLineNumber(1);\r
- ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);\r
- in=(StringInputSrc*)cpp->currentInput;\r
- continue; \r
- }\r
- else{\r
- cpp->currentInput = in->base.prev;\r
- cpp->PaWhichStr=0;\r
- free(in);\r
- return EOF;\r
- } \r
- }\r
-} /* str_getch */
-\r
-static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {\r
- if (in->p[-1] == ch)in->p--;\r
- else {\r
- *(in->p)='\0'; /*this would take care of shifting to the previous string. */
- cpp->PaWhichStr--;\r
- } \r
- if (ch == '\n') {\r
- in->base.line--;\r
- DecLineNumber();\r
- }\r
-} /* str_ungetch */
-\r
-int ScanFromString(char *s)\r
-{\r
- \r
- StringInputSrc *in = malloc(sizeof(StringInputSrc));\r
- memset(in, 0, sizeof(StringInputSrc));\r
- in->p = s;\r
- in->base.line = 1;\r
- in->base.scan = byte_scan;\r
- in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;\r
- in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;\r
- in->base.prev = cpp->currentInput;\r
- cpp->currentInput = &in->base;\r
-\r
- return 1;\r
-} /* ScanFromString; */
-\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////// Floating point constants: ///////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*\r
- * lBuildFloatValue() - Quick and dirty conversion to floating point. Since all\r
- * we need is single precision this should be quite precise.\r
- */\r
-\r
-static float lBuildFloatValue(const char *str, int len, int exp)\r
-{\r
- double val, expval, ten;\r
- int ii, llen, absexp;\r
- float rv;\r
-\r
- val = 0.0;\r
- llen = len;\r
- for (ii = 0; ii < len; ii++)\r
- val = val*10.0 + (str[ii] - '0');\r
- if (exp != 0) {\r
- absexp = exp > 0 ? exp : -exp;\r
- expval = 1.0f;\r
- ten = 10.0;\r
- while (absexp) {\r
- if (absexp & 1)\r
- expval *= ten;\r
- ten *= ten;\r
- absexp >>= 1;\r
- }\r
- if (exp >= 0) {\r
- val *= expval;\r
- } else {\r
- val /= expval;\r
- }\r
- }\r
- rv = (float)val;\r
- if (isinff(rv)) {\r
- CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");\r
- }\r
- return rv;\r
-} /* lBuildFloatValue */
-\r
-\r
-/*\r
- * lFloatConst() - Scan a floating point constant. Assumes that the scanner\r
- * has seen at least one digit, followed by either a decimal '.' or the\r
- * letter 'e'.\r
- */\r
-\r
-static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)\r
-{\r
- int HasDecimal, declen, exp, ExpSign;\r
- int str_len;\r
- float lval;\r
- \r
- HasDecimal = 0;\r
- declen = 0;\r
- exp = 0;\r
- \r
- str_len=len;\r
- if (ch == '.') {\r
- str[len++]=ch;\r
- HasDecimal = 1;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- while (ch >= '0' && ch <= '9') {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- declen++;\r
- if (len > 0 || ch != '0') {\r
- str[len] = ch;\r
- len++;str_len++;\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } else {\r
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");\r
- len = 1,str_len=1;\r
- }\r
- }\r
- }\r
-\r
- /* Exponent: */
-\r
- if (ch == 'e' || ch == 'E') {\r
- ExpSign = 1;\r
- str[len++]=ch;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '+') {\r
- str[len++]=ch; \r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } else if (ch == '-') {\r
- ExpSign = -1;\r
- str[len++]=ch;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- if (ch >= '0' && ch <= '9') {\r
- while (ch >= '0' && ch <= '9') {\r
- exp = exp*10 + ch - '0';\r
- str[len++]=ch;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- } else {\r
- CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");\r
- }\r
- exp *= ExpSign;\r
- }\r
- \r
- if (len == 0) {\r
- lval = 0.0f;\r
- strcpy(str,"0.0");\r
- } else {\r
- str[len]='\0'; \r
- lval = lBuildFloatValue(str, str_len, exp - declen);\r
- }\r
- /* Suffix: */
- \r
- yylvalpp->sc_fval = lval;\r
- strcpy(yylvalpp->symbol_name,str);\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); \r
- return CPP_FLOATCONSTANT;\r
-} /* lFloatConst */
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*/////////////////////////////////////// Normal Scanner ////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
- \r
-static int byte_scan(InputSrc *in, yystypepp * yylvalpp)\r
-{\r
- char symbol_name[MAX_SYMBOL_NAME_LEN + 1];\r
- char string_val[MAX_STRING_LEN + 1];\r
- int AlreadyComplained;\r
- int len, ch, ii, ival = 0;\r
-\r
- for (;;) {\r
- yylvalpp->sc_int = 0;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- \r
- while (ch == ' ' || ch == '\t' || ch == '\r') {\r
- yylvalpp->sc_int = 1;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- \r
- cpp->ltokenLoc.file = cpp->currentInput->name;\r
- cpp->ltokenLoc.line = cpp->currentInput->line;\r
- len = 0;\r
- switch (ch) {\r
- default:\r
- return ch; /* Single character token */
- case EOF:\r
- return -1;\r
- case 'A': case 'B': case 'C': case 'D': case 'E':\r
- case 'F': case 'G': case 'H': case 'I': case 'J':\r
- case 'K': case 'L': case 'M': case 'N': case 'O':\r
- case 'P': case 'Q': case 'R': case 'S': case 'T':\r
- case 'U': case 'V': case 'W': case 'X': case 'Y':\r
- case 'Z': case '_':\r
- case 'a': case 'b': case 'c': case 'd': case 'e':\r
- case 'f': case 'g': case 'h': case 'i': case 'j':\r
- case 'k': case 'l': case 'm': case 'n': case 'o':\r
- case 'p': case 'q': case 'r': case 's': case 't':\r
- case 'u': case 'v': case 'w': case 'x': case 'y':\r
- case 'z': \r
- do {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- symbol_name[len] = ch;\r
- len++;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } else {\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- } while ((ch >= 'a' && ch <= 'z') ||\r
- (ch >= 'A' && ch <= 'Z') ||\r
- (ch >= '0' && ch <= '9') ||\r
- ch == '_');\r
- if (len >= MAX_SYMBOL_NAME_LEN)\r
- len = MAX_SYMBOL_NAME_LEN - 1;\r
- symbol_name[len] = '\0';\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);\r
- return CPP_IDENTIFIER;\r
- break;\r
- case '0':\r
- yylvalpp->symbol_name[len++] = ch;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == 'x' || ch == 'X') {\r
- yylvalpp->symbol_name[len++] = ch;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if ((ch >= '0' && ch <= '9') ||\r
- (ch >= 'A' && ch <= 'F') ||\r
- (ch >= 'a' && ch <= 'f'))\r
- {\r
- AlreadyComplained = 0;\r
- ival = 0;\r
- do {\r
- yylvalpp->symbol_name[len++] = ch;\r
- if (ival <= 0x0fffffff) {\r
- if (ch >= '0' && ch <= '9') {\r
- ii = ch - '0';\r
- } else if (ch >= 'A' && ch <= 'F') {\r
- ii = ch - 'A' + 10;\r
- } else {\r
- ii = ch - 'a' + 10;\r
- }\r
- ival = (ival << 4) | ii;\r
- } else {\r
- if (!AlreadyComplained)\r
- CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");\r
- AlreadyComplained = 1;\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } while ((ch >= '0' && ch <= '9') ||\r
- (ch >= 'A' && ch <= 'F') ||\r
- (ch >= 'a' && ch <= 'f'));\r
- } else {\r
- CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");\r
- }\r
- yylvalpp->symbol_name[len] = '\0';\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- yylvalpp->sc_int = ival;\r
- return CPP_INTCONSTANT;\r
- } else if (ch >= '0' && ch <= '7') { /* octal integer constants */
- AlreadyComplained = 0;\r
- ival = 0;\r
- do {\r
- yylvalpp->symbol_name[len++] = ch;\r
- if (ival <= 0x1fffffff) {\r
- ii = ch - '0';\r
- ival = (ival << 3) | ii;\r
- } else {\r
- if (!AlreadyComplained)\r
- CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");\r
- AlreadyComplained = 1;\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } while (ch >= '0' && ch <= '7');\r
- if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') \r
- return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);\r
- yylvalpp->symbol_name[len] = '\0';\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- yylvalpp->sc_int = ival;\r
- return CPP_INTCONSTANT;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- ch = '0';\r
- }\r
- /* Fall through... */
- case '1': case '2': case '3': case '4':\r
- case '5': case '6': case '7': case '8': case '9':\r
- do {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- if (len > 0 || ch != '0') {\r
- yylvalpp->symbol_name[len] = ch;\r
- len++;\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- } while (ch >= '0' && ch <= '9');\r
- if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {\r
- return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);\r
- } else {\r
- yylvalpp->symbol_name[len] = '\0';\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- ival = 0;\r
- AlreadyComplained = 0;\r
- for (ii = 0; ii < len; ii++) {\r
- ch = yylvalpp->symbol_name[ii] - '0';\r
- if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) {\r
- if (!AlreadyComplained)\r
- CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");\r
- AlreadyComplained = 1;\r
- }\r
- ival = ival*10 + ch;\r
- }\r
- yylvalpp->sc_int = ival;\r
- if(ival==0)\r
- strcpy(yylvalpp->symbol_name,"0");\r
- return CPP_INTCONSTANT;\r
- }\r
- break;\r
- case '-':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '-') {\r
- return CPP_DEC_OP;\r
- } else if (ch == '=') {\r
- return CPP_SUB_ASSIGN;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '-';\r
- }\r
- case '+':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '+') {\r
- return CPP_INC_OP;\r
- } else if (ch == '=') {\r
- return CPP_ADD_ASSIGN;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '+';\r
- }\r
- case '*':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '=') {\r
- return CPP_MUL_ASSIGN;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '*';\r
- }\r
- case '%':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '=') {\r
- return CPP_MOD_ASSIGN;\r
- } else if (ch == '>'){\r
- return CPP_RIGHT_BRACE;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '%';\r
- }\r
- case ':':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '>') {\r
- return CPP_RIGHT_BRACKET;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return ':';\r
- }\r
- case '^':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '^') {\r
- return CPP_XOR_OP;\r
- } else {\r
- if (ch == '=')\r
- return CPP_XOR_ASSIGN;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '^';\r
- }\r
- }\r
- \r
- case '=':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '=') {\r
- return CPP_EQ_OP;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '=';\r
- }\r
- case '!':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '=') {\r
- return CPP_NE_OP;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '!';\r
- }\r
- case '|':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '|') {\r
- return CPP_OR_OP;\r
- } else {\r
- if (ch == '=')\r
- return CPP_OR_ASSIGN;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '|';\r
- }\r
- }\r
- case '&':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '&') {\r
- return CPP_AND_OP;\r
- } else {\r
- if (ch == '=')\r
- return CPP_AND_ASSIGN;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '&';\r
- }\r
- }\r
- case '<':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '<') {\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if(ch == '=')\r
- return CPP_LEFT_ASSIGN;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return CPP_LEFT_OP;\r
- }\r
- } else {\r
- if (ch == '=') {\r
- return CPP_LE_OP;\r
- } else {\r
- if (ch == '%')\r
- return CPP_LEFT_BRACE;\r
- else if (ch == ':')\r
- return CPP_LEFT_BRACKET;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '<';\r
- }\r
- }\r
- }\r
- case '>':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '>') {\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if(ch == '=')\r
- return CPP_RIGHT_ASSIGN;\r
- else{\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return CPP_RIGHT_OP;\r
- }\r
- } else {\r
- if (ch == '=') {\r
- return CPP_GE_OP;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '>';\r
- }\r
- }\r
- case '.':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch >= '0' && ch <= '9') {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);\r
- } else {\r
- if (ch == '.') {\r
- return -1; /* Special EOF hack */
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '.';\r
- }\r
- }\r
- case '/':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '/') {\r
- do {\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- } while (ch != '\n' && ch != EOF);\r
- if (ch == EOF)\r
- return -1;\r
- return '\n';\r
- } else if (ch == '*') {\r
- int nlcount = 0;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- do {\r
- while (ch != '*') {\r
- if (ch == '\n') nlcount++;\r
- if (ch == EOF) {\r
- CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");\r
- return -1;\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == EOF) {\r
- CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");\r
- return -1;\r
- }\r
- } while (ch != '/');\r
- if (nlcount) {\r
- return '\n';\r
- }\r
- /* Go try it again... */
- } else if (ch == '=') {\r
- return CPP_DIV_ASSIGN;\r
- } else {\r
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
- return '/';\r
- }\r
- break;\r
- case '"':\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- while (ch != '"' && ch != '\n' && ch != EOF) {\r
- if (ch == '\\') {\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- if (ch == '\n' || ch == EOF) {\r
- break;\r
- }\r
- }\r
- if (len < MAX_STRING_LEN) {\r
- string_val[len] = ch;\r
- len++;\r
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
- }\r
- };\r
- string_val[len] = '\0';\r
- if (ch == '"') {\r
- yylvalpp->sc_ident = LookUpAddString(atable, string_val);\r
- return CPP_STRCONSTANT;\r
- } else {\r
- CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");\r
- return ERROR_SY;\r
- }\r
- }\r
- }\r
-} /* byte_scan */
-\r
-int yylex_CPP(char* buf, int maxSize)\r
-{ \r
- yystypepp yylvalpp;\r
- int token = '\n';\r
-\r
- for(;;) {\r
- \r
- char* tokenString = 0;\r
- token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);\r
- if(check_EOF(token))\r
- return 0;\r
- if (token == '#' && (cpp->previous_token == '\n'||cpp->previous_token==0)) {\r
- token = readCPPline(&yylvalpp);\r
- if(check_EOF(token))\r
- return 0;\r
- continue;\r
- }\r
- cpp->previous_token = token;\r
- /* expand macros */
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {\r
- cpp->notAVersionToken = 1;\r
- continue;\r
- }\r
- \r
- if (token == '\n')\r
- continue;\r
- \r
- if (token == CPP_IDENTIFIER) {\r
- cpp->notAVersionToken = 1;\r
- tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);\r
- } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){ \r
- cpp->notAVersionToken = 1;\r
- tokenString = yylvalpp.symbol_name;\r
- } else {\r
- cpp->notAVersionToken = 1;\r
- tokenString = GetStringOfAtom(atable,token);\r
- }\r
- \r
- if (tokenString) {\r
- if ((signed)strlen(tokenString) >= maxSize) {\r
- cpp->tokensBeforeEOF = 1;\r
- return maxSize;\r
- } else if (strlen(tokenString) > 0) {\r
- strcpy(buf, tokenString);\r
- cpp->tokensBeforeEOF = 1;\r
- return (int)strlen(tokenString);\r
- }\r
-\r
- return 0;\r
- }\r
- }\r
-\r
- return 0;\r
-} /* yylex */
-\r
-/*Checks if the token just read is EOF or not. */
-int check_EOF(int token)\r
-{\r
- if(token==-1){\r
- if(cpp->ifdepth >0){\r
- CPPErrorToInfoLog("#endif missing!! Compilation stopped");\r
- cpp->CompileError=1;\r
- }\r
- return 1;\r
- }\r
- return 0;\r
-}\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////////// End of scanner.c ////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* scanner.h */
-/* */
-\r
-#if !defined(__SCANNER_H)\r
-#define __SCANNER_H 1\r
-\r
-#define MAX_SYMBOL_NAME_LEN 128\r
-#define MAX_STRING_LEN 512\r
-\r
-#include "parser.h"\r
-\r
-/* Not really atom table stuff but needed first... */
-\r
-typedef struct SourceLoc_Rec {\r
- unsigned short file, line;\r
-} SourceLoc;\r
-\r
-int yyparse (void);\r
-\r
-int yylex_CPP(char* buf, int maxSize);\r
-\r
-typedef struct InputSrc {\r
- struct InputSrc *prev;\r
- int (*scan)(struct InputSrc *, yystypepp *);\r
- int (*getch)(struct InputSrc *, yystypepp *);\r
- void (*ungetch)(struct InputSrc *, int, yystypepp *);\r
- int name; /* atom */\r
- int line;\r
-} InputSrc;\r
-\r
-int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
-int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
-int check_EOF(int); /* check if we hit a EOF abruptly */
-void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
-void SetLineNumber(int);\r
-void SetStringNumber(int);\r
-void IncLineNumber(void);\r
-void DecLineNumber(void);\r
-int FreeScanner(void); /* Free the cpp scanner */
-#endif /* !(defined(__SCANNER_H) */
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* slglobals.h */
-/* */
-\r
-#if !defined(__SLGLOBALS_H)\r
-#define __SLGLOBALS_H 1\r
-\r
-typedef struct CPPStruct_Rec CPPStruct;\r
-\r
-extern CPPStruct *cpp;\r
-\r
-#undef CPPC_DEBUG_THE_COMPILER\r
-#if defined(_DEBUG)\r
-#define CPPC_DEBUG_THE_COMPILER 1\r
-#endif\r
-\r
-#undef CPPC_ENABLE_TOOLS\r
-#define CPPC_ENABLE_TOOLS 1\r
-\r
-#include "memory.h"\r
-#include "atom.h"\r
-#include "scanner.h"\r
-#include "cpp.h"\r
-#include "tokens.h"\r
-#include "symbols.h"\r
-#include "compile.h"\r
-#if !defined(NO_PARSER)\r
-#include "parser.h"\r
-#endif\r
-\r
-#if !defined(NULL)\r
-#define NULL 0\r
-#endif\r
-\r
-#endif /* !(defined(__SLGLOBALS_H) */
-\r
-\r
- \r
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* symbols.c */
-/* */
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include "slglobals.h"\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////// Symbol Table Variables: /////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-Scope *ScopeList = NULL;\r
-Scope *CurrentScope = NULL;\r
-Scope *GlobalScope = NULL;\r
-\r
-static void unlinkScope(void *_scope) {\r
- Scope *scope = _scope;\r
-\r
- if (scope->next)\r
- scope->next->prev = scope->prev;\r
- if (scope->prev)\r
- scope->prev->next = scope->next;\r
- else\r
- ScopeList = scope->next;\r
-}\r
-\r
-/*\r
- * NewScope()\r
- *\r
- */\r
-Scope *NewScopeInPool(MemoryPool *pool)\r
-{\r
- Scope *lScope;\r
-\r
- lScope = mem_Alloc(pool, sizeof(Scope));\r
- lScope->pool = pool;\r
- lScope->parent = NULL;\r
- lScope->funScope = NULL;\r
- lScope->symbols = NULL;\r
- \r
- lScope->level = 0;\r
-\r
- lScope->programs = NULL;\r
- if ((lScope->next = ScopeList))\r
- ScopeList->prev = lScope;\r
- lScope->prev = 0;\r
- ScopeList = lScope;\r
- mem_AddCleanup(pool, unlinkScope, lScope);\r
- return lScope;\r
-} /* NewScope */
-\r
-/*\r
- * PushScope()\r
- *\r
- */\r
-\r
-void PushScope(Scope *fScope)\r
-{\r
- Scope *lScope;\r
-\r
- if (CurrentScope) {\r
- fScope->level = CurrentScope->level + 1;\r
- if (fScope->level == 1) {\r
- if (!GlobalScope) {\r
- /* HACK - CTD -- if GlobalScope==NULL and level==1, we're\r
- * defining a function in the superglobal scope. Things\r
- * will break if we leave the level as 1, so we arbitrarily\r
- * set it to 2 */\r
- fScope->level = 2;\r
- }\r
- }\r
- if (fScope->level >= 2) {\r
- lScope = fScope;\r
- while (lScope->level > 2)\r
- lScope = lScope->next;\r
- fScope->funScope = lScope;\r
- }\r
- } else {\r
- fScope->level = 0;\r
- }\r
- fScope->parent = CurrentScope;\r
- CurrentScope = fScope;\r
-} /* PushScope */
-\r
-/*\r
- * PopScope()\r
- *\r
- */\r
-\r
-Scope *PopScope(void)\r
-{\r
- Scope *lScope;\r
-\r
- lScope = CurrentScope;\r
- if (CurrentScope)\r
- CurrentScope = CurrentScope->parent;\r
- return lScope;\r
-} /* PopScope */
-\r
-/*\r
- * NewSymbol() - Allocate a new symbol node;\r
- *\r
- */\r
-\r
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)\r
-{\r
- Symbol *lSymb;\r
- char *pch;\r
- int ii;\r
-\r
- lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));\r
- lSymb->left = NULL;\r
- lSymb->right = NULL;\r
- lSymb->next = NULL;\r
- lSymb->name = name;\r
- lSymb->loc = *loc;\r
- lSymb->kind = kind;\r
- \r
- /* Clear union area: */
-\r
- pch = (char *) &lSymb->details;\r
- for (ii = 0; ii < sizeof(lSymb->details); ii++)\r
- *pch++ = 0;\r
- return lSymb;\r
-} /* NewSymbol */
-\r
-/*\r
- * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they\r
- * are generated in order. We'll fix this later (by reversing the bit pattern).\r
- */\r
-\r
-static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)\r
-{\r
- Symbol *lSymb;\r
- int lrev, frev;\r
-\r
- lSymb = *fSymbols;\r
- if (lSymb) {\r
- frev = GetReversedAtom(atable, fSymb->name);\r
- while (lSymb) {\r
- lrev = GetReversedAtom(atable, lSymb->name);\r
- if (lrev == frev) {\r
- CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");\r
- break;\r
- } else {\r
- if (lrev > frev) {\r
- if (lSymb->left) {\r
- lSymb = lSymb->left;\r
- } else {\r
- lSymb->left = fSymb;\r
- break;\r
- }\r
- } else {\r
- if (lSymb->right) {\r
- lSymb = lSymb->right;\r
- } else {\r
- lSymb->right = fSymb;\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- } else {\r
- *fSymbols = fSymb;\r
- }\r
-} /* lAddToTree */
-\r
-\r
-/*\r
- * AddSymbol() - Add a variable, type, or function name to a scope.\r
- *\r
- */\r
-\r
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)\r
-{\r
- Symbol *lSymb;\r
-\r
- if (!fScope)\r
- fScope = CurrentScope;\r
- lSymb = NewSymbol(loc, fScope, atom, kind);\r
- lAddToTree(&fScope->symbols, lSymb);\r
- return lSymb;\r
-} /* AddSymbol */
-\r
-\r
-/*********************************************************************************************/\r
-/************************************ Symbol Semantic Functions ******************************/\r
-/*********************************************************************************************/\r
-\r
-/*\r
- * LookUpLocalSymbol()\r
- *\r
- */\r
-\r
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom)\r
-{\r
- Symbol *lSymb;\r
- int rname, ratom;\r
-\r
- ratom = GetReversedAtom(atable, atom);\r
- if (!fScope)\r
- fScope = CurrentScope;\r
- lSymb = fScope->symbols;\r
- while (lSymb) {\r
- rname = GetReversedAtom(atable, lSymb->name);\r
- if (rname == ratom) {\r
- return lSymb;\r
- } else {\r
- if (rname > ratom) {\r
- lSymb = lSymb->left;\r
- } else {\r
- lSymb = lSymb->right;\r
- }\r
- }\r
- }\r
- return NULL;\r
-} /* LookUpLocalSymbol */
-\r
-/*\r
- * LookUpSymbol()\r
- *\r
- */\r
-\r
-Symbol *LookUpSymbol(Scope *fScope, int atom)\r
-{\r
- Symbol *lSymb;\r
-\r
- if (!fScope)\r
- fScope = CurrentScope;\r
- while (fScope) {\r
- lSymb = LookUpLocalSymbol(fScope, atom);\r
- if (lSymb)\r
- return lSymb;\r
- fScope = fScope->parent;\r
- }\r
- return NULL;\r
-} /* LookUpSymbol */
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* symbols.h */
-/* */
-\r
-#if !defined(__SYMBOLS_H)\r
-#define __SYMBOLS_H 1\r
-\r
-#include "memory.h"\r
-\r
-typedef enum symbolkind {\r
- MACRO_S\r
-} symbolkind;\r
-\r
-/* Typedefs for things defined here in "symbols.h": */
-\r
-typedef struct Scope_Rec Scope;\r
-typedef struct Symbol_Rec Symbol;\r
-\r
-typedef struct SymbolList_Rec {\r
- struct SymbolList_Rec *next;\r
- Symbol *symb;\r
-} SymbolList;\r
-\r
-struct Scope_Rec {\r
- Scope *next, *prev; /* doubly-linked list of all scopes */
- Scope *parent;\r
- Scope *funScope; /* Points to base scope of enclosing function */
- MemoryPool *pool; /* pool used for allocation in this scope */
- Symbol *symbols;\r
- \r
- int level; /* 0 = super globals, 1 = globals, etc. */
-\r
- /* Only used at global scope (level 1): */
- SymbolList *programs; /* List of programs for this compilation. */
-};\r
-\r
-\r
-/* Symbol table is a simple binary tree. */
-\r
-#include "cpp.h" /* to get MacroSymbol def */
-\r
-struct Symbol_Rec {\r
- Symbol *left, *right;\r
- Symbol *next;\r
- int name; /* Name atom */
- SourceLoc loc;\r
- symbolkind kind;\r
- union {\r
- MacroSymbol mac;\r
- } details;\r
-};\r
-\r
-extern Scope *CurrentScope;\r
-extern Scope *GlobalScope;\r
-extern Scope *ScopeList;\r
-\r
-Scope *NewScopeInPool(MemoryPool *);\r
-#define NewScope() NewScopeInPool(CurrentScope->pool)\r
-void PushScope(Scope *fScope);\r
-Scope *PopScope(void);\r
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);\r
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);\r
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom);\r
-Symbol *LookUpSymbol(Scope *fScope, int atom);\r
-void CPPErrorToInfoLog(char *);\r
-\r
-\r
-#endif /* !defined(__SYMBOLS_H) */
-\r
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* tokens.c */
-/* */
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-\r
-#include "slglobals.h"\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-\r
-/*\r
- * idstr()\r
- * Copy a string to a malloc'ed block and convert it into something suitable\r
- * for an ID\r
- *\r
- */\r
-\r
-static char *idstr(const char *fstr)\r
-{\r
- size_t len;\r
- char *str, *t;\r
- const char *f;\r
-\r
- len = strlen(fstr);\r
- str = (char *) malloc(len + 1);\r
- for (f=fstr, t=str; *f; f++) {\r
- if (isalnum(*f)) *t++ = *f;\r
- else if (*f == '.' || *f == '/') *t++ = '_';\r
- }\r
- *t = 0;\r
- return str;\r
-} /* idstr */
-\r
-\r
-/*\r
- * lNewBlock()\r
- *\r
- */\r
-\r
-static TokenBlock *lNewBlock(TokenStream *fTok)\r
-{\r
- TokenBlock *lBlock;\r
-\r
- lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);\r
- lBlock->count = 0;\r
- lBlock->current = 0;\r
- lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);\r
- lBlock->max = 256;\r
- lBlock->next = NULL;\r
- if (fTok->head) {\r
- fTok->current->next = lBlock;\r
- } else {\r
- fTok->head = lBlock;\r
- }\r
- fTok->current = lBlock;\r
- return lBlock;\r
-} /* lNewBlock */
-\r
-/*\r
- * lAddByte()\r
- *\r
- */\r
-\r
-static void lAddByte(TokenStream *fTok, unsigned char fVal)\r
-{\r
- TokenBlock *lBlock;\r
- lBlock = fTok->current;\r
- if (lBlock->count >= lBlock->max)\r
- lBlock = lNewBlock(fTok);\r
- lBlock->data[lBlock->count++] = fVal;\r
-} /* lAddByte */
-\r
-\r
-\r
-/*\r
- * lReadByte() - Get the next byte from a stream.\r
- *\r
- */\r
-\r
-static int lReadByte(TokenStream *pTok)\r
-{\r
- TokenBlock *lBlock;\r
- int lval = -1;\r
-\r
- lBlock = pTok->current;\r
- if (lBlock) {\r
- if (lBlock->current >= lBlock->count) {\r
- lBlock = lBlock->next;\r
- if (lBlock)\r
- lBlock->current = 0;\r
- pTok->current = lBlock;\r
- }\r
- if (lBlock)\r
- lval = lBlock->data[lBlock->current++];\r
- }\r
- return lval;\r
-} /* lReadByte */
-\r
-/*///////////////////////////////////// Global Functions:////////////////////////////////////// */
-\r
-/*\r
- * NewTokenStream()\r
- *\r
- */\r
-\r
-TokenStream *NewTokenStream(const char *name)\r
-{\r
- TokenStream *pTok;\r
-\r
- pTok = (TokenStream *) malloc(sizeof(TokenStream));\r
- pTok->next = NULL;\r
- pTok->name = idstr(name);\r
- pTok->head = NULL;\r
- pTok->current = NULL;\r
- lNewBlock(pTok);\r
- return pTok;\r
-} /* NewTokenStream */
-\r
-/*\r
- * DeleteTokenStream()\r
- *\r
- */\r
-\r
-void DeleteTokenStream(TokenStream *pTok)\r
-{\r
- TokenBlock *pBlock, *nBlock;\r
-\r
- if (pTok) {\r
- pBlock = pTok->head;\r
- while (pBlock) {\r
- nBlock = pBlock->next;\r
- free(pBlock);\r
- pBlock = nBlock;\r
- }\r
- if (pTok->name)\r
- free(pTok->name);\r
- free(pTok);\r
- }\r
-} /* DeleteTokenStream */
-\r
-/*\r
- * RecordToken() - Add a token to the end of a list for later playback or printout.\r
- *\r
- */\r
-\r
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)\r
-{\r
- const char *s;\r
- unsigned char *str=NULL;\r
-\r
- if (token > 256)\r
- lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));\r
- else\r
- lAddByte(pTok, (unsigned char)(token & 0x7f));\r
- switch (token) {\r
- case CPP_IDENTIFIER:\r
- case CPP_TYPEIDENTIFIER:\r
- case CPP_STRCONSTANT:\r
- s = GetAtomString(atable, yylvalpp->sc_ident);\r
- while (*s)\r
- lAddByte(pTok, (unsigned char) *s++);\r
- lAddByte(pTok, 0);\r
- break;\r
- case CPP_FLOATCONSTANT:\r
- case CPP_INTCONSTANT:\r
- str=yylvalpp->symbol_name;\r
- while (*str){\r
- lAddByte(pTok,(unsigned char) *str);\r
- *str++;\r
- }\r
- lAddByte(pTok, 0);\r
- break;\r
- case '(':\r
- lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));\r
- default:\r
- break;\r
- }\r
-} /* RecordToken */
-\r
-/*\r
- * RewindTokenStream() - Reset a token stream in preperation for reading.\r
- *\r
- */\r
-\r
-void RewindTokenStream(TokenStream *pTok)\r
-{\r
- if (pTok->head) {\r
- pTok->current = pTok->head;\r
- pTok->current->current = 0;\r
- }\r
-} /* RewindTokenStream */
-\r
-/*\r
- * ReadToken() - Read the next token from a stream.\r
- *\r
- */\r
-\r
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)\r
-{\r
- char symbol_name[MAX_SYMBOL_NAME_LEN + 1];\r
- char string_val[MAX_STRING_LEN + 1];\r
- int ltoken, len;\r
- char ch;\r
-\r
- ltoken = lReadByte(pTok);\r
- if (ltoken >= 0) {\r
- if (ltoken > 127)\r
- ltoken += 128;\r
- switch (ltoken) {\r
- case CPP_IDENTIFIER:\r
- case CPP_TYPEIDENTIFIER:\r
- len = 0;\r
- ch = lReadByte(pTok);\r
- while ((ch >= 'a' && ch <= 'z') ||\r
- (ch >= 'A' && ch <= 'Z') ||\r
- (ch >= '0' && ch <= '9') ||\r
- ch == '_')\r
- {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- symbol_name[len] = ch;\r
- len++;\r
- ch = lReadByte(pTok);\r
- }\r
- }\r
- symbol_name[len] = '\0';\r
- assert(ch == '\0');\r
- yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);\r
- return CPP_IDENTIFIER;\r
- break;\r
- case CPP_STRCONSTANT:\r
- len = 0;\r
- while ((ch = lReadByte(pTok)) != 0)\r
- if (len < MAX_STRING_LEN)\r
- string_val[len++] = ch;\r
- string_val[len] = 0;\r
- yylvalpp->sc_ident = LookUpAddString(atable, string_val);\r
- break;\r
- case CPP_FLOATCONSTANT:\r
- len = 0;\r
- ch = lReadByte(pTok);\r
- while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))\r
- {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- symbol_name[len] = ch;\r
- len++;\r
- ch = lReadByte(pTok);\r
- }\r
- }\r
- symbol_name[len] = '\0';\r
- assert(ch == '\0');\r
- strcpy(yylvalpp->symbol_name,symbol_name);\r
- yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);\r
- break;\r
- case CPP_INTCONSTANT:\r
- len = 0;\r
- ch = lReadByte(pTok);\r
- while ((ch >= '0' && ch <= '9'))\r
- {\r
- if (len < MAX_SYMBOL_NAME_LEN) {\r
- symbol_name[len] = ch;\r
- len++;\r
- ch = lReadByte(pTok);\r
- }\r
- }\r
- symbol_name[len] = '\0';\r
- assert(ch == '\0');\r
- strcpy(yylvalpp->symbol_name,symbol_name);\r
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
- break;\r
- case '(':\r
- yylvalpp->sc_int = lReadByte(pTok);\r
- break;\r
- }\r
- return ltoken;\r
- }\r
- return EOF_SY;\r
-} /* ReadToken */
-\r
-typedef struct TokenInputSrc {\r
- InputSrc base;\r
- TokenStream *tokens;\r
- int (*final)(CPPStruct *);\r
-} TokenInputSrc;\r
-\r
-static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)\r
-{\r
- int token = ReadToken(in->tokens, yylvalpp);\r
- int (*final)(CPPStruct *);\r
- cpp->tokenLoc->file = cpp->currentInput->name;\r
- cpp->tokenLoc->line = cpp->currentInput->line;\r
- if (token == '\n') {\r
- in->base.line++;\r
- return token;\r
- }\r
- if (token > 0) return token;\r
- cpp->currentInput = in->base.prev;\r
- final = in->final;\r
- free(in);\r
- if (final && !final(cpp)) return -1;\r
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-}\r
-\r
-int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))\r
-{\r
- TokenInputSrc *in = malloc(sizeof(TokenInputSrc));\r
- memset(in, 0, sizeof(TokenInputSrc));\r
- in->base.name = name;\r
- in->base.prev = cpp->currentInput;\r
- in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;\r
- in->base.line = 1;\r
- in->tokens = ts;\r
- in->final = final;\r
- RewindTokenStream(ts);\r
- cpp->currentInput = &in->base;\r
- return 1;\r
-}\r
-\r
-typedef struct UngotToken {\r
- InputSrc base;\r
- int token;\r
- yystypepp lval;\r
-} UngotToken;\r
-\r
-static int reget_token(UngotToken *t, yystypepp * yylvalpp)\r
-{\r
- int token = t->token;\r
- *yylvalpp = t->lval;\r
- cpp->currentInput = t->base.prev;\r
- free(t);\r
- return token;\r
-}\r
-\r
-void UngetToken(int token, yystypepp * yylvalpp) {\r
- UngotToken *t = malloc(sizeof(UngotToken));\r
- memset(t, 0, sizeof(UngotToken));\r
- t->token = token;\r
- t->lval = *yylvalpp;\r
- t->base.scan = (void *)reget_token;\r
- t->base.prev = cpp->currentInput;\r
- t->base.name = cpp->currentInput->name;\r
- t->base.line = cpp->currentInput->line;\r
- cpp->currentInput = &t->base;\r
-}\r
-\r
-\r
-void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {\r
- int token;\r
- char str[100];\r
-\r
- if (fp == 0) fp = stdout;\r
- RewindTokenStream(s);\r
- while ((token = ReadToken(s, yylvalpp)) > 0) {\r
- switch (token) {\r
- case CPP_IDENTIFIER:\r
- case CPP_TYPEIDENTIFIER:\r
- sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));\r
- break;\r
- case CPP_STRCONSTANT:\r
- sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));\r
- break;\r
- case CPP_FLOATCONSTANT:\r
- /*printf("%g9.6 ", yylvalpp->sc_fval); */
- break;\r
- case CPP_INTCONSTANT:\r
- /*printf("%d ", yylvalpp->sc_int); */
- break;\r
- default:\r
- if (token >= 127)\r
- sprintf(str, "%s ", GetAtomString(atable, token));\r
- else\r
- sprintf(str, "%c", token);\r
- break;\r
- }\r
- CPPDebugLogMsg(str);\r
- }\r
-}\r
-\r
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
-/*///////////////////////////////////// End of tokens.c /////////////////////////////////////// */
-/*///////////////////////////////////////////////////////////////////////////////////////////// */
+++ /dev/null
-/* */
-/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
-/*All rights reserved. */
-/* */
-/*Redistribution and use in source and binary forms, with or without */
-/*modification, are permitted provided that the following conditions */
-/*are met: */
-/* */
-/* Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* */
-/* Redistributions in binary form must reproduce the above */
-/* copyright notice, this list of conditions and the following */
-/* disclaimer in the documentation and/or other materials provided */
-/* with the distribution. */
-/* */
-/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
-/* contributors may be used to endorse or promote products derived */
-/* from this software without specific prior written permission. */
-/* */
-/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
-/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
-/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
-/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
-/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
-/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
-/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
-/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
-/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
-/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
-/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
-/*POSSIBILITY OF SUCH DAMAGE. */
-/* */
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms. If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-/* */
-/* tokens.h */
-/* */
-\r
-#if !defined(__TOKENS_H)\r
-#define __TOKENS_H 1\r
-\r
-#include "parser.h"\r
-\r
-#define EOF_SY (-1)\r
-\r
-typedef struct TokenBlock_Rec TokenBlock;\r
-\r
-typedef struct TokenStream_Rec {\r
- struct TokenStream_Rec *next;\r
- char *name;\r
- TokenBlock *head;\r
- TokenBlock *current;\r
-} TokenStream;\r
-\r
-struct TokenBlock_Rec {\r
- TokenBlock *next;\r
- int current;\r
- int count;\r
- int max;\r
- unsigned char *data;\r
-};\r
-\r
-extern TokenStream stdlib_cpp_stream;\r
-\r
-\r
-TokenStream *NewTokenStream(const char *name);\r
-void DeleteTokenStream(TokenStream *pTok); \r
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);\r
-void RewindTokenStream(TokenStream *pTok);\r
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);\r
-int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));\r
-void UngetToken(int, yystypepp * yylvalpp);\r
-\r
-#if defined(CPPC_ENABLE_TOOLS)\r
-\r
-void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);\r
-\r
-#endif /* defined(CPPC_ENABLE_TOOLS) */
-\r
-#endif /* !defined(__TOKENS_H) */
+++ /dev/null
-// This is a NULL file and is meant to be empty\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-\r
-#define SH_EXPORTING\r
-#include "Initialisation.h"\r
-#include "Include/InitializeGlobals.h"\r
-#include "Include/InitializeParseContext.h"\r
-#include "Public/ShaderLang.h"\r
-\r
-OS_TLSIndex GlobalProcessFlag = OS_INVALID_TLS_INDEX;\r
-\r
-bool InitProcess()\r
-{\r
- if (GlobalProcessFlag != OS_INVALID_TLS_INDEX) {\r
- //\r
- // Function is re-entrant.\r
- //\r
- return true;\r
- }\r
-\r
- GlobalProcessFlag = OS_AllocTLSIndex();\r
-\r
- if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {\r
- assert (0 && "InitProcess(): Failed to allocate TLS area for init flag");\r
- return false;\r
- }\r
-\r
- if (!InitializePoolIndex()) {\r
- assert (0 && "InitProcess(): Failed to initalize global pool");\r
- return false;\r
- }\r
-\r
- if (!InitializeParseContextIndex()) {\r
- assert (0 && "InitProcess(): Failed to initalize parse context");\r
- return false;\r
- }\r
-\r
- InitThread();\r
- return true;\r
-}\r
-\r
-\r
-bool InitThread()\r
-{\r
- //\r
- // This function is re-entrant\r
- //\r
- if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "InitThread(): Process hasn't been initalised.");\r
- return false;\r
- }\r
-\r
- if (OS_GetTLSValue(GlobalProcessFlag) != 0) {\r
- return true;\r
- }\r
-\r
- InitializeGlobalPools();\r
-\r
- if(!InitializeGlobalParseContext()) \r
- return false;\r
-\r
- if(!OS_SetTLSValue(GlobalProcessFlag, (void *)1)) {\r
- assert(0 && "InitThread(): Unable to set init flag.");\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-\r
-bool DetachThread()\r
-{\r
- bool retFlag = true;\r
-\r
- if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {\r
- assert(0 && "DetachThread(): Process hasn't been initalised.");\r
- return false;\r
- }\r
-\r
- //\r
- // Function is re-entrant and this thread may not have been initalised.\r
- //\r
- if (OS_GetTLSValue(GlobalProcessFlag) != 0)\r
- {\r
- if(!OS_SetTLSValue(GlobalProcessFlag, (void *)0)) {\r
- assert(0 && "DetachThread(): Unable to clear init flag.");\r
- retFlag = false;\r
- }\r
-\r
- FreeGlobalPools();\r
-\r
- if (!FreeParseContext())\r
- retFlag = false;\r
- }\r
-\r
- return retFlag;\r
-}\r
-\r
-bool DetachProcess()\r
-{\r
- bool retFlag = true;\r
-\r
- if (GlobalProcessFlag == OS_INVALID_TLS_INDEX)\r
- return true;\r
- \r
- ShFinalize();\r
-\r
- retFlag = DetachThread();\r
-\r
- FreePoolIndex();\r
-\r
- if(!FreeParseContextIndex())\r
- retFlag = false;\r
-\r
- OS_FreeTLSIndex(GlobalProcessFlag);\r
- GlobalProcessFlag = OS_INVALID_TLS_INDEX;\r
-\r
- return retFlag;\r
-}\r
-\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-#ifndef __INITIALISATION_H\r
-#define __INITIALISATION_H\r
-\r
-\r
-#include "osinclude.h"\r
-\r
-\r
-bool InitProcess();\r
-bool InitThread();\r
-bool DetachThread();\r
-bool DetachProcess();\r
-\r
-#endif // __INITIALISATION_H\r
-\r
+++ /dev/null
-/*\r
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-#ifndef _COMPILER_INTERFACE_INCLUDED_\r
-#define _COMPILER_INTERFACE_INCLUDED_\r
-\r
-#include "../Include/ResourceLimits.h"\r
-\r
-#ifdef _WIN32\r
-#define C_DECL __cdecl\r
-/*#ifdef SH_EXPORTING\r
- #define SH_IMPORT_EXPORT __declspec(dllexport)\r
-#else\r
- #define SH_IMPORT_EXPORT __declspec(dllimport)\r
-#endif*/\r
-/* disable DLL linking */\r
-#define SH_IMPORT_EXPORT\r
-#else\r
-#define SH_IMPORT_EXPORT\r
-#define __fastcall\r
-#define C_DECL\r
-#endif\r
-\r
-/*\r
-// This is the platform independent interface between an OGL driver\r
-// and the shading language compiler/linker.\r
-*/\r
-\r
-#ifdef __cplusplus\r
- extern "C" {\r
-#endif\r
-\r
-/*\r
-// Driver must call this first, once, before doing any other\r
-// compiler/linker operations.\r
-*/\r
-SH_IMPORT_EXPORT int ShInitialize();\r
-/*\r
-// Driver should call this at shutdown.\r
-*/\r
-SH_IMPORT_EXPORT int __fastcall ShFinalize();\r
-\r
-/*\r
-// Types of languages the compiler can consume.\r
-*/\r
-typedef enum {\r
- EShLangVertex,\r
- EShLangFragment,\r
- EShLangPack,\r
- EShLangUnpack,\r
- EShLangCount\r
-} EShLanguage;\r
-\r
-/*\r
-// Types of output the linker will create.\r
-*/\r
-typedef enum {\r
- EShExVertexFragment,\r
- EShExPackFragment,\r
- EShExUnpackFragment,\r
- EShExFragment\r
-} EShExecutable;\r
-\r
-/*\r
-// Optimization level for the compiler.\r
-*/\r
-typedef enum {\r
- EShOptNoGeneration,\r
- EShOptNone,\r
- EShOptSimple, /* Optimizations that can be done quickly */\r
- EShOptFull /* Optimizations that will take more time */\r
-} EShOptimizationLevel;\r
-\r
-/*\r
-// Build a table for bindings. This can be used for locating\r
-// attributes, uniforms, globals, etc., as needed.\r
-*/\r
-typedef struct {\r
- char* name;\r
- int binding;\r
-} ShBinding;\r
-\r
-typedef struct {\r
- int numBindings;\r
- ShBinding* bindings; /* array of bindings */\r
-} ShBindingTable;\r
-\r
-/*\r
-// ShHandle held by but opaque to the driver. It is allocated,\r
-// managed, and de-allocated by the compiler/linker. It's contents \r
-// are defined by and used by the compiler and linker. For example,\r
-// symbol table information and object code passed from the compiler \r
-// to the linker can be stored where ShHandle points.\r
-//\r
-// If handle creation fails, 0 will be returned.\r
-*/\r
-typedef void* ShHandle;\r
-\r
-/*\r
-// Driver calls these to create and destroy compiler/linker\r
-// objects.\r
-*/\r
-SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); /* one per shader */\r
-SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); /* one per shader pair */\r
-SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */\r
-SH_IMPORT_EXPORT void ShDestruct(ShHandle);\r
-\r
-/*\r
-// The return value of ShCompile is boolean, indicating\r
-// success or failure.\r
-//\r
-// The info-log should be written by ShCompile into \r
-// ShHandle, so it can answer future queries.\r
-*/\r
-SH_IMPORT_EXPORT int ShCompile(\r
- const ShHandle,\r
- const char* const shaderStrings[],\r
- const int numStrings,\r
- const EShOptimizationLevel,\r
- const TBuiltInResource *resources,\r
- int debugOptions\r
- );\r
-\r
-\r
-/*\r
-// Similar to ShCompile, but accepts an opaque handle to an\r
-// intermediate language structure.\r
-*/\r
-SH_IMPORT_EXPORT int ShCompileIntermediate(\r
- ShHandle compiler,\r
- ShHandle intermediate,\r
- const EShOptimizationLevel,\r
- int debuggable /* boolean */\r
- );\r
-\r
-SH_IMPORT_EXPORT int ShLink(\r
- const ShHandle, /* linker object */\r
- const ShHandle h[], /* compiler objects to link together */\r
- const int numHandles,\r
- ShHandle uniformMap, /* updated with new uniforms */\r
- short int** uniformsAccessed, /* returned with indexes of uniforms accessed */\r
- int* numUniformsAccessed); \r
-\r
-/*\r
-// ShSetEncrpytionMethod is a place-holder for specifying\r
-// how source code is encrypted.\r
-*/\r
-SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);\r
-\r
-/*\r
-// All the following return 0 if the information is not\r
-// available in the object passed down, or the object is bad.\r
-*/\r
-SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle);\r
-SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle);\r
-SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); /* to detect user aliasing */\r
-SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); /* to force any physical mappings */\r
-SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); /* for all attributes */\r
-/*\r
-// Tell the linker to never assign a vertex attribute to this list of physical attributes\r
-*/\r
-SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);\r
-\r
-/*\r
-// Returns the location ID of the named uniform.\r
-// Returns -1 if error.\r
-*/\r
-SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);\r
-\r
-enum TDebugOptions {\r
- EDebugOpNone = 0x000,\r
- EDebugOpIntermediate = 0x001,\r
- EDebugOpAssembly = 0x002,\r
- EDebugOpObjectCode = 0x004,\r
- EDebugOpLinkMaps = 0x008\r
-};\r
-\r
-#ifdef __cplusplus\r
- }\r
-#endif\r
-\r
-#endif /* _COMPILER_INTERFACE_INCLUDED_ */\r
+++ /dev/null
-//\r
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-// Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-//\r
-// Redistributions in binary form must reproduce the above\r
-// copyright notice, this list of conditions and the following\r
-// disclaimer in the documentation and/or other materials provided\r
-// with the distribution.\r
-//\r
-// Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-// contributors may be used to endorse or promote products derived\r
-// from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-#ifndef _SHADERLANG_EXTENSION_INCLUDED_\r
-#define _SHADERLANG_EXTENSION_INCLUDED_\r
-\r
-#include "ShaderLang.h"\r
-\r
-//\r
-// This is the platform independent interface between an OGL driver\r
-// and the shading language compiler/linker.\r
-//\r
-\r
-#ifdef __cplusplus\r
- extern "C" {\r
-#endif\r
-\r
-SH_IMPORT_EXPORT int ShLinkExt(\r
- const ShHandle, // linker object\r
- const ShHandle h[], // compiler objects to link together\r
- const int numHandles);\r
-\r
-#ifdef __cplusplus\r
- }\r
-#endif\r
-\r
-#endif // _SHADERLANG_EXTENSION_INCLUDED_\r