author | Vladimir Vukicevic <vladimir@pobox.com> |
Fri, 03 Dec 2010 14:44:01 -0800 | |
changeset 58582 | 370f95da0cc1959c7ff3df5254d93e3e511cbf39 |
parent 58581 | dff69338ba79852d62502e212a243de2ded5c358 |
child 58583 | f1dd337db722f9ae3c57cd80d50a8ac654037b96 |
push id | 17367 |
push user | vladimir@mozilla.com |
push date | Fri, 03 Dec 2010 22:44:27 +0000 |
treeherder | mozilla-central@0ebee0d30b04 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bjacob |
bugs | 616290 |
milestone | 2.0b8pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/angle/DEPS +++ b/gfx/angle/DEPS @@ -1,20 +1,12 @@ deps = { "trunk/third_party/gyp": "http://gyp.googlecode.com/svn/trunk@800", } -deps_os = { - "win": { - # Cygwin is required for gyp actions, flex, and bison. - "trunk/third_party/cygwin": - "http://src.chromium.org/svn/trunk/deps/third_party/cygwin@11984", - } -} - hooks = [ { # A change to a .gyp, .gypi, or to GYP itself should run the generator. "pattern": ".", "action": ["python", "trunk/build/gyp_angle"], }, ]
--- a/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in @@ -54,17 +54,16 @@ EXPORTS_angle = \ include/GLSLANG/ResourceLimits.h \ $(NULL) LOCAL_INCLUDES += -I$(srcdir)/include -I$(srcdir)/src VPATH += $(srcdir)/src VPATH += $(srcdir)/src/compiler VPATH += $(srcdir)/src/compiler/preprocessor -VPATH += $(srcdir)/generated CPPSRCS = \ Compiler.cpp \ InfoSink.cpp \ Initialize.cpp \ InitializeDll.cpp \ Intermediate.cpp \ intermOut.cpp \ @@ -75,29 +74,32 @@ CPPSRCS = \ PoolAlloc.cpp \ QualifierAlive.cpp \ RemoveTree.cpp \ ShaderLang.cpp \ SymbolTable.cpp \ VariableInfo.cpp \ debug.cpp \ ossource_nspr.cpp \ + util.cpp \ + ValidateLimitations.cpp \ $(NULL) # flex/yacc generated files CPPSRCS += \ - glslang.cpp \ + glslang_lex.cpp \ glslang_tab.cpp \ $(NULL) # GLSL translator backend CPPSRCS += \ CodeGenGLSL.cpp \ OutputGLSL.cpp \ TranslatorGLSL.cpp \ + VersionGLSL.cpp \ $(NULL) # Currently, only one or the other # can be selected. ## HLSL translator backend ##CPPSRCS += \ ## CodeGenHLSL.cpp \
--- a/gfx/angle/README.mozilla +++ b/gfx/angle/README.mozilla @@ -1,35 +1,20 @@ This is the ANGLE project, from http://code.google.com/p/angleproject/. -Current revision: r445 +Current revision: r498 Local patches: - angle-nspr.patch - use NSPR for TLS + angle-shared.patch - add declspec dllexport/dllimport support on win32 - angle-shared.patch - add declspec dllexport/dllimport support on win32 + angle-fixes.patch - fix angle issues 51 & 52 == Visual Studio Solution Files == The VS solution/project files that are used to build ANGLE are built with VS2008 in upstream ANGLE. Because our build machines use VS2005, they need to be downgraded using http://www.emmet-gray.com/Articles/ProjectConverter.htm before being checked in with an ANGLE update. == Regenerating Parser == - -To regenerate the flex/yacc generated files, do the following -- note -that they'll generate different results, but with the same effect. -Doing this on linux is preferred: - - flex --noline --nounistd --outfile=generated/glslang.cpp src/compiler/glslang.l - bison --no-lines --defines=generated/glslang_tab.h --skeleton=yacc.c --output=generated/glslang_tab.cpp src/compiler/glslang.y - -or (win32) -- note the manual removal of unistd.h and the renaming of the bison generated file: - - src/compiler/tools/flex.exe -L -ogenerated/glslang.cpp src/compiler/glslang.l -# get rid of #include <unistd.h> - grep -v unistd generated/glslang.cpp > foo && mv foo generated/glslang.cpp - BISON_SIMPLE=src/compiler/tools/bison.simple src/compiler/tools/bison.exe --no-lines --defines --yacc --output=generated/glslang_tab.cpp src/compiler/glslang.y - mv generated/glslang_tab.cpp.h generated/glslang_tab.h - +The parser is now generated and included in the ANGLE svn repo. \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/gfx/angle/angle-fixes.patch @@ -0,0 +1,116 @@ +Fixes for angle defects 51 and 52 + +Index: src/libGLESv2/Texture.cpp +=================================================================== +--- src/libGLESv2/Texture.cpp (revision 474) ++++ src/libGLESv2/Texture.cpp (working copy) +@@ -1207,6 +1207,9 @@ + mHeight = height << level; + mImageArray[0].format = internalFormat; + mType = type; ++ ++ if (mColorbufferProxy.get()) ++ mColorbufferProxy->setStorage(new TextureColorbufferProxy(this, GL_TEXTURE_2D)); + } + + return !textureOkay; +@@ -2081,6 +2084,12 @@ + mImageArray[0][0].height = width << level; + + mImageArray[0][0].format = internalFormat; ++ ++ for (int i = 0; i < 6; i++) ++ { ++ if (mFaceProxies[i].get()) ++ mFaceProxies[i]->setStorage(new TextureColorbufferProxy(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i)); ++ } + } + + return !textureOkay; +Index: src/libGLESv2/Renderbuffer.cpp +=================================================================== +--- src/libGLESv2/Renderbuffer.cpp (revision 474) ++++ src/libGLESv2/Renderbuffer.cpp (working copy) +@@ -246,12 +246,12 @@ + return true; + } + +-GLuint Colorbuffer::getRedSize() const ++GLuint Colorbuffer::getRedSize() + { +- if (mRenderTarget) ++ if (getRenderTarget()) + { + D3DSURFACE_DESC description; +- mRenderTarget->GetDesc(&description); ++ getRenderTarget()->GetDesc(&description); + + return es2dx::GetRedSize(description.Format); + } +@@ -259,12 +259,12 @@ + return 0; + } + +-GLuint Colorbuffer::getGreenSize() const ++GLuint Colorbuffer::getGreenSize() + { +- if (mRenderTarget) ++ if (getRenderTarget()) + { + D3DSURFACE_DESC description; +- mRenderTarget->GetDesc(&description); ++ getRenderTarget()->GetDesc(&description); + + return es2dx::GetGreenSize(description.Format); + } +@@ -272,12 +272,12 @@ + return 0; + } + +-GLuint Colorbuffer::getBlueSize() const ++GLuint Colorbuffer::getBlueSize() + { +- if (mRenderTarget) ++ if (getRenderTarget()) + { + D3DSURFACE_DESC description; +- mRenderTarget->GetDesc(&description); ++ getRenderTarget()->GetDesc(&description); + + return es2dx::GetBlueSize(description.Format); + } +@@ -285,12 +285,12 @@ + return 0; + } + +-GLuint Colorbuffer::getAlphaSize() const ++GLuint Colorbuffer::getAlphaSize() + { +- if (mRenderTarget) ++ if (getRenderTarget()) + { + D3DSURFACE_DESC description; +- mRenderTarget->GetDesc(&description); ++ getRenderTarget()->GetDesc(&description); + + return es2dx::GetAlphaSize(description.Format); + } +Index: src/libGLESv2/Renderbuffer.h +=================================================================== +--- src/libGLESv2/Renderbuffer.h (revision 474) ++++ src/libGLESv2/Renderbuffer.h (working copy) +@@ -109,10 +109,10 @@ + + bool isColorbuffer() const; + +- GLuint getRedSize() const; +- GLuint getGreenSize() const; +- GLuint getBlueSize() const; +- GLuint getAlphaSize() const; ++ GLuint getRedSize(); ++ GLuint getGreenSize(); ++ GLuint getBlueSize(); ++ GLuint getAlphaSize(); + + IDirect3DSurface9 *getRenderTarget(); +
deleted file mode 100644 --- a/gfx/angle/angle-nspr.patch +++ /dev/null @@ -1,100 +0,0 @@ -Simple ossource implementation using NSPR - -diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h ---- a/gfx/angle/src/compiler/osinclude.h -+++ b/gfx/angle/src/compiler/osinclude.h -@@ -7,8 +7,14 @@ - #ifndef __OSINCLUDE_H - #define __OSINCLUDE_H - -+#ifdef ANGLE_USE_NSPR -+ -+#include "prthread.h" -+ -+#else -+ - // --// This file contains contains the window's specific datatypes and -+// This file contains contains windows specific datatypes and - // declares any windows specific functions. - // - -@@ -32,12 +38,17 @@ - #include <errno.h> - #endif // ANGLE_OS_WIN - -+#endif // ANGLE_USE_NSPR -+ - #include "compiler/debug.h" - - // - // Thread Local Storage Operations - // --#if defined(ANGLE_OS_WIN) -+#if defined(ANGLE_USE_NSPR) -+typedef PRUintn OS_TLSIndex; -+#define OS_INVALID_TLS_INDEX 0xFFFFFFFF -+#elif defined(ANGLE_OS_WIN) - typedef DWORD OS_TLSIndex; - #define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES) - #elif defined(ANGLE_OS_POSIX) -@@ -52,7 +63,9 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex) - inline void* OS_GetTLSValue(OS_TLSIndex nIndex) - { - assert(nIndex != OS_INVALID_TLS_INDEX); --#if defined(ANGLE_OS_WIN) -+#if defined(ANGLE_USE_NSPR) -+ return PR_GetThreadPrivate(nIndex); -+#elif defined(ANGLE_OS_WIN) - return TlsGetValue(nIndex); - #elif defined(ANGLE_OS_POSIX) - return pthread_getspecific(nIndex); -diff --git a/gfx/angle/src/compiler/ossource_nspr.cpp b/gfx/angle/src/compiler/ossource_nspr.cpp -new file mode 100644 ---- /dev/null -+++ b/gfx/angle/src/compiler/ossource_nspr.cpp -@@ -0,0 +1,44 @@ -+// -+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+// -+ -+// -+// This file contains the posix specific functions -+// -+#include "compiler/osinclude.h" -+ -+// -+// Thread Local Storage Operations -+// -+OS_TLSIndex OS_AllocTLSIndex() -+{ -+ PRUintn index; -+ PRStatus status = PR_NewThreadPrivateIndex(&index, NULL); -+ -+ if (status) { -+ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); -+ return OS_INVALID_TLS_INDEX; -+ } -+ -+ return index; -+} -+ -+ -+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) -+{ -+ if (nIndex == OS_INVALID_TLS_INDEX) { -+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); -+ return false; -+ } -+ -+ return PR_SetThreadPrivate(nIndex, lpvValue) == 0; -+} -+ -+ -+bool OS_FreeTLSIndex(OS_TLSIndex nIndex) -+{ -+ // Can't delete TLS keys with nspr -+ return true; -+}
--- a/gfx/angle/angle-shared.patch +++ b/gfx/angle/angle-shared.patch @@ -1,47 +1,51 @@ diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h --- a/gfx/angle/include/GLSLANG/ShaderLang.h +++ b/gfx/angle/include/GLSLANG/ShaderLang.h -@@ -1,16 +1,32 @@ +@@ -1,16 +1,36 @@ // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #ifndef _COMPILER_INTERFACE_INCLUDED_ #define _COMPILER_INTERFACE_INCLUDED_ ++#ifdef MOZILLA_VERSION +#include "nscore.h" + +#ifdef WIN32 +# if !defined(MOZ_ENABLE_LIBXUL) && !defined(MOZ_STATIC_BUILD) +# ifdef ANGLE_BUILD +# define ANGLE_API NS_EXPORT +# else +# define ANGLE_API NS_IMPORT +# endif +# else +# define ANGLE_API /*nothing*/ +# endif +#else +# define ANGLE_API NS_EXTERNAL_VIS +#endif ++#else ++#define ANGLE_API /*nothing*/ ++#endif + // // This is the platform independent interface between an OGL driver // and the shading language compiler. // #ifdef __cplusplus extern "C" { #endif -@@ -72,21 +88,21 @@ typedef enum { - SH_OBJECT_CODE = 0x002, - SH_ATTRIBUTES_UNIFORMS = 0x004 +@@ -73,21 +93,21 @@ typedef enum { + SH_OBJECT_CODE = 0x0004, + SH_ATTRIBUTES_UNIFORMS = 0x0008 } ShCompileOptions; // // Driver must call this first, once, before doing any other // compiler operations. // -int ShInitialize(); +ANGLE_API int ShInitialize(); @@ -53,17 +57,17 @@ diff --git a/gfx/angle/include/GLSLANG/S // // Implementation dependent built-in resources (constants and extensions). // The names for these resources has been obtained by stripping gl_/GL_. // typedef struct { // Constants. -@@ -102,17 +118,17 @@ typedef struct +@@ -103,17 +123,17 @@ typedef struct // Extensions. // Set to 1 to enable the extension, else 0. int OES_standard_derivatives; } ShBuiltInResources; // // Initialize built-in resources with minimum expected values. // @@ -72,17 +76,17 @@ diff --git a/gfx/angle/include/GLSLANG/S // // ShHandle held by but opaque to the driver. It is allocated, // managed, and de-allocated by the compiler. It's contents // are defined by and used by the compiler. // // If handle creation fails, 0 will be returned. // -@@ -122,19 +138,19 @@ typedef void* ShHandle; +@@ -123,19 +143,19 @@ typedef void* ShHandle; // Driver calls these to create and destroy compiler objects. // // Returns the handle of constructed compiler. // Parameters: // type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER. // spec: Specifies the language spec the compiler must conform to - // SH_GLES2_SPEC or SH_WEBGL_SPEC. // resources: Specifies the built-in resources. @@ -94,17 +98,17 @@ diff --git a/gfx/angle/include/GLSLANG/S // // Compiles the given shader source. // If the function succeeds, the return value is nonzero, else zero. // Parameters: // handle: Specifies the handle of compiler to be used. // shaderStrings: Specifies an array of pointers to null-terminated strings // containing the shader source code. -@@ -144,17 +160,17 @@ void ShDestruct(ShHandle handle); +@@ -152,17 +172,17 @@ void ShDestruct(ShHandle handle); // SH_INTERMEDIATE_TREE: Writes intermediate tree to info log. // Can be queried by calling ShGetInfoLog(). // SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. // Can be queried by calling ShGetObjectCode(). // SH_ATTRIBUTES_UNIFORMS: Extracts attributes and uniforms. // Can be queried by calling ShGetActiveAttrib() and // ShGetActiveUniform(). // @@ -113,17 +117,17 @@ diff --git a/gfx/angle/include/GLSLANG/S const ShHandle handle, const char* const shaderStrings[], const int numStrings, int compileOptions ); // Returns a parameter from a compiled shader. // Parameters: -@@ -170,53 +186,53 @@ int ShCompile( +@@ -178,53 +198,53 @@ int ShCompile( // variable name including the null // termination character. // SH_ACTIVE_UNIFORMS: the number of active uniform variables. // SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform // variable name including the null // termination character. // // params: Requested parameter @@ -171,17 +175,17 @@ diff --git a/gfx/angle/include/GLSLANG/S int index, int* length, int* size, ShDataType* type, char* name); // Returns information about an active uniform variable. // Parameters: -@@ -227,17 +243,17 @@ void ShGetActiveAttrib(const ShHandle ha +@@ -235,17 +255,17 @@ void ShGetActiveAttrib(const ShHandle ha // other than NULL is passed. // size: Returns the size of the uniform variable. // type: Returns the data type of the uniform variable. // name: Returns a null terminated string containing the name of the // uniform variable. It is assumed that name has enough memory to // accomodate the uniform variable name. The size of the buffer required // to store the uniform variable name can be obtained by calling // ShGetInfo with SH_ACTIVE_UNIFORMS_MAX_LENGTH. @@ -190,47 +194,8 @@ diff --git a/gfx/angle/include/GLSLANG/S int index, int* length, int* size, ShDataType* type, char* name); #ifdef __cplusplus } -diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h ---- a/gfx/angle/include/GLSLANG/ShaderLang.h -+++ b/gfx/angle/include/GLSLANG/ShaderLang.h -@@ -1,31 +1,35 @@ - // - // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - // - #ifndef _COMPILER_INTERFACE_INCLUDED_ - #define _COMPILER_INTERFACE_INCLUDED_ - -+#ifdef MOZILLA_VERSION - #include "nscore.h" - - #ifdef WIN32 - # if !defined(MOZ_ENABLE_LIBXUL) && !defined(MOZ_STATIC_BUILD) - # ifdef ANGLE_BUILD - # define ANGLE_API NS_EXPORT - # else - # define ANGLE_API NS_IMPORT - # endif - # else - # define ANGLE_API /*nothing*/ - # endif - #else - # define ANGLE_API NS_EXTERNAL_VIS - #endif -+#else -+#define ANGLE_API /*nothing*/ -+#endif - - // - // This is the platform independent interface between an OGL driver - // and the shading language compiler. - // - - #ifdef __cplusplus - extern "C" {
deleted file mode 100644 --- a/gfx/angle/fix-compile.patch +++ /dev/null @@ -1,45 +0,0 @@ - -# HG changeset patch -# User Robert Sayre <sayrer@gmail.com> -# Date 1280559674 25200 -# Node ID bb4a143ee814097076640c37df84ef7f1303b63b -# Parent 9e08308ca8cb9d4584ff990f441f363f3d81bd57 -Fix ShaderLang.h bustage. Commas at the end of enum lists. - -diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h ---- a/gfx/angle/include/GLSLANG/ShaderLang.h -+++ b/gfx/angle/include/GLSLANG/ShaderLang.h -@@ -47,7 +47,7 @@ ANGLE_API int ShFinalize(); - typedef enum { - EShLangVertex, - EShLangFragment, -- EShLangCount, -+ EShLangCount - } EShLanguage; - - // -@@ -56,7 +56,7 @@ typedef enum { - // - typedef enum { - EShSpecGLES2, -- EShSpecWebGL, -+ EShSpecWebGL - } EShSpec; - - // -@@ -66,12 +66,12 @@ typedef enum { - EShOptNoGeneration, - EShOptNone, - EShOptSimple, // Optimizations that can be done quickly -- EShOptFull, // Optimizations that will take more time -+ EShOptFull // Optimizations that will take more time - } EShOptimizationLevel; - - enum TDebugOptions { - EDebugOpNone = 0x000, -- EDebugOpIntermediate = 0x001, // Writes intermediate tree into info-log. -+ EDebugOpIntermediate = 0x001 // Writes intermediate tree into info-log. - }; - - // -
deleted file mode 100644 --- a/gfx/angle/generated/glslang.cpp +++ /dev/null @@ -1,2793 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include <stdio.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_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 *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 YY_USES_REJECT - -#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 int yylineno; -int yylineno = 1; -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 142 -#define YY_END_OF_BUFFER 143 -static yyconst short int yy_acclist[581] = - { 0, - 143, 141, 142, 140, 141, 142, 140, 142, 125, 141, - 142, 131, 141, 142, 136, 141, 142, 120, 141, 142, - 121, 141, 142, 129, 141, 142, 128, 141, 142, 117, - 141, 142, 126, 141, 142, 124, 141, 142, 130, 141, - 142, 88, 141, 142, 88, 141, 142, 118, 141, 142, - 114, 141, 142, 132, 141, 142, 119, 141, 142, 133, - 141, 142, 137, 141, 142, 84, 141, 142, 122, 141, - 142, 123, 141, 142, 135, 141, 142, 84, 141, 142, - 84, 141, 142, 84, 141, 142, 84, 141, 142, 84, - 141, 142, 84, 141, 142, 84, 141, 142, 84, 141, - - 142, 84, 141, 142, 84, 141, 142, 84, 141, 142, - 84, 141, 142, 84, 141, 142, 84, 141, 142, 84, - 141, 142, 84, 141, 142, 84, 141, 142, 84, 141, - 142, 84, 141, 142, 84, 141, 142, 115, 141, 142, - 134, 141, 142, 116, 141, 142, 127, 141, 142, 139, - 141, 142, 142, 141, 142, 138, 141, 142, 111, 97, - 116, 105, 100, 95, 103, 93, 104, 94, 91, 92, - 96, 90, 86, 87, 88, 87, 88, 88, 123, 115, - 122, 112, 108, 110, 109, 113, 84, 101, 107, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 13, - - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 16, 84, 18, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 102, 106, 138, 1, 90, 89, - 85, 98, 99, 44, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 14, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 22, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 19, 84, 84, 84, 84, 84, 84, 84, - - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 91, 90, 84, 24, - 84, 84, 84, 81, 84, 84, 84, 84, 84, 84, - 84, 84, 17, 84, 47, 84, 84, 84, 84, 84, - 84, 52, 84, 66, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 63, 84, 5, 84, 29, 84, 30, - 84, 31, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 50, 84, - 25, 84, 84, 84, 84, 84, 84, 84, 32, 84, - 33, 84, 34, 84, 23, 84, 84, 84, 84, 11, - - 84, 38, 84, 39, 84, 40, 84, 45, 84, 8, - 84, 84, 84, 84, 84, 77, 84, 78, 84, 79, - 84, 84, 26, 84, 67, 84, 21, 84, 74, 84, - 75, 84, 76, 84, 3, 84, 71, 84, 72, 84, - 73, 84, 84, 20, 84, 69, 84, 84, 84, 35, - 84, 36, 84, 37, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 64, 84, 84, 84, 84, 84, - 84, 84, 84, 46, 84, 84, 83, 84, 84, 84, - 15, 84, 84, 84, 84, 84, 65, 84, 60, 84, - 55, 84, 84, 84, 84, 84, 84, 70, 84, 51, - - 84, 84, 58, 84, 28, 84, 84, 80, 84, 59, - 84, 43, 84, 53, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 54, 84, 27, 84, 84, 84, 84, - 4, 84, 84, 84, 84, 84, 84, 48, 84, 9, - 84, 84, 10, 84, 84, 84, 12, 84, 61, 84, - 84, 84, 84, 56, 84, 84, 84, 84, 49, 84, - 68, 84, 57, 84, 7, 84, 62, 84, 2, 84, - 82, 84, 6, 84, 41, 84, 84, 84, 42, 84 - } ; - -static yyconst short int yy_accept[408] = - { 0, - 1, 1, 1, 1, 1, 2, 4, 7, 9, 12, - 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, - 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, - 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, - 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, - 135, 138, 141, 144, 147, 150, 153, 154, 156, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, - 170, 171, 171, 172, 173, 176, 178, 178, 178, 179, - 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - - 200, 202, 203, 204, 205, 206, 207, 208, 209, 210, - 211, 212, 213, 214, 215, 217, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, - 243, 244, 245, 246, 247, 248, 248, 248, 249, 250, - 250, 250, 251, 252, 253, 254, 256, 257, 258, 259, - 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 275, 276, 277, 278, 279, 280, - 281, 282, 283, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 295, 296, 297, 298, 299, 300, 301, 302, - - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 317, 318, 318, 319, 320, - 322, 323, 324, 326, 327, 328, 329, 330, 331, 332, - 333, 335, 337, 338, 339, 340, 341, 342, 344, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 356, 358, - 360, 362, 364, 365, 366, 367, 368, 369, 370, 371, - 372, 373, 374, 375, 376, 377, 378, 379, 381, 383, - 384, 385, 386, 387, 388, 389, 391, 393, 395, 397, - 398, 399, 400, 402, 404, 406, 408, 410, 412, 413, - 414, 415, 416, 418, 420, 422, 423, 425, 427, 429, - - 431, 433, 435, 437, 439, 441, 443, 444, 446, 448, - 449, 450, 452, 454, 456, 457, 458, 459, 460, 461, - 462, 463, 464, 465, 467, 468, 469, 470, 471, 472, - 473, 474, 476, 477, 479, 480, 481, 483, 484, 485, - 486, 487, 489, 491, 493, 494, 495, 496, 497, 498, - 500, 502, 503, 505, 507, 508, 510, 512, 514, 516, - 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, - 529, 530, 531, 533, 534, 535, 536, 537, 538, 540, - 542, 543, 545, 546, 547, 549, 551, 552, 553, 554, - 556, 557, 558, 559, 561, 563, 565, 567, 569, 571, - - 573, 575, 577, 578, 579, 581, 581 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 1, 1, 1, 5, 6, 1, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 16, 16, 16, 20, 20, 21, 22, 23, - 24, 25, 26, 1, 27, 27, 28, 29, 30, 27, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, - 33, 1, 34, 35, 31, 1, 36, 37, 38, 39, - - 40, 41, 42, 43, 44, 31, 45, 46, 47, 48, - 49, 50, 31, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 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[64] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 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[411] = - { 0, - 0, 0, 63, 0, 600, 601, 601, 601, 575, 103, - 123, 601, 601, 574, 120, 601, 119, 117, 131, 143, - 151, 572, 601, 169, 572, 114, 601, 0, 601, 601, - 117, 96, 102, 136, 140, 130, 150, 546, 110, 156, - 545, 162, 152, 539, 167, 552, 170, 169, 167, 188, - 548, 601, 118, 601, 601, 601, 601, 576, 0, 601, - 601, 601, 601, 601, 601, 601, 601, 601, 601, 214, - 601, 586, 601, 223, 232, 251, 267, 0, 277, 601, - 601, 601, 564, 601, 601, 601, 563, 0, 601, 601, - 539, 532, 535, 543, 542, 529, 544, 531, 537, 525, - - 522, 535, 522, 519, 519, 525, 513, 520, 517, 527, - 513, 519, 522, 523, 0, 253, 522, 160, 508, 521, - 512, 514, 504, 518, 515, 517, 500, 505, 502, 491, - 171, 505, 501, 503, 492, 495, 173, 500, 492, 504, - 211, 497, 601, 601, 0, 303, 537, 601, 309, 325, - 335, 341, 0, 601, 601, 0, 488, 492, 501, 498, - 482, 482, 183, 497, 494, 494, 492, 489, 481, 487, - 474, 485, 488, 0, 485, 473, 480, 477, 481, 474, - 463, 462, 475, 478, 475, 470, 461, 241, 466, 469, - 460, 457, 461, 467, 458, 449, 452, 450, 460, 446, - - 444, 444, 446, 443, 454, 453, 224, 448, 443, 432, - 257, 450, 452, 441, 347, 353, 359, 365, 442, 0, - 440, 292, 0, 432, 430, 438, 427, 444, 433, 313, - 0, 0, 427, 437, 437, 422, 329, 0, 0, 424, - 369, 425, 419, 418, 419, 418, 372, 0, 0, 0, - 0, 0, 414, 415, 420, 411, 424, 419, 418, 410, - 414, 406, 409, 413, 418, 417, 408, 0, 0, 414, - 403, 403, 408, 407, 404, 0, 0, 0, 0, 394, - 406, 408, 0, 0, 0, 0, 0, 0, 396, 397, - 391, 401, 0, 0, 0, 392, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 399, 0, 0, 397, - 393, 0, 0, 0, 389, 385, 390, 380, 393, 379, - 392, 381, 388, 0, 386, 388, 372, 381, 387, 382, - 370, 0, 372, 0, 371, 374, 0, 363, 362, 362, - 375, 0, 377, 0, 376, 375, 360, 373, 360, 0, - 0, 363, 0, 0, 355, 0, 0, 0, 0, 352, - 363, 356, 362, 359, 354, 346, 298, 0, 0, 290, - 296, 285, 0, 278, 274, 263, 261, 265, 0, 0, - 265, 0, 261, 260, 0, 0, 258, 235, 240, 0, - 213, 227, 192, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 173, 137, 0, 601, 390, 392, 395, 148 - } ; - -static yyconst short int yy_def[411] = - { 0, - 406, 1, 406, 3, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 407, 406, 406, - 406, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 406, 406, 406, 406, 406, 406, 406, 408, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 409, 406, 406, 406, 406, 406, 410, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 407, 406, 406, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 406, 406, 408, 406, 409, 406, 406, 406, - 406, 406, 410, 406, 406, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 406, 406, 406, 406, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 0, 406, 406, 406, 406 - } ; - -static yyconst short int yy_nxt[665] = - { 0, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 21, 21, 21, 21, - 22, 23, 24, 25, 26, 27, 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, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 58, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 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, 86, 87, 71, - 89, 143, 69, 67, 72, 112, 64, 91, 92, 153, - 93, 90, 94, 113, 73, 74, 95, 75, 75, 75, - 75, 75, 76, 74, 114, 79, 79, 79, 79, 79, - 79, 96, 77, 81, 78, 103, 405, 104, 144, 99, - 77, 97, 77, 100, 98, 106, 105, 121, 101, 82, - 77, 83, 84, 107, 102, 108, 115, 119, 109, 78, - - 122, 120, 124, 116, 110, 128, 200, 186, 133, 404, - 117, 134, 129, 130, 137, 187, 207, 125, 138, 135, - 126, 201, 131, 139, 208, 132, 136, 140, 70, 70, - 70, 70, 70, 70, 225, 226, 141, 149, 149, 149, - 149, 149, 149, 146, 74, 403, 75, 75, 75, 75, - 75, 76, 150, 146, 212, 402, 213, 250, 251, 252, - 401, 77, 150, 74, 271, 76, 76, 76, 76, 76, - 76, 77, 272, 276, 277, 278, 151, 392, 151, 400, - 77, 152, 152, 152, 152, 152, 152, 399, 393, 74, - 77, 79, 79, 79, 79, 79, 79, 398, 180, 397, - - 396, 181, 182, 395, 394, 183, 77, 184, 284, 285, - 286, 391, 215, 390, 215, 389, 77, 216, 216, 216, - 216, 216, 216, 149, 149, 149, 149, 149, 149, 293, - 294, 295, 388, 387, 217, 386, 217, 385, 150, 218, - 218, 218, 218, 218, 218, 300, 301, 302, 150, 152, - 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 216, 216, 216, 216, 216, 216, 216, 216, 216, - 216, 216, 216, 218, 218, 218, 218, 218, 218, 218, - 218, 218, 218, 218, 218, 304, 305, 306, 312, 313, - 314, 88, 88, 145, 145, 147, 147, 147, 384, 383, - - 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, - 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, - 362, 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, 336, 335, 334, 333, - 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, - 322, 321, 320, 319, 318, 317, 316, 315, 311, 310, - 309, 308, 307, 303, 299, 298, 297, 296, 292, 291, - 290, 289, 288, 287, 283, 282, 281, 280, 279, 275, - 274, 273, 270, 269, 268, 267, 266, 265, 264, 263, - - 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, - 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, - 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, - 229, 228, 227, 224, 223, 222, 221, 220, 219, 148, - 214, 211, 210, 209, 206, 205, 204, 203, 202, 199, - 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, - 188, 185, 179, 178, 177, 176, 175, 174, 173, 172, - 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, - 161, 160, 159, 158, 157, 156, 155, 154, 148, 72, - 142, 127, 123, 118, 111, 85, 80, 65, 60, 406, - - 5, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406 - } ; - -static yyconst short int yy_chk[665] = - { 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, 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, 26, 26, 19, - 31, 53, 17, 15, 19, 39, 11, 32, 32, 410, - 33, 31, 33, 39, 19, 20, 33, 20, 20, 20, - 20, 20, 20, 21, 39, 21, 21, 21, 21, 21, - 21, 34, 20, 24, 20, 36, 404, 36, 53, 35, - 21, 34, 20, 35, 34, 37, 36, 43, 35, 24, - 21, 24, 24, 37, 35, 37, 40, 42, 37, 20, - - 43, 42, 45, 40, 37, 47, 131, 118, 48, 403, - 40, 48, 47, 47, 49, 118, 137, 45, 49, 48, - 45, 131, 47, 50, 137, 47, 48, 50, 70, 70, - 70, 70, 70, 70, 163, 163, 50, 74, 74, 74, - 74, 74, 74, 70, 75, 393, 75, 75, 75, 75, - 75, 75, 74, 70, 141, 392, 141, 188, 188, 188, - 391, 75, 74, 76, 207, 76, 76, 76, 76, 76, - 76, 75, 207, 211, 211, 211, 77, 377, 77, 389, - 76, 77, 77, 77, 77, 77, 77, 388, 377, 79, - 76, 79, 79, 79, 79, 79, 79, 387, 116, 384, - - 383, 116, 116, 381, 378, 116, 79, 116, 222, 222, - 222, 376, 146, 375, 146, 374, 79, 146, 146, 146, - 146, 146, 146, 149, 149, 149, 149, 149, 149, 230, - 230, 230, 372, 371, 150, 370, 150, 367, 149, 150, - 150, 150, 150, 150, 150, 237, 237, 237, 149, 151, - 151, 151, 151, 151, 151, 152, 152, 152, 152, 152, - 152, 215, 215, 215, 215, 215, 215, 216, 216, 216, - 216, 216, 216, 217, 217, 217, 217, 217, 217, 218, - 218, 218, 218, 218, 218, 241, 241, 241, 247, 247, - 247, 407, 407, 408, 408, 409, 409, 409, 366, 365, - - 364, 363, 362, 361, 360, 355, 352, 349, 348, 347, - 346, 345, 343, 341, 340, 339, 338, 336, 335, 333, - 331, 330, 329, 328, 327, 326, 325, 323, 322, 321, - 320, 319, 318, 317, 316, 315, 311, 310, 307, 296, - 292, 291, 290, 289, 282, 281, 280, 275, 274, 273, - 272, 271, 270, 267, 266, 265, 264, 263, 262, 261, - 260, 259, 258, 257, 256, 255, 254, 253, 246, 245, - 244, 243, 242, 240, 236, 235, 234, 233, 229, 228, - 227, 226, 225, 224, 221, 219, 214, 213, 212, 210, - 209, 208, 206, 205, 204, 203, 202, 201, 200, 199, - - 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, - 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, - 177, 176, 175, 173, 172, 171, 170, 169, 168, 167, - 166, 165, 164, 162, 161, 160, 159, 158, 157, 147, - 142, 140, 139, 138, 136, 135, 134, 133, 132, 130, - 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, - 119, 117, 114, 113, 112, 111, 110, 109, 108, 107, - 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, - 96, 95, 94, 93, 92, 91, 87, 83, 72, 58, - 51, 46, 44, 41, 38, 25, 22, 14, 9, 5, - - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406 - } ; - -static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; -static char *yy_full_match; -static int yy_lp; -#define REJECT \ -{ \ -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yy_full_match; /* restore poss. backed-over text */ \ -++yy_lp; \ -goto find_rule; \ -} -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -char *yytext; -#define INITIAL 0 -/* -// -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -*/ -/* Based on -ANSI C grammar, Lex specification - -In 1985, Jeff Lee published this Lex specification together with a Yacc -grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted -both 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 -*/ -#define YY_NO_UNPUT 1 -#include <stdio.h> -#include <stdlib.h> - -#include "compiler/ParseHelper.h" -#include "glslang_tab.h" - -/* windows only pragma */ -#ifdef _MSC_VER -#pragma warning(disable : 4102) -#endif - -int yy_input(char* buf, int max_size); - -extern int yyparse(void*); -#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) -#define parseContext (*((TParseContext*)(parseContextLocal))) - -#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size)) - -/* -TODO(alokp): yylineno is only here to support old flex.exe in compiler/tools. -Remove it when we can exclusively use the newer version. -*/ -#define YY_NEVER_INTERACTIVE 1 -#define FIELDS 1 - - -/* 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 - -#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; - - - - 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_state_ptr = yy_state_buf; - *yy_state_ptr++ = yy_current_state; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*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 >= 407 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yy_state_ptr++ = yy_current_state; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 601 ); - -yy_find_action: - yy_current_state = *--yy_state_ptr; - yy_lp = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[yy_lp]; - { - yy_full_match = yy_cp; - break; - } - } - --yy_cp; - yy_current_state = *--yy_state_ptr; - yy_lp = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - if ( yy_act != YY_END_OF_BUFFER ) - { - int yyl; - for ( yyl = 0; yyl < yyleng; ++yyl ) - if ( yytext[yyl] == '\n' ) - ++yylineno; - } - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -YY_RULE_SETUP -{ /* ?? carriage and/or line-feed? */ }; - YY_BREAK -case 2: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(INVARIANT); } - YY_BREAK -case 3: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(HIGH_PRECISION); } - YY_BREAK -case 4: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); } - YY_BREAK -case 5: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LOW_PRECISION); } - YY_BREAK -case 6: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(PRECISION); } - YY_BREAK -case 7: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(ATTRIBUTE); } - YY_BREAK -case 8: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(CONST_QUAL); } - YY_BREAK -case 9: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(UNIFORM); } - YY_BREAK -case 10: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(VARYING); } - YY_BREAK -case 11: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(BREAK); } - YY_BREAK -case 12: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(CONTINUE); } - YY_BREAK -case 13: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(DO); } - YY_BREAK -case 14: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(FOR); } - YY_BREAK -case 15: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(WHILE); } - YY_BREAK -case 16: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(IF); } - YY_BREAK -case 17: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(ELSE); } - YY_BREAK -case 18: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(IN_QUAL); } - YY_BREAK -case 19: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(OUT_QUAL); } - YY_BREAK -case 20: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(INOUT_QUAL); } - YY_BREAK -case 21: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); } - YY_BREAK -case 22: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); } - YY_BREAK -case 23: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); } - YY_BREAK -case 24: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); } - YY_BREAK -case 25: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); } - YY_BREAK -case 26: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); } - YY_BREAK -case 27: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(DISCARD); } - YY_BREAK -case 28: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RETURN); } - YY_BREAK -case 29: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); } - YY_BREAK -case 30: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); } - YY_BREAK -case 31: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); } - YY_BREAK -case 32: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); } - YY_BREAK -case 33: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); } - YY_BREAK -case 34: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); } - YY_BREAK -case 35: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); } - YY_BREAK -case 36: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); } - YY_BREAK -case 37: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); } - YY_BREAK -case 38: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); } - YY_BREAK -case 39: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); } - YY_BREAK -case 40: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); } - YY_BREAK -case 41: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; } - YY_BREAK -case 42: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; } - YY_BREAK -case 43: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(STRUCT); } - YY_BREAK -case 44: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 45: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 46: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 47: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 48: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 49: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 50: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 51: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 52: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 53: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 54: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 55: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 56: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 57: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 58: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 59: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 60: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 61: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 62: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 63: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 64: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 65: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 66: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 67: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 68: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 69: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 70: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 71: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 72: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 73: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 74: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 75: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 76: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 77: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 78: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 79: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 80: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 81: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 82: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 83: -YY_RULE_SETUP -{ PaReservedWord(); return 0; } - YY_BREAK -case 84: -YY_RULE_SETUP -{ - pyylval->lex.line = yylineno; - pyylval->lex.string = NewPoolTString(yytext); - return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); -} - YY_BREAK -case 85: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } - YY_BREAK -case 86: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } - YY_BREAK -case 87: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;} - YY_BREAK -case 88: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } - YY_BREAK -case 89: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } - YY_BREAK -case 90: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } - YY_BREAK -case 91: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } - YY_BREAK -case 92: -YY_RULE_SETUP -{ int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; } - YY_BREAK -case 93: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(ADD_ASSIGN); } - YY_BREAK -case 94: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(SUB_ASSIGN); } - YY_BREAK -case 95: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(MUL_ASSIGN); } - YY_BREAK -case 96: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(DIV_ASSIGN); } - YY_BREAK -case 97: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(MOD_ASSIGN); } - YY_BREAK -case 98: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LEFT_ASSIGN); } - YY_BREAK -case 99: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); } - YY_BREAK -case 100: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(AND_ASSIGN); } - YY_BREAK -case 101: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(XOR_ASSIGN); } - YY_BREAK -case 102: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(OR_ASSIGN); } - YY_BREAK -case 103: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(INC_OP); } - YY_BREAK -case 104: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(DEC_OP); } - YY_BREAK -case 105: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(AND_OP); } - YY_BREAK -case 106: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(OR_OP); } - YY_BREAK -case 107: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(XOR_OP); } - YY_BREAK -case 108: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LE_OP); } - YY_BREAK -case 109: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(GE_OP); } - YY_BREAK -case 110: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(EQ_OP); } - YY_BREAK -case 111: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(NE_OP); } - YY_BREAK -case 112: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LEFT_OP); } - YY_BREAK -case 113: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RIGHT_OP); } - YY_BREAK -case 114: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); } - YY_BREAK -case 115: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); } - YY_BREAK -case 116: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RIGHT_BRACE); } - YY_BREAK -case 117: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); } - YY_BREAK -case 118: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(COLON); } - YY_BREAK -case 119: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); } - YY_BREAK -case 120: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); } - YY_BREAK -case 121: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); } - YY_BREAK -case 122: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LEFT_BRACKET); } - YY_BREAK -case 123: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RIGHT_BRACKET); } - YY_BREAK -case 124: -YY_RULE_SETUP -{ BEGIN(FIELDS); return(DOT); } - YY_BREAK -case 125: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(BANG); } - YY_BREAK -case 126: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(DASH); } - YY_BREAK -case 127: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(TILDE); } - YY_BREAK -case 128: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(PLUS); } - YY_BREAK -case 129: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(STAR); } - YY_BREAK -case 130: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(SLASH); } - YY_BREAK -case 131: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(PERCENT); } - YY_BREAK -case 132: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(LEFT_ANGLE); } - YY_BREAK -case 133: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(RIGHT_ANGLE); } - YY_BREAK -case 134: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(VERTICAL_BAR); } - YY_BREAK -case 135: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(CARET); } - YY_BREAK -case 136: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(AMPERSAND); } - YY_BREAK -case 137: -YY_RULE_SETUP -{ pyylval->lex.line = yylineno; return(QUESTION); } - YY_BREAK -case 138: -YY_RULE_SETUP -{ -BEGIN(INITIAL); - pyylval->lex.line = yylineno; - pyylval->lex.string = NewPoolTString(yytext); - return FIELD_SELECTION; } - YY_BREAK -case 139: -YY_RULE_SETUP -{} - YY_BREAK -case 140: -YY_RULE_SETUP -{ } - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(FIELDS): -{ (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();} - YY_BREAK -case 141: -YY_RULE_SETUP -{ parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n"; - return 0; } - YY_BREAK -case 142: -YY_RULE_SETUP -ECHO; - YY_BREAK - - 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; - - 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 singled characater, 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_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 ); - } - - 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; - yy_state_ptr = yy_state_buf; - *yy_state_ptr++ = yy_current_state; - - 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); - 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 >= 407 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yy_state_ptr++ = yy_current_state; - } - - 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 YY_CHAR yy_c = 1; - 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 >= 407 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yy_state_ptr++ = yy_current_state; - yy_is_jam = (yy_current_state == 406); - - 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_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; - - if ( c == '\n' ) - --yylineno; - - 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 */ - yytext_ptr = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; - 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 + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif - } - } - } - - 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; - - if ( c == '\n' ) - ++yylineno; - - 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 ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#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 - - { - 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 *str ) -#else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; -#endif - { - int len; - for ( len = 0; str[len]; ++len ) - ; - - return yy_scan_bytes( 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_MORE_ADJ; \ - 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_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 - - - -//Including Pre-processor. -extern "C" { - #include "compiler/preprocessor/preprocess.h" -} - -// -// The YY_INPUT macro just calls this. Maybe this could be just put into -// the macro directly. -// - -int yy_input(char* buf, int max_size) -{ - int len; - - if ((len = yylex_CPP(buf, max_size)) == 0) - return 0; - if (len >= max_size) - YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - buf[len] = ' '; - return len+1; -} - - -// -// Parse an array of strings using yyparse. We set up globals used by -// yywrap. -// -// Returns 0 for success, as per yyparse(). -// -int PaParseStrings(const char* const argv[], const int strLen[], int argc, TParseContext& parseContextLocal) -{ - int argv0len; - - ScanFromString(argv[0]); - - //Storing the Current Compiler Parse context into the cpp structure. - cpp->pC = (void*)&parseContextLocal; - - if (!argv || argc == 0) - return 1; - - for (int i = 0; i < argc; ++i) { - if (!argv[i]) { - parseContextLocal.error(0, "Null shader source string", "", ""); - parseContextLocal.recover(); - return 1; - } - } - - if (!strLen) { - argv0len = (int) strlen(argv[0]); - strLen = &argv0len; - } - yyrestart(0); - (&parseContextLocal)->AfterEOF = false; - cpp->PaWhichStr = 0; - cpp->PaArgv = argv; - cpp->PaArgc = argc; - cpp->PaStrLen = strLen; - cpp->pastFirstStatement = 0; - yylineno = 1; - - if (*cpp->PaStrLen >= 0) { - int ret = yyparse((void*)(&parseContextLocal)); - if (ret || cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0) - return 1; - else - return 0; - } - else - return 0; -} - -void yyerror(const char *s) -{ - if (((TParseContext *)cpp->pC)->AfterEOF) { - if (cpp->tokensBeforeEOF == 1) { - GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, ""); - GlobalParseContext->recover(); - } - } else { - GlobalParseContext->error(yylineno, "syntax error", yytext, s, ""); - GlobalParseContext->recover(); - } -} - -void PaReservedWord() -{ - GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", ""); - GlobalParseContext->recover(); -} - -int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol) -{ - symbol = parseContextLocal.symbolTable.find(id); - if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) { - TVariable* variable = static_cast<TVariable*>(symbol); - if (variable->isUserType()) { - parseContextLocal.lexAfterType = true; - return TYPE_NAME; - } - } - - return IDENTIFIER; -} - -int PaParseComment(int &lineno, TParseContext& parseContextLocal) -{ - int transitionFlag = 0; - int nextChar; - - while (transitionFlag != 2) { - nextChar = yyinput(); - if (nextChar == '\n') - lineno++; - switch (nextChar) { - case '*' : - transitionFlag = 1; - break; - case '/' : /* if star is the previous character, then it is the end of comment */ - if (transitionFlag == 1) { - return 1 ; - } - break; - case EOF : - /* Raise error message here */ - parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", ""); - GlobalParseContext->recover(); - return YY_NULL; - default : /* Any other character will be a part of the comment */ - transitionFlag = 0; - } - } - return 1; -} - -extern "C" { - -void CPPDebugLogMsg(const char *msg) -{ - ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg); -} - -void CPPWarningToInfoLog(const char *msg) -{ - ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); -} - -void CPPShInfoLogMsg(const char *msg) -{ - ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,""); - GlobalParseContext->recover(); -} - -void CPPErrorToInfoLog(char *msg) -{ - ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,""); - GlobalParseContext->recover(); -} - -void SetLineNumber(int line) -{ - yylineno &= ~SourceLocLineMask; - yylineno |= line; -} - -void SetStringNumber(int string) -{ - yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask); -} - -int GetStringNumber(void) -{ - return yylineno >> 16; -} - -int GetLineNumber(void) -{ - return yylineno & SourceLocLineMask; -} - -void IncLineNumber(void) -{ - if ((yylineno & SourceLocLineMask) <= SourceLocLineMask) - ++yylineno; -} - -void DecLineNumber(void) -{ - if ((yylineno & SourceLocLineMask) > 0) - --yylineno; -} - -void HandlePragma(const char **tokens, int numTokens) -{ - if (!strcmp(tokens[0], "optimize")) { - if (numTokens != 4) { - CPPShInfoLogMsg("optimize pragma syntax is incorrect"); - return; - } - - if (strcmp(tokens[1], "(")) { - CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword"); - return; - } - - if (!strcmp(tokens[2], "on")) - ((TParseContext *)cpp->pC)->contextPragma.optimize = true; - else if (!strcmp(tokens[2], "off")) - ((TParseContext *)cpp->pC)->contextPragma.optimize = false; - else { - CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma"); - return; - } - - if (strcmp(tokens[3], ")")) { - CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma"); - return; - } - } else if (!strcmp(tokens[0], "debug")) { - if (numTokens != 4) { - CPPShInfoLogMsg("debug pragma syntax is incorrect"); - return; - } - - if (strcmp(tokens[1], "(")) { - CPPShInfoLogMsg("\"(\" expected after 'debug' keyword"); - return; - } - - if (!strcmp(tokens[2], "on")) - ((TParseContext *)cpp->pC)->contextPragma.debug = true; - else if (!strcmp(tokens[2], "off")) - ((TParseContext *)cpp->pC)->contextPragma.debug = false; - else { - CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma"); - return; - } - - if (strcmp(tokens[3], ")")) { - CPPShInfoLogMsg("\")\" expected to end 'debug' pragma"); - return; - } - } else { - -#ifdef PRAGMA_TABLE - // - // implementation specific pragma - // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma - // For now, just ignore the pragma that the implementation cannot recognize - // An Example of one such implementation for a pragma that has a syntax like - // #pragma pragmaname(pragmavalue) - // This implementation stores the current pragmavalue against the pragma name in pragmaTable. - // - if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { - TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; - TPragmaTable::iterator iter; - iter = pragmaTable.find(TString(tokens[0])); - if (iter != pragmaTable.end()) { - iter->second = tokens[2]; - } else { - pragmaTable[ tokens[0] ] = tokens[2]; - } - } else if (numTokens >= 2) { - TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; - TPragmaTable::iterator iter; - iter = pragmaTable.find(TString(tokens[0])); - if (iter != pragmaTable.end()) { - iter->second = tokens[1]; - } else { - pragmaTable[ tokens[0] ] = tokens[1]; - } - } -#endif // PRAGMA_TABLE - } -} - -void StoreStr(char *string) -{ - TString strSrc; - strSrc = TString(string); - - ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc; -} - -const char* GetStrfromTStr(void) -{ - cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str(); - return cpp->ErrMsg; -} - -void ResetTString(void) -{ - ((TParseContext *)cpp->pC)->HashErrMsg = ""; -} - -TBehavior GetBehavior(const char* behavior) -{ - if (!strcmp("require", behavior)) - return EBhRequire; - else if (!strcmp("enable", behavior)) - return EBhEnable; - else if (!strcmp("disable", behavior)) - return EBhDisable; - else if (!strcmp("warn", behavior)) - return EBhWarn; - else { - CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str()); - return EBhDisable; - } -} - -void updateExtensionBehavior(const char* extName, const char* behavior) -{ - TBehavior behaviorVal = GetBehavior(behavior); - TMap<TString, TBehavior>:: iterator iter; - TString msg; - - // special cased for all extension - if (!strcmp(extName, "all")) { - if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) { - CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); - return; - } else { - for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter) - iter->second = behaviorVal; - } - } else { - iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName)); - if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) { - switch (behaviorVal) { - case EBhRequire: - CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); - break; - case EBhEnable: - case EBhWarn: - case EBhDisable: - msg = TString("extension '") + extName + "' is not supported"; - ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); - break; - } - return; - } else - iter->second = behaviorVal; - } -} - -} // extern "C" - -void setInitialState() -{ - yy_start = 1; -}
deleted file mode 100644 --- a/gfx/angle/generated/glslang_tab.cpp +++ /dev/null @@ -1,3509 +0,0 @@ - -/* A Bison parser, made from src/compiler/glslang.y with Bison version GNU Bison version 1.24 - */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define INVARIANT 258 -#define HIGH_PRECISION 259 -#define MEDIUM_PRECISION 260 -#define LOW_PRECISION 261 -#define PRECISION 262 -#define ATTRIBUTE 263 -#define CONST_QUAL 264 -#define BOOL_TYPE 265 -#define FLOAT_TYPE 266 -#define INT_TYPE 267 -#define BREAK 268 -#define CONTINUE 269 -#define DO 270 -#define ELSE 271 -#define FOR 272 -#define IF 273 -#define DISCARD 274 -#define RETURN 275 -#define BVEC2 276 -#define BVEC3 277 -#define BVEC4 278 -#define IVEC2 279 -#define IVEC3 280 -#define IVEC4 281 -#define VEC2 282 -#define VEC3 283 -#define VEC4 284 -#define MATRIX2 285 -#define MATRIX3 286 -#define MATRIX4 287 -#define IN_QUAL 288 -#define OUT_QUAL 289 -#define INOUT_QUAL 290 -#define UNIFORM 291 -#define VARYING 292 -#define STRUCT 293 -#define VOID_TYPE 294 -#define WHILE 295 -#define SAMPLER2D 296 -#define SAMPLERCUBE 297 -#define IDENTIFIER 298 -#define TYPE_NAME 299 -#define FLOATCONSTANT 300 -#define INTCONSTANT 301 -#define BOOLCONSTANT 302 -#define FIELD_SELECTION 303 -#define LEFT_OP 304 -#define RIGHT_OP 305 -#define INC_OP 306 -#define DEC_OP 307 -#define LE_OP 308 -#define GE_OP 309 -#define EQ_OP 310 -#define NE_OP 311 -#define AND_OP 312 -#define OR_OP 313 -#define XOR_OP 314 -#define MUL_ASSIGN 315 -#define DIV_ASSIGN 316 -#define ADD_ASSIGN 317 -#define MOD_ASSIGN 318 -#define LEFT_ASSIGN 319 -#define RIGHT_ASSIGN 320 -#define AND_ASSIGN 321 -#define XOR_ASSIGN 322 -#define OR_ASSIGN 323 -#define SUB_ASSIGN 324 -#define LEFT_PAREN 325 -#define RIGHT_PAREN 326 -#define LEFT_BRACKET 327 -#define RIGHT_BRACKET 328 -#define LEFT_BRACE 329 -#define RIGHT_BRACE 330 -#define DOT 331 -#define COMMA 332 -#define COLON 333 -#define EQUAL 334 -#define SEMICOLON 335 -#define BANG 336 -#define DASH 337 -#define TILDE 338 -#define PLUS 339 -#define STAR 340 -#define SLASH 341 -#define PERCENT 342 -#define LEFT_ANGLE 343 -#define RIGHT_ANGLE 344 -#define VERTICAL_BAR 345 -#define CARET 346 -#define AMPERSAND 347 -#define QUESTION 348 - - - -/* 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 "compiler/SymbolTable.h" -#include "compiler/ParseHelper.h" -#include "GLSLANG/ShaderLang.h" - -#define YYPARSE_PARAM parseContextLocal -/* -TODO(alokp): YYPARSE_PARAM_DECL is only here to support old bison.exe in -compiler/tools. Remove it when we can exclusively use the newer version. -*/ -#define YYPARSE_PARAM_DECL void* -#define parseContext ((TParseContext*)(parseContextLocal)) -#define YYLEX_PARAM parseContextLocal -#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) -extern void yyerror(const char*); - -#define FRAG_VERT_ONLY(S, L) { \ - if (parseContext->shaderType != SH_FRAGMENT_SHADER && \ - parseContext->shaderType != SH_VERTEX_SHADER) { \ - parseContext->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -#define VERTEX_ONLY(S, L) { \ - if (parseContext->shaderType != SH_VERTEX_SHADER) { \ - parseContext->error(L, " supported in vertex shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -#define FRAG_ONLY(S, L) { \ - if (parseContext->shaderType != SH_FRAGMENT_SHADER) { \ - parseContext->error(L, " supported in fragment shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -typedef union { - 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; - TPrecision precision; - TQualifier qualifier; - TFunction* function; - TParameter param; - TTypeLine typeLine; - TTypeList* typeList; - }; - } interm; -} YYSTYPE; - - extern int yylex(YYSTYPE*, void*); - -#ifndef YYLTYPE -typedef - struct yyltype - { - int timestamp; - int first_line; - int first_column; - int last_line; - int last_column; - char *text; - } - yyltype; - -#define YYLTYPE yyltype -#endif - -#include <stdio.h> - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 296 -#define YYFLAG -32768 -#define YYNTBASE 94 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 348 ? yytranslate[x] : 171) - -static const 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, 93 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 4, 6, 8, 10, 14, 16, 21, 23, - 27, 30, 33, 35, 37, 39, 43, 46, 49, 52, - 54, 57, 61, 64, 66, 68, 70, 72, 75, 78, - 81, 83, 85, 87, 89, 93, 97, 99, 103, 107, - 109, 111, 115, 119, 123, 127, 129, 133, 137, 139, - 141, 143, 145, 149, 151, 155, 157, 161, 163, 169, - 171, 175, 177, 179, 181, 183, 185, 187, 191, 193, - 196, 199, 204, 207, 209, 211, 214, 218, 222, 225, - 231, 235, 238, 242, 245, 246, 248, 250, 252, 254, - 256, 260, 266, 273, 279, 281, 284, 289, 295, 300, - 303, 305, 308, 310, 312, 314, 317, 319, 321, 324, - 326, 328, 330, 332, 337, 339, 341, 343, 345, 347, - 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, - 369, 371, 373, 375, 377, 383, 388, 390, 393, 397, - 399, 403, 405, 410, 412, 414, 416, 418, 420, 422, - 424, 426, 428, 431, 432, 433, 439, 441, 443, 446, - 450, 452, 455, 457, 460, 466, 470, 472, 474, 479, - 480, 487, 488, 497, 498, 506, 508, 510, 512, 513, - 516, 520, 523, 526, 529, 533, 536, 538, 541, 543, - 545, 546 -}; - -static const short yyrhs[] = { 43, - 0, 94, 0, 46, 0, 45, 0, 47, 0, 70, - 121, 71, 0, 95, 0, 96, 72, 97, 73, 0, - 98, 0, 96, 76, 48, 0, 96, 51, 0, 96, - 52, 0, 121, 0, 99, 0, 100, 0, 96, 76, - 100, 0, 102, 71, 0, 101, 71, 0, 103, 39, - 0, 103, 0, 103, 119, 0, 102, 77, 119, 0, - 104, 70, 0, 136, 0, 43, 0, 48, 0, 96, - 0, 51, 105, 0, 52, 105, 0, 106, 105, 0, - 84, 0, 82, 0, 81, 0, 105, 0, 107, 85, - 105, 0, 107, 86, 105, 0, 107, 0, 108, 84, - 107, 0, 108, 82, 107, 0, 108, 0, 109, 0, - 110, 88, 109, 0, 110, 89, 109, 0, 110, 53, - 109, 0, 110, 54, 109, 0, 110, 0, 111, 55, - 110, 0, 111, 56, 110, 0, 111, 0, 112, 0, - 113, 0, 114, 0, 115, 57, 114, 0, 115, 0, - 116, 59, 115, 0, 116, 0, 117, 58, 116, 0, - 117, 0, 117, 93, 121, 78, 119, 0, 118, 0, - 105, 120, 119, 0, 79, 0, 60, 0, 61, 0, - 62, 0, 69, 0, 119, 0, 121, 77, 119, 0, - 118, 0, 124, 80, 0, 132, 80, 0, 7, 137, - 138, 80, 0, 125, 71, 0, 127, 0, 126, 0, - 127, 129, 0, 126, 77, 129, 0, 134, 43, 70, - 0, 136, 43, 0, 136, 43, 72, 122, 73, 0, - 135, 130, 128, 0, 130, 128, 0, 135, 130, 131, - 0, 130, 131, 0, 0, 33, 0, 34, 0, 35, - 0, 136, 0, 133, 0, 132, 77, 43, 0, 132, - 77, 43, 72, 73, 0, 132, 77, 43, 72, 122, - 73, 0, 132, 77, 43, 79, 145, 0, 134, 0, - 134, 43, 0, 134, 43, 72, 73, 0, 134, 43, - 72, 122, 73, 0, 134, 43, 79, 145, 0, 3, - 43, 0, 136, 0, 135, 136, 0, 9, 0, 8, - 0, 37, 0, 3, 37, 0, 36, 0, 138, 0, - 137, 138, 0, 4, 0, 5, 0, 6, 0, 139, - 0, 139, 72, 122, 73, 0, 39, 0, 11, 0, - 12, 0, 10, 0, 27, 0, 28, 0, 29, 0, - 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, - 26, 0, 30, 0, 31, 0, 32, 0, 41, 0, - 42, 0, 140, 0, 44, 0, 38, 43, 74, 141, - 75, 0, 38, 74, 141, 75, 0, 142, 0, 141, - 142, 0, 136, 143, 80, 0, 144, 0, 143, 77, - 144, 0, 43, 0, 43, 72, 122, 73, 0, 119, - 0, 123, 0, 149, 0, 148, 0, 146, 0, 155, - 0, 156, 0, 159, 0, 166, 0, 74, 75, 0, - 0, 0, 74, 150, 154, 151, 75, 0, 153, 0, - 148, 0, 74, 75, 0, 74, 154, 75, 0, 147, - 0, 154, 147, 0, 80, 0, 121, 80, 0, 18, - 70, 121, 71, 157, 0, 147, 16, 147, 0, 147, - 0, 121, 0, 134, 43, 79, 145, 0, 0, 40, - 70, 160, 158, 71, 152, 0, 0, 15, 161, 147, - 40, 70, 121, 71, 80, 0, 0, 17, 70, 162, - 163, 165, 71, 152, 0, 155, 0, 146, 0, 158, - 0, 0, 164, 80, 0, 164, 80, 121, 0, 14, - 80, 0, 13, 80, 0, 20, 80, 0, 20, 121, - 80, 0, 19, 80, 0, 168, 0, 167, 168, 0, - 169, 0, 123, 0, 0, 124, 170, 153, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 161, 196, 199, 212, 217, 222, 228, 231, 304, 307, - 416, 426, 439, 447, 546, 549, 557, 561, 568, 572, - 579, 585, 594, 602, 664, 671, 681, 684, 694, 704, - 725, 726, 727, 732, 733, 742, 754, 755, 763, 774, - 778, 779, 789, 799, 809, 822, 823, 833, 846, 850, - 854, 858, 859, 872, 873, 886, 887, 900, 901, 918, - 919, 932, 933, 934, 935, 936, 940, 943, 954, 962, - 987, 992, 999, 1035, 1038, 1045, 1053, 1074, 1093, 1104, - 1133, 1138, 1148, 1153, 1163, 1166, 1169, 1172, 1178, 1185, - 1195, 1207, 1225, 1249, 1272, 1276, 1290, 1310, 1339, 1359, - 1435, 1444, 1467, 1470, 1476, 1484, 1492, 1500, 1503, 1510, - 1513, 1516, 1522, 1525, 1540, 1544, 1548, 1552, 1561, 1566, - 1571, 1576, 1581, 1586, 1591, 1596, 1601, 1606, 1612, 1618, - 1624, 1629, 1634, 1639, 1652, 1665, 1673, 1676, 1691, 1722, - 1726, 1732, 1740, 1756, 1760, 1764, 1765, 1771, 1772, 1773, - 1774, 1775, 1779, 1780, 1780, 1780, 1788, 1789, 1794, 1797, - 1805, 1808, 1814, 1815, 1819, 1827, 1831, 1841, 1846, 1863, - 1863, 1868, 1868, 1875, 1875, 1883, 1886, 1892, 1895, 1901, - 1905, 1912, 1919, 1926, 1933, 1944, 1953, 1957, 1964, 1967, - 1973, 2054 -}; - -static const char * const yytname[] = { "$","error","$undefined.","INVARIANT", -"HIGH_PRECISION","MEDIUM_PRECISION","LOW_PRECISION","PRECISION","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","SAMPLER2D","SAMPLERCUBE","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","variable_identifier", -"primary_expression","postfix_expression","integer_expression","function_call", -"function_call_or_method","function_call_generic","function_call_header_no_parameters", -"function_call_header_with_parameters","function_call_header","function_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", -"precision_qualifier","type_specifier_no_prec","type_specifier_nonarray","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","" -}; -#endif - -static const short yyr1[] = { 0, - 94, 95, 95, 95, 95, 95, 96, 96, 96, 96, - 96, 96, 97, 98, 99, 99, 100, 100, 101, 101, - 102, 102, 103, 104, 104, 104, 105, 105, 105, 105, - 106, 106, 106, 107, 107, 107, 108, 108, 108, 109, - 110, 110, 110, 110, 110, 111, 111, 111, 112, 113, - 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, - 119, 120, 120, 120, 120, 120, 121, 121, 122, 123, - 123, 123, 124, 125, 125, 126, 126, 127, 128, 128, - 129, 129, 129, 129, 130, 130, 130, 130, 131, 132, - 132, 132, 132, 132, 133, 133, 133, 133, 133, 133, - 134, 134, 135, 135, 135, 135, 135, 136, 136, 137, - 137, 137, 138, 138, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 140, 140, 141, 141, 142, 143, - 143, 144, 144, 145, 146, 147, 147, 148, 148, 148, - 148, 148, 149, 150, 151, 149, 152, 152, 153, 153, - 154, 154, 155, 155, 156, 157, 157, 158, 158, 160, - 159, 161, 159, 162, 159, 163, 163, 164, 164, 165, - 165, 166, 166, 166, 166, 166, 167, 167, 168, 168, - 170, 169 -}; - -static const short yyr2[] = { 0, - 1, 1, 1, 1, 1, 3, 1, 4, 1, 3, - 2, 2, 1, 1, 1, 3, 2, 2, 2, 1, - 2, 3, 2, 1, 1, 1, 1, 2, 2, 2, - 1, 1, 1, 1, 3, 3, 1, 3, 3, 1, - 1, 3, 3, 3, 3, 1, 3, 3, 1, 1, - 1, 1, 3, 1, 3, 1, 3, 1, 5, 1, - 3, 1, 1, 1, 1, 1, 1, 3, 1, 2, - 2, 4, 2, 1, 1, 2, 3, 3, 2, 5, - 3, 2, 3, 2, 0, 1, 1, 1, 1, 1, - 3, 5, 6, 5, 1, 2, 4, 5, 4, 2, - 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, - 1, 1, 1, 4, 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 -}; - -static const short yydefact[] = { 0, - 0, 110, 111, 112, 0, 104, 103, 118, 116, 117, - 122, 123, 124, 125, 126, 127, 119, 120, 121, 128, - 129, 130, 107, 105, 0, 115, 131, 132, 134, 190, - 191, 0, 75, 85, 0, 90, 95, 0, 101, 0, - 108, 113, 133, 0, 187, 189, 106, 100, 0, 0, - 0, 70, 0, 73, 85, 0, 86, 87, 88, 76, - 0, 85, 0, 71, 96, 102, 109, 0, 188, 0, - 0, 0, 0, 137, 0, 192, 77, 82, 84, 89, - 0, 91, 78, 0, 0, 1, 4, 3, 5, 26, - 0, 0, 0, 33, 32, 31, 2, 7, 27, 9, - 14, 15, 0, 0, 20, 0, 34, 0, 37, 40, - 41, 46, 49, 50, 51, 52, 54, 56, 58, 69, - 0, 24, 72, 0, 142, 0, 140, 136, 138, 0, - 0, 172, 0, 0, 0, 0, 0, 154, 159, 163, - 34, 60, 67, 0, 145, 0, 101, 148, 161, 147, - 146, 0, 149, 150, 151, 152, 79, 81, 83, 0, - 0, 97, 0, 144, 99, 28, 29, 0, 11, 12, - 0, 0, 18, 17, 0, 115, 21, 23, 30, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 114, 135, 0, 0, 139, 183, 182, - 0, 174, 0, 186, 184, 0, 170, 153, 0, 63, - 64, 65, 66, 62, 0, 0, 164, 160, 162, 0, - 92, 0, 94, 98, 6, 0, 13, 25, 10, 16, - 22, 35, 36, 39, 38, 44, 45, 42, 43, 47, - 48, 53, 55, 57, 0, 0, 141, 0, 0, 0, - 185, 0, 155, 61, 68, 0, 93, 8, 0, 143, - 0, 177, 176, 179, 0, 168, 0, 0, 0, 80, - 59, 0, 178, 0, 0, 167, 165, 0, 0, 156, - 0, 180, 0, 0, 0, 158, 171, 157, 0, 181, - 175, 166, 169, 173, 0, 0 -}; - -static const short yydefgoto[] = { 97, - 98, 99, 226, 100, 101, 102, 103, 104, 105, 106, - 141, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 142, 143, 215, 144, 121, 145, 146, - 32, 33, 34, 78, 60, 61, 79, 35, 36, 37, - 38, 122, 40, 41, 42, 43, 73, 74, 126, 127, - 165, 148, 149, 150, 151, 209, 269, 287, 288, 152, - 153, 154, 277, 268, 155, 252, 201, 249, 264, 274, - 275, 156, 44, 45, 46, 53 -}; - -static const short yypact[] = { 1224, - 2,-32768,-32768,-32768, 115,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768, -31,-32768,-32768,-32768,-32768,-32768, - -67, 36, -54, 23, 11,-32768, 27, 1265,-32768, 1289, --32768, 5,-32768, 1137,-32768,-32768,-32768,-32768, 1289, 42, - 1265,-32768, 56,-32768, 76, 99,-32768,-32768,-32768,-32768, - 1265, 94, 108,-32768, -52,-32768,-32768, 907,-32768, 78, - 1265, 116, 1041,-32768, 282,-32768,-32768,-32768,-32768, 117, - 1265, -55,-32768, 193, 907, 91,-32768,-32768,-32768,-32768, - 907, 907, 907,-32768,-32768,-32768,-32768,-32768, -42,-32768, --32768,-32768, 93, -5, 974, 92,-32768, 907, 15, -47, --32768, -25, -1,-32768,-32768,-32768, 110, 106, -53,-32768, - 95,-32768,-32768, 1082, 97, 26,-32768,-32768,-32768, 90, - 98,-32768, 101, 102, 100, 759, 103, 104,-32768,-32768, - 7,-32768,-32768, 28,-32768, -67, 111,-32768,-32768,-32768, --32768, 364,-32768,-32768,-32768,-32768, 112,-32768,-32768, 826, - 907,-32768, 109,-32768,-32768,-32768,-32768, 3,-32768,-32768, - 907, 1178,-32768,-32768, 907, 118,-32768,-32768,-32768, 907, - 907, 907, 907, 907, 907, 907, 907, 907, 907, 907, - 907, 907, 907,-32768,-32768, 907, 116,-32768,-32768,-32768, - 446,-32768, 907,-32768,-32768, 38,-32768,-32768, 446,-32768, --32768,-32768,-32768,-32768, 907, 907,-32768,-32768,-32768, 907, --32768, 113,-32768,-32768,-32768, 114, 119,-32768, 120,-32768, --32768,-32768,-32768, 15, 15,-32768,-32768,-32768,-32768, -25, - -25,-32768, 110, 106, 45, 121,-32768, 134, 610, 12, --32768, 692, 446,-32768,-32768, 122,-32768,-32768, 907,-32768, - 130,-32768,-32768, 692, 446, 119, 145, 135, 132,-32768, --32768, 907,-32768, 128, 139, 175,-32768, 133, 528,-32768, - 16, 907, 528, 446, 907,-32768,-32768,-32768, 131, 119, --32768,-32768,-32768,-32768, 192,-32768 -}; - -static const short yypgoto[] = {-32768, --32768,-32768,-32768,-32768,-32768, 41,-32768,-32768,-32768,-32768, - -43,-32768, -48,-32768, -88, -32,-32768,-32768,-32768, 37, - 35, 50,-32768, -65, -83,-32768, -89, -70, 6, 8, --32768,-32768,-32768, 147, 174, 168, 152,-32768,-32768, -231, - -19, 0, 238, -33,-32768,-32768, 176, -62,-32768, 49, - -160, 1, -99, -237,-32768,-32768,-32768, -35, 198, 46, - 9,-32768,-32768, -10,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768,-32768, 212,-32768,-32768 -}; - - -#define YYLAST 1333 - - -static const short yytable[] = { 39, - 223, 164, 120, 168, 192, 30, 67, 31, 169, 170, - 129, 50, 52, 163, 62, 70, 160, 83, 120, 84, - 267, 177, 55, 161, 107, 56, 85, 184, 185, 171, - 6, 7, 267, 172, 182, 62, 183, 66, 47, 193, - 107, 286, 51, 39, 48, 286, 206, 166, 167, 30, - 72, 31, 219, 188, 189, 57, 58, 59, 23, 24, - 80, 129, 186, 187, 179, 174, 210, 211, 212, 65, - 72, 175, 72, 225, 147, 213, 68, 164, 56, 216, - 80, 227, 265, 6, 7, 214, 289, 63, 216, 222, - 64, 231, 216, -74, 120, 236, 237, 238, 239, 180, - 181, 248, 197, 245, 216, 198, 54, 217, 57, 58, - 59, 23, 24, 250, 216, 71, 107, 251, 2, 3, - 4, 216, 259, 72, 293, 246, 57, 58, 59, 75, - 120, 254, 255, 234, 235, 47, 232, 233, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 256, - 82, 147, 107, 219, 120, 240, 241, 123, 125, 157, - -25, 178, 266, 173, 191, 276, 190, 194, 196, 199, - 202, 203, 207, 261, 266, 271, 107, 200, 208, 204, - -24, 224, 281, 220, 292, 257, 258, 278, -19, -26, - 284, 296, 290, 260, 270, 216, 2, 3, 4, 272, - 147, 164, 8, 9, 10, 279, 280, 282, 147, 283, - 294, 285, 230, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 243, 242, 158, 77, 81, - 25, 26, 159, 27, 28, 86, 29, 87, 88, 89, - 90, 244, 49, 91, 92, 247, 124, 291, 147, 262, - 76, 147, 147, 273, 253, 69, 0, 263, 0, 0, - 0, 0, 93, 147, 147, 162, 0, 0, 0, 0, - 0, 0, 0, 94, 95, 0, 96, 0, 147, 0, - 0, 0, 147, 147, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 130, 131, 132, 0, 133, 134, - 135, 136, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 0, 0, 23, 24, 25, - 26, 137, 27, 28, 86, 29, 87, 88, 89, 90, - 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 93, 0, 0, 0, 138, 139, 0, 0, 0, - 0, 140, 94, 95, 0, 96, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 130, 131, 132, 0, - 133, 134, 135, 136, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, - 24, 25, 26, 137, 27, 28, 86, 29, 87, 88, - 89, 90, 0, 0, 91, 92, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 93, 0, 0, 0, 138, 218, 0, - 0, 0, 0, 140, 94, 95, 0, 96, 1, 2, - 3, 4, 5, 6, 7, 8, 9, 10, 130, 131, - 132, 0, 133, 134, 135, 136, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, - 0, 23, 24, 25, 26, 137, 27, 28, 86, 29, - 87, 88, 89, 90, 0, 0, 91, 92, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 0, 138, - 0, 0, 0, 0, 0, 140, 94, 95, 0, 96, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 130, 131, 132, 0, 133, 134, 135, 136, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 0, 23, 24, 25, 26, 137, 27, 28, - 86, 29, 87, 88, 89, 90, 0, 0, 91, 92, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 93, 0, 0, - 0, 75, 0, 0, 0, 0, 0, 140, 94, 95, - 0, 96, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 0, 0, 0, 23, 24, 25, 26, 0, - 27, 28, 86, 29, 87, 88, 89, 90, 0, 0, - 91, 92, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, - 94, 95, 0, 96, 56, 2, 3, 4, 0, 6, - 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 0, 0, 23, 24, 25, - 26, 0, 27, 28, 86, 29, 87, 88, 89, 90, - 0, 0, 91, 92, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 93, 2, 3, 4, 0, 0, 0, 8, 9, - 10, 0, 94, 95, 0, 96, 0, 0, 0, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 0, 0, 0, 0, 25, 26, 0, 27, - 28, 86, 29, 87, 88, 89, 90, 0, 0, 91, - 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 93, 2, - 3, 4, 0, 0, 0, 8, 9, 10, 205, 94, - 95, 0, 96, 0, 0, 0, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, - 0, 0, 0, 25, 26, 0, 27, 28, 86, 29, - 87, 88, 89, 90, 0, 0, 91, 92, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 93, 0, 0, 221, 0, - 0, 0, 0, 0, 0, 0, 94, 95, 0, 96, - 2, 3, 4, 0, 0, 0, 8, 9, 10, 0, - 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, - 0, 0, 0, 0, 25, 26, 0, 27, 28, 86, - 29, 87, 88, 89, 90, 0, 0, 91, 92, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 93, 2, 3, 4, - 0, 0, 0, 8, 9, 10, 0, 94, 95, 0, - 96, 0, 0, 0, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 0, 0, - 0, 25, 176, 0, 27, 28, 86, 29, 87, 88, - 89, 90, 0, 0, 91, 92, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 93, 2, 3, 4, 0, 0, 0, - 8, 9, 10, 0, 94, 95, 0, 96, 0, 0, - 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 0, 0, 0, 0, 0, 25, 26, - 0, 27, 28, 0, 29, 2, 3, 4, 0, 0, - 0, 8, 9, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 128, 0, 0, 0, 25, - 26, 0, 27, 28, 0, 29, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 295, 0, 0, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, - 0, 0, 0, 0, 0, 0, 195, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, - 0, 0, 23, 24, 25, 26, 0, 27, 28, 0, - 29, 2, 3, 4, 0, 0, 0, 8, 9, 10, - 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 0, 0, 0, 25, 26, 0, 27, 28, - 228, 29, 0, 0, 0, 229, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, - 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, - 24, 25, 26, 0, 27, 28, 0, 29, 2, 3, - 4, 0, 0, 0, 8, 9, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 0, 8, 9, - 10, 0, 25, 26, 0, 27, 28, 0, 29, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 0, 0, 0, 0, 25, 26, 0, 27, - 28, 0, 29 -}; - -static const short yycheck[] = { 0, - 161, 85, 68, 93, 58, 0, 40, 0, 51, 52, - 73, 43, 80, 84, 34, 49, 72, 70, 84, 72, - 252, 105, 77, 79, 68, 3, 79, 53, 54, 72, - 8, 9, 264, 76, 82, 55, 84, 38, 37, 93, - 84, 279, 74, 44, 43, 283, 136, 91, 92, 44, - 51, 44, 152, 55, 56, 33, 34, 35, 36, 37, - 61, 124, 88, 89, 108, 71, 60, 61, 62, 43, - 71, 77, 73, 71, 75, 69, 72, 161, 3, 77, - 81, 171, 71, 8, 9, 79, 71, 77, 77, 160, - 80, 175, 77, 71, 160, 184, 185, 186, 187, 85, - 86, 201, 77, 193, 77, 80, 71, 80, 33, 34, - 35, 36, 37, 203, 77, 74, 160, 80, 4, 5, - 6, 77, 78, 124, 285, 196, 33, 34, 35, 74, - 196, 215, 216, 182, 183, 37, 180, 181, 182, 183, - 184, 185, 186, 187, 188, 189, 190, 191, 192, 220, - 43, 152, 196, 253, 220, 188, 189, 80, 43, 43, - 70, 70, 252, 71, 59, 265, 57, 73, 72, 80, - 70, 70, 70, 40, 264, 259, 220, 80, 75, 80, - 70, 73, 272, 72, 284, 73, 73, 43, 71, 70, - 16, 0, 282, 73, 73, 77, 4, 5, 6, 70, - 201, 285, 10, 11, 12, 71, 75, 80, 209, 71, - 80, 79, 172, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 191, 190, 81, 55, 62, - 38, 39, 81, 41, 42, 43, 44, 45, 46, 47, - 48, 192, 5, 51, 52, 197, 71, 283, 249, 249, - 53, 252, 253, 264, 209, 44, -1, 249, -1, -1, - -1, -1, 70, 264, 265, 73, -1, -1, -1, -1, - -1, -1, -1, 81, 82, -1, 84, -1, 279, -1, - -1, -1, 283, 284, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, -1, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, -1, -1, -1, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - -1, -1, 51, 52, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 70, -1, -1, -1, 74, 75, -1, -1, -1, - -1, 80, 81, 82, -1, 84, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 70, -1, -1, -1, 74, 75, -1, - -1, -1, -1, 80, 81, 82, -1, 84, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, -1, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, - -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 70, -1, -1, -1, 74, - -1, -1, -1, -1, -1, 80, 81, 82, -1, 84, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, -1, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - -1, -1, -1, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, -1, -1, 51, 52, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, - -1, 74, -1, -1, -1, -1, -1, 80, 81, 82, - -1, 84, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, -1, -1, -1, 36, 37, 38, 39, -1, - 41, 42, 43, 44, 45, 46, 47, 48, -1, -1, - 51, 52, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, - 81, 82, -1, 84, 3, 4, 5, 6, -1, 8, - 9, 10, 11, 12, -1, -1, -1, -1, -1, -1, - -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, -1, -1, -1, 36, 37, 38, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, - -1, -1, 51, 52, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 70, 4, 5, 6, -1, -1, -1, 10, 11, - 12, -1, 81, 82, -1, 84, -1, -1, -1, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, -1, -1, -1, -1, -1, 38, 39, -1, 41, - 42, 43, 44, 45, 46, 47, 48, -1, -1, 51, - 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 70, 4, - 5, 6, -1, -1, -1, 10, 11, 12, 80, 81, - 82, -1, 84, -1, -1, -1, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, - -1, -1, -1, 38, 39, -1, 41, 42, 43, 44, - 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 70, -1, -1, 73, -1, - -1, -1, -1, -1, -1, -1, 81, 82, -1, 84, - 4, 5, 6, -1, -1, -1, 10, 11, 12, -1, - -1, -1, -1, -1, -1, -1, -1, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, - -1, -1, -1, -1, 38, 39, -1, 41, 42, 43, - 44, 45, 46, 47, 48, -1, -1, 51, 52, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 70, 4, 5, 6, - -1, -1, -1, 10, 11, 12, -1, 81, 82, -1, - 84, -1, -1, -1, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, - -1, 38, 39, -1, 41, 42, 43, 44, 45, 46, - 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 70, 4, 5, 6, -1, -1, -1, - 10, 11, 12, -1, 81, 82, -1, 84, -1, -1, - -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, -1, -1, -1, -1, -1, 38, 39, - -1, 41, 42, -1, 44, 4, 5, 6, -1, -1, - -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, - -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, -1, 75, -1, -1, -1, 38, - 39, -1, 41, 42, -1, 44, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, -1, -1, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, - -1, -1, -1, -1, -1, -1, 75, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, - -1, -1, 36, 37, 38, 39, -1, 41, 42, -1, - 44, 4, 5, 6, -1, -1, -1, 10, 11, 12, - -1, -1, -1, -1, -1, -1, -1, -1, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - -1, -1, -1, -1, -1, 38, 39, -1, 41, 42, - 43, 44, -1, -1, -1, 48, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, -1, -1, -1, -1, - -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, - 37, 38, 39, -1, 41, 42, -1, 44, 4, 5, - 6, -1, -1, -1, 10, 11, 12, -1, -1, -1, - -1, -1, -1, -1, -1, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, -1, 10, 11, - 12, -1, 38, 39, -1, 41, 42, -1, 44, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, -1, -1, -1, -1, -1, 38, 39, -1, 41, - 42, -1, 44 -}; -#define YYPURE 1 - -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, 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. */ - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include <alloca.h> -#else /* not HAVE_ALLOCA_H */ -#ifdef _AIX - #pragma alloca -#else /* not _AIX */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -extern void yyerror(char* s); - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include <alloca.h> -#else /* not sparc */ -#if (defined (MSDOS) && !defined (__TURBOC__)) || defined (WIN32) -#include <malloc.h> -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include <malloc.h> - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#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); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (from, to, count) - char *from; - char *to; - size_t count; -{ - register char *f = from; - register char *t = to; - register size_t i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *from, char *to, size_t count) -{ - register char *f = from; - register char *t = to; - register size_t i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifndef YYPARSE_PARAM_DECL -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif -#else -#define YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#endif - -extern YY_DECL; - -int -yyparse(YYPARSE_PARAM_DECL YYPARSE_PARAM) { - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - size_t yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - 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 - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* 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; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - size_t size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* 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, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto 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 == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 1: -{ - // 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, EbpUndefined); - 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 ) { - ConstantUnion* 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 2: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 3: -{ - // - // 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(); - } - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(yyvsp[0].lex.i); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), yyvsp[0].lex.line); - ; - break;} -case 4: -{ - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setFConst(yyvsp[0].lex.f); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), yyvsp[0].lex.line); - ; - break;} -case 5: -{ - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(yyvsp[0].lex.b); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[0].lex.line); - ; - break;} -case 6: -{ - yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode; - ; - break;} -case 7: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 8: -{ - 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[-1].interm.intermTypedNode->getQualifier() == EvqConst) { - if (yyvsp[-3].interm.intermTypedNode->isArray()) { // constant folding for arrays - yyval.interm.intermTypedNode = parseContext->addConstArrayNode(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), yyvsp[-3].interm.intermTypedNode, yyvsp[-2].lex.line); - } else if (yyvsp[-3].interm.intermTypedNode->isVector()) { // constant folding for vectors - TVectorFields fields; - fields.num = 1; - fields.offsets[0] = yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // 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()->getIConst(), 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()->getIConst() && !yyvsp[-3].interm.intermTypedNode->isArray() ) { - parseContext->error(yyvsp[-2].lex.line, "", "[", "field selection out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); - 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()->getIConst()) { - if (parseContext->arraySetMaxSize(yyvsp[-3].interm.intermTypedNode->getAsSymbolNode(), yyvsp[-3].interm.intermTypedNode->getTypePointer(), yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), 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()->getIConst() >= yyvsp[-3].interm.intermTypedNode->getType().getArraySize()) { - parseContext->error(yyvsp[-2].lex.line, "", "[", "array index out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); - 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) { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setFConst(0.0f); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, 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(), yyvsp[-3].interm.intermTypedNode->getPrecision(), EvqTemporary, yyvsp[-3].interm.intermTypedNode->getNominalSize(), yyvsp[-3].interm.intermTypedNode->isMatrix())); - - if (yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst) - yyval.interm.intermTypedNode->getTypePointer()->setQualifier(EvqConst); - } else if (yyvsp[-3].interm.intermTypedNode->isMatrix() && yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst) - yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), yyvsp[-3].interm.intermTypedNode->getPrecision(), EvqConst, yyvsp[-3].interm.intermTypedNode->getNominalSize())); - else if (yyvsp[-3].interm.intermTypedNode->isMatrix()) - yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), yyvsp[-3].interm.intermTypedNode->getPrecision(), 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(), yyvsp[-3].interm.intermTypedNode->getPrecision(), EvqConst)); - else if (yyvsp[-3].interm.intermTypedNode->isVector()) - yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), yyvsp[-3].interm.intermTypedNode->getPrecision(), EvqTemporary)); - else - yyval.interm.intermTypedNode->setType(yyvsp[-3].interm.intermTypedNode->getType()); - ; - break;} -case 9: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 10: -{ - 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(), yyvsp[-2].interm.intermTypedNode->getPrecision(), EvqConst, (int) (*yyvsp[0].lex.string).size())); - } else { - if (fields.num == 1) { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(fields.offsets[0]); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, 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(), yyvsp[-2].interm.intermTypedNode->getPrecision())); - } 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(), yyvsp[-2].interm.intermTypedNode->getPrecision(), 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(0); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, 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(), yyvsp[-2].interm.intermTypedNode->getPrecision(),EvqTemporary, yyvsp[-2].interm.intermTypedNode->getNominalSize())); - } else { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(fields.col * yyvsp[-2].interm.intermTypedNode->getNominalSize() + fields.row); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, 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(), yyvsp[-2].interm.intermTypedNode->getPrecision())); - } - } else if (yyvsp[-2].interm.intermTypedNode->getBasicType() == EbtStruct) { - bool fieldFound = false; - const 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()->setQualifier(EvqConst); - } - } else { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(i); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, 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 11: -{ - 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 12: -{ - 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 13: -{ - if (parseContext->integerErrorCheck(yyvsp[0].interm.intermTypedNode, "[]")) - parseContext->recover(); - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 14: -{ - TFunction* fnCall = yyvsp[0].interm.function; - TOperator op = fnCall->getBuiltInOp(); - - if (op != EOpNull) - { - // - // Then this should be a constructor. - // Don't go through the symbol table for constructors. - // Their parameters will be verified algorithmically. - // - TType type(EbtVoid, EbpUndefined); // 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. - // - if (builtIn && !fnCandidate->getExtension().empty() && - parseContext->extensionErrorCheck(yyvsp[0].interm.line, fnCandidate->getExtension())) { - parseContext->recover(); - } - 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; - for (int i = 0; i < fnCandidate->getParamCount(); ++i) { - qual = fnCandidate->getParam(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(); - } - } - } - } - yyval.interm.intermTypedNode->setType(fnCandidate->getReturnType()); - } else { - // error message was put out by PaFindFunction() - // Put on a dummy node for error recovery - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setFConst(0.0f); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), yyvsp[0].interm.line); - parseContext->recover(); - } - } - delete fnCall; - ; - break;} -case 15: -{ - yyval.interm = yyvsp[0].interm; - ; - break;} -case 16: -{ - parseContext->error(yyvsp[0].interm.line, "methods are not supported", "", ""); - parseContext->recover(); - yyval.interm = yyvsp[0].interm; - ; - break;} -case 17: -{ - yyval.interm = yyvsp[-1].interm; - yyval.interm.line = yyvsp[0].lex.line; - ; - break;} -case 18: -{ - yyval.interm = yyvsp[-1].interm; - yyval.interm.line = yyvsp[0].lex.line; - ; - break;} -case 19: -{ - yyval.interm.function = yyvsp[-1].interm.function; - yyval.interm.intermNode = 0; - ; - break;} -case 20: -{ - yyval.interm.function = yyvsp[0].interm.function; - yyval.interm.intermNode = 0; - ; - break;} -case 21: -{ - 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 22: -{ - 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 23: -{ - yyval.interm.function = yyvsp[-1].interm.function; - ; - break;} -case 24: -{ - // - // Constructor - // - if (yyvsp[0].interm.type.array) { - // Constructors for arrays are not allowed. - parseContext->error(yyvsp[0].interm.type.line, "cannot construct this type", "array", ""); - parseContext->recover(); - yyvsp[0].interm.type.setArray(false); - } - - TOperator op = EOpNull; - if (yyvsp[0].interm.type.userDef) { - op = EOpConstructStruct; - } else { - switch (yyvsp[0].interm.type.type) { - case EbtFloat: - if (yyvsp[0].interm.type.matrix) { - switch(yyvsp[0].interm.type.size) { - case 2: op = EOpConstructMat2; break; - case 3: op = EOpConstructMat3; break; - case 4: op = EOpConstructMat4; break; - } - } else { - switch(yyvsp[0].interm.type.size) { - case 1: op = EOpConstructFloat; break; - case 2: op = EOpConstructVec2; break; - case 3: op = EOpConstructVec3; break; - case 4: op = EOpConstructVec4; break; - } - } - break; - case EbtInt: - switch(yyvsp[0].interm.type.size) { - case 1: op = EOpConstructInt; break; - case 2: FRAG_VERT_ONLY("ivec2", yyvsp[0].interm.type.line); op = EOpConstructIVec2; break; - case 3: FRAG_VERT_ONLY("ivec3", yyvsp[0].interm.type.line); op = EOpConstructIVec3; break; - case 4: FRAG_VERT_ONLY("ivec4", yyvsp[0].interm.type.line); op = EOpConstructIVec4; break; - } - break; - case EbtBool: - switch(yyvsp[0].interm.type.size) { - case 1: op = EOpConstructBool; break; - case 2: FRAG_VERT_ONLY("bvec2", yyvsp[0].interm.type.line); op = EOpConstructBVec2; break; - case 3: FRAG_VERT_ONLY("bvec3", yyvsp[0].interm.type.line); op = EOpConstructBVec3; break; - case 4: FRAG_VERT_ONLY("bvec4", yyvsp[0].interm.type.line); op = EOpConstructBVec4; break; - } - break; - default: break; - } - if (op == EOpNull) { - parseContext->error(yyvsp[0].interm.type.line, "cannot construct this type", getBasicString(yyvsp[0].interm.type.type), ""); - parseContext->recover(); - yyvsp[0].interm.type.type = EbtFloat; - op = EOpConstructFloat; - } - } - TString tempString; - TType type(yyvsp[0].interm.type); - TFunction *function = new TFunction(&tempString, type, op); - yyval.interm.function = function; - ; - break;} -case 25: -{ - if (parseContext->reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string)) - parseContext->recover(); - TType type(EbtVoid, EbpUndefined); - TFunction *function = new TFunction(yyvsp[0].lex.string, type); - yyval.interm.function = function; - ; - break;} -case 26: -{ - if (parseContext->reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string)) - parseContext->recover(); - TType type(EbtVoid, EbpUndefined); - TFunction *function = new TFunction(yyvsp[0].lex.string, type); - yyval.interm.function = function; - ; - break;} -case 27: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 28: -{ - 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 29: -{ - 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 30: -{ - 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) { - const char* errorOp = ""; - switch(yyvsp[-1].interm.op) { - case EOpNegative: errorOp = "-"; break; - case EOpLogicalNot: 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 31: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNull; ; - break;} -case 32: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNegative; ; - break;} -case 33: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpLogicalNot; ; - break;} -case 34: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 35: -{ - 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 36: -{ - 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 37: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 38: -{ - 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 39: -{ - 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 40: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 41: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 42: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 43: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 44: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 45: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 46: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 47: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 48: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 49: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 50: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 51: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 52: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 53: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 54: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 55: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 56: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 57: -{ - 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(); - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setBConst(false); - yyval.interm.intermTypedNode = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), yyvsp[-1].lex.line); - } - ; - break;} -case 58: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 59: -{ - 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 60: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 61: -{ - 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 62: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAssign; ; - break;} -case 63: -{ FRAG_VERT_ONLY("*=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpMulAssign; ; - break;} -case 64: -{ FRAG_VERT_ONLY("/=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpDivAssign; ; - break;} -case 65: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAddAssign; ; - break;} -case 66: -{ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpSubAssign; ; - break;} -case 67: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 68: -{ - 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 69: -{ - if (parseContext->constErrorCheck(yyvsp[0].interm.intermTypedNode)) - parseContext->recover(); - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 70: -{ - TFunction &function = *(yyvsp[-1].interm.function); - - TIntermAggregate *prototype = new TIntermAggregate; - prototype->setType(function.getReturnType()); - prototype->setName(function.getName()); - - for (int i = 0; i < function.getParamCount(); i++) - { - const TParameter ¶m = function.getParam(i); - if (param.name != 0) - { - TVariable *variable = new TVariable(param.name, *param.type); - - prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), yyvsp[-1].interm.line), yyvsp[-1].interm.line); - } - else - { - prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(0, "", *param.type, yyvsp[-1].interm.line), yyvsp[-1].interm.line); - } - } - - prototype->setOp(EOpPrototype); - yyval.interm.intermNode = prototype; - ; - break;} -case 71: -{ - if (yyvsp[-1].interm.intermAggregate) - yyvsp[-1].interm.intermAggregate->setOp(EOpDeclaration); - yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate; - ; - break;} -case 72: -{ - parseContext->symbolTable.setDefaultPrecision( yyvsp[-1].interm.type.type, yyvsp[-2].interm.precision ); - yyval.interm.intermNode = 0; - ; - break;} -case 73: -{ - // - // 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->getParam(i).type->getQualifier() != yyvsp[-1].interm.function->getParam(i).type->getQualifier()) { - parseContext->error(yyvsp[0].lex.line, "overloaded functions must have the same parameter qualifiers", yyvsp[-1].interm.function->getParam(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 74: -{ - yyval.interm.function = yyvsp[0].interm.function; - ; - break;} -case 75: -{ - yyval.interm.function = yyvsp[0].interm.function; - ; - break;} -case 76: -{ - // 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 77: -{ - // - // 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 78: -{ - 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 79: -{ - 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 80: -{ - // Check that we can make an array out of this type - if (parseContext->arrayTypeErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - - if (parseContext->reservedErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string)) - parseContext->recover(); - - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-2].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - yyvsp[-4].interm.type.setArray(true, size); - - TType* type = new TType(yyvsp[-4].interm.type); - TParameter param = { yyvsp[-3].lex.string, type }; - yyval.interm.line = yyvsp[-3].lex.line; - yyval.interm.param = param; - ; - break;} -case 81: -{ - 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 82: -{ - 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 83: -{ - 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 84: -{ - 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 85: -{ - yyval.interm.qualifier = EvqIn; - ; - break;} -case 86: -{ - yyval.interm.qualifier = EvqIn; - ; - break;} -case 87: -{ - yyval.interm.qualifier = EvqOut; - ; - break;} -case 88: -{ - yyval.interm.qualifier = EvqInOut; - ; - break;} -case 89: -{ - TParameter param = { 0, new TType(yyvsp[0].interm.type) }; - yyval.interm.param = param; - ; - break;} -case 90: -{ - yyval.interm = yyvsp[0].interm; - - if (yyval.interm.type.precision == EbpUndefined) { - yyval.interm.type.precision = parseContext->symbolTable.getDefaultPrecision(yyvsp[0].interm.type.type); - if (parseContext->precisionErrorCheck(yyvsp[0].interm.line, yyval.interm.type.precision, yyvsp[0].interm.type.type)) { - parseContext->recover(); - } - } - ; - break;} -case 91: -{ - yyval.interm.intermAggregate = parseContext->intermediate.growAggregate(yyvsp[-2].interm.intermNode, parseContext->intermediate.addSymbol(0, *yyvsp[0].lex.string, TType(yyvsp[-2].interm.type), yyvsp[0].lex.line), yyvsp[0].lex.line); - - if (parseContext->structQualifierErrorCheck(yyvsp[0].lex.line, yyval.interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type)) - parseContext->recover(); - - if (parseContext->nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type)) - parseContext->recover(); - ; - break;} -case 92: -{ - if (parseContext->structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-4].interm.type)) - parseContext->recover(); - - yyval.interm = yyvsp[-4].interm; - - if (parseContext->arrayTypeErrorCheck(yyvsp[-1].lex.line, yyvsp[-4].interm.type) || parseContext->arrayQualifierErrorCheck(yyvsp[-1].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - else { - yyvsp[-4].interm.type.setArray(true); - TVariable* variable; - if (parseContext->arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyvsp[-4].interm.type, variable)) - parseContext->recover(); - } - ; - break;} -case 93: -{ - if (parseContext->structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-5].interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string, yyvsp[-5].interm.type)) - parseContext->recover(); - - yyval.interm = yyvsp[-5].interm; - - if (parseContext->arrayTypeErrorCheck(yyvsp[-2].lex.line, yyvsp[-5].interm.type) || parseContext->arrayQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-5].interm.type)) - parseContext->recover(); - else { - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-2].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - yyvsp[-5].interm.type.setArray(true, size); - TVariable* variable; - if (parseContext->arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyvsp[-5].interm.type, variable)) - parseContext->recover(); - TType type = TType(yyvsp[-5].interm.type); - type.setArraySize(size); - yyval.interm.intermAggregate = parseContext->intermediate.growAggregate(yyvsp[-5].interm.intermNode, parseContext->intermediate.addSymbol(0, *yyvsp[-3].lex.string, type, yyvsp[-3].lex.line), yyvsp[-3].lex.line); - } - ; - break;} -case 94: -{ - if (parseContext->structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - - yyval.interm = yyvsp[-4].interm; - - 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 95: -{ - yyval.interm.type = yyvsp[0].interm.type; - yyval.interm.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType(yyvsp[0].interm.type), yyvsp[0].interm.type.line), yyvsp[0].interm.type.line); - ; - break;} -case 96: -{ - yyval.interm.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *yyvsp[0].lex.string, TType(yyvsp[-1].interm.type), yyvsp[0].lex.line), yyvsp[0].lex.line); - - if (parseContext->structQualifierErrorCheck(yyvsp[0].lex.line, yyval.interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type)) - parseContext->recover(); - - yyval.interm.type = yyvsp[-1].interm.type; - - if (parseContext->nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type)) - parseContext->recover(); - ; - break;} -case 97: -{ - yyval.interm.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *yyvsp[-2].lex.string, TType(yyvsp[-3].interm.type), yyvsp[-2].lex.line), yyvsp[-2].lex.line); - - if (parseContext->structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type)) - parseContext->recover(); - - yyval.interm.type = yyvsp[-3].interm.type; - - if (parseContext->arrayTypeErrorCheck(yyvsp[-1].lex.line, yyvsp[-3].interm.type) || parseContext->arrayQualifierErrorCheck(yyvsp[-1].lex.line, yyvsp[-3].interm.type)) - parseContext->recover(); - else { - yyvsp[-3].interm.type.setArray(true); - TVariable* variable; - if (parseContext->arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type, variable)) - parseContext->recover(); - } - ; - break;} -case 98: -{ - TType type = TType(yyvsp[-4].interm.type); - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-3].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - type.setArraySize(size); - yyval.interm.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *yyvsp[-3].lex.string, type, yyvsp[-3].lex.line), yyvsp[-3].lex.line); - - if (parseContext->structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - - if (parseContext->nonInitConstErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string, yyvsp[-4].interm.type)) - parseContext->recover(); - - yyval.interm.type = yyvsp[-4].interm.type; - - if (parseContext->arrayTypeErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type) || parseContext->arrayQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type)) - parseContext->recover(); - else { - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-2].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - - yyvsp[-4].interm.type.setArray(true, size); - TVariable* variable; - if (parseContext->arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyvsp[-4].interm.type, variable)) - parseContext->recover(); - } - ; - break;} -case 99: -{ - if (parseContext->structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type)) - parseContext->recover(); - - yyval.interm.type = yyvsp[-3].interm.type; - - 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 100: -{ - VERTEX_ONLY("invariant declaration", yyvsp[-1].lex.line); - yyval.interm.qualifier = EvqInvariantVaryingOut; - yyval.interm.intermAggregate = 0; - ; - break;} -case 101: -{ - yyval.interm.type = yyvsp[0].interm.type; - - if (yyvsp[0].interm.type.array) { - parseContext->error(yyvsp[0].interm.type.line, "not supported", "first-class array", ""); - parseContext->recover(); - yyvsp[0].interm.type.setArray(false); - } - ; - break;} -case 102: -{ - if (yyvsp[0].interm.type.array) { - parseContext->error(yyvsp[0].interm.type.line, "not supported", "first-class array", ""); - parseContext->recover(); - yyvsp[0].interm.type.setArray(false); - } - - 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 = yyvsp[0].interm.type; - yyval.interm.type.qualifier = yyvsp[-1].interm.type.qualifier; - ; - break;} -case 103: -{ - yyval.interm.type.setBasic(EbtVoid, EvqConst, yyvsp[0].lex.line); - ; - break;} -case 104: -{ - VERTEX_ONLY("attribute", yyvsp[0].lex.line); - if (parseContext->globalErrorCheck(yyvsp[0].lex.line, parseContext->symbolTable.atGlobalLevel(), "attribute")) - parseContext->recover(); - yyval.interm.type.setBasic(EbtVoid, EvqAttribute, yyvsp[0].lex.line); - ; - break;} -case 105: -{ - if (parseContext->globalErrorCheck(yyvsp[0].lex.line, parseContext->symbolTable.atGlobalLevel(), "varying")) - parseContext->recover(); - if (parseContext->shaderType == SH_VERTEX_SHADER) - yyval.interm.type.setBasic(EbtVoid, EvqVaryingOut, yyvsp[0].lex.line); - else - yyval.interm.type.setBasic(EbtVoid, EvqVaryingIn, yyvsp[0].lex.line); - ; - break;} -case 106: -{ - if (parseContext->globalErrorCheck(yyvsp[-1].lex.line, parseContext->symbolTable.atGlobalLevel(), "invariant varying")) - parseContext->recover(); - if (parseContext->shaderType == SH_VERTEX_SHADER) - yyval.interm.type.setBasic(EbtVoid, EvqInvariantVaryingOut, yyvsp[-1].lex.line); - else - yyval.interm.type.setBasic(EbtVoid, EvqInvariantVaryingIn, yyvsp[-1].lex.line); - ; - break;} -case 107: -{ - if (parseContext->globalErrorCheck(yyvsp[0].lex.line, parseContext->symbolTable.atGlobalLevel(), "uniform")) - parseContext->recover(); - yyval.interm.type.setBasic(EbtVoid, EvqUniform, yyvsp[0].lex.line); - ; - break;} -case 108: -{ - yyval.interm.type = yyvsp[0].interm.type; - ; - break;} -case 109: -{ - yyval.interm.type = yyvsp[0].interm.type; - yyval.interm.type.precision = yyvsp[-1].interm.precision; - ; - break;} -case 110: -{ - yyval.interm.precision = EbpHigh; - ; - break;} -case 111: -{ - yyval.interm.precision = EbpMedium; - ; - break;} -case 112: -{ - yyval.interm.precision = EbpLow; - ; - break;} -case 113: -{ - yyval.interm.type = yyvsp[0].interm.type; - ; - break;} -case 114: -{ - yyval.interm.type = yyvsp[-3].interm.type; - - if (parseContext->arrayTypeErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type)) - parseContext->recover(); - else { - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-2].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - yyval.interm.type.setArray(true, size); - } - ; - break;} -case 115: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtVoid, qual, yyvsp[0].lex.line); - ; - break;} -case 116: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - ; - break;} -case 117: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtInt, qual, yyvsp[0].lex.line); - ; - break;} -case 118: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtBool, qual, yyvsp[0].lex.line); - ; - break;} -case 119: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(2); - ; - break;} -case 120: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(3); - ; - break;} -case 121: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(4); - ; - break;} -case 122: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtBool, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(2); - ; - break;} -case 123: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtBool, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(3); - ; - break;} -case 124: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtBool, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(4); - ; - break;} -case 125: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtInt, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(2); - ; - break;} -case 126: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtInt, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(3); - ; - break;} -case 127: -{ - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtInt, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(4); - ; - break;} -case 128: -{ - FRAG_VERT_ONLY("mat2", yyvsp[0].lex.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(2, true); - ; - break;} -case 129: -{ - FRAG_VERT_ONLY("mat3", yyvsp[0].lex.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(3, true); - ; - break;} -case 130: -{ - FRAG_VERT_ONLY("mat4", yyvsp[0].lex.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtFloat, qual, yyvsp[0].lex.line); - yyval.interm.type.setAggregate(4, true); - ; - break;} -case 131: -{ - FRAG_VERT_ONLY("sampler2D", yyvsp[0].lex.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtSampler2D, qual, yyvsp[0].lex.line); - ; - break;} -case 132: -{ - FRAG_VERT_ONLY("samplerCube", yyvsp[0].lex.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; - yyval.interm.type.setBasic(EbtSamplerCube, qual, yyvsp[0].lex.line); - ; - break;} -case 133: -{ - 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 134: -{ - // - // 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; - yyval.interm.type.setBasic(EbtStruct, qual, yyvsp[0].lex.line); - yyval.interm.type.userDef = &structure; - ; - break;} -case 135: -{ - if (parseContext->reservedErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string)) - parseContext->recover(); - - 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(); - } - yyval.interm.type.setBasic(EbtStruct, EvqTemporary, yyvsp[-4].lex.line); - yyval.interm.type.userDef = structure; - ; - break;} -case 136: -{ - TType* structure = new TType(yyvsp[-1].interm.typeList, TString("")); - yyval.interm.type.setBasic(EbtStruct, EvqTemporary, yyvsp[-3].lex.line); - yyval.interm.type.userDef = structure; - ; - break;} -case 137: -{ - yyval.interm.typeList = yyvsp[0].interm.typeList; - ; - break;} -case 138: -{ - 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 139: -{ - 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 known aspects of type, like array-ness - // - TType* type = (*yyval.interm.typeList)[i].type; - type->setBasicType(yyvsp[-2].interm.type.type); - type->setNominalSize(yyvsp[-2].interm.type.size); - type->setMatrix(yyvsp[-2].interm.type.matrix); - - // don't allow arrays of arrays - if (type->isArray()) { - if (parseContext->arrayTypeErrorCheck(yyvsp[-2].interm.type.line, yyvsp[-2].interm.type)) - parseContext->recover(); - } - if (yyvsp[-2].interm.type.array) - type->setArraySize(yyvsp[-2].interm.type.arraySize); - if (yyvsp[-2].interm.type.userDef) { - type->setStruct(yyvsp[-2].interm.type.userDef->getStruct()); - type->setTypeName(yyvsp[-2].interm.type.userDef->getTypeName()); - } - } - ; - break;} -case 140: -{ - yyval.interm.typeList = NewPoolTTypeList(); - yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine); - ; - break;} -case 141: -{ - yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine); - ; - break;} -case 142: -{ - if (parseContext->reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string)) - parseContext->recover(); - - yyval.interm.typeLine.type = new TType(EbtVoid, EbpUndefined); - yyval.interm.typeLine.line = yyvsp[0].lex.line; - yyval.interm.typeLine.type->setFieldName(*yyvsp[0].lex.string); - ; - break;} -case 143: -{ - if (parseContext->reservedErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string)) - parseContext->recover(); - - yyval.interm.typeLine.type = new TType(EbtVoid, EbpUndefined); - yyval.interm.typeLine.line = yyvsp[-3].lex.line; - yyval.interm.typeLine.type->setFieldName(*yyvsp[-3].lex.string); - - int size; - if (parseContext->arraySizeErrorCheck(yyvsp[-2].lex.line, yyvsp[-1].interm.intermTypedNode, size)) - parseContext->recover(); - yyval.interm.typeLine.type->setArraySize(size); - ; - break;} -case 144: -{ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ; - break;} -case 145: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 146: -{ yyval.interm.intermNode = yyvsp[0].interm.intermAggregate; ; - break;} -case 147: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 148: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 149: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 150: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 151: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 152: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 153: -{ yyval.interm.intermAggregate = 0; ; - break;} -case 154: -{ parseContext->symbolTable.push(); ; - break;} -case 155: -{ parseContext->symbolTable.pop(); ; - break;} -case 156: -{ - if (yyvsp[-2].interm.intermAggregate != 0) - yyvsp[-2].interm.intermAggregate->setOp(EOpSequence); - yyval.interm.intermAggregate = yyvsp[-2].interm.intermAggregate; - ; - break;} -case 157: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 158: -{ yyval.interm.intermNode = yyvsp[0].interm.intermNode; ; - break;} -case 159: -{ - yyval.interm.intermNode = 0; - ; - break;} -case 160: -{ - if (yyvsp[-1].interm.intermAggregate) - yyvsp[-1].interm.intermAggregate->setOp(EOpSequence); - yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate; - ; - break;} -case 161: -{ - yyval.interm.intermAggregate = parseContext->intermediate.makeAggregate(yyvsp[0].interm.intermNode, 0); - ; - break;} -case 162: -{ - yyval.interm.intermAggregate = parseContext->intermediate.growAggregate(yyvsp[-1].interm.intermAggregate, yyvsp[0].interm.intermNode, 0); - ; - break;} -case 163: -{ yyval.interm.intermNode = 0; ; - break;} -case 164: -{ yyval.interm.intermNode = static_cast<TIntermNode*>(yyvsp[-1].interm.intermTypedNode); ; - break;} -case 165: -{ - 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 166: -{ - yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermNode; - yyval.interm.nodePair.node2 = yyvsp[0].interm.intermNode; - ; - break;} -case 167: -{ - yyval.interm.nodePair.node1 = yyvsp[0].interm.intermNode; - yyval.interm.nodePair.node2 = 0; - ; - break;} -case 168: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - if (parseContext->boolErrorCheck(yyvsp[0].interm.intermTypedNode->getLine(), yyvsp[0].interm.intermTypedNode)) - parseContext->recover(); - ; - break;} -case 169: -{ - 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 170: -{ parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; ; - break;} -case 171: -{ - parseContext->symbolTable.pop(); - yyval.interm.intermNode = parseContext->intermediate.addLoop(0, yyvsp[0].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, true, yyvsp[-5].lex.line); - --parseContext->loopNestingLevel; - ; - break;} -case 172: -{ ++parseContext->loopNestingLevel; ; - break;} -case 173: -{ - if (parseContext->boolErrorCheck(yyvsp[0].lex.line, yyvsp[-2].interm.intermTypedNode)) - parseContext->recover(); - - yyval.interm.intermNode = parseContext->intermediate.addLoop(0, yyvsp[-5].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, false, yyvsp[-4].lex.line); - --parseContext->loopNestingLevel; - ; - break;} -case 174: -{ parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; ; - break;} -case 175: -{ - parseContext->symbolTable.pop(); - yyval.interm.intermNode = parseContext->intermediate.addLoop(yyvsp[-3].interm.intermNode, 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); - --parseContext->loopNestingLevel; - ; - break;} -case 176: -{ - yyval.interm.intermNode = yyvsp[0].interm.intermNode; - ; - break;} -case 177: -{ - yyval.interm.intermNode = yyvsp[0].interm.intermNode; - ; - break;} -case 178: -{ - yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 179: -{ - yyval.interm.intermTypedNode = 0; - ; - break;} -case 180: -{ - yyval.interm.nodePair.node1 = yyvsp[-1].interm.intermTypedNode; - yyval.interm.nodePair.node2 = 0; - ; - break;} -case 181: -{ - yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermTypedNode; - yyval.interm.nodePair.node2 = yyvsp[0].interm.intermTypedNode; - ; - break;} -case 182: -{ - 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 183: -{ - 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 184: -{ - 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 185: -{ - 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 186: -{ - FRAG_ONLY("discard", yyvsp[-1].lex.line); - yyval.interm.intermNode = parseContext->intermediate.addBranch(EOpKill, yyvsp[-1].lex.line); - ; - break;} -case 187: -{ - yyval.interm.intermNode = yyvsp[0].interm.intermNode; - parseContext->treeRoot = yyval.interm.intermNode; - ; - break;} -case 188: -{ - yyval.interm.intermNode = parseContext->intermediate.growAggregate(yyvsp[-1].interm.intermNode, yyvsp[0].interm.intermNode, 0); - parseContext->treeRoot = yyval.interm.intermNode; - ; - break;} -case 189: -{ - yyval.interm.intermNode = yyvsp[0].interm.intermNode; - ; - break;} -case 190: -{ - yyval.interm.intermNode = yyvsp[0].interm.intermNode; - ; - break;} -case 191: -{ - 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++) { - const TParameter& param = function->getParam(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; - } - - // - // 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 192: -{ - //?? 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;} -} - /* the action file gets copied in in place of this dollarsign */ - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* 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 - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - 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) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} -
deleted file mode 100644 --- a/gfx/angle/generated/glslang_tab.h +++ /dev/null @@ -1,123 +0,0 @@ -typedef union { - 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; - TPrecision precision; - TQualifier qualifier; - TFunction* function; - TParameter param; - TTypeLine typeLine; - TTypeList* typeList; - }; - } interm; -} YYSTYPE; -#define INVARIANT 258 -#define HIGH_PRECISION 259 -#define MEDIUM_PRECISION 260 -#define LOW_PRECISION 261 -#define PRECISION 262 -#define ATTRIBUTE 263 -#define CONST_QUAL 264 -#define BOOL_TYPE 265 -#define FLOAT_TYPE 266 -#define INT_TYPE 267 -#define BREAK 268 -#define CONTINUE 269 -#define DO 270 -#define ELSE 271 -#define FOR 272 -#define IF 273 -#define DISCARD 274 -#define RETURN 275 -#define BVEC2 276 -#define BVEC3 277 -#define BVEC4 278 -#define IVEC2 279 -#define IVEC3 280 -#define IVEC4 281 -#define VEC2 282 -#define VEC3 283 -#define VEC4 284 -#define MATRIX2 285 -#define MATRIX3 286 -#define MATRIX4 287 -#define IN_QUAL 288 -#define OUT_QUAL 289 -#define INOUT_QUAL 290 -#define UNIFORM 291 -#define VARYING 292 -#define STRUCT 293 -#define VOID_TYPE 294 -#define WHILE 295 -#define SAMPLER2D 296 -#define SAMPLERCUBE 297 -#define IDENTIFIER 298 -#define TYPE_NAME 299 -#define FLOATCONSTANT 300 -#define INTCONSTANT 301 -#define BOOLCONSTANT 302 -#define FIELD_SELECTION 303 -#define LEFT_OP 304 -#define RIGHT_OP 305 -#define INC_OP 306 -#define DEC_OP 307 -#define LE_OP 308 -#define GE_OP 309 -#define EQ_OP 310 -#define NE_OP 311 -#define AND_OP 312 -#define OR_OP 313 -#define XOR_OP 314 -#define MUL_ASSIGN 315 -#define DIV_ASSIGN 316 -#define ADD_ASSIGN 317 -#define MOD_ASSIGN 318 -#define LEFT_ASSIGN 319 -#define RIGHT_ASSIGN 320 -#define AND_ASSIGN 321 -#define XOR_ASSIGN 322 -#define OR_ASSIGN 323 -#define SUB_ASSIGN 324 -#define LEFT_PAREN 325 -#define RIGHT_PAREN 326 -#define LEFT_BRACKET 327 -#define RIGHT_BRACKET 328 -#define LEFT_BRACE 329 -#define RIGHT_BRACE 330 -#define DOT 331 -#define COMMA 332 -#define COLON 333 -#define EQUAL 334 -#define SEMICOLON 335 -#define BANG 336 -#define DASH 337 -#define TILDE 338 -#define PLUS 339 -#define STAR 340 -#define SLASH 341 -#define PERCENT 342 -#define LEFT_ANGLE 343 -#define RIGHT_ANGLE 344 -#define VERTICAL_BAR 345 -#define CARET 346 -#define AMPERSAND 347 -#define QUESTION 348 -
--- a/gfx/angle/include/GLSLANG/ShaderLang.h +++ b/gfx/angle/include/GLSLANG/ShaderLang.h @@ -32,17 +32,17 @@ // #ifdef __cplusplus extern "C" { #endif // Version number for shader translation API. // It is incremented everytime the API changes. -#define SH_VERSION 101 +#define SH_VERSION 103 // // The names of the following enums have been derived by replacing GL prefix // with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH. // The enum values are also equal to the values of their GL counterpart. This // is done to make it easier for applications to use the shader library. // typedef enum { @@ -82,20 +82,21 @@ typedef enum { SH_ACTIVE_UNIFORMS = 0x8B86, SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, SH_ACTIVE_ATTRIBUTES = 0x8B89, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A } ShShaderInfo; // Compile options. typedef enum { - SH_VALIDATE = 0, - SH_INTERMEDIATE_TREE = 0x001, - SH_OBJECT_CODE = 0x002, - SH_ATTRIBUTES_UNIFORMS = 0x004 + SH_VALIDATE = 0, + SH_VALIDATE_LOOP_INDEXING = 0x0001, + SH_INTERMEDIATE_TREE = 0x0002, + SH_OBJECT_CODE = 0x0004, + SH_ATTRIBUTES_UNIFORMS = 0x0008 } ShCompileOptions; // // Driver must call this first, once, before doing any other // compiler operations. // ANGLE_API int ShInitialize(); // @@ -155,17 +156,24 @@ ANGLE_API void ShDestruct(ShHandle handl // Compiles the given shader source. // If the function succeeds, the return value is nonzero, else zero. // Parameters: // handle: Specifies the handle of compiler to be used. // shaderStrings: Specifies an array of pointers to null-terminated strings // containing the shader source code. // numStrings: Specifies the number of elements in shaderStrings array. // compileOptions: A mask containing the following parameters: -// SH_VALIDATE: Performs validations only. +// SH_VALIDATE: Validates shader to ensure that it conforms to the spec +// specified during compiler construction. +// SH_VALIDATE_LOOP_INDEXING: Validates loop and indexing in the shader to +// ensure that they do not exceed the minimum +// functionality mandated in GLSL 1.0 spec, +// Appendix A, Section 4 and 5. +// There is no need to specify this parameter when +// compiling for WebGL - it is implied. // SH_INTERMEDIATE_TREE: Writes intermediate tree to info log. // Can be queried by calling ShGetInfoLog(). // SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. // Can be queried by calling ShGetObjectCode(). // SH_ATTRIBUTES_UNIFORMS: Extracts attributes and uniforms. // Can be queried by calling ShGetActiveAttrib() and // ShGetActiveUniform(). //
--- a/gfx/angle/src/build_angle.gyp +++ b/gfx/angle/src/build_angle.gyp @@ -11,28 +11,27 @@ 'targets': [ { 'target_name': 'translator_common', 'type': 'static_library', 'include_dirs': [ '.', '../include', ], - 'variables': { - 'glslang_cpp_file': '<(INTERMEDIATE_DIR)/glslang.cpp', - 'glslang_tab_cpp_file': '<(INTERMEDIATE_DIR)/glslang_tab.cpp', - 'glslang_tab_h_file': '<(INTERMEDIATE_DIR)/glslang_tab.h', - }, 'sources': [ 'compiler/BaseTypes.h', 'compiler/Common.h', 'compiler/Compiler.cpp', 'compiler/ConstantUnion.h', 'compiler/debug.cpp', 'compiler/debug.h', + 'compiler/glslang.h', + 'compiler/glslang_lex.cpp', + 'compiler/glslang_tab.cpp', + 'compiler/glslang_tab.h', 'compiler/InfoSink.cpp', 'compiler/InfoSink.h', 'compiler/Initialize.cpp', 'compiler/Initialize.h', 'compiler/InitializeDll.cpp', 'compiler/InitializeDll.h', 'compiler/InitializeGlobals.h', 'compiler/InitializeParseContext.h', @@ -53,16 +52,20 @@ 'compiler/RemoveTree.cpp', 'compiler/RemoveTree.h', 'compiler/ShaderLang.cpp', 'compiler/ShHandle.h', 'compiler/SymbolTable.cpp', 'compiler/SymbolTable.h', 'compiler/Types.h', 'compiler/unistd.h', + 'compiler/util.cpp', + 'compiler/util.h', + 'compiler/ValidateLimitations.cpp', + 'compiler/ValidateLimitations.h', 'compiler/VariableInfo.cpp', 'compiler/VariableInfo.h', 'compiler/preprocessor/atom.c', 'compiler/preprocessor/atom.h', 'compiler/preprocessor/compile.h', 'compiler/preprocessor/cpp.c', 'compiler/preprocessor/cpp.h', 'compiler/preprocessor/cppstruct.c', @@ -72,72 +75,41 @@ 'compiler/preprocessor/preprocess.h', 'compiler/preprocessor/scanner.c', 'compiler/preprocessor/scanner.h', 'compiler/preprocessor/slglobals.h', 'compiler/preprocessor/symbols.c', 'compiler/preprocessor/symbols.h', 'compiler/preprocessor/tokens.c', 'compiler/preprocessor/tokens.h', - # Generated files - '<(glslang_cpp_file)', - '<(glslang_tab_cpp_file)', - '<(glslang_tab_h_file)', ], 'conditions': [ ['OS=="win"', { 'sources': ['compiler/ossource_win.cpp'], }, { # else: posix 'sources': ['compiler/ossource_posix.cpp'], }], ], - 'actions': [ - { - 'action_name': 'flex_glslang', - 'inputs': ['compiler/glslang.l'], - 'outputs': ['<(glslang_cpp_file)'], - 'action': [ - 'flex', - '--noline', - '--nounistd', - '--outfile=<(glslang_cpp_file)', - '<(_inputs)', - ], - 'message': 'Executing flex on <(_inputs)', - }, - { - 'action_name': 'bison_glslang', - 'inputs': ['compiler/glslang.y'], - 'outputs': ['<(glslang_tab_cpp_file)', '<(glslang_tab_h_file)'], - 'action': [ - 'bison', - '--no-lines', - '--defines=<(glslang_tab_h_file)', - '--skeleton=yacc.c', - '--output=<(glslang_tab_cpp_file)', - '<(_inputs)', - ], - 'message': 'Executing bison on <(_inputs)', - }, - ], }, { 'target_name': 'translator_glsl', 'type': 'static_library', 'dependencies': ['translator_common'], 'include_dirs': [ '.', '../include', ], 'sources': [ 'compiler/CodeGenGLSL.cpp', 'compiler/OutputGLSL.cpp', 'compiler/OutputGLSL.h', 'compiler/TranslatorGLSL.cpp', 'compiler/TranslatorGLSL.h', + 'compiler/VersionGLSL.cpp', + 'compiler/VersionGLSL.h', ], }, { 'target_name': 'translator_hlsl', 'type': 'static_library', 'dependencies': ['translator_common'], 'include_dirs': [ '.', @@ -146,16 +118,18 @@ 'sources': [ 'compiler/CodeGenHLSL.cpp', 'compiler/OutputHLSL.cpp', 'compiler/OutputHLSL.h', 'compiler/TranslatorHLSL.cpp', 'compiler/TranslatorHLSL.h', 'compiler/UnfoldSelect.cpp', 'compiler/UnfoldSelect.h', + 'compiler/SearchSymbol.cpp', + 'compiler/SearchSymbol.h', ], }, ], 'conditions': [ ['OS=="win"', { 'targets': [ { 'target_name': 'libGLESv2',
--- a/gfx/angle/src/compiler/Common.h +++ b/gfx/angle/src/compiler/Common.h @@ -9,19 +9,34 @@ #include <map> #include <sstream> #include <string> #include <vector> #include "compiler/PoolAlloc.h" +// We need two pieces of information to report errors/warnings - string and +// line number. We encode these into a single int so that it can be easily +// incremented/decremented by lexer. The right SOURCE_LOC_LINE_SIZE bits store +// line number while the rest store the string number. Since the shaders are +// usually small, we should not run out of memory. SOURCE_LOC_LINE_SIZE +// can be increased to alleviate this issue. typedef int TSourceLoc; -const unsigned int SourceLocLineMask = 0xffff; -const unsigned int SourceLocStringShift = 16; +const unsigned int SOURCE_LOC_LINE_SIZE = 16; // in bits. +const unsigned int SOURCE_LOC_LINE_MASK = (1 << SOURCE_LOC_LINE_SIZE) - 1; + +inline TSourceLoc EncodeSourceLoc(int string, int line) { + return (string << SOURCE_LOC_LINE_SIZE) | (line & SOURCE_LOC_LINE_MASK); +} + +inline void DecodeSourceLoc(TSourceLoc loc, int* string, int* line) { + if (string) *string = loc >> SOURCE_LOC_LINE_SIZE; + if (line) *line = loc & SOURCE_LOC_LINE_MASK; +} // // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme. // #define POOL_ALLOCATOR_NEW_DELETE(A) \ void* operator new(size_t s) { return (A).allocate(s); } \ void* operator new(size_t, void *_Where) { return (_Where); } \ void operator delete(void*) { } \
--- a/gfx/angle/src/compiler/Compiler.cpp +++ b/gfx/angle/src/compiler/Compiler.cpp @@ -2,146 +2,162 @@ // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/Initialize.h" #include "compiler/ParseHelper.h" #include "compiler/ShHandle.h" +#include "compiler/ValidateLimitations.h" -static bool InitializeSymbolTable( - const TBuiltInStrings& builtInStrings, - ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, - TInfoSink& infoSink, TSymbolTable& symbolTable) +namespace { +bool InitializeSymbolTable( + const TBuiltInStrings& builtInStrings, + ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, + TInfoSink& infoSink, TSymbolTable& symbolTable) { TIntermediate intermediate(infoSink); TExtensionBehavior extBehavior; TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, infoSink); GlobalParseContext = &parseContext; - setInitialState(); - assert(symbolTable.isEmpty()); // // Parse the built-ins. This should only happen once per // language symbol table. // // Push the symbol table to give it an initial scope. This // push should not have a corresponding pop, so that built-ins // are preserved, and the test for an empty table fails. // symbolTable.push(); - - //Initialize the Preprocessor - if (InitPreprocessor()) - { - infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor"); - return false; - } for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i) { const char* builtInShaders = i->c_str(); int builtInLengths = static_cast<int>(i->size()); if (builtInLengths <= 0) continue; - if (PaParseStrings(&builtInShaders, &builtInLengths, 1, parseContext) != 0) + if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0) { infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); return false; } } IdentifyBuiltIns(type, spec, resources, symbolTable); - FinalizePreprocessor(); - return true; } -static void DefineExtensionMacros(const TExtensionBehavior& extBehavior) -{ - for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); - iter != extBehavior.end(); ++iter) { - PredefineIntMacro(iter->first.c_str(), 1); +class TScopedPoolAllocator { +public: + TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop) + : mAllocator(allocator), mPushPopAllocator(pushPop) { + if (mPushPopAllocator) mAllocator->push(); + SetGlobalPoolAllocator(mAllocator); + } + ~TScopedPoolAllocator() { + SetGlobalPoolAllocator(NULL); + if (mPushPopAllocator) mAllocator->pop(); } + +private: + TPoolAllocator* mAllocator; + bool mPushPopAllocator; +}; +} // namespace + +TShHandleBase::TShHandleBase() { + allocator.push(); + SetGlobalPoolAllocator(&allocator); +} + +TShHandleBase::~TShHandleBase() { + SetGlobalPoolAllocator(NULL); + allocator.popAll(); } TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec) : shaderType(type), shaderSpec(spec) { } TCompiler::~TCompiler() { } bool TCompiler::Init(const ShBuiltInResources& resources) { + TScopedPoolAllocator scopedAlloc(&allocator, false); + // Generate built-in symbol table. if (!InitBuiltInSymbolTable(resources)) return false; + InitExtensionBehavior(resources, extensionBehavior); - InitExtensionBehavior(resources, extensionBehavior); return true; } bool TCompiler::compile(const char* const shaderStrings[], const int numStrings, int compileOptions) { + TScopedPoolAllocator scopedAlloc(&allocator, true); clearResults(); if (numStrings == 0) return true; + // If compiling for WebGL, validate loop and indexing as well. + if (shaderSpec == SH_WEBGL_SPEC) + compileOptions |= SH_VALIDATE_LOOP_INDEXING; + TIntermediate intermediate(infoSink); TParseContext parseContext(symbolTable, extensionBehavior, intermediate, shaderType, shaderSpec, infoSink); GlobalParseContext = &parseContext; - setInitialState(); - - // Initialize preprocessor. - InitPreprocessor(); - DefineExtensionMacros(extensionBehavior); // We preserve symbols at the built-in level from compile-to-compile. // Start pushing the user-defined symbols at global level. symbolTable.push(); if (!symbolTable.atGlobalLevel()) infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); // Parse shader. bool success = - (PaParseStrings(shaderStrings, 0, numStrings, parseContext) == 0) && + (PaParseStrings(numStrings, shaderStrings, NULL, &parseContext) == 0) && (parseContext.treeRoot != NULL); if (success) { - success = intermediate.postProcess(parseContext.treeRoot); + TIntermNode* root = parseContext.treeRoot; + success = intermediate.postProcess(root); + + if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) + success = validateLimitations(root); if (success && (compileOptions & SH_INTERMEDIATE_TREE)) - intermediate.outputTree(parseContext.treeRoot); + intermediate.outputTree(root); if (success && (compileOptions & SH_OBJECT_CODE)) - translate(parseContext.treeRoot); + translate(root); if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) - collectAttribsUniforms(parseContext.treeRoot); + collectAttribsUniforms(root); } // Cleanup memory. intermediate.remove(parseContext.treeRoot); // Ensure symbol table is returned to the built-in level, // throwing away all but the built-ins. while (!symbolTable.atBuiltInLevel()) symbolTable.pop(); - FinalizePreprocessor(); return success; } bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources& resources) { TBuiltIns builtIns; @@ -155,14 +171,20 @@ void TCompiler::clearResults() infoSink.info.erase(); infoSink.obj.erase(); infoSink.debug.erase(); attribs.clear(); uniforms.clear(); } +bool TCompiler::validateLimitations(TIntermNode* root) { + ValidateLimitations validate(shaderType, infoSink.info); + root->traverse(&validate); + return validate.numErrors() == 0; +} + void TCompiler::collectAttribsUniforms(TIntermNode* root) { CollectAttribsUniforms collect(attribs, uniforms); root->traverse(&collect); }
--- a/gfx/angle/src/compiler/InfoSink.cpp +++ b/gfx/angle/src/compiler/InfoSink.cpp @@ -27,18 +27,18 @@ void TInfoSinkBase::prefix(TPrefixType m break; default: sink.append("UNKOWN ERROR: "); break; } } void TInfoSinkBase::location(TSourceLoc loc) { - int string = loc >> SourceLocStringShift; - int line = loc & SourceLocLineMask; + int string = 0, line = 0; + DecodeSourceLoc(loc, &string, &line); TPersistStringStream stream; if (line) stream << string << ":" << line; else stream << string << ":? "; stream << ": ";
--- a/gfx/angle/src/compiler/Initialize.h +++ b/gfx/angle/src/compiler/Initialize.h @@ -27,13 +27,9 @@ protected: void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, TSymbolTable& symbolTable); void InitExtensionBehavior(const ShBuiltInResources& resources, TExtensionBehavior& extensionBehavior); -extern "C" int InitPreprocessor(void); -extern "C" int FinalizePreprocessor(void); -extern "C" void PredefineIntMacro(const char *name, int value); - #endif // _INITIALIZE_INCLUDED_
--- a/gfx/angle/src/compiler/IntermTraverse.cpp +++ b/gfx/angle/src/compiler/IntermTraverse.cpp @@ -224,46 +224,46 @@ void TIntermLoop::traverse(TIntermTraver } if(visit) { it->incrementDepth(); if(it->rightToLeft) { - if(terminal) + if(expr) { - terminal->traverse(it); + expr->traverse(it); } if(body) { body->traverse(it); } - if(test) + if(cond) { - test->traverse(it); + cond->traverse(it); } } else { - if(test) + if(cond) { - test->traverse(it); + cond->traverse(it); } if(body) { body->traverse(it); } - if(terminal) + if(expr) { - terminal->traverse(it); + expr->traverse(it); } } it->decrementDepth(); } if(visit && it->postVisit) {
--- a/gfx/angle/src/compiler/Intermediate.cpp +++ b/gfx/angle/src/compiler/Intermediate.cpp @@ -17,16 +17,111 @@ #include "compiler/RemoveTree.h" bool CompareStructure(const TType& leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray); static TPrecision GetHigherPrecision( TPrecision left, TPrecision right ){ return left > right ? left : right; } +const char* getOperatorString(TOperator op) { + switch (op) { + case EOpInitialize: return "="; + case EOpAssign: return "="; + case EOpAddAssign: return "+="; + case EOpSubAssign: return "-="; + case EOpDivAssign: return "/="; + + // Fall-through. + case EOpMulAssign: + case EOpVectorTimesMatrixAssign: + case EOpVectorTimesScalarAssign: + case EOpMatrixTimesScalarAssign: + case EOpMatrixTimesMatrixAssign: return "*="; + + // Fall-through. + case EOpIndexDirect: + case EOpIndexIndirect: return "[]"; + + case EOpIndexDirectStruct: return "."; + case EOpVectorSwizzle: return "."; + case EOpAdd: return "+"; + case EOpSub: return "-"; + case EOpMul: return "*"; + case EOpDiv: return "/"; + case EOpMod: UNIMPLEMENTED(); break; + case EOpEqual: return "=="; + case EOpNotEqual: return "!="; + case EOpLessThan: return "<"; + case EOpGreaterThan: return ">"; + case EOpLessThanEqual: return "<="; + case EOpGreaterThanEqual: return ">="; + + // Fall-through. + case EOpVectorTimesScalar: + case EOpVectorTimesMatrix: + case EOpMatrixTimesVector: + case EOpMatrixTimesScalar: + case EOpMatrixTimesMatrix: return "*"; + + case EOpLogicalOr: return "||"; + case EOpLogicalXor: return "^^"; + case EOpLogicalAnd: return "&&"; + case EOpNegative: return "-"; + case EOpVectorLogicalNot: return "not"; + case EOpLogicalNot: return "!"; + case EOpPostIncrement: return "++"; + case EOpPostDecrement: return "--"; + case EOpPreIncrement: return "++"; + case EOpPreDecrement: return "--"; + + // Fall-through. + case EOpConvIntToBool: + case EOpConvFloatToBool: return "bool"; + + // Fall-through. + case EOpConvBoolToFloat: + case EOpConvIntToFloat: return "float"; + + // Fall-through. + case EOpConvFloatToInt: + case EOpConvBoolToInt: return "int"; + + case EOpRadians: return "radians"; + case EOpDegrees: return "degrees"; + case EOpSin: return "sin"; + case EOpCos: return "cos"; + case EOpTan: return "tan"; + case EOpAsin: return "asin"; + case EOpAcos: return "acos"; + case EOpAtan: return "atan"; + case EOpExp: return "exp"; + case EOpLog: return "log"; + case EOpExp2: return "exp2"; + case EOpLog2: return "log2"; + case EOpSqrt: return "sqrt"; + case EOpInverseSqrt: return "inversesqrt"; + case EOpAbs: return "abs"; + case EOpSign: return "sign"; + case EOpFloor: return "floor"; + case EOpCeil: return "ceil"; + case EOpFract: return "fract"; + case EOpLength: return "length"; + case EOpNormalize: return "normalize"; + case EOpDFdx: return "dFdx"; + case EOpDFdy: return "dFdy"; + case EOpFwidth: return "fwidth"; + case EOpAny: return "any"; + case EOpAll: return "all"; + + default: break; + } + return ""; +} + //////////////////////////////////////////////////////////////////////////// // // First set of functions are to help build the intermediate representation. // These functions are not member functions of the nodes. // They are called from parser productions. // ///////////////////////////////////////////////////////////////////////////// @@ -598,19 +693,19 @@ TIntermTyped* TIntermediate::addSwizzle( } return node; } // // Create loop nodes. // -TIntermNode* TIntermediate::addLoop(TIntermNode *init, TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line) +TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line) { - TIntermNode* node = new TIntermLoop(init, body, test, terminal, testFirst); + TIntermNode* node = new TIntermLoop(type, init, cond, expr, body); node->setLine(line); return node; } // // Add branches. //
--- a/gfx/angle/src/compiler/OutputGLSL.cpp +++ b/gfx/angle/src/compiler/OutputGLSL.cpp @@ -607,45 +607,54 @@ bool TOutputGLSL::visitAggregate(Visit v } bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node) { TInfoSinkBase& out = objSink(); incrementDepth(); // Loop header. - if (node->testFirst()) // for loop + TLoopType loopType = node->getType(); + if (loopType == ELoopFor) // for loop { out << "for ("; if (node->getInit()) node->getInit()->traverse(this); out << "; "; - ASSERT(node->getTest() != NULL); - node->getTest()->traverse(this); + if (node->getCondition()) + node->getCondition()->traverse(this); out << "; "; - if (node->getTerminal()) - node->getTerminal()->traverse(this); + if (node->getExpression()) + node->getExpression()->traverse(this); + out << ")\n"; + } + else if (loopType == ELoopWhile) // while loop + { + out << "while ("; + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); out << ")\n"; } else // do-while loop { + ASSERT(loopType == ELoopDoWhile); out << "do\n"; } // Loop body. visitCodeBlock(node->getBody()); // Loop footer. - if (!node->testFirst()) // while loop + if (loopType == ELoopDoWhile) // do-while loop { out << "while ("; - ASSERT(node->getTest() != NULL); - node->getTest()->traverse(this); + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); out << ");\n"; } decrementDepth(); // No need to visit children. They have been already processed in // this function. return false; }
--- a/gfx/angle/src/compiler/OutputHLSL.cpp +++ b/gfx/angle/src/compiler/OutputHLSL.cpp @@ -4,16 +4,17 @@ // found in the LICENSE file. // #include "compiler/OutputHLSL.h" #include "compiler/debug.h" #include "compiler/InfoSink.h" #include "compiler/UnfoldSelect.h" +#include "compiler/SearchSymbol.h" #include <stdio.h> #include <algorithm> namespace sh { // Integer to TString conversion TString str(int i) @@ -59,17 +60,17 @@ OutputHLSL::OutputHLSL(TParseContext &co mUsesEqualIVec4 = false; mUsesEqualBVec2 = false; mUsesEqualBVec3 = false; mUsesEqualBVec4 = false; mUsesAtan2 = false; mScopeDepth = 0; - mArgumentIndex = 0; + mUniqueIndex = 0; } OutputHLSL::~OutputHLSL() { delete mUnfoldSelect; } void OutputHLSL::output() @@ -356,17 +357,18 @@ void OutputHLSL::header() { out << "struct gl_DepthRangeParameters\n" "{\n" " float near;\n" " float far;\n" " float diff;\n" "};\n" "\n" - "uniform gl_DepthRangeParameters gl_DepthRange;\n" + "uniform float3 dx_DepthRange;" + "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n" "\n"; } if (mUsesXor) { out << "bool xor(bool p, bool q)\n" "{\n" " return (p || q) && !(p && q);\n" @@ -648,17 +650,49 @@ void OutputHLSL::visitSymbol(TIntermSymb bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) { TInfoSinkBase &out = mBody; switch (node->getOp()) { case EOpAssign: outputTriplet(visit, "(", " = ", ")"); break; - case EOpInitialize: outputTriplet(visit, "", " = ", ""); break; + case EOpInitialize: + if (visit == PreVisit) + { + // GLSL allows to write things like "float x = x;" where a new variable x is defined + // and the value of an existing variable x is assigned. HLSL uses C semantics (the + // new variable is created before the assignment is evaluated), so we need to convert + // this to "float t = x, x = t;". + + TIntermSymbol *symbolNode = node->getLeft()->getAsSymbolNode(); + TIntermTyped *expression = node->getRight(); + + sh::SearchSymbol searchSymbol(symbolNode->getSymbol()); + expression->traverse(&searchSymbol); + bool sameSymbol = searchSymbol.foundMatch(); + + if (sameSymbol) + { + // Type already printed + out << "t" + str(mUniqueIndex) + " = "; + expression->traverse(this); + out << ", "; + symbolNode->traverse(this); + out << " = t" + str(mUniqueIndex); + + mUniqueIndex++; + return false; + } + } + else if (visit == InVisit) + { + out << " = "; + } + break; case EOpAddAssign: outputTriplet(visit, "(", " += ", ")"); break; case EOpSubAssign: outputTriplet(visit, "(", " -= ", ")"); break; case EOpMulAssign: outputTriplet(visit, "(", " *= ", ")"); break; case EOpVectorTimesScalarAssign: outputTriplet(visit, "(", " *= ", ")"); break; case EOpMatrixTimesScalarAssign: outputTriplet(visit, "(", " *= ", ")"); break; case EOpVectorTimesMatrixAssign: if (visit == PreVisit) { @@ -1387,75 +1421,75 @@ bool OutputHLSL::visitLoop(Visit visit, { if (handleExcessiveLoop(node)) { return false; } TInfoSinkBase &out = mBody; - if (!node->testFirst()) + if (node->getType() == ELoopDoWhile) { out << "do\n" "{\n"; } else { if (node->getInit()) { mUnfoldSelect->traverse(node->getInit()); } - if (node->getTest()) + if (node->getCondition()) { - mUnfoldSelect->traverse(node->getTest()); + mUnfoldSelect->traverse(node->getCondition()); } - if (node->getTerminal()) + if (node->getExpression()) { - mUnfoldSelect->traverse(node->getTerminal()); + mUnfoldSelect->traverse(node->getExpression()); } out << "for("; if (node->getInit()) { node->getInit()->traverse(this); } out << "; "; - if (node->getTest()) + if (node->getCondition()) { - node->getTest()->traverse(this); + node->getCondition()->traverse(this); } out << "; "; - if (node->getTerminal()) + if (node->getExpression()) { - node->getTerminal()->traverse(this); + node->getExpression()->traverse(this); } out << ")\n" "{\n"; } if (node->getBody()) { node->getBody()->traverse(this); } out << "}\n"; - if (!node->testFirst()) + if (node->getType() == ELoopDoWhile) { out << "while(\n"; - node->getTest()->traverse(this); + node->getCondition()->traverse(this); out << ")"; } out << ";\n"; return false; } @@ -1560,19 +1594,19 @@ bool OutputHLSL::handleExcessiveLoop(TIn } } } } } } // Parse comparator and limit value - if (index != NULL && node->getTest()) + if (index != NULL && node->getCondition()) { - TIntermBinary *test = node->getTest()->getAsBinaryNode(); + TIntermBinary *test = node->getCondition()->getAsBinaryNode(); if (test && test->getLeft()->getAsSymbolNode()->getId() == index->getId()) { TIntermConstantUnion *constant = test->getRight()->getAsConstantUnion(); if (constant) { if (constant->getBasicType() == EbtInt && constant->getNominalSize() == 1) @@ -1580,20 +1614,20 @@ bool OutputHLSL::handleExcessiveLoop(TIn comparator = test->getOp(); limit = constant->getUnionArrayPointer()[0].getIConst(); } } } } // Parse increment - if (index != NULL && comparator != EOpNull && node->getTerminal()) + if (index != NULL && comparator != EOpNull && node->getExpression()) { - TIntermBinary *binaryTerminal = node->getTerminal()->getAsBinaryNode(); - TIntermUnary *unaryTerminal = node->getTerminal()->getAsUnaryNode(); + TIntermBinary *binaryTerminal = node->getExpression()->getAsBinaryNode(); + TIntermUnary *unaryTerminal = node->getExpression()->getAsUnaryNode(); if (binaryTerminal) { TOperator op = binaryTerminal->getOp(); TIntermConstantUnion *constant = binaryTerminal->getRight()->getAsConstantUnion(); if (constant) { @@ -1706,17 +1740,17 @@ void OutputHLSL::outputTriplet(Visit vis TString OutputHLSL::argumentString(const TIntermSymbol *symbol) { TQualifier qualifier = symbol->getQualifier(); const TType &type = symbol->getType(); TString name = symbol->getSymbol(); if (name.empty()) // HLSL demands named arguments, also for prototypes { - name = "x" + str(mArgumentIndex++); + name = "x" + str(mUniqueIndex++); } else { name = decorate(name); } return qualifierString(qualifier) + " " + typeString(type) + " " + name + arrayString(type); }
--- a/gfx/angle/src/compiler/OutputHLSL.h +++ b/gfx/angle/src/compiler/OutputHLSL.h @@ -115,13 +115,13 @@ class OutputHLSL : public TIntermTravers typedef std::list<TString> StructDeclarations; StructDeclarations mStructDeclarations; typedef std::vector<int> ScopeBracket; ScopeBracket mScopeBracket; unsigned int mScopeDepth; - int mArgumentIndex; // For creating unique argument names + int mUniqueIndex; // For creating unique names }; } #endif // COMPILER_OUTPUTHLSL_H_
--- a/gfx/angle/src/compiler/ParseHelper.cpp +++ b/gfx/angle/src/compiler/ParseHelper.cpp @@ -4,19 +4,45 @@ // found in the LICENSE file. // #include "compiler/ParseHelper.h" #include <stdarg.h> #include <stdio.h> +#include "compiler/glslang.h" #include "compiler/osinclude.h" #include "compiler/InitializeParseContext.h" +extern "C" { +extern int InitPreprocessor(); +extern int FinalizePreprocessor(); +extern void PredefineIntMacro(const char *name, int value); +} + +static void ReportInfo(TInfoSinkBase& sink, + TPrefixType type, TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfo) +{ + /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ + sink.prefix(type); + sink.location(loc); + sink << "'" << token << "' : " << reason << " " << extraInfo << "\n"; +} + +static void DefineExtensionMacros(const TExtensionBehavior& extBehavior) +{ + for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); + iter != extBehavior.end(); ++iter) { + PredefineIntMacro(iter->first.c_str(), 1); + } +} + /////////////////////////////////////////////////////////////////////// // // Sub- vector and matrix fields // //////////////////////////////////////////////////////////////////////// // // Look at a '.' field selector string and change it into offsets @@ -171,34 +197,42 @@ bool TParseContext::parseMatrixFields(co void TParseContext::recover() { recoveredFromError = true; } // // Used by flex/bison to output all syntax and parsing errors. // -void TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, - const char *szExtraInfoFormat, ...) +void TParseContext::error(TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfoFormat, ...) { - char szExtraInfo[400]; + char extraInfo[512]; va_list marker; + va_start(marker, extraInfoFormat); + vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker); - va_start(marker, szExtraInfoFormat); - - vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker); - - /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ - infoSink.info.prefix(EPrefixError); - infoSink.info.location(nLine); - infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n"; + ReportInfo(infoSink.info, EPrefixError, loc, reason, token, extraInfo); va_end(marker); + ++numErrors; +} - ++numErrors; +void TParseContext::warning(TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfoFormat, ...) { + char extraInfo[512]; + va_list marker; + va_start(marker, extraInfoFormat); + vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker); + + ReportInfo(infoSink.info, EPrefixWarning, loc, reason, token, extraInfo); + + va_end(marker); } // // Same error message for all places assignments don't work. // void TParseContext::assignError(int line, const char* op, TString left, TString right) { error(line, "", op, "cannot convert from '%s' to '%s'", @@ -1020,30 +1054,28 @@ bool TParseContext::executeInitializer(T } else intermNode = 0; return false; } bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode) { + ASSERT(aggrNode != NULL); if (!aggrNode->isConstructor()) return false; bool allConstant = true; // check if all the child nodes are constants so that they can be inserted into // the parent node - if (aggrNode) { - TIntermSequence &childSequenceVector = aggrNode->getSequence() ; - for (TIntermSequence::iterator p = childSequenceVector.begin(); - p != childSequenceVector.end(); p++) { - if (!(*p)->getAsTyped()->getAsConstantUnion()) - return false; - } + TIntermSequence &sequence = aggrNode->getSequence() ; + for (TIntermSequence::iterator p = sequence.begin(); p != sequence.end(); ++p) { + if (!(*p)->getAsTyped()->getAsConstantUnion()) + return false; } return allConstant; } // This function is used to test for the correctness of the parameters passed to various constructor functions // and also convert them to the right datatype if it is allowed and required. // @@ -1377,16 +1409,42 @@ TIntermTyped* TParseContext::addConstStr recover(); return 0; } return typedNode; } +// +// Parse an array of strings using yyparse. +// +// Returns 0 for success. +// +int PaParseStrings(int count, const char* const string[], const int length[], + TParseContext* context) { + if ((count == 0) || (string == NULL)) + return 1; + + // setup preprocessor. + if (InitPreprocessor()) + return 1; + DefineExtensionMacros(context->extensionBehavior); + + if (glslang_initialize(context)) + return 1; + + glslang_scan(count, string, length, context); + int error = glslang_parse(context); + + glslang_finalize(context); + FinalizePreprocessor(); + return (error == 0) && (context->numErrors == 0) ? 0 : 1; +} + OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX; bool InitializeParseContextIndex() { if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) { assert(0 && "InitializeParseContextIndex(): Parse Context already initalised"); return false; }
--- a/gfx/angle/src/compiler/ParseHelper.h +++ b/gfx/angle/src/compiler/ParseHelper.h @@ -28,34 +28,36 @@ struct TPragma { // // The following are extra variables needed during parsing, grouped together so // they can be passed to the parser without needing a global. // struct TParseContext { TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, TInfoSink& is) : intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), treeRoot(0), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), - inTypeParen(false), contextPragma(true, false) { } + inTypeParen(false), scanner(NULL), contextPragma(true, false) { } TIntermediate& intermediate; // to hold and build a parse tree TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior. TInfoSink& infoSink; ShShaderType shaderType; // vertex or fragment language (future: pack or unpack) ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. TIntermNode* treeRoot; // root of parse tree being created bool recoveredFromError; // true if a parse error has occurred, but we continue to parse int numErrors; bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier int loopNestingLevel; // 0 if outside all loops bool inTypeParen; // true if in parentheses, looking only for an identifier const TType* currentFunctionType; // the return type of the function that's currently being parsed bool functionReturnsValue; // true if a non-void function has a return - void error(TSourceLoc, const char *szReason, const char *szToken, - const char *szExtraInfoFormat, ...); + void error(TSourceLoc loc, const char *reason, const char* token, + const char* extraInfoFormat, ...); + void warning(TSourceLoc loc, const char* reason, const char* token, + const char* extraInfoFormat, ...); bool reservedErrorCheck(int line, const TString& identifier); void recover(); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line); bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line); void assignError(int line, const char* op, TString left, TString right); void unaryOpError(int line, const char* op, TString operand); void binaryOpError(int line, const char* op, TString left, TString right); @@ -88,26 +90,24 @@ struct TParseContext { TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset); TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); + void* scanner; struct TPragma contextPragma; TString HashErrMsg; bool AfterEOF; }; -int PaParseStrings(const char* const argv[], const int strLen[], int argc, TParseContext&); -void PaReservedWord(); -int PaIdentOrType(TString& id, TParseContext&, TSymbol*&); -int PaParseComment(int &lineno, TParseContext&); -void setInitialState(); +int PaParseStrings(int count, const char* const string[], const int length[], + TParseContext* context); typedef TParseContext* TParseContextPointer; extern TParseContextPointer& GetGlobalParseContext(); #define GlobalParseContext GetGlobalParseContext() typedef struct TThreadParseContextRec { TParseContext *lpGlobalParseContext;
--- a/gfx/angle/src/compiler/PoolAlloc.cpp +++ b/gfx/angle/src/compiler/PoolAlloc.cpp @@ -17,35 +17,29 @@ OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX; void InitializeGlobalPools() { TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); if (globalPools) return; - TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true); + TThreadGlobalPools* threadData = new TThreadGlobalPools(); + threadData->globalPoolAllocator = 0; - TThreadGlobalPools* threadData = new TThreadGlobalPools(); - - threadData->globalPoolAllocator = globalPoolAllocator; - - OS_SetTLSValue(PoolIndex, threadData); - globalPoolAllocator->push(); + OS_SetTLSValue(PoolIndex, threadData); } void FreeGlobalPools() { // Release the allocated memory for this thread. TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); if (!globalPools) return; - - GlobalPoolAllocator.popAll(); - delete &GlobalPoolAllocator; + delete globalPools; } bool InitializePoolIndex() { // Allocate a TLS index. if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX) return false; @@ -61,34 +55,34 @@ void FreePoolIndex() TPoolAllocator& GetGlobalPoolAllocator() { TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); return *threadData->globalPoolAllocator; } -void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator) +void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator) { TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); threadData->globalPoolAllocator = poolAllocator; } // // Implement the functionality of the TPoolAllocator class, which // is documented in PoolAlloc.h. // -TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) : - global(g), +TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) : pageSize(growthIncrement), alignment(allocationAlignment), freeList(0), inUseList(0), - numCalls(0) + numCalls(0), + totalBytes(0) { // // Don't allow page sizes we know are smaller than all common // OS page sizes. // if (pageSize < 4*1024) pageSize = 4*1024; @@ -118,34 +112,24 @@ TPoolAllocator::TPoolAllocator(bool g, i headerSkip = minAlign; if (headerSkip < sizeof(tHeader)) { headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask; } } TPoolAllocator::~TPoolAllocator() { - if (!global) { - // - // Then we know that this object is not being - // allocated after other, globally scoped objects - // that depend on it. So we can delete the "in use" memory. - // - while (inUseList) { - tHeader* next = inUseList->nextPage; - inUseList->~tHeader(); - delete [] reinterpret_cast<char*>(inUseList); - inUseList = next; - } + while (inUseList) { + tHeader* next = inUseList->nextPage; + inUseList->~tHeader(); + delete [] reinterpret_cast<char*>(inUseList); + inUseList = next; } - // - // Always delete the free list memory - it can't be being - // (correctly) referenced, whether the pool allocator was - // global or not. We should not check the guard blocks + // We should not check the guard blocks // here, because we did it already when the block was // placed into the free list. // while (freeList) { tHeader* next = freeList->nextPage; delete [] reinterpret_cast<char*>(freeList); freeList = next; }
--- a/gfx/angle/src/compiler/PoolAlloc.h +++ b/gfx/angle/src/compiler/PoolAlloc.h @@ -110,17 +110,17 @@ private: // re-use. // // The "page size" used is not, nor must it match, the underlying OS // page size. But, having it be about that size or equal to a set of // pages is likely most optimal. // class TPoolAllocator { public: - TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16); + TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16); // // Don't call the destructor just to free up the memory, call pop() // ~TPoolAllocator(); // // Call push() to establish a new place to pop memory too. Does not @@ -189,17 +189,16 @@ protected: #ifdef GUARD_BLOCKS new(memory) TAllocation(numBytes, memory, block->lastAllocation); block->lastAllocation = reinterpret_cast<TAllocation*>(memory); #endif // This is optimized entirely away if GUARD_BLOCKS is not defined. return TAllocation::offsetAllocation(memory); } - bool global; // should be true if this object is globally scoped size_t pageSize; // granularity of allocation from the OS size_t alignment; // all returned allocations will be aligned at // this granularity, which will be a power of 2 size_t alignmentMask; size_t headerSkip; // amount of memory to skip to make room for the // header (basically, size of header, rounded // up to make it aligned size_t currentPageOffset; // next offset in top of inUseList to allocate from @@ -215,28 +214,25 @@ private: }; // // There could potentially be many pools with pops happening at // different times. But a simple use is to have a global pop // with everyone using the same global allocator. // -typedef TPoolAllocator* PoolAllocatorPointer; extern TPoolAllocator& GetGlobalPoolAllocator(); +extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator); #define GlobalPoolAllocator GetGlobalPoolAllocator() - struct TThreadGlobalPools { TPoolAllocator* globalPoolAllocator; }; -void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator); - // // This STL compatible allocator is intended to be used as the allocator // parameter to templatized STL containers, like vector and map. // // It will use the pools for allocation, and not // do any deallocation, but will still do destruction. // template<class T>
new file mode 100644 --- /dev/null +++ b/gfx/angle/src/compiler/SearchSymbol.cpp @@ -0,0 +1,38 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// SearchSymbol is an AST traverser to detect the use of a given symbol name +// + +#include "compiler/SearchSymbol.h" + +#include "compiler/InfoSink.h" +#include "compiler/OutputHLSL.h" + +namespace sh +{ +SearchSymbol::SearchSymbol(const TString &symbol) : mSymbol(symbol) +{ + match = false; +} + +void SearchSymbol::traverse(TIntermNode *node) +{ + node->traverse(this); +} + +void SearchSymbol::visitSymbol(TIntermSymbol *symbolNode) +{ + if (symbolNode->getSymbol() == mSymbol) + { + match = true; + } +} + +bool SearchSymbol::foundMatch() const +{ + return match; +} +}
new file mode 100644 --- /dev/null +++ b/gfx/angle/src/compiler/SearchSymbol.h @@ -0,0 +1,33 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// SearchSymbol is an AST traverser to detect the use of a given symbol name +// + +#ifndef COMPILER_SEARCHSYMBOL_H_ +#define COMPILER_SEARCHSYMBOL_H_ + +#include "compiler/intermediate.h" +#include "compiler/ParseHelper.h" + +namespace sh +{ +class SearchSymbol : public TIntermTraverser +{ + public: + SearchSymbol(const TString &symbol); + + void traverse(TIntermNode *node); + void visitSymbol(TIntermSymbol *symbolNode); + + bool foundMatch() const; + + protected: + const TString &mSymbol; + bool match; +}; +} + +#endif // COMPILER_SEARCHSYMBOL_H_
--- a/gfx/angle/src/compiler/ShHandle.h +++ b/gfx/angle/src/compiler/ShHandle.h @@ -23,19 +23,24 @@ class TCompiler; // // The base class used to back handles returned to the driver. // class TShHandleBase { public: - TShHandleBase() { } - virtual ~TShHandleBase() { } + TShHandleBase(); + virtual ~TShHandleBase(); virtual TCompiler* getAsCompiler() { return 0; } + +protected: + // Memory allocator. Allocates and tracks memory required by the compiler. + // Deallocates all memory when compiler is destructed. + TPoolAllocator allocator; }; // // The base class for the machine dependent compiler to derive from // for managing object code from the compile. // class TCompiler : public TShHandleBase { public: @@ -49,20 +54,25 @@ public: int compileOptions); // Get results of the last compilation. TInfoSink& getInfoSink() { return infoSink; } const TVariableInfoList& getAttribs() const { return attribs; } const TVariableInfoList& getUniforms() const { return uniforms; } protected: + ShShaderType getShaderType() const { return shaderType; } + ShShaderSpec getShaderSpec() const { return shaderSpec; } // Initialize symbol-table with built-in symbols. bool InitBuiltInSymbolTable(const ShBuiltInResources& resources); // Clears the results from the previous compilation. void clearResults(); + // Returns true if the given shader does not exceed the minimum + // functionality mandated in GLSL 1.0 spec Appendix A. + bool validateLimitations(TIntermNode* root); // Collect info for all attribs and uniforms. void collectAttribsUniforms(TIntermNode* root); // Translate to object code. virtual void translate(TIntermNode* root) = 0; private: ShShaderType shaderType; ShShaderSpec shaderSpec;
--- a/gfx/angle/src/compiler/ShaderLang.cpp +++ b/gfx/angle/src/compiler/ShaderLang.cpp @@ -156,25 +156,17 @@ int ShCompile( if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; - GlobalPoolAllocator.push(); - bool success = compiler->compile(shaderStrings, numStrings, compileOptions); - - // - // Throw away all the temporary memory used by the compilation process. - // - GlobalPoolAllocator.pop(); - return success ? 1 : 0; } void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params) { if (!handle || !params) return;
--- a/gfx/angle/src/compiler/SymbolTable.h +++ b/gfx/angle/src/compiler/SymbolTable.h @@ -89,17 +89,20 @@ public: return unionArray; } ConstantUnion* getConstPointer() const { return unionArray; } void shareConstPointer( ConstantUnion *constArray) { - delete unionArray; + if (unionArray == constArray) + return; + + delete[] unionArray; unionArray = constArray; } TVariable(const TVariable&, TStructureMap& remapper); // copy constructor virtual TVariable* clone(TStructureMap& remapper); protected: TType type; bool userType;
--- a/gfx/angle/src/compiler/TranslatorGLSL.cpp +++ b/gfx/angle/src/compiler/TranslatorGLSL.cpp @@ -2,17 +2,36 @@ // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "compiler/TranslatorGLSL.h" #include "compiler/OutputGLSL.h" +#include "compiler/VersionGLSL.h" + +static void writeVersion(ShShaderType type, TIntermNode* root, + TInfoSinkBase& sink) { + TVersionGLSL versionGLSL(type); + root->traverse(&versionGLSL); + int version = versionGLSL.getVersion(); + // We need to write version directive only if it is greater than 110. + // If there is no version directive in the shader, 110 is implied. + if (version > 110) { + sink << "#version " << version << "\n"; + } +} TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec) : TCompiler(type, spec) { } void TranslatorGLSL::translate(TIntermNode* root) { - TOutputGLSL outputGLSL(getInfoSink().obj); + TInfoSinkBase& sink = getInfoSink().obj; + + // Write GLSL version. + writeVersion(getShaderType(), root, sink); + + // Write translated shader. + TOutputGLSL outputGLSL(sink); root->traverse(&outputGLSL); }
--- a/gfx/angle/src/compiler/UnfoldSelect.cpp +++ b/gfx/angle/src/compiler/UnfoldSelect.cpp @@ -1,13 +1,15 @@ // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements +// #include "compiler/UnfoldSelect.h" #include "compiler/InfoSink.h" #include "compiler/OutputHLSL.h" namespace sh { @@ -39,17 +41,17 @@ bool UnfoldSelect::visitSelection(Visit "{\n"; node->getTrueBlock()->traverse(this); out << " t" << i << " = "; node->getTrueBlock()->traverse(mOutputHLSL); out << ";\n" "}\n" "else\n" "{\n"; - node->getCondition()->traverse(this); + node->getFalseBlock()->traverse(this); out << " t" << i << " = "; node->getFalseBlock()->traverse(mOutputHLSL); out << ";\n" "}\n"; mTemporaryIndex--; }
--- a/gfx/angle/src/compiler/UnfoldSelect.h +++ b/gfx/angle/src/compiler/UnfoldSelect.h @@ -1,13 +1,15 @@ // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements +// #ifndef COMPILER_UNFOLDSELECT_H_ #define COMPILER_UNFOLDSELECT_H_ #include "compiler/intermediate.h" #include "compiler/ParseHelper.h" namespace sh
new file mode 100644 --- /dev/null +++ b/gfx/angle/src/compiler/ValidateLimitations.cpp @@ -0,0 +1,468 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/ValidateLimitations.h" +#include "compiler/InfoSink.h" +#include "compiler/ParseHelper.h" + +namespace { +bool IsLoopIndex(const TIntermSymbol* symbol, const TLoopStack& stack) { + for (TLoopStack::const_iterator i = stack.begin(); i != stack.end(); ++i) { + if (i->index.id == symbol->getId()) + return true; + } + return false; +} + +// Traverses a node to check if it represents a constant index expression. +// Definition: +// constant-index-expressions are a superset of constant-expressions. +// Constant-index-expressions can include loop indices as defined in +// GLSL ES 1.0 spec, Appendix A, section 4. +// The following are constant-index-expressions: +// - Constant expressions +// - Loop indices as defined in section 4 +// - Expressions composed of both of the above +class ValidateConstIndexExpr : public TIntermTraverser { +public: + ValidateConstIndexExpr(const TLoopStack& stack) + : mValid(true), mLoopStack(stack) {} + + // Returns true if the parsed node represents a constant index expression. + bool isValid() const { return mValid; } + + virtual void visitSymbol(TIntermSymbol* symbol) { + // Only constants and loop indices are allowed in a + // constant index expression. + if (mValid) { + mValid = (symbol->getQualifier() == EvqConst) || + IsLoopIndex(symbol, mLoopStack); + } + } + virtual void visitConstantUnion(TIntermConstantUnion*) {} + virtual bool visitBinary(Visit, TIntermBinary*) { return true; } + virtual bool visitUnary(Visit, TIntermUnary*) { return true; } + virtual bool visitSelection(Visit, TIntermSelection*) { return true; } + virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; } + virtual bool visitLoop(Visit, TIntermLoop*) { return true; } + virtual bool visitBranch(Visit, TIntermBranch*) { return true; } + +private: + bool mValid; + const TLoopStack& mLoopStack; +}; +} // namespace + +ValidateLimitations::ValidateLimitations(ShShaderType shaderType, + TInfoSinkBase& sink) + : mShaderType(shaderType), + mSink(sink), + mNumErrors(0) +{ +} + +void ValidateLimitations::visitSymbol(TIntermSymbol*) +{ +} + +void ValidateLimitations::visitConstantUnion(TIntermConstantUnion*) +{ +} + +bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node) +{ + // Check if loop index is modified in the loop body. + validateOperation(node, node->getLeft()); + + // Check indexing. + switch (node->getOp()) { + case EOpIndexDirect: + case EOpIndexIndirect: + validateIndexing(node); + break; + default: break; + } + return true; +} + +bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node) +{ + // Check if loop index is modified in the loop body. + validateOperation(node, node->getOperand()); + + return true; +} + +bool ValidateLimitations::visitSelection(Visit, TIntermSelection*) +{ + return true; +} + +bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node) +{ + switch (node->getOp()) { + case EOpFunctionCall: + validateFunctionCall(node); + break; + default: + break; + } + return true; +} + +bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node) +{ + if (!validateLoopType(node)) + return false; + + TLoopInfo info; + memset(&info, 0, sizeof(TLoopInfo)); + if (!validateForLoopHeader(node, &info)) + return false; + + TIntermNode* body = node->getBody(); + if (body != NULL) { + mLoopStack.push_back(info); + body->traverse(this); + mLoopStack.pop_back(); + } + + // The loop is fully processed - no need to visit children. + return false; +} + +bool ValidateLimitations::visitBranch(Visit, TIntermBranch*) +{ + return true; +} + +void ValidateLimitations::error(TSourceLoc loc, + const char *reason, const char* token) +{ + mSink.prefix(EPrefixError); + mSink.location(loc); + mSink << "'" << token << "' : " << reason << "\n"; + ++mNumErrors; +} + +bool ValidateLimitations::withinLoopBody() const +{ + return !mLoopStack.empty(); +} + +bool ValidateLimitations::isLoopIndex(const TIntermSymbol* symbol) const +{ + return IsLoopIndex(symbol, mLoopStack); +} + +bool ValidateLimitations::validateLoopType(TIntermLoop* node) { + TLoopType type = node->getType(); + if (type == ELoopFor) + return true; + + // Reject while and do-while loops. + error(node->getLine(), + "This type of loop is not allowed", + type == ELoopWhile ? "while" : "do"); + return false; +} + +bool ValidateLimitations::validateForLoopHeader(TIntermLoop* node, + TLoopInfo* info) +{ + ASSERT(node->getType() == ELoopFor); + + // + // The for statement has the form: + // for ( init-declaration ; condition ; expression ) statement + // + if (!validateForLoopInit(node, info)) + return false; + if (!validateForLoopCond(node, info)) + return false; + if (!validateForLoopExpr(node, info)) + return false; + + return true; +} + +bool ValidateLimitations::validateForLoopInit(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* init = node->getInit(); + if (init == NULL) { + error(node->getLine(), "Missing init declaration", "for"); + return false; + } + + // + // init-declaration has the form: + // type-specifier identifier = constant-expression + // + TIntermAggregate* decl = init->getAsAggregate(); + if ((decl == NULL) || (decl->getOp() != EOpDeclaration)) { + error(init->getLine(), "Invalid init declaration", "for"); + return false; + } + // To keep things simple do not allow declaration list. + TIntermSequence& declSeq = decl->getSequence(); + if (declSeq.size() != 1) { + error(decl->getLine(), "Invalid init declaration", "for"); + return false; + } + TIntermBinary* declInit = declSeq[0]->getAsBinaryNode(); + if ((declInit == NULL) || (declInit->getOp() != EOpInitialize)) { + error(decl->getLine(), "Invalid init declaration", "for"); + return false; + } + TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode(); + if (symbol == NULL) { + error(declInit->getLine(), "Invalid init declaration", "for"); + return false; + } + // The loop index has type int or float. + TBasicType type = symbol->getBasicType(); + if ((type != EbtInt) && (type != EbtFloat)) { + error(symbol->getLine(), + "Invalid type for loop index", getBasicString(type)); + return false; + } + // The loop index is initialized with constant expression. + if (!isConstExpr(declInit->getRight())) { + error(declInit->getLine(), + "Loop index cannot be initialized with non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + + info->index.id = symbol->getId(); + return true; +} + +bool ValidateLimitations::validateForLoopCond(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* cond = node->getCondition(); + if (cond == NULL) { + error(node->getLine(), "Missing condition", "for"); + return false; + } + // + // condition has the form: + // loop_index relational_operator constant_expression + // + TIntermBinary* binOp = cond->getAsBinaryNode(); + if (binOp == NULL) { + error(node->getLine(), "Invalid condition", "for"); + return false; + } + // Loop index should be to the left of relational operator. + TIntermSymbol* symbol = binOp->getLeft()->getAsSymbolNode(); + if (symbol == NULL) { + error(binOp->getLine(), "Invalid condition", "for"); + return false; + } + if (symbol->getId() != info->index.id) { + error(symbol->getLine(), + "Expected loop index", symbol->getSymbol().c_str()); + return false; + } + // Relational operator is one of: > >= < <= == or !=. + switch (binOp->getOp()) { + case EOpEqual: + case EOpNotEqual: + case EOpLessThan: + case EOpGreaterThan: + case EOpLessThanEqual: + case EOpGreaterThanEqual: + break; + default: + error(binOp->getLine(), + "Invalid relational operator", + getOperatorString(binOp->getOp())); + break; + } + // Loop index must be compared with a constant. + if (!isConstExpr(binOp->getRight())) { + error(binOp->getLine(), + "Loop index cannot be compared with non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + + return true; +} + +bool ValidateLimitations::validateForLoopExpr(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* expr = node->getExpression(); + if (expr == NULL) { + error(node->getLine(), "Missing expression", "for"); + return false; + } + + // for expression has one of the following forms: + // loop_index++ + // loop_index-- + // loop_index += constant_expression + // loop_index -= constant_expression + // ++loop_index + // --loop_index + // The last two forms are not specified in the spec, but I am assuming + // its an oversight. + TIntermUnary* unOp = expr->getAsUnaryNode(); + TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode(); + + TOperator op = EOpNull; + TIntermSymbol* symbol = NULL; + if (unOp != NULL) { + op = unOp->getOp(); + symbol = unOp->getOperand()->getAsSymbolNode(); + } else if (binOp != NULL) { + op = binOp->getOp(); + symbol = binOp->getLeft()->getAsSymbolNode(); + } + + // The operand must be loop index. + if (symbol == NULL) { + error(expr->getLine(), "Invalid expression", "for"); + return false; + } + if (symbol->getId() != info->index.id) { + error(symbol->getLine(), + "Expected loop index", symbol->getSymbol().c_str()); + return false; + } + + // The operator is one of: ++ -- += -=. + switch (op) { + case EOpPostIncrement: + case EOpPostDecrement: + case EOpPreIncrement: + case EOpPreDecrement: + ASSERT((unOp != NULL) && (binOp == NULL)); + break; + case EOpAddAssign: + case EOpSubAssign: + ASSERT((unOp == NULL) && (binOp != NULL)); + break; + default: + error(expr->getLine(), "Invalid operator", getOperatorString(op)); + return false; + } + + // Loop index must be incremented/decremented with a constant. + if (binOp != NULL) { + if (!isConstExpr(binOp->getRight())) { + error(binOp->getLine(), + "Loop index cannot be modified by non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + } + + return true; +} + +bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node) +{ + ASSERT(node->getOp() == EOpFunctionCall); + + // If not within loop body, there is nothing to check. + if (!withinLoopBody()) + return true; + + // List of param indices for which loop indices are used as argument. + typedef std::vector<int> ParamIndex; + ParamIndex pIndex; + TIntermSequence& params = node->getSequence(); + for (TIntermSequence::size_type i = 0; i < params.size(); ++i) { + TIntermSymbol* symbol = params[i]->getAsSymbolNode(); + if (symbol && isLoopIndex(symbol)) + pIndex.push_back(i); + } + // If none of the loop indices are used as arguments, + // there is nothing to check. + if (pIndex.empty()) + return true; + + bool valid = true; + TSymbolTable& symbolTable = GlobalParseContext->symbolTable; + TSymbol* symbol = symbolTable.find(node->getName()); + ASSERT(symbol && symbol->isFunction()); + TFunction* function = static_cast<TFunction*>(symbol); + for (ParamIndex::const_iterator i = pIndex.begin(); + i != pIndex.end(); ++i) { + const TParameter& param = function->getParam(*i); + TQualifier qual = param.type->getQualifier(); +