Commit 29d56fbb by alokp@chromium.org

Added GYP build files. GYP files are needed for integration with chromium and…

Added GYP build files. GYP files are needed for integration with chromium and cross-platform build for glsl translator. It would really be nice if we did not have to maintain two build systems. For now I have only moved the GLSL translator to gyp build system. Please note that the gyp files awkwardly have build_ prefix so they do not conflict with the manually-maintained sln files. Review URL: http://codereview.appspot.com/885043 git-svn-id: https://angleproject.googlecode.com/svn/trunk@98 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0e3358a6
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"],
},
]
# Copyright (c) 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.
{
'targets': [
{
'target_name': 'all',
'type': 'none',
'dependencies': [
# TODO(alokp): build_ prefix should be removed from the gyp files
# as soon as we can get rid of manually-maintained sln files.
# Otherwise auto-generated sln files will overwrite/conflict the
# manually maintained ones.
'../samples/build_samples.gyp:*',
'../src/build_angle.gyp:*',
# '../tests/tests.gyp:*',
],
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
# Copyright (c) 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.
{
'variables': {
'library%': 'static_library',
},
'target_defaults': {
'default_configuration': 'Debug',
'configurations': {
'Common': {
'abstract': 1,
'msvs_configuration_attributes': {
'OutputDirectory': '$(SolutionDir)$(ConfigurationName)',
'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
},
'msvs_configuration_platform': 'Win32',
'msvs_settings': {
'VCCLCompilerTool': {
'BufferSecurityCheck': 'true',
'DebugInformationFormat': '3',
'ExceptionHandling': '0',
'EnableFunctionLevelLinking': 'true',
'MinimalRebuild': 'false',
'PreprocessorDefinitions': [
'_CRT_SECURE_NO_DEPRECATE',
'_HAS_EXCEPTIONS=0',
'_HAS_TR1=0',
'_WIN32_WINNT=0x0600',
'_WINDOWS',
'NOMINMAX',
'WIN32',
'WIN32_LEAN_AND_MEAN',
'WINVER=0x0600',
],
'RuntimeTypeInfo': 'false',
'WarningLevel': '3',
},
'VCLinkerTool': {
'FixedBaseAddress': '1',
'GenerateDebugInformation': 'true',
'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
'MapFileName': '$(OutDir)\\$(TargetName).map',
# SubSystem values:
# 0 == not set
# 1 == /SUBSYSTEM:CONSOLE
# 2 == /SUBSYSTEM:WINDOWS
# Most of the executables we'll ever create are tests
# and utilities with console output.
'SubSystem': '1',
},
},
}, # Common
'Debug': {
'inherit_from': ['Common'],
'msvs_settings': {
'VCCLCompilerTool': {
'Optimization': '0', # /Od
'PreprocessorDefinitions': ['_DEBUG'],
'BasicRuntimeChecks': '3',
'RuntimeLibrary': '1', # /MTd (debug static)
},
'VCLinkerTool': {
'LinkIncremental': '2',
},
},
}, # Debug
'Release': {
'inherit_from': ['Common'],
'msvs_settings': {
'VCCLCompilerTool': {
'Optimization': '2', # /Os
'PreprocessorDefinitions': ['NDEBUG'],
'RuntimeLibrary': '0', # /MT (static)
},
'VCLinkerTool': {
'LinkIncremental': '1',
},
},
}, # Release
}, # configurations
}, # target_defaults
'conditions': [
['OS=="win"', {
'target_defaults': {
'msvs_cygwin_dirs': ['../third_party/cygwin'],
},
}]
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
#!/usr/bin/python
# Copyright (c) 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 script is wrapper for ANGLE that adds some support for how GYP
# is invoked by ANGLE beyond what can be done in the gclient hooks.
import os
import sys
script_dir = os.path.dirname(__file__)
angle_dir = os.path.normpath(os.path.join(script_dir, os.pardir))
sys.path.append(os.path.join(angle_dir, 'third_party', 'gyp', 'pylib'))
import gyp
if __name__ == '__main__':
args = sys.argv[1:]
print 'Updating projects from gyp files...'
sys.stdout.flush()
# Add common.gypi to the include path.
args.append('-I' + os.path.join(script_dir, 'common.gypi'))
# Add all.gyp as the main gyp file to be generated.
args.append(os.path.join(script_dir, 'all.gyp'))
sys.exit(gyp.main(args))
# Copyright (c) 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.
{
'targets': [
{
'target_name': 'essl_to_glsl',
'type': 'executable',
'dependencies': [
'../src/build_angle.gyp:translator_glsl',
],
'include_dirs': [
'../include',
],
'sources': [
'translator/translator.cpp',
],
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
...@@ -61,21 +61,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "..\src\libGLES ...@@ -61,21 +61,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "..\src\libGLES
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_glsl", "..\src\compiler\translator_glsl.vcproj", "{65DB6E65-00E6-4533-8446-5F623BD94909}"
ProjectSection(ProjectDependencies) = postProject
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "..\src\compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "..\src\compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_glsl", "translator\essl_to_glsl.vcproj", "{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}"
ProjectSection(ProjectDependencies) = postProject
{65DB6E65-00E6-4533-8446-5F623BD94909} = {65DB6E65-00E6-4533-8446-5F623BD94909}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_hlsl", "translator\essl_to_hlsl.vcproj", "{E12EA115-EBC7-47C2-B651-30A0CE986025}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_hlsl", "translator\essl_to_hlsl.vcproj", "{E12EA115-EBC7-47C2-B651-30A0CE986025}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
...@@ -137,18 +127,10 @@ Global ...@@ -137,18 +127,10 @@ Global
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.ActiveCfg = Debug|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.Build.0 = Debug|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.ActiveCfg = Release|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.Build.0 = Release|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Debug|Win32.ActiveCfg = Debug|Win32
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Debug|Win32.Build.0 = Debug|Win32
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Release|Win32.ActiveCfg = Release|Win32
{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}.Release|Win32.Build.0 = Release|Win32
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.ActiveCfg = Debug|Win32 {E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.ActiveCfg = Debug|Win32
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.Build.0 = Debug|Win32 {E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.Build.0 = Debug|Win32
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.ActiveCfg = Release|Win32 {E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.ActiveCfg = Release|Win32
......
...@@ -11,11 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libG ...@@ -11,11 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libG
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} {5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_glsl", "compiler\translator_glsl.vcproj", "{65DB6E65-00E6-4533-8446-5F623BD94909}"
ProjectSection(ProjectDependencies) = postProject
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
...@@ -37,10 +32,6 @@ Global ...@@ -37,10 +32,6 @@ Global
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.ActiveCfg = Debug|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Debug|Win32.Build.0 = Debug|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.ActiveCfg = Release|Win32
{65DB6E65-00E6-4533-8446-5F623BD94909}.Release|Win32.Build.0 = Release|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
......
# Copyright (c) 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.
{
'variables': {
# Source files common between translator_glsl and translator_hlsl
'translator_common_sources': [
'common/angleutils.h',
'common/debug.cpp',
'common/debug.h',
'compiler/BaseTypes.h',
'compiler/Common.h',
'compiler/ConstantUnion.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',
'compiler/Intermediate.cpp',
'compiler/intermediate.h',
'compiler/intermOut.cpp',
'compiler/IntermTraverse.cpp',
'compiler/Link.cpp',
'compiler/localintermediate.h',
'compiler/MMap.h',
'compiler/osinclude.h',
'compiler/ossource.cpp',
'compiler/parseConst.cpp',
'compiler/ParseHelper.cpp',
'compiler/ParseHelper.h',
'compiler/PoolAlloc.cpp',
'compiler/PoolAlloc.h',
'compiler/QualifierAlive.cpp',
'compiler/QualifierAlive.h',
'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/preprocessor/atom.c',
'compiler/preprocessor/atom.h',
'compiler/preprocessor/compile.h',
'compiler/preprocessor/cpp.c',
'compiler/preprocessor/cpp.h',
'compiler/preprocessor/cppstruct.c',
'compiler/preprocessor/memory.c',
'compiler/preprocessor/memory.h',
'compiler/preprocessor/parser.h',
'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
'compiler/Gen_glslang.cpp',
'compiler/Gen_glslang_tab.cpp',
'compiler/glslang_tab.h',
],
},
'targets': [
{
'target_name': 'translator_glsl',
'type': '<(library)',
'include_dirs': [
'compiler',
'.',
'../include',
],
'sources': [
'<@(translator_common_sources)',
'compiler/CodeGenGLSL.cpp',
'compiler/OutputGLSL.cpp',
'compiler/OutputGLSL.h',
'compiler/TranslatorGLSL.cpp',
'compiler/TranslatorGLSL.h',
],
'actions': [
{
'action_name': 'flex_glslang',
'inputs': ['compiler/glslang.l'],
'outputs': ['compiler/Gen_glslang.cpp'],
'action': [
'flex',
'--noline',
'--outfile=<(_outputs)',
'<(_inputs)',
],
},
{
'action_name': 'bison_glslang',
'inputs': ['compiler/glslang.y'],
'outputs': ['compiler/Gen_glslang_tab.cpp'],
'action': [
'bison',
'--no-lines',
'--defines=compiler/glslang_tab.h',
'--skeleton=yacc.c',
'--output=<(_outputs)',
'<(_inputs)',
],
},
],
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
...@@ -39,24 +39,23 @@ O [0-7] ...@@ -39,24 +39,23 @@ O [0-7]
#endif #endif
int yy_input(char* buf, int max_size); int yy_input(char* buf, int max_size);
TSourceLoc yylineno;
extern int yyparse(void*);
#ifdef _WIN32 #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
extern int yyparse(TParseContext&); #define parseContext (*((TParseContext*)(parseContextLocal)))
#define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
#else
extern int yyparse(void*);
#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
#define parseContext (*((TParseContext*)(parseContextLocal)))
#endif
#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size)) #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.
*/
%option yylineno
%option noyywrap %option noyywrap
%option never-interactive %option never-interactive
%option outfile="Gen_glslang.cpp"
%x FIELDS %x FIELDS
...@@ -308,12 +307,7 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon ...@@ -308,12 +307,7 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon
yylineno = 1; yylineno = 1;
if (*cpp->PaStrLen >= 0) { if (*cpp->PaStrLen >= 0) {
int ret; int ret = yyparse((void*)(&parseContextLocal));
#ifdef _WIN32
ret = yyparse(parseContextLocal);
#else
ret = yyparse((void*)(&parseContextLocal));
#endif
if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0) if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
return 1; return 1;
else else
......
...@@ -29,60 +29,58 @@ Jutta Degener, 1995 ...@@ -29,60 +29,58 @@ Jutta Degener, 1995
#include "ParseHelper.h" #include "ParseHelper.h"
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#ifdef _WIN32 #define YYPARSE_PARAM parseContextLocal
#define YYPARSE_PARAM parseContext /*
#define YYPARSE_PARAM_DECL TParseContext& TODO(alokp): YYPARSE_PARAM_DECL is only here to support old bison.exe in
#define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext) compiler/tools. Remove it when we can exclusively use the newer version.
#define YYLEX_PARAM parseContext */
#else #define YYPARSE_PARAM_DECL void*
#define YYPARSE_PARAM parseContextLocal #define parseContext ((TParseContext*)(parseContextLocal))
#define parseContext (*((TParseContext*)(parseContextLocal))) #define YYLEX_PARAM parseContextLocal
#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
#define YYLEX_PARAM (void*)(parseContextLocal) extern void yyerror(char*);
extern void yyerror(char*);
#endif
#define FRAG_VERT_ONLY(S, L) { \ #define FRAG_VERT_ONLY(S, L) { \
if (parseContext.language != EShLangFragment && \ if (parseContext->language != EShLangFragment && \
parseContext.language != EShLangVertex) { \ parseContext->language != EShLangVertex) { \
parseContext.error(L, " supported in vertex/fragment shaders only ", S, "", ""); \ parseContext->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
#define VERTEX_ONLY(S, L) { \ #define VERTEX_ONLY(S, L) { \
if (parseContext.language != EShLangVertex) { \ if (parseContext->language != EShLangVertex) { \
parseContext.error(L, " supported in vertex shaders only ", S, "", ""); \ parseContext->error(L, " supported in vertex shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
#define FRAG_ONLY(S, L) { \ #define FRAG_ONLY(S, L) { \
if (parseContext.language != EShLangFragment) { \ if (parseContext->language != EShLangFragment) { \
parseContext.error(L, " supported in fragment shaders only ", S, "", ""); \ parseContext->error(L, " supported in fragment shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
#define PACK_ONLY(S, L) { \ #define PACK_ONLY(S, L) { \
if (parseContext.language != EShLangPack) { \ if (parseContext->language != EShLangPack) { \
parseContext.error(L, " supported in pack shaders only ", S, "", ""); \ parseContext->error(L, " supported in pack shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
#define UNPACK_ONLY(S, L) { \ #define UNPACK_ONLY(S, L) { \
if (parseContext.language != EShLangUnpack) { \ if (parseContext->language != EShLangUnpack) { \
parseContext.error(L, " supported in unpack shaders only ", S, "", ""); \ parseContext->error(L, " supported in unpack shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
#define PACK_UNPACK_ONLY(S, L) { \ #define PACK_UNPACK_ONLY(S, L) { \
if (parseContext.language != EShLangUnpack && \ if (parseContext->language != EShLangUnpack && \
parseContext.language != EShLangPack) { \ parseContext->language != EShLangPack) { \
parseContext.error(L, " supported in pack/unpack shaders only ", S, "", ""); \ parseContext->error(L, " supported in pack/unpack shaders only ", S, "", ""); \
parseContext.recover(); \ parseContext->recover(); \
} \ } \
} }
%} %}
...@@ -119,9 +117,7 @@ Jutta Degener, 1995 ...@@ -119,9 +117,7 @@ Jutta Degener, 1995
} }
%{ %{
#ifndef _WIN32
extern int yylex(YYSTYPE*, void*); extern int yylex(YYSTYPE*, void*);
#endif
%} %}
%pure_parser /* Just in case is called from multiple threads */ %pure_parser /* Just in case is called from multiple threads */
...@@ -189,17 +185,17 @@ variable_identifier ...@@ -189,17 +185,17 @@ variable_identifier
const TSymbol* symbol = $1.symbol; const TSymbol* symbol = $1.symbol;
const TVariable* variable; const TVariable* variable;
if (symbol == 0) { if (symbol == 0) {
parseContext.error($1.line, "undeclared identifier", $1.string->c_str(), ""); parseContext->error($1.line, "undeclared identifier", $1.string->c_str(), "");
parseContext.recover(); parseContext->recover();
TType type(EbtFloat); TType type(EbtFloat);
TVariable* fakeVariable = new TVariable($1.string, type); TVariable* fakeVariable = new TVariable($1.string, type);
parseContext.symbolTable.insert(*fakeVariable); parseContext->symbolTable.insert(*fakeVariable);
variable = fakeVariable; variable = fakeVariable;
} else { } else {
// This identifier can only be a variable type symbol // This identifier can only be a variable type symbol
if (! symbol->isVariable()) { if (! symbol->isVariable()) {
parseContext.error($1.line, "variable expected", $1.string->c_str(), ""); parseContext->error($1.line, "variable expected", $1.string->c_str(), "");
parseContext.recover(); parseContext->recover();
} }
variable = static_cast<const TVariable*>(symbol); variable = static_cast<const TVariable*>(symbol);
} }
...@@ -210,9 +206,9 @@ variable_identifier ...@@ -210,9 +206,9 @@ variable_identifier
if (variable->getType().getQualifier() == EvqConst ) { if (variable->getType().getQualifier() == EvqConst ) {
constUnion* constArray = variable->getConstPointer(); constUnion* constArray = variable->getConstPointer();
TType t(variable->getType()); TType t(variable->getType());
$$ = parseContext.intermediate.addConstantUnion(constArray, t, $1.line); $$ = parseContext->intermediate.addConstantUnion(constArray, t, $1.line);
} else } else
$$ = parseContext.intermediate.addSymbol(variable->getUniqueId(), $$ = parseContext->intermediate.addSymbol(variable->getUniqueId(),
variable->getName(), variable->getName(),
variable->getType(), $1.line); variable->getType(), $1.line);
} }
...@@ -228,22 +224,22 @@ primary_expression ...@@ -228,22 +224,22 @@ primary_expression
// check for overflow for constants // check for overflow for constants
// //
if (abs($1.i) >= (1 << 16)) { if (abs($1.i) >= (1 << 16)) {
parseContext.error($1.line, " integer constant overflow", "", ""); parseContext->error($1.line, " integer constant overflow", "", "");
parseContext.recover(); parseContext->recover();
} }
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setIConst($1.i); unionArray->setIConst($1.i);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.line);
} }
| FLOATCONSTANT { | FLOATCONSTANT {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setFConst($1.f); unionArray->setFConst($1.f);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
} }
| BOOLCONSTANT { | BOOLCONSTANT {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst($1.b); unionArray->setBConst($1.b);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.line);
} }
| LEFT_PAREN expression RIGHT_PAREN { | LEFT_PAREN expression RIGHT_PAREN {
$$ = $2; $$ = $2;
...@@ -257,57 +253,57 @@ postfix_expression ...@@ -257,57 +253,57 @@ postfix_expression
| postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET { | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) { if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {
if ($1->getAsSymbolNode()) if ($1->getAsSymbolNode())
parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), ""); parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
else else
parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", ""); parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
parseContext.recover(); parseContext->recover();
} }
if ($1->getType().getQualifier() == EvqConst && $3->getQualifier() == EvqConst) { if ($1->getType().getQualifier() == EvqConst && $3->getQualifier() == EvqConst) {
if ($1->isArray()) { // constant folding for arrays if ($1->isArray()) { // constant folding for arrays
$$ = parseContext.addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); $$ = parseContext->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
} else if ($1->isVector()) { // constant folding for vectors } else if ($1->isVector()) { // constant folding for vectors
TVectorFields fields; TVectorFields fields;
fields.num = 1; fields.num = 1;
fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // need to do it this way because v.xy sends fields integer array fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // need to do it this way because v.xy sends fields integer array
$$ = parseContext.addConstVectorNode(fields, $1, $2.line); $$ = parseContext->addConstVectorNode(fields, $1, $2.line);
} else if ($1->isMatrix()) { // constant folding for matrices } else if ($1->isMatrix()) { // constant folding for matrices
$$ = parseContext.addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); $$ = parseContext->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
} }
} else { } else {
if ($3->getQualifier() == EvqConst) { if ($3->getQualifier() == EvqConst) {
if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() && !$1->isArray() ) { if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() && !$1->isArray() ) {
parseContext.error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); parseContext->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
parseContext.recover(); parseContext->recover();
} else { } else {
if ($1->isArray()) { if ($1->isArray()) {
if ($1->getType().getArraySize() == 0) { if ($1->getType().getArraySize() == 0) {
if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) { if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) {
if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line)) if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line))
parseContext.recover(); parseContext->recover();
} else { } else {
if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line)) if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
parseContext.recover(); parseContext->recover();
} }
} else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= $1->getType().getArraySize()) { } else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= $1->getType().getArraySize()) {
parseContext.error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); parseContext->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
parseContext.recover(); parseContext->recover();
} }
} }
$$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
} }
} else { } else {
if ($1->isArray() && $1->getType().getArraySize() == 0) { if ($1->isArray() && $1->getType().getArraySize() == 0) {
parseContext.error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable"); parseContext->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
parseContext.recover(); parseContext->recover();
} }
$$ = parseContext.intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
} }
} }
if ($$ == 0) { if ($$ == 0) {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setFConst(0.0f); unionArray->setFConst(0.0f);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line);
} else if ($1->isArray()) { } else if ($1->isArray()) {
if ($1->getType().getStruct()) if ($1->getType().getStruct())
$$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName())); $$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName()));
...@@ -332,22 +328,22 @@ postfix_expression ...@@ -332,22 +328,22 @@ postfix_expression
} }
| postfix_expression DOT FIELD_SELECTION { | postfix_expression DOT FIELD_SELECTION {
if ($1->isArray()) { if ($1->isArray()) {
parseContext.error($3.line, "cannot apply dot operator to an array", ".", ""); parseContext->error($3.line, "cannot apply dot operator to an array", ".", "");
parseContext.recover(); parseContext->recover();
} }
if ($1->isVector()) { if ($1->isVector()) {
TVectorFields fields; TVectorFields fields;
if (! parseContext.parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { if (! parseContext->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
fields.num = 1; fields.num = 1;
fields.offsets[0] = 0; fields.offsets[0] = 0;
parseContext.recover(); parseContext->recover();
} }
if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields
$$ = parseContext.addConstVectorNode(fields, $1, $3.line); $$ = parseContext->addConstVectorNode(fields, $1, $3.line);
if ($$ == 0) { if ($$ == 0) {
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
else else
...@@ -356,47 +352,47 @@ postfix_expression ...@@ -356,47 +352,47 @@ postfix_expression
if (fields.num == 1) { if (fields.num == 1) {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setIConst(fields.offsets[0]); unionArray->setIConst(fields.offsets[0]);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line); TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
$$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType())); $$->setType(TType($1->getBasicType()));
} else { } else {
TString vectorString = *$3.string; TString vectorString = *$3.string;
TIntermTyped* index = parseContext.intermediate.addSwizzle(fields, $3.line); TIntermTyped* index = parseContext->intermediate.addSwizzle(fields, $3.line);
$$ = parseContext.intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line); $$ = parseContext->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
$$->setType(TType($1->getBasicType(),EvqTemporary, (int) vectorString.size())); $$->setType(TType($1->getBasicType(),EvqTemporary, (int) vectorString.size()));
} }
} }
} else if ($1->isMatrix()) { } else if ($1->isMatrix()) {
TMatrixFields fields; TMatrixFields fields;
if (! parseContext.parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { if (! parseContext->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
fields.wholeRow = false; fields.wholeRow = false;
fields.wholeCol = false; fields.wholeCol = false;
fields.row = 0; fields.row = 0;
fields.col = 0; fields.col = 0;
parseContext.recover(); parseContext->recover();
} }
if (fields.wholeRow || fields.wholeCol) { if (fields.wholeRow || fields.wholeCol) {
parseContext.error($2.line, " non-scalar fields not implemented yet", ".", ""); parseContext->error($2.line, " non-scalar fields not implemented yet", ".", "");
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setIConst(0); unionArray->setIConst(0);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line); TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
$$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize())); $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize()));
} else { } else {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row); unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line); TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
$$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType())); $$->setType(TType($1->getBasicType()));
} }
} else if ($1->getBasicType() == EbtStruct) { } else if ($1->getBasicType() == EbtStruct) {
bool fieldFound = false; bool fieldFound = false;
TTypeList* fields = $1->getType().getStruct(); TTypeList* fields = $1->getType().getStruct();
if (fields == 0) { if (fields == 0) {
parseContext.error($2.line, "structure has no fields", "Internal Error", ""); parseContext->error($2.line, "structure has no fields", "Internal Error", "");
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} else { } else {
unsigned int i; unsigned int i;
...@@ -408,9 +404,9 @@ postfix_expression ...@@ -408,9 +404,9 @@ postfix_expression
} }
if (fieldFound) { if (fieldFound) {
if ($1->getType().getQualifier() == EvqConst) { if ($1->getType().getQualifier() == EvqConst) {
$$ = parseContext.addConstStruct(*$3.string, $1, $2.line); $$ = parseContext->addConstStruct(*$3.string, $1, $2.line);
if ($$ == 0) { if ($$ == 0) {
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
else { else {
...@@ -422,40 +418,40 @@ postfix_expression ...@@ -422,40 +418,40 @@ postfix_expression
} else { } else {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setIConst(i); unionArray->setIConst(i);
TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line); TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
$$ = parseContext.intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line); $$ = parseContext->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
$$->setType(*(*fields)[i].type); $$->setType(*(*fields)[i].type);
} }
} else { } else {
parseContext.error($2.line, " no such field in structure", $3.string->c_str(), ""); parseContext->error($2.line, " no such field in structure", $3.string->c_str(), "");
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
} else { } else {
parseContext.error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), ""); parseContext->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
// don't delete $3.string, it's from the pool // don't delete $3.string, it's from the pool
} }
| postfix_expression INC_OP { | postfix_expression INC_OP {
if (parseContext.lValueErrorCheck($2.line, "++", $1)) if (parseContext->lValueErrorCheck($2.line, "++", $1))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.unaryOpError($2.line, "++", $1->getCompleteString()); parseContext->unaryOpError($2.line, "++", $1->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
| postfix_expression DEC_OP { | postfix_expression DEC_OP {
if (parseContext.lValueErrorCheck($2.line, "--", $1)) if (parseContext->lValueErrorCheck($2.line, "--", $1))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.unaryOpError($2.line, "--", $1->getCompleteString()); parseContext->unaryOpError($2.line, "--", $1->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
...@@ -463,8 +459,8 @@ postfix_expression ...@@ -463,8 +459,8 @@ postfix_expression
integer_expression integer_expression
: expression { : expression {
if (parseContext.integerErrorCheck($1, "[]")) if (parseContext->integerErrorCheck($1, "[]"))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
; ;
...@@ -482,18 +478,18 @@ function_call ...@@ -482,18 +478,18 @@ function_call
// Their parameters will be verified algorithmically. // Their parameters will be verified algorithmically.
// //
TType type(EbtVoid); // use this to get the type back TType type(EbtVoid); // use this to get the type back
if (parseContext.constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) { if (parseContext->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
$$ = 0; $$ = 0;
} else { } else {
// //
// It's a constructor, of type 'type'. // It's a constructor, of type 'type'.
// //
$$ = parseContext.addConstructor($1.intermNode, &type, op, fnCall, $1.line); $$ = parseContext->addConstructor($1.intermNode, &type, op, fnCall, $1.line);
} }
if ($$ == 0) { if ($$ == 0) {
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.setAggregateOperator(0, op, $1.line); $$ = parseContext->intermediate.setAggregateOperator(0, op, $1.line);
} }
$$->setType(type); $$->setType(type);
} else { } else {
...@@ -502,7 +498,7 @@ function_call ...@@ -502,7 +498,7 @@ function_call
// //
const TFunction* fnCandidate; const TFunction* fnCandidate;
bool builtIn; bool builtIn;
fnCandidate = parseContext.findFunction($1.line, fnCall, &builtIn); fnCandidate = parseContext->findFunction($1.line, fnCall, &builtIn);
if (fnCandidate) { if (fnCandidate) {
// //
// A declared function. But, it might still map to a built-in // A declared function. But, it might still map to a built-in
...@@ -517,20 +513,20 @@ function_call ...@@ -517,20 +513,20 @@ function_call
// //
// Treat it like a built-in unary operator. // Treat it like a built-in unary operator.
// //
$$ = parseContext.intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.error($1.intermNode->getLine(), " wrong operand type", "Internal Error", parseContext->error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s", "built in unary operator function. Type: %s",
static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str()); static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str());
YYERROR; YYERROR;
} }
} else { } else {
$$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, op, $1.line); $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
} }
} else { } else {
// This is a real function call // This is a real function call
$$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line); $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
$$->setType(fnCandidate->getReturnType()); $$->setType(fnCandidate->getReturnType());
// this is how we know whether the given function is a builtIn function or a user defined function // this is how we know whether the given function is a builtIn function or a user defined function
...@@ -545,9 +541,9 @@ function_call ...@@ -545,9 +541,9 @@ function_call
for (int i = 0; i < fnCandidate->getParamCount(); ++i) { for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
qual = (*fnCandidate)[i].type->getQualifier(); qual = (*fnCandidate)[i].type->getQualifier();
if (qual == EvqOut || qual == EvqInOut) { if (qual == EvqOut || qual == EvqInOut) {
if (parseContext.lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) { if (parseContext->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
parseContext.error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", ""); parseContext->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
parseContext.recover(); parseContext->recover();
} }
} }
qualifierList.push_back(qual); qualifierList.push_back(qual);
...@@ -559,8 +555,8 @@ function_call ...@@ -559,8 +555,8 @@ function_call
// Put on a dummy node for error recovery // Put on a dummy node for error recovery
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setFConst(0.0f); unionArray->setFConst(0.0f);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
parseContext.recover(); parseContext->recover();
} }
} }
delete fnCall; delete fnCall;
...@@ -572,8 +568,8 @@ function_call_or_method ...@@ -572,8 +568,8 @@ function_call_or_method
$$ = $1; $$ = $1;
} }
| postfix_expression DOT function_call_generic { | postfix_expression DOT function_call_generic {
parseContext.error($3.line, "methods are not supported", "", ""); parseContext->error($3.line, "methods are not supported", "", "");
parseContext.recover(); parseContext->recover();
$$ = $3; $$ = $3;
} }
; ;
...@@ -611,7 +607,7 @@ function_call_header_with_parameters ...@@ -611,7 +607,7 @@ function_call_header_with_parameters
TParameter param = { 0, new TType($3->getType()) }; TParameter param = { 0, new TType($3->getType()) };
$1.function->addParameter(param); $1.function->addParameter(param);
$$.function = $1.function; $$.function = $1.function;
$$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.line); $$.intermNode = parseContext->intermediate.growAggregate($1.intermNode, $3, $2.line);
} }
; ;
...@@ -629,8 +625,8 @@ function_identifier ...@@ -629,8 +625,8 @@ function_identifier
// Constructor // Constructor
// //
if ($1.array) { if ($1.array) {
if (parseContext.extensionErrorCheck($1.line, "GL_3DL_array_objects")) { if (parseContext->extensionErrorCheck($1.line, "GL_3DL_array_objects")) {
parseContext.recover(); parseContext->recover();
$1.setArray(false); $1.setArray(false);
} }
} }
...@@ -677,8 +673,8 @@ function_identifier ...@@ -677,8 +673,8 @@ function_identifier
break; break;
} }
if (op == EOpNull) { if (op == EOpNull) {
parseContext.error($1.line, "cannot construct this type", TType::getBasicString($1.type), ""); parseContext->error($1.line, "cannot construct this type", TType::getBasicString($1.type), "");
parseContext.recover(); parseContext->recover();
$1.type = EbtFloat; $1.type = EbtFloat;
op = EOpConstructFloat; op = EOpConstructFloat;
} }
...@@ -689,15 +685,15 @@ function_identifier ...@@ -689,15 +685,15 @@ function_identifier
} }
} }
| IDENTIFIER { | IDENTIFIER {
if (parseContext.reservedErrorCheck($1.line, *$1.string)) if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext.recover(); parseContext->recover();
TType type(EbtVoid); TType type(EbtVoid);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
} }
| FIELD_SELECTION { | FIELD_SELECTION {
if (parseContext.reservedErrorCheck($1.line, *$1.string)) if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext.recover(); parseContext->recover();
TType type(EbtVoid); TType type(EbtVoid);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
...@@ -709,28 +705,28 @@ unary_expression ...@@ -709,28 +705,28 @@ unary_expression
$$ = $1; $$ = $1;
} }
| INC_OP unary_expression { | INC_OP unary_expression {
if (parseContext.lValueErrorCheck($1.line, "++", $2)) if (parseContext->lValueErrorCheck($1.line, "++", $2))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.unaryOpError($1.line, "++", $2->getCompleteString()); parseContext->unaryOpError($1.line, "++", $2->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $2; $$ = $2;
} }
} }
| DEC_OP unary_expression { | DEC_OP unary_expression {
if (parseContext.lValueErrorCheck($1.line, "--", $2)) if (parseContext->lValueErrorCheck($1.line, "--", $2))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.unaryOpError($1.line, "--", $2->getCompleteString()); parseContext->unaryOpError($1.line, "--", $2->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $2; $$ = $2;
} }
} }
| unary_operator unary_expression { | unary_operator unary_expression {
if ($1.op != EOpNull) { if ($1.op != EOpNull) {
$$ = parseContext.intermediate.addUnaryMath($1.op, $2, $1.line, parseContext.symbolTable); $$ = parseContext->intermediate.addUnaryMath($1.op, $2, $1.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
const char* errorOp = ""; const char* errorOp = "";
switch($1.op) { switch($1.op) {
...@@ -738,8 +734,8 @@ unary_expression ...@@ -738,8 +734,8 @@ unary_expression
case EOpLogicalNot: errorOp = "!"; break; case EOpLogicalNot: errorOp = "!"; break;
default: break; default: break;
} }
parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString()); parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $2; $$ = $2;
} }
} else } else
...@@ -759,19 +755,19 @@ multiplicative_expression ...@@ -759,19 +755,19 @@ multiplicative_expression
: unary_expression { $$ = $1; } : unary_expression { $$ = $1; }
| multiplicative_expression STAR unary_expression { | multiplicative_expression STAR unary_expression {
FRAG_VERT_ONLY("*", $2.line); FRAG_VERT_ONLY("*", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
| multiplicative_expression SLASH unary_expression { | multiplicative_expression SLASH unary_expression {
FRAG_VERT_ONLY("/", $2.line); FRAG_VERT_ONLY("/", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
...@@ -780,18 +776,18 @@ multiplicative_expression ...@@ -780,18 +776,18 @@ multiplicative_expression
additive_expression additive_expression
: multiplicative_expression { $$ = $1; } : multiplicative_expression { $$ = $1; }
| additive_expression PLUS multiplicative_expression { | additive_expression PLUS multiplicative_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
| additive_expression DASH multiplicative_expression { | additive_expression DASH multiplicative_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
} }
...@@ -804,43 +800,43 @@ shift_expression ...@@ -804,43 +800,43 @@ shift_expression
relational_expression relational_expression
: shift_expression { $$ = $1; } : shift_expression { $$ = $1; }
| relational_expression LEFT_ANGLE shift_expression { | relational_expression LEFT_ANGLE shift_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
| relational_expression RIGHT_ANGLE shift_expression { | relational_expression RIGHT_ANGLE shift_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
| relational_expression LE_OP shift_expression { | relational_expression LE_OP shift_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
| relational_expression GE_OP shift_expression { | relational_expression GE_OP shift_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
; ;
...@@ -848,26 +844,26 @@ relational_expression ...@@ -848,26 +844,26 @@ relational_expression
equality_expression equality_expression
: relational_expression { $$ = $1; } : relational_expression { $$ = $1; }
| equality_expression EQ_OP relational_expression { | equality_expression EQ_OP relational_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} else if (($1->isArray() || $3->isArray()) && parseContext.extensionErrorCheck($2.line, "GL_3DL_array_objects")) } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
parseContext.recover(); parseContext->recover();
} }
| equality_expression NE_OP relational_expression { | equality_expression NE_OP relational_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} else if (($1->isArray() || $3->isArray()) && parseContext.extensionErrorCheck($2.line, "GL_3DL_array_objects")) } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
parseContext.recover(); parseContext->recover();
} }
; ;
...@@ -886,13 +882,13 @@ inclusive_or_expression ...@@ -886,13 +882,13 @@ inclusive_or_expression
logical_and_expression logical_and_expression
: inclusive_or_expression { $$ = $1; } : inclusive_or_expression { $$ = $1; }
| logical_and_expression AND_OP inclusive_or_expression { | logical_and_expression AND_OP inclusive_or_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
; ;
...@@ -900,13 +896,13 @@ logical_and_expression ...@@ -900,13 +896,13 @@ logical_and_expression
logical_xor_expression logical_xor_expression
: logical_and_expression { $$ = $1; } : logical_and_expression { $$ = $1; }
| logical_xor_expression XOR_OP logical_and_expression { | logical_xor_expression XOR_OP logical_and_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
; ;
...@@ -914,13 +910,13 @@ logical_xor_expression ...@@ -914,13 +910,13 @@ logical_xor_expression
logical_or_expression logical_or_expression
: logical_xor_expression { $$ = $1; } : logical_xor_expression { $$ = $1; }
| logical_or_expression OR_OP logical_xor_expression { | logical_or_expression OR_OP logical_xor_expression {
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext.symbolTable); $$ = parseContext->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext->symbolTable);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line); $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
} }
} }
; ;
...@@ -928,16 +924,16 @@ logical_or_expression ...@@ -928,16 +924,16 @@ logical_or_expression
conditional_expression conditional_expression
: logical_or_expression { $$ = $1; } : logical_or_expression { $$ = $1; }
| logical_or_expression QUESTION expression COLON assignment_expression { | logical_or_expression QUESTION expression COLON assignment_expression {
if (parseContext.boolErrorCheck($2.line, $1)) if (parseContext->boolErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addSelection($1, $3, $5, $2.line); $$ = parseContext->intermediate.addSelection($1, $3, $5, $2.line);
if ($3->getType() != $5->getType()) if ($3->getType() != $5->getType())
$$ = 0; $$ = 0;
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString()); parseContext->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $5; $$ = $5;
} }
} }
...@@ -946,15 +942,15 @@ conditional_expression ...@@ -946,15 +942,15 @@ conditional_expression
assignment_expression assignment_expression
: conditional_expression { $$ = $1; } : conditional_expression { $$ = $1; }
| unary_expression assignment_operator assignment_expression { | unary_expression assignment_operator assignment_expression {
if (parseContext.lValueErrorCheck($2.line, "assign", $1)) if (parseContext->lValueErrorCheck($2.line, "assign", $1))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.line); $$ = parseContext->intermediate.addAssign($2.op, $1, $3, $2.line);
if ($$ == 0) { if ($$ == 0) {
parseContext.assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString()); parseContext->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} else if (($1->isArray() || $3->isArray()) && parseContext.extensionErrorCheck($2.line, "GL_3DL_array_objects")) } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
parseContext.recover(); parseContext->recover();
} }
; ;
...@@ -971,10 +967,10 @@ expression ...@@ -971,10 +967,10 @@ expression
$$ = $1; $$ = $1;
} }
| expression COMMA assignment_expression { | expression COMMA assignment_expression {
$$ = parseContext.intermediate.addComma($1, $3, $2.line); $$ = parseContext->intermediate.addComma($1, $3, $2.line);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString()); parseContext->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover(); parseContext->recover();
$$ = $3; $$ = $3;
} }
} }
...@@ -982,8 +978,8 @@ expression ...@@ -982,8 +978,8 @@ expression
constant_expression constant_expression
: conditional_expression { : conditional_expression {
if (parseContext.constErrorCheck($1)) if (parseContext->constErrorCheck($1))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
} }
; ;
...@@ -1010,16 +1006,16 @@ function_prototype ...@@ -1010,16 +1006,16 @@ function_prototype
// //
// Redeclarations are allowed. But, return types and parameter qualifiers must match. // Redeclarations are allowed. But, return types and parameter qualifiers must match.
// //
TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find($1->getMangledName())); TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find($1->getMangledName()));
if (prevDec) { if (prevDec) {
if (prevDec->getReturnType() != $1->getReturnType()) { if (prevDec->getReturnType() != $1->getReturnType()) {
parseContext.error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), ""); parseContext->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
parseContext.recover(); parseContext->recover();
} }
for (int i = 0; i < prevDec->getParamCount(); ++i) { for (int i = 0; i < prevDec->getParamCount(); ++i) {
if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) { if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) {
parseContext.error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), ""); parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), "");
parseContext.recover(); parseContext->recover();
} }
} }
} }
...@@ -1032,7 +1028,7 @@ function_prototype ...@@ -1032,7 +1028,7 @@ function_prototype
$$.function = $1; $$.function = $1;
$$.line = $2.line; $$.line = $2.line;
parseContext.symbolTable.insert(*$$.function); parseContext->symbolTable.insert(*$$.function);
} }
; ;
...@@ -1064,8 +1060,8 @@ function_header_with_parameters ...@@ -1064,8 +1060,8 @@ function_header_with_parameters
// //
// This parameter > first is void // This parameter > first is void
// //
parseContext.error($2.line, "cannot be an argument type except for '(void)'", "void", ""); parseContext->error($2.line, "cannot be an argument type except for '(void)'", "void", "");
parseContext.recover(); parseContext->recover();
delete $3.param.type; delete $3.param.type;
} else { } else {
// Add the parameter // Add the parameter
...@@ -1078,12 +1074,12 @@ function_header_with_parameters ...@@ -1078,12 +1074,12 @@ function_header_with_parameters
function_header function_header
: fully_specified_type IDENTIFIER LEFT_PAREN { : fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) { if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) {
parseContext.error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), ""); parseContext->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
parseContext.recover(); parseContext->recover();
} }
// make sure a sampler is not involved as well... // make sure a sampler is not involved as well...
if (parseContext.structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
// Add the function as a prototype after parsing it (we do not support recursion) // Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function; TFunction *function;
...@@ -1097,26 +1093,26 @@ parameter_declarator ...@@ -1097,26 +1093,26 @@ parameter_declarator
// Type + name // Type + name
: type_specifier IDENTIFIER { : type_specifier IDENTIFIER {
if ($1.type == EbtVoid) { if ($1.type == EbtVoid) {
parseContext.error($2.line, "illegal use of type 'void'", $2.string->c_str(), ""); parseContext->error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
parseContext.recover(); parseContext->recover();
} }
if (parseContext.reservedErrorCheck($2.line, *$2.string)) if (parseContext->reservedErrorCheck($2.line, *$2.string))
parseContext.recover(); parseContext->recover();
TParameter param = {$2.string, new TType($1)}; TParameter param = {$2.string, new TType($1)};
$$.line = $2.line; $$.line = $2.line;
$$.param = param; $$.param = param;
} }
| type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
// Check that we can make an array out of this type // Check that we can make an array out of this type
if (parseContext.arrayTypeErrorCheck($3.line, $1)) if (parseContext->arrayTypeErrorCheck($3.line, $1))
parseContext.recover(); parseContext->recover();
if (parseContext.reservedErrorCheck($2.line, *$2.string)) if (parseContext->reservedErrorCheck($2.line, *$2.string))
parseContext.recover(); parseContext->recover();
int size; int size;
if (parseContext.arraySizeErrorCheck($3.line, $4, size)) if (parseContext->arraySizeErrorCheck($3.line, $4, size))
parseContext.recover(); parseContext->recover();
$1.setArray(true, size); $1.setArray(true, size);
TType* type = new TType($1); TType* type = new TType($1);
...@@ -1137,30 +1133,30 @@ parameter_declaration ...@@ -1137,30 +1133,30 @@ parameter_declaration
// //
: type_qualifier parameter_qualifier parameter_declarator { : type_qualifier parameter_qualifier parameter_declarator {
$$ = $3; $$ = $3;
if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
parseContext.recover(); parseContext->recover();
} }
| parameter_qualifier parameter_declarator { | parameter_qualifier parameter_declarator {
$$ = $2; $$ = $2;
if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
parseContext.recover(); parseContext->recover();
if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
parseContext.recover(); parseContext->recover();
} }
// //
// Only type // Only type
// //
| type_qualifier parameter_qualifier parameter_type_specifier { | type_qualifier parameter_qualifier parameter_type_specifier {
$$ = $3; $$ = $3;
if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
parseContext.recover(); parseContext->recover();
} }
| parameter_qualifier parameter_type_specifier { | parameter_qualifier parameter_type_specifier {
$$ = $2; $$ = $2;
if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
parseContext.recover(); parseContext->recover();
if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
parseContext.recover(); parseContext->recover();
} }
; ;
...@@ -1191,142 +1187,142 @@ init_declarator_list ...@@ -1191,142 +1187,142 @@ init_declarator_list
$$ = $1; $$ = $1;
} }
| init_declarator_list COMMA IDENTIFIER { | init_declarator_list COMMA IDENTIFIER {
$$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, parseContext.intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line); $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, parseContext->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line);
if (parseContext.structQualifierErrorCheck($3.line, $$.type)) if (parseContext->structQualifierErrorCheck($3.line, $$.type))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($3.line, *$3.string, $$.type)) if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitErrorCheck($3.line, *$3.string, $$.type)) if (parseContext->nonInitErrorCheck($3.line, *$3.string, $$.type))
parseContext.recover(); parseContext->recover();
} }
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET { | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
if (parseContext.structQualifierErrorCheck($3.line, $1.type)) if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($3.line, *$3.string, $1.type)) if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
if (parseContext.arrayTypeErrorCheck($4.line, $1.type) || parseContext.arrayQualifierErrorCheck($4.line, $1.type)) if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext.recover(); parseContext->recover();
else { else {
$1.type.setArray(true); $1.type.setArray(true);
TVariable* variable; TVariable* variable;
if (parseContext.arrayErrorCheck($4.line, *$3.string, $1.type, variable)) if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext.recover(); parseContext->recover();
} }
} }
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
if (parseContext.structQualifierErrorCheck($3.line, $1.type)) if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($3.line, *$3.string, $1.type)) if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
if (parseContext.arrayTypeErrorCheck($4.line, $1.type) || parseContext.arrayQualifierErrorCheck($4.line, $1.type)) if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext.recover(); parseContext->recover();
else { else {
int size; int size;
if (parseContext.arraySizeErrorCheck($4.line, $5, size)) if (parseContext->arraySizeErrorCheck($4.line, $5, size))
parseContext.recover(); parseContext->recover();
$1.type.setArray(true, size); $1.type.setArray(true, size);
TVariable* variable; TVariable* variable;
if (parseContext.arrayErrorCheck($4.line, *$3.string, $1.type, variable)) if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext.recover(); parseContext->recover();
} }
} }
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer {
if (parseContext.structQualifierErrorCheck($3.line, $1.type)) if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
TVariable* variable = 0; TVariable* variable = 0;
if (parseContext.arrayTypeErrorCheck($4.line, $1.type) || parseContext.arrayQualifierErrorCheck($4.line, $1.type)) if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext.recover(); parseContext->recover();
else { else {
$1.type.setArray(true, $7->getType().getArraySize()); $1.type.setArray(true, $7->getType().getArraySize());
if (parseContext.arrayErrorCheck($4.line, *$3.string, $1.type, variable)) if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext.recover(); parseContext->recover();
} }
if (parseContext.extensionErrorCheck($$.line, "GL_3DL_array_objects")) if (parseContext->extensionErrorCheck($$.line, "GL_3DL_array_objects"))
parseContext.recover(); parseContext->recover();
else { else {
TIntermNode* intermNode; TIntermNode* intermNode;
if (!parseContext.executeInitializer($3.line, *$3.string, $1.type, $7, intermNode, variable)) { if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $7, intermNode, variable)) {
// //
// build the intermediate representation // build the intermediate representation
// //
if (intermNode) if (intermNode)
$$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $6.line); $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $6.line);
else else
$$.intermAggregate = $1.intermAggregate; $$.intermAggregate = $1.intermAggregate;
} else { } else {
parseContext.recover(); parseContext->recover();
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
} }
} }
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer {
if (parseContext.structQualifierErrorCheck($3.line, $1.type)) if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
TVariable* variable = 0; TVariable* variable = 0;
if (parseContext.arrayTypeErrorCheck($4.line, $1.type) || parseContext.arrayQualifierErrorCheck($4.line, $1.type)) if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext.recover(); parseContext->recover();
else { else {
int size; int size;
if (parseContext.arraySizeErrorCheck($4.line, $5, size)) if (parseContext->arraySizeErrorCheck($4.line, $5, size))
parseContext.recover(); parseContext->recover();
$1.type.setArray(true, size); $1.type.setArray(true, size);
if (parseContext.arrayErrorCheck($4.line, *$3.string, $1.type, variable)) if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext.recover(); parseContext->recover();
} }
if (parseContext.extensionErrorCheck($$.line, "GL_3DL_array_objects")) if (parseContext->extensionErrorCheck($$.line, "GL_3DL_array_objects"))
parseContext.recover(); parseContext->recover();
else { else {
TIntermNode* intermNode; TIntermNode* intermNode;
if (!parseContext.executeInitializer($3.line, *$3.string, $1.type, $8, intermNode, variable)) { if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $8, intermNode, variable)) {
// //
// build the intermediate representation // build the intermediate representation
// //
if (intermNode) if (intermNode)
$$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $7.line); $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $7.line);
else else
$$.intermAggregate = $1.intermAggregate; $$.intermAggregate = $1.intermAggregate;
} else { } else {
parseContext.recover(); parseContext->recover();
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
} }
} }
| init_declarator_list COMMA IDENTIFIER EQUAL initializer { | init_declarator_list COMMA IDENTIFIER EQUAL initializer {
if (parseContext.structQualifierErrorCheck($3.line, $1.type)) if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext.recover(); parseContext->recover();
$$ = $1; $$ = $1;
TIntermNode* intermNode; TIntermNode* intermNode;
if (!parseContext.executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) { if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) {
// //
// build the intermediate representation // build the intermediate representation
// //
if (intermNode) if (intermNode)
$$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $4.line); $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $4.line);
else else
$$.intermAggregate = $1.intermAggregate; $$.intermAggregate = $1.intermAggregate;
} else { } else {
parseContext.recover(); parseContext->recover();
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
} }
...@@ -1338,85 +1334,85 @@ single_declaration ...@@ -1338,85 +1334,85 @@ single_declaration
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
| fully_specified_type IDENTIFIER { | fully_specified_type IDENTIFIER {
$$.intermAggregate = parseContext.intermediate.makeAggregate(parseContext.intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
if (parseContext.structQualifierErrorCheck($2.line, $$.type)) if (parseContext->structQualifierErrorCheck($2.line, $$.type))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($2.line, *$2.string, $$.type)) if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $$.type))
parseContext.recover(); parseContext->recover();
$$.type = $1; $$.type = $1;
if (parseContext.nonInitErrorCheck($2.line, *$2.string, $$.type)) if (parseContext->nonInitErrorCheck($2.line, *$2.string, $$.type))
parseContext.recover(); parseContext->recover();
} }
| fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET { | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
$$.intermAggregate = parseContext.intermediate.makeAggregate(parseContext.intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
if (parseContext.structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($2.line, *$2.string, $1)) if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1))
parseContext.recover(); parseContext->recover();
$$.type = $1; $$.type = $1;
if (parseContext.arrayTypeErrorCheck($3.line, $1) || parseContext.arrayQualifierErrorCheck($3.line, $1)) if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1))
parseContext.recover(); parseContext->recover();
else { else {
$1.setArray(true); $1.setArray(true);
TVariable* variable; TVariable* variable;
if (parseContext.arrayErrorCheck($3.line, *$2.string, $1, variable)) if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable))
parseContext.recover(); parseContext->recover();
} }
} }
| fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
TType type = TType($1); TType type = TType($1);
int size; int size;
if (parseContext.arraySizeErrorCheck($2.line, $4, size)) if (parseContext->arraySizeErrorCheck($2.line, $4, size))
parseContext.recover(); parseContext->recover();
type.setArraySize(size); type.setArraySize(size);
$$.intermAggregate = parseContext.intermediate.makeAggregate(parseContext.intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line);
if (parseContext.structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
if (parseContext.nonInitConstErrorCheck($2.line, *$2.string, $1)) if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1))
parseContext.recover(); parseContext->recover();
$$.type = $1; $$.type = $1;
if (parseContext.arrayTypeErrorCheck($3.line, $1) || parseContext.arrayQualifierErrorCheck($3.line, $1)) if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1))
parseContext.recover(); parseContext->recover();
else { else {
int size; int size;
if (parseContext.arraySizeErrorCheck($3.line, $4, size)) if (parseContext->arraySizeErrorCheck($3.line, $4, size))
parseContext.recover(); parseContext->recover();
$1.setArray(true, size); $1.setArray(true, size);
TVariable* variable; TVariable* variable;
if (parseContext.arrayErrorCheck($3.line, *$2.string, $1, variable)) if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable))
parseContext.recover(); parseContext->recover();
} }
} }
| fully_specified_type IDENTIFIER EQUAL initializer { | fully_specified_type IDENTIFIER EQUAL initializer {
if (parseContext.structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
$$.type = $1; $$.type = $1;
TIntermNode* intermNode; TIntermNode* intermNode;
if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode)) { if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {
// //
// Build intermediate representation // Build intermediate representation
// //
if(intermNode) if(intermNode)
$$.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, $3.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(intermNode, $3.line);
else else
$$.intermAggregate = 0; $$.intermAggregate = 0;
} else { } else {
parseContext.recover(); parseContext->recover();
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
} }
...@@ -1448,14 +1444,14 @@ single_declaration ...@@ -1448,14 +1444,14 @@ single_declaration
// //
//input_or_output //input_or_output
// : INPUT { // : INPUT {
// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "input")) // if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "input"))
// parseContext.recover(); // parseContext->recover();
// UNPACK_ONLY("input", $1.line); // UNPACK_ONLY("input", $1.line);
// $$.qualifier = EvqInput; // $$.qualifier = EvqInput;
// } // }
// | OUTPUT { // | OUTPUT {
// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "output")) // if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "output"))
// parseContext.recover(); // parseContext->recover();
// PACK_ONLY("output", $1.line); // PACK_ONLY("output", $1.line);
// $$.qualifier = EvqOutput; // $$.qualifier = EvqOutput;
// } // }
...@@ -1484,12 +1480,12 @@ single_declaration ...@@ -1484,12 +1480,12 @@ single_declaration
// //
//buffer_declaration //buffer_declaration
// : type_specifier IDENTIFIER COLON constant_expression SEMICOLON { // : type_specifier IDENTIFIER COLON constant_expression SEMICOLON {
// if (parseContext.reservedErrorCheck($2.line, *$2.string, parseContext)) // if (parseContext->reservedErrorCheck($2.line, *$2.string, parseContext))
// parseContext.recover(); // parseContext->recover();
// $$.variable = new TVariable($2.string, $1); // $$.variable = new TVariable($2.string, $1);
// if (! parseContext.symbolTable.insert(*$$.variable)) { // if (! parseContext->symbolTable.insert(*$$.variable)) {
// parseContext.error($2.line, "redefinition", $$.variable->getName().c_str(), ""); // parseContext->error($2.line, "redefinition", $$.variable->getName().c_str(), "");
// parseContext.recover(); // parseContext->recover();
// // don't have to delete $$.variable, the pool pop will take care of it // // don't have to delete $$.variable, the pool pop will take care of it
// } // }
// } // }
...@@ -1500,31 +1496,31 @@ fully_specified_type ...@@ -1500,31 +1496,31 @@ fully_specified_type
$$ = $1; $$ = $1;
if ($1.array) { if ($1.array) {
if (parseContext.extensionErrorCheck($1.line, "GL_3DL_array_objects")) { if (parseContext->extensionErrorCheck($1.line, "GL_3DL_array_objects")) {
parseContext.recover(); parseContext->recover();
$1.setArray(false); $1.setArray(false);
} }
} }
} }
| type_qualifier type_specifier { | type_qualifier type_specifier {
if ($2.array && parseContext.extensionErrorCheck($2.line, "GL_3DL_array_objects")) { if ($2.array && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects")) {
parseContext.recover(); parseContext->recover();
$2.setArray(false); $2.setArray(false);
} }
if ($2.array && parseContext.arrayQualifierErrorCheck($2.line, $1)) { if ($2.array && parseContext->arrayQualifierErrorCheck($2.line, $1)) {
parseContext.recover(); parseContext->recover();
$2.setArray(false); $2.setArray(false);
} }
if ($1.qualifier == EvqAttribute && if ($1.qualifier == EvqAttribute &&
($2.type == EbtBool || $2.type == EbtInt)) { ($2.type == EbtBool || $2.type == EbtInt)) {
parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
parseContext.recover(); parseContext->recover();
} }
if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) && if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &&
($2.type == EbtBool || $2.type == EbtInt)) { ($2.type == EbtBool || $2.type == EbtInt)) {
parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
parseContext.recover(); parseContext->recover();
} }
$$ = $2; $$ = $2;
$$.qualifier = $1.qualifier; $$.qualifier = $1.qualifier;
...@@ -1537,29 +1533,29 @@ type_qualifier ...@@ -1537,29 +1533,29 @@ type_qualifier
} }
| ATTRIBUTE { | ATTRIBUTE {
VERTEX_ONLY("attribute", $1.line); VERTEX_ONLY("attribute", $1.line);
if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "attribute")) if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "attribute"))
parseContext.recover(); parseContext->recover();
$$.setBasic(EbtVoid, EvqAttribute, $1.line); $$.setBasic(EbtVoid, EvqAttribute, $1.line);
} }
| VARYING { | VARYING {
if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "varying")) if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "varying"))
parseContext.recover(); parseContext->recover();
if (parseContext.language == EShLangVertex) if (parseContext->language == EShLangVertex)
$$.setBasic(EbtVoid, EvqVaryingOut, $1.line); $$.setBasic(EbtVoid, EvqVaryingOut, $1.line);
else else
$$.setBasic(EbtVoid, EvqVaryingIn, $1.line); $$.setBasic(EbtVoid, EvqVaryingIn, $1.line);
} }
| INVARIANT VARYING { | INVARIANT VARYING {
if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "invariant varying")) if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "invariant varying"))
parseContext.recover(); parseContext->recover();
if (parseContext.language == EShLangVertex) if (parseContext->language == EShLangVertex)
$$.setBasic(EbtVoid, EvqInvariantVaryingOut, $1.line); $$.setBasic(EbtVoid, EvqInvariantVaryingOut, $1.line);
else else
$$.setBasic(EbtVoid, EvqInvariantVaryingIn, $1.line); $$.setBasic(EbtVoid, EvqInvariantVaryingIn, $1.line);
} }
| UNIFORM { | UNIFORM {
if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "uniform")) if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "uniform"))
parseContext.recover(); parseContext->recover();
$$.setBasic(EbtVoid, EvqUniform, $1.line); $$.setBasic(EbtVoid, EvqUniform, $1.line);
} }
; ;
...@@ -1593,12 +1589,12 @@ type_specifier_no_prec ...@@ -1593,12 +1589,12 @@ type_specifier_no_prec
| type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET { | type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET {
$$ = $1; $$ = $1;
if (parseContext.arrayTypeErrorCheck($2.line, $1)) if (parseContext->arrayTypeErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
else { else {
int size; int size;
if (parseContext.arraySizeErrorCheck($2.line, $3, size)) if (parseContext->arraySizeErrorCheck($2.line, $3, size))
parseContext.recover(); parseContext->recover();
$$.setArray(true, size); $$.setArray(true, size);
} }
} }
...@@ -1606,103 +1602,103 @@ type_specifier_no_prec ...@@ -1606,103 +1602,103 @@ type_specifier_no_prec
type_specifier_nonarray type_specifier_nonarray
: VOID_TYPE { : VOID_TYPE {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtVoid, qual, $1.line); $$.setBasic(EbtVoid, qual, $1.line);
} }
| FLOAT_TYPE { | FLOAT_TYPE {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
} }
| INT_TYPE { | INT_TYPE {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line); $$.setBasic(EbtInt, qual, $1.line);
} }
| BOOL_TYPE { | BOOL_TYPE {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line); $$.setBasic(EbtBool, qual, $1.line);
} }
// | UNSIGNED INT_TYPE { // | UNSIGNED INT_TYPE {
// PACK_UNPACK_ONLY("unsigned", $1.line); // PACK_UNPACK_ONLY("unsigned", $1.line);
// TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; // TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
// $$.setBasic(EbtInt, qual, $1.line); // $$.setBasic(EbtInt, qual, $1.line);
// } // }
| VEC2 { | VEC2 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(2); $$.setAggregate(2);
} }
| VEC3 { | VEC3 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(3); $$.setAggregate(3);
} }
| VEC4 { | VEC4 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(4); $$.setAggregate(4);
} }
| BVEC2 { | BVEC2 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line); $$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(2); $$.setAggregate(2);
} }
| BVEC3 { | BVEC3 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line); $$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(3); $$.setAggregate(3);
} }
| BVEC4 { | BVEC4 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line); $$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(4); $$.setAggregate(4);
} }
| IVEC2 { | IVEC2 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line); $$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(2); $$.setAggregate(2);
} }
| IVEC3 { | IVEC3 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line); $$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(3); $$.setAggregate(3);
} }
| IVEC4 { | IVEC4 {
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line); $$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(4); $$.setAggregate(4);
} }
| MATRIX2 { | MATRIX2 {
FRAG_VERT_ONLY("mat2", $1.line); FRAG_VERT_ONLY("mat2", $1.line);
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(2, true); $$.setAggregate(2, true);
} }
| MATRIX3 { | MATRIX3 {
FRAG_VERT_ONLY("mat3", $1.line); FRAG_VERT_ONLY("mat3", $1.line);
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(3, true); $$.setAggregate(3, true);
} }
| MATRIX4 { | MATRIX4 {
FRAG_VERT_ONLY("mat4", $1.line); FRAG_VERT_ONLY("mat4", $1.line);
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line); $$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(4, true); $$.setAggregate(4, true);
} }
| SAMPLER2D { | SAMPLER2D {
FRAG_VERT_ONLY("sampler2D", $1.line); FRAG_VERT_ONLY("sampler2D", $1.line);
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSampler2D, qual, $1.line); $$.setBasic(EbtSampler2D, qual, $1.line);
} }
| SAMPLERCUBE { | SAMPLERCUBE {
FRAG_VERT_ONLY("samplerCube", $1.line); FRAG_VERT_ONLY("samplerCube", $1.line);
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerCube, qual, $1.line); $$.setBasic(EbtSamplerCube, qual, $1.line);
} }
| struct_specifier { | struct_specifier {
FRAG_VERT_ONLY("struct", $1.line); FRAG_VERT_ONLY("struct", $1.line);
$$ = $1; $$ = $1;
$$.qualifier = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.qualifier = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
} }
| TYPE_NAME { | TYPE_NAME {
// //
...@@ -1710,7 +1706,7 @@ type_specifier_nonarray ...@@ -1710,7 +1706,7 @@ type_specifier_nonarray
// type. // type.
// //
TType& structure = static_cast<TVariable*>($1.symbol)->getType(); TType& structure = static_cast<TVariable*>($1.symbol)->getType();
TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtStruct, qual, $1.line); $$.setBasic(EbtStruct, qual, $1.line);
$$.userDef = &structure; $$.userDef = &structure;
} }
...@@ -1720,9 +1716,9 @@ struct_specifier ...@@ -1720,9 +1716,9 @@ struct_specifier
: STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE { : STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE {
TType* structure = new TType($4, *$2.string); TType* structure = new TType($4, *$2.string);
TVariable* userTypeDef = new TVariable($2.string, *structure, true); TVariable* userTypeDef = new TVariable($2.string, *structure, true);
if (! parseContext.symbolTable.insert(*userTypeDef)) { if (! parseContext->symbolTable.insert(*userTypeDef)) {
parseContext.error($2.line, "redefinition", $2.string->c_str(), "struct"); parseContext->error($2.line, "redefinition", $2.string->c_str(), "struct");
parseContext.recover(); parseContext->recover();
} }
$$.setBasic(EbtStruct, EvqTemporary, $1.line); $$.setBasic(EbtStruct, EvqTemporary, $1.line);
$$.userDef = structure; $$.userDef = structure;
...@@ -1743,8 +1739,8 @@ struct_declaration_list ...@@ -1743,8 +1739,8 @@ struct_declaration_list
for (unsigned int i = 0; i < $2->size(); ++i) { for (unsigned int i = 0; i < $2->size(); ++i) {
for (unsigned int j = 0; j < $$->size(); ++j) { for (unsigned int j = 0; j < $$->size(); ++j) {
if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) { if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) {
parseContext.error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str()); parseContext->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());
parseContext.recover(); parseContext->recover();
} }
} }
$$->push_back((*$2)[i]); $$->push_back((*$2)[i]);
...@@ -1756,8 +1752,8 @@ struct_declaration ...@@ -1756,8 +1752,8 @@ struct_declaration
: type_specifier struct_declarator_list SEMICOLON { : type_specifier struct_declarator_list SEMICOLON {
$$ = $2; $$ = $2;
if (parseContext.voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) { if (parseContext->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {
parseContext.recover(); parseContext->recover();
} }
for (unsigned int i = 0; i < $$->size(); ++i) { for (unsigned int i = 0; i < $$->size(); ++i) {
// //
...@@ -1767,8 +1763,8 @@ struct_declaration ...@@ -1767,8 +1763,8 @@ struct_declaration
// don't allow arrays of arrays // don't allow arrays of arrays
if ((*$$)[i].type->isArray()) { if ((*$$)[i].type->isArray()) {
if (parseContext.arrayTypeErrorCheck($1.line, $1)) if (parseContext->arrayTypeErrorCheck($1.line, $1))
parseContext.recover(); parseContext->recover();
} }
if ($1.array) if ($1.array)
(*$$)[i].type->setArraySize($1.arraySize); (*$$)[i].type->setArraySize($1.arraySize);
...@@ -1800,8 +1796,8 @@ struct_declarator ...@@ -1800,8 +1796,8 @@ struct_declarator
$$.type->setFieldName(*$1.string); $$.type->setFieldName(*$1.string);
int size; int size;
if (parseContext.arraySizeErrorCheck($2.line, $3, size)) if (parseContext->arraySizeErrorCheck($2.line, $3, size))
parseContext.recover(); parseContext->recover();
$$.type->setArraySize(size); $$.type->setArraySize(size);
} }
; ;
...@@ -1831,7 +1827,7 @@ simple_statement ...@@ -1831,7 +1827,7 @@ simple_statement
compound_statement compound_statement
: LEFT_BRACE RIGHT_BRACE { $$ = 0; } : LEFT_BRACE RIGHT_BRACE { $$ = 0; }
| LEFT_BRACE { parseContext.symbolTable.push(); } statement_list { parseContext.symbolTable.pop(); } RIGHT_BRACE { | LEFT_BRACE { parseContext->symbolTable.push(); } statement_list { parseContext->symbolTable.pop(); } RIGHT_BRACE {
if ($3 != 0) if ($3 != 0)
$3->setOperator(EOpSequence); $3->setOperator(EOpSequence);
$$ = $3; $$ = $3;
...@@ -1857,10 +1853,10 @@ compound_statement_no_new_scope ...@@ -1857,10 +1853,10 @@ compound_statement_no_new_scope
statement_list statement_list
: statement { : statement {
$$ = parseContext.intermediate.makeAggregate($1, 0); $$ = parseContext->intermediate.makeAggregate($1, 0);
} }
| statement_list statement { | statement_list statement {
$$ = parseContext.intermediate.growAggregate($1, $2, 0); $$ = parseContext->intermediate.growAggregate($1, $2, 0);
} }
; ;
...@@ -1871,9 +1867,9 @@ expression_statement ...@@ -1871,9 +1867,9 @@ expression_statement
selection_statement selection_statement
: IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
if (parseContext.boolErrorCheck($1.line, $3)) if (parseContext->boolErrorCheck($1.line, $3))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addSelection($3, $5, $1.line); $$ = parseContext->intermediate.addSelection($3, $5, $1.line);
} }
; ;
...@@ -1894,42 +1890,42 @@ condition ...@@ -1894,42 +1890,42 @@ condition
// In 1996 c++ draft, conditions can include single declarations // In 1996 c++ draft, conditions can include single declarations
: expression { : expression {
$$ = $1; $$ = $1;
if (parseContext.boolErrorCheck($1->getLine(), $1)) if (parseContext->boolErrorCheck($1->getLine(), $1))
parseContext.recover(); parseContext->recover();
} }
| fully_specified_type IDENTIFIER EQUAL initializer { | fully_specified_type IDENTIFIER EQUAL initializer {
TIntermNode* intermNode; TIntermNode* intermNode;
if (parseContext.structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
if (parseContext.boolErrorCheck($2.line, $1)) if (parseContext->boolErrorCheck($2.line, $1))
parseContext.recover(); parseContext->recover();
if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode)) if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode))
$$ = $4; $$ = $4;
else { else {
parseContext.recover(); parseContext->recover();
$$ = 0; $$ = 0;
} }
} }
; ;
iteration_statement iteration_statement
: WHILE LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope { : WHILE LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope {
parseContext.symbolTable.pop(); parseContext->symbolTable.pop();
$$ = parseContext.intermediate.addLoop(0, $6, $4, 0, true, $1.line); $$ = parseContext->intermediate.addLoop(0, $6, $4, 0, true, $1.line);
--parseContext.loopNestingLevel; --parseContext->loopNestingLevel;
} }
| DO { ++parseContext.loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON { | DO { ++parseContext->loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
if (parseContext.boolErrorCheck($8.line, $6)) if (parseContext->boolErrorCheck($8.line, $6))
parseContext.recover(); parseContext->recover();
$$ = parseContext.intermediate.addLoop(0, $3, $6, 0, false, $4.line); $$ = parseContext->intermediate.addLoop(0, $3, $6, 0, false, $4.line);
--parseContext.loopNestingLevel; --parseContext->loopNestingLevel;
} }
| FOR LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope { | FOR LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
parseContext.symbolTable.pop(); parseContext->symbolTable.pop();
$$ = parseContext.intermediate.addLoop($4, $7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line); $$ = parseContext->intermediate.addLoop($4, $7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line);
--parseContext.loopNestingLevel; --parseContext->loopNestingLevel;
} }
; ;
...@@ -1964,40 +1960,40 @@ for_rest_statement ...@@ -1964,40 +1960,40 @@ for_rest_statement
jump_statement jump_statement
: CONTINUE SEMICOLON { : CONTINUE SEMICOLON {
if (parseContext.loopNestingLevel <= 0) { if (parseContext->loopNestingLevel <= 0) {
parseContext.error($1.line, "continue statement only allowed in loops", "", ""); parseContext->error($1.line, "continue statement only allowed in loops", "", "");
parseContext.recover(); parseContext->recover();
} }
$$ = parseContext.intermediate.addBranch(EOpContinue, $1.line); $$ = parseContext->intermediate.addBranch(EOpContinue, $1.line);
} }
| BREAK SEMICOLON { | BREAK SEMICOLON {
if (parseContext.loopNestingLevel <= 0) { if (parseContext->loopNestingLevel <= 0) {
parseContext.error($1.line, "break statement only allowed in loops", "", ""); parseContext->error($1.line, "break statement only allowed in loops", "", "");
parseContext.recover(); parseContext->recover();
} }
$$ = parseContext.intermediate.addBranch(EOpBreak, $1.line); $$ = parseContext->intermediate.addBranch(EOpBreak, $1.line);
} }
| RETURN SEMICOLON { | RETURN SEMICOLON {
$$ = parseContext.intermediate.addBranch(EOpReturn, $1.line); $$ = parseContext->intermediate.addBranch(EOpReturn, $1.line);
if (parseContext.currentFunctionType->getBasicType() != EbtVoid) { if (parseContext->currentFunctionType->getBasicType() != EbtVoid) {
parseContext.error($1.line, "non-void function must return a value", "return", ""); parseContext->error($1.line, "non-void function must return a value", "return", "");
parseContext.recover(); parseContext->recover();
} }
} }
| RETURN expression SEMICOLON { | RETURN expression SEMICOLON {
$$ = parseContext.intermediate.addBranch(EOpReturn, $2, $1.line); $$ = parseContext->intermediate.addBranch(EOpReturn, $2, $1.line);
parseContext.functionReturnsValue = true; parseContext->functionReturnsValue = true;
if (parseContext.currentFunctionType->getBasicType() == EbtVoid) { if (parseContext->currentFunctionType->getBasicType() == EbtVoid) {
parseContext.error($1.line, "void function cannot return a value", "return", ""); parseContext->error($1.line, "void function cannot return a value", "return", "");
parseContext.recover(); parseContext->recover();
} else if (*(parseContext.currentFunctionType) != $2->getType()) { } else if (*(parseContext->currentFunctionType) != $2->getType()) {
parseContext.error($1.line, "function return is not matching type:", "return", ""); parseContext->error($1.line, "function return is not matching type:", "return", "");
parseContext.recover(); parseContext->recover();
} }
} }
| DISCARD SEMICOLON { | DISCARD SEMICOLON {
FRAG_ONLY("discard", $1.line); FRAG_ONLY("discard", $1.line);
$$ = parseContext.intermediate.addBranch(EOpKill, $1.line); $$ = parseContext->intermediate.addBranch(EOpKill, $1.line);
} }
; ;
...@@ -2006,11 +2002,11 @@ jump_statement ...@@ -2006,11 +2002,11 @@ jump_statement
translation_unit translation_unit
: external_declaration { : external_declaration {
$$ = $1; $$ = $1;
parseContext.treeRoot = $$; parseContext->treeRoot = $$;
} }
| translation_unit external_declaration { | translation_unit external_declaration {
$$ = parseContext.intermediate.growAggregate($1, $2, 0); $$ = parseContext->intermediate.growAggregate($1, $2, 0);
parseContext.treeRoot = $$; parseContext->treeRoot = $$;
} }
; ;
...@@ -2026,7 +2022,7 @@ external_declaration ...@@ -2026,7 +2022,7 @@ external_declaration
function_definition function_definition
: function_prototype { : function_prototype {
TFunction& function = *($1.function); TFunction& function = *($1.function);
TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(function.getMangledName())); 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 // 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 // as it would have just been put in the symbol table. Otherwise, we're looking up
...@@ -2036,8 +2032,8 @@ function_definition ...@@ -2036,8 +2032,8 @@ function_definition
// //
// Then this function already has a body. // Then this function already has a body.
// //
parseContext.error($1.line, "function already has a body", function.getName().c_str(), ""); parseContext->error($1.line, "function already has a body", function.getName().c_str(), "");
parseContext.recover(); parseContext->recover();
} }
prevDec->setDefined(); prevDec->setDefined();
...@@ -2046,25 +2042,25 @@ function_definition ...@@ -2046,25 +2042,25 @@ function_definition
// //
if (function.getName() == "main") { if (function.getName() == "main") {
if (function.getParamCount() > 0) { if (function.getParamCount() > 0) {
parseContext.error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), ""); parseContext->error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), "");
parseContext.recover(); parseContext->recover();
} }
if (function.getReturnType().getBasicType() != EbtVoid) { if (function.getReturnType().getBasicType() != EbtVoid) {
parseContext.error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value"); parseContext->error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value");
parseContext.recover(); parseContext->recover();
} }
} }
// //
// New symbol table scope for body of function plus its arguments // New symbol table scope for body of function plus its arguments
// //
parseContext.symbolTable.push(); parseContext->symbolTable.push();
// //
// Remember the return type for later checking for RETURN statements. // Remember the return type for later checking for RETURN statements.
// //
parseContext.currentFunctionType = &(prevDec->getReturnType()); parseContext->currentFunctionType = &(prevDec->getReturnType());
parseContext.functionReturnsValue = false; parseContext->functionReturnsValue = false;
// //
// Insert parameters into the symbol table. // Insert parameters into the symbol table.
...@@ -2082,9 +2078,9 @@ function_definition ...@@ -2082,9 +2078,9 @@ function_definition
// //
// Insert the parameters with name in the symbol table. // Insert the parameters with name in the symbol table.
// //
if (! parseContext.symbolTable.insert(*variable)) { if (! parseContext->symbolTable.insert(*variable)) {
parseContext.error($1.line, "redefinition", variable->getName().c_str(), ""); parseContext->error($1.line, "redefinition", variable->getName().c_str(), "");
parseContext.recover(); parseContext->recover();
delete variable; delete variable;
} }
// //
...@@ -2095,38 +2091,38 @@ function_definition ...@@ -2095,38 +2091,38 @@ function_definition
// //
// Add the parameter to the HIL // Add the parameter to the HIL
// //
paramNodes = parseContext.intermediate.growAggregate( paramNodes = parseContext->intermediate.growAggregate(
paramNodes, paramNodes,
parseContext.intermediate.addSymbol(variable->getUniqueId(), parseContext->intermediate.addSymbol(variable->getUniqueId(),
variable->getName(), variable->getName(),
variable->getType(), $1.line), variable->getType(), $1.line),
$1.line); $1.line);
} else { } else {
paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); paramNodes = parseContext->intermediate.growAggregate(paramNodes, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
} }
} }
parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line); parseContext->intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line);
$1.intermAggregate = paramNodes; $1.intermAggregate = paramNodes;
parseContext.loopNestingLevel = 0; parseContext->loopNestingLevel = 0;
} }
compound_statement_no_new_scope { compound_statement_no_new_scope {
//?? Check that all paths return a value if return type != void ? //?? Check that all paths return a value if return type != void ?
// May be best done as post process phase on intermediate code // May be best done as post process phase on intermediate code
if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) { if (parseContext->currentFunctionType->getBasicType() != EbtVoid && ! parseContext->functionReturnsValue) {
parseContext.error($1.line, "function does not return a value:", "", $1.function->getName().c_str()); parseContext->error($1.line, "function does not return a value:", "", $1.function->getName().c_str());
parseContext.recover(); parseContext->recover();
} }
parseContext.symbolTable.pop(); parseContext->symbolTable.pop();
$$ = parseContext.intermediate.growAggregate($1.intermAggregate, $3, 0); $$ = parseContext->intermediate.growAggregate($1.intermAggregate, $3, 0);
parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.line); parseContext->intermediate.setAggregateOperator($$, EOpFunction, $1.line);
$$->getAsAggregate()->setName($1.function->getMangledName().c_str()); $$->getAsAggregate()->setName($1.function->getMangledName().c_str());
$$->getAsAggregate()->setType($1.function->getReturnType()); $$->getAsAggregate()->setType($1.function->getReturnType());
// store the pragma information for debug and optimize and other vendor specific // store the pragma information for debug and optimize and other vendor specific
// information. This information can be queried from the parse tree // information. This information can be queried from the parse tree
$$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize); $$->getAsAggregate()->setOptimize(parseContext->contextPragma.optimize);
$$->getAsAggregate()->setDebug(parseContext.contextPragma.debug); $$->getAsAggregate()->setDebug(parseContext->contextPragma.debug);
$$->getAsAggregate()->addToPragmaTable(parseContext.contextPragma.pragmaTable); $$->getAsAggregate()->addToPragmaTable(parseContext->contextPragma.pragmaTable);
} }
; ;
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
Description="Executing flex on $(InputPath)" Description="Executing flex on $(InputPath)"
CommandLine="if EXIST $(InputDir)Gen_glslang.cpp del $(InputDir)Gen_glslang.cpp&#x0D;&#x0A;$(InputDir)tools\flex.exe $(InputPath)&#x0D;&#x0A;" CommandLine="if EXIST $(InputDir)Gen_glslang.cpp del $(InputDir)Gen_glslang.cpp&#x0D;&#x0A;$(InputDir)tools\flex.exe $(InputPath)&#x0D;&#x0A;rename $(InputDir)lex.yy.c Gen_$(InputName).cpp&#x0D;&#x0A;"
AdditionalDependencies="glslang_tab.h" AdditionalDependencies="glslang_tab.h"
Outputs="$(InputDir)Gen_glslang.cpp" Outputs="$(InputDir)Gen_glslang.cpp"
/> />
......
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="translator_glsl"
ProjectGUID="{65DB6E65-00E6-4533-8446-5F623BD94909}"
RootNamespace="CrossCompilerGLSL"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\glsl"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\glsl"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="./;../;../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\CodeGenGLSL.cpp"
>
</File>
<File
RelativePath=".\OutputGLSL.cpp"
>
</File>
<File
RelativePath=".\TranslatorGLSL.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\OutputGLSL.h"
>
</File>
<File
RelativePath=".\TranslatorGLSL.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment