2011-01-18 Ben Vanik <ben.vanik@gmail.com>
authorkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jan 2011 03:00:39 +0000 (03:00 +0000)
committerkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jan 2011 03:00:39 +0000 (03:00 +0000)
        Reviewed by Kenneth Russell.

        Updating ANGLE in WebKit to r533.
        https://bugs.webkit.org/show_bug.cgi?id=47194

        * platform/graphics/ANGLEWebKitBridge.cpp:
        (WebCore::ANGLEWebKitBridge::ANGLEWebKitBridge):
        (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge):
        (WebCore::ANGLEWebKitBridge::validateShaderSource):
        Update to new ANGLE API for shader validation.
        * platform/graphics/ANGLEWebKitBridge.h:
        (WebCore::ANGLEWebKitBridge::setResources):
        Renaming types to new names.
        * platform/graphics/mac/GraphicsContext3DMac.mm:
        (WebCore::GraphicsContext3D::GraphicsContext3D):
        Initialize ANGLEResources with ANGLE init call to prevent uninitialized variables.
2011-01-18  Ben Vanik  <ben.vanik@gmail.com>

        Reviewed by Kenneth Russell.

        Updating ANGLE in WebKit to r533.
        https://bugs.webkit.org/show_bug.cgi?id=47194

        * ANGLE.xcodeproj/project.pbxproj:
        * include/GLSLANG/ShaderLang.h:
        * src/common/debug.cpp:
        (gl::trace):
        * src/common/debug.h:
        * src/compiler/CodeGenGLSL.cpp:
        (ConstructCompiler):
        * src/compiler/CodeGenHLSL.cpp:
        (ConstructCompiler):
        * src/compiler/Common.h:
        (EncodeSourceLoc):
        (DecodeSourceLoc):
        * src/compiler/Compiler.cpp: Added.
        (TShHandleBase::TShHandleBase):
        (TShHandleBase::~TShHandleBase):
        (TCompiler::TCompiler):
        (TCompiler::~TCompiler):
        (TCompiler::Init):
        (TCompiler::compile):
        (TCompiler::InitBuiltInSymbolTable):
        (TCompiler::clearResults):
        (TCompiler::validateLimitations):
        (TCompiler::collectAttribsUniforms):
        * src/compiler/ExtensionBehavior.h: Added.
        * src/compiler/InfoSink.cpp:
        (TInfoSinkBase::location):
        * src/compiler/InfoSink.h:
        (TInfoSinkBase::size):
        * src/compiler/Initialize.cpp:
        (BuiltInFunctionsCommon):
        (BuiltInFunctionsVertex):
        (BuiltInFunctionsFragment):
        (StandardUniforms):
        (DefaultPrecisionVertex):
        (DefaultPrecisionFragment):
        (BuiltInConstants):
        (TBuiltIns::initialize):
        (IdentifyBuiltIns):
        (InitExtensionBehavior):
        * src/compiler/Initialize.h:
        * src/compiler/IntermTraverse.cpp:
        (TIntermLoop::traverse):
        * src/compiler/Intermediate.cpp:
        (getOperatorString):
        (TIntermediate::addBinaryMath):
        (TIntermediate::addLoop):
        (TIntermediate::postProcess):
        (TIntermBinary::promote):
        * src/compiler/OutputGLSL.cpp:
        (TOutputGLSL::visitUnary):
        (TOutputGLSL::visitLoop):
        * src/compiler/OutputHLSL.cpp:
        (sh::OutputHLSL::OutputHLSL):
        (sh::OutputHLSL::header):
        (sh::OutputHLSL::visitBinary):
        (sh::OutputHLSL::visitUnary):
        (sh::OutputHLSL::visitAggregate):
        (sh::OutputHLSL::visitLoop):
        (sh::OutputHLSL::handleExcessiveLoop):
        (sh::OutputHLSL::argumentString):
        * src/compiler/OutputHLSL.h:
        * src/compiler/ParseHelper.cpp:
        (ReportInfo):
        (DefineExtensionMacros):
        (TParseContext::error):
        (TParseContext::warning):
        (TParseContext::reservedErrorCheck):
        (TParseContext::constructorErrorCheck):
        (TParseContext::arrayQualifierErrorCheck):
        (TParseContext::extensionErrorCheck):
        (TParseContext::areAllChildConst):
        (PaParseStrings):
        * src/compiler/ParseHelper.h:
        (TParseContext::TParseContext):
        * src/compiler/PoolAlloc.cpp:
        (InitializeGlobalPools):
        (FreeGlobalPools):
        (SetGlobalPoolAllocator):
        (TPoolAllocator::TPoolAllocator):
        (TPoolAllocator::~TPoolAllocator):
        (TAllocation::checkAllocList):
        * src/compiler/PoolAlloc.h:
        * src/compiler/SearchSymbol.cpp: Added.
        (sh::SearchSymbol::SearchSymbol):
        (sh::SearchSymbol::traverse):
        (sh::SearchSymbol::visitSymbol):
        (sh::SearchSymbol::foundMatch):
        * src/compiler/SearchSymbol.h: Added.
        * src/compiler/ShHandle.h:
        (TCompiler::getAsCompiler):
        (TCompiler::getInfoSink):
        (TCompiler::getAttribs):
        (TCompiler::getUniforms):
        (TCompiler::getShaderType):
        (TCompiler::getShaderSpec):
        * src/compiler/ShaderLang.cpp:
        (getVariableMaxLength):
        (getVariableInfo):
        (ShInitBuiltInResources):
        (ShConstructCompiler):
        (ShCompile):
        (ShGetInfo):
        (ShGetInfoLog):
        (ShGetObjectCode):
        (ShGetActiveAttrib):
        (ShGetActiveUniform):
        * src/compiler/SymbolTable.cpp:
        (TSymbolTableLevel::relateToExtension):
        * src/compiler/SymbolTable.h:
        (TVariable::shareConstPointer):
        (TFunction::relateToExtension):
        (TFunction::getExtension):
        (TFunction::getParamCount):
        (TFunction::getParam):
        (TSymbolTable::getGlobalLevel):
        (TSymbolTable::relateToOperator):
        (TSymbolTable::relateToExtension):
        * src/compiler/TranslatorGLSL.cpp:
        (writeVersion):
        (TranslatorGLSL::TranslatorGLSL):
        (TranslatorGLSL::translate):
        * src/compiler/TranslatorGLSL.h:
        * src/compiler/TranslatorHLSL.cpp:
        (TranslatorHLSL::TranslatorHLSL):
        (TranslatorHLSL::translate):
        * src/compiler/TranslatorHLSL.h:
        * src/compiler/Types.h:
        (TType::TType):
        * src/compiler/UnfoldSelect.cpp:
        (sh::UnfoldSelect::visitSelection):
        * src/compiler/UnfoldSelect.h:
        * src/compiler/ValidateLimitations.cpp: Added.
        (ValidateLimitations::ValidateLimitations):
        (ValidateLimitations::visitSymbol):
        (ValidateLimitations::visitConstantUnion):
        (ValidateLimitations::visitBinary):
        (ValidateLimitations::visitUnary):
        (ValidateLimitations::visitSelection):
        (ValidateLimitations::visitAggregate):
        (ValidateLimitations::visitLoop):
        (ValidateLimitations::visitBranch):
        (ValidateLimitations::error):
        (ValidateLimitations::withinLoopBody):
        (ValidateLimitations::isLoopIndex):
        (ValidateLimitations::validateLoopType):
        (ValidateLimitations::validateForLoopHeader):
        (ValidateLimitations::validateForLoopInit):
        (ValidateLimitations::validateForLoopCond):
        (ValidateLimitations::validateForLoopExpr):
        (ValidateLimitations::validateFunctionCall):
        (ValidateLimitations::validateOperation):
        (ValidateLimitations::isConstExpr):
        (ValidateLimitations::isConstIndexExpr):
        (ValidateLimitations::validateIndexing):
        * src/compiler/ValidateLimitations.h: Added.
        (ValidateLimitations::numErrors):
        * src/compiler/VariableInfo.cpp: Added.
        (arrayBrackets):
        (getVariableDataType):
        (getVariableInfo):
        (getBuiltInVariableInfo):
        (getUserDefinedVariableInfo):
        (CollectAttribsUniforms::CollectAttribsUniforms):
        (CollectAttribsUniforms::visitSymbol):
        (CollectAttribsUniforms::visitConstantUnion):
        (CollectAttribsUniforms::visitBinary):
        (CollectAttribsUniforms::visitUnary):
        (CollectAttribsUniforms::visitSelection):
        (CollectAttribsUniforms::visitAggregate):
        (CollectAttribsUniforms::visitLoop):
        (CollectAttribsUniforms::visitBranch):
        * src/compiler/VariableInfo.h: Added.
        * src/compiler/VersionGLSL.cpp: Added.
        (TVersionGLSL::TVersionGLSL):
        (TVersionGLSL::visitSymbol):
        (TVersionGLSL::visitConstantUnion):
        (TVersionGLSL::visitBinary):
        (TVersionGLSL::visitUnary):
        (TVersionGLSL::visitSelection):
        (TVersionGLSL::visitAggregate):
        (TVersionGLSL::visitLoop):
        (TVersionGLSL::visitBranch):
        (TVersionGLSL::updateVersion):
        * src/compiler/VersionGLSL.h: Added.
        (TVersionGLSL::getVersion):
        * src/compiler/generate_glslang_lexer.sh: Added.
        * src/compiler/generate_glslang_parser.sh: Added.
        * src/compiler/glslang.h: Added.
        * src/compiler/glslang.l:
        * src/compiler/glslang.y:
        * src/compiler/glslang_lex.cpp: Added.
        (yy_get_next_buffer):
        (yy_get_previous_state):
        (yy_try_NUL_trans):
        (input):
        (yyrestart):
        (yy_switch_to_buffer):
        (yy_load_buffer_state):
        (yy_create_buffer):
        (yy_delete_buffer):
        (yy_init_buffer):
        (yy_flush_buffer):
        (yypush_buffer_state):
        (yypop_buffer_state):
        (yyensure_buffer_stack):
        (yy_scan_buffer):
        (yy_scan_string):
        (yy_scan_bytes):
        (yy_push_state):
        (yy_pop_state):
        (yy_top_state):
        (yy_fatal_error):
        (yyget_extra):
        (yyget_lineno):
        (yyget_column):
        (yyget_in):
        (yyget_out):
        (yyget_leng):
        (yyget_text):
        (yyset_extra):
        (yyset_lineno):
        (yyset_column):
        (yyset_in):
        (yyset_out):
        (yyget_debug):
        (yyset_debug):
        (yyget_lval):
        (yyset_lval):
        (yylex_init):
        (yylex_init_extra):
        (yy_init_globals):
        (yylex_destroy):
        (yy_flex_strncpy):
        (yy_flex_strlen):
        (yyalloc):
        (yyrealloc):
        (yyfree):
        (string_input):
        (check_type):
        (reserved_word):
        (yyerror):
        (glslang_initialize):
        (glslang_finalize):
        (glslang_scan):
        * src/compiler/glslang_tab.cpp: Added.
        (yytnamerr):
        (yysyntax_error):
        (glslang_parse):
        * src/compiler/glslang_tab.h: Added.
        * src/compiler/intermOut.cpp:
        (TOutputTraverser::TOutputTraverser):
        (OutputTreeText):
        (TOutputTraverser::visitSymbol):
        (TOutputTraverser::visitBinary):
        (TOutputTraverser::visitUnary):
        (TOutputTraverser::visitAggregate):
        (TOutputTraverser::visitSelection):
        (TOutputTraverser::visitConstantUnion):
        (TOutputTraverser::visitLoop):
        (TOutputTraverser::visitBranch):
        (TIntermediate::outputTree):
        * src/compiler/intermediate.h:
        (TIntermLoop::TIntermLoop):
        (TIntermLoop::getType):
        (TIntermLoop::getInit):
        (TIntermLoop::getCondition):
        (TIntermLoop::getExpression):
        (TIntermLoop::getBody):
        * src/compiler/localintermediate.h:
        * src/compiler/osinclude.h:
        (OS_GetTLSValue):
        * src/compiler/ossource_nspr.cpp: Added.
        (OS_AllocTLSIndex):
        (OS_SetTLSValue):
        (OS_FreeTLSIndex):
        * src/compiler/preprocessor/compile.h:
        * src/compiler/preprocessor/cpp.c:
        (CPPdefine):
        (CPPelse):
        (CPPif):
        (CPPifdef):
        (CPPerror):
        (CPPextension):
        (readCPPline):
        * src/compiler/preprocessor/preprocess.h:
        * src/compiler/preprocessor/scanner.c:
        (str_getch):
        (str_ungetch):
        (ScanFromString):
        (lFloatConst):
        (byte_scan):
        (yylex_CPP):
        (check_EOF):
        * src/compiler/preprocessor/scanner.h:
        * src/compiler/preprocessor/tokens.c:
        (RecordToken):
        (ReadToken):
        * src/compiler/tools: Removed.
        * src/compiler/unistd.h: Removed.
        * src/compiler/util.cpp: Added.
        (atof_dot):
        * src/compiler/util.h: Added.
        * src/libEGL/Config.cpp:
        (egl::Config::set):
        * src/libEGL/Display.cpp:
        (egl::Display::Display):
        (egl::Display::initialize):
        (egl::Display::terminate):
        (egl::Display::createDevice):
        (egl::Display::resetDevice):
        (egl::Display::createContext):
        (egl::Display::destroyContext):
        (egl::Display::getMinSwapInterval):
        (egl::Display::getMaxSwapInterval):
        (egl::Display::getDevice):
        (egl::Display::getFloatTextureSupport):
        (egl::Display::getHalfFloatTextureSupport):
        (egl::Display::getLuminanceTextureSupport):
        (egl::Display::getLuminanceAlphaTextureSupport):
        (egl::Display::getBufferPool):
        (egl::Display::getEventQuerySupport):
        (egl::Display::getDefaultPresentParameters):
        * src/libEGL/Display.h:
        * src/libEGL/Surface.cpp:
        (egl::Surface::Surface):
        (egl::Surface::~Surface):
        (egl::Surface::release):
        (egl::Surface::resetSwapChain):
        (egl::Surface::writeRecordableFlipState):
        (egl::Surface::restoreState):
        (egl::SurfaceWindowProc):
        (egl::Surface::subclassWindow):
        (egl::Surface::unsubclassWindow):
        (egl::Surface::checkForOutOfDateSwapChain):
        (egl::Surface::convertInterval):
        (egl::Surface::swap):
        (egl::Surface::getRenderTarget):
        (egl::Surface::setSwapInterval):
        * src/libEGL/Surface.h:
        * src/libEGL/libEGL.cpp:
        * src/libGLESv2/Blit.cpp:
        (gl::Blit::copySurfaceToTexture):
        (gl::Blit::setCommonBlitState):
        * src/libGLESv2/Buffer.cpp:
        (gl::Buffer::Buffer):
        (gl::Buffer::~Buffer):
        (gl::Buffer::bufferData):
        (gl::Buffer::bufferSubData):
        (gl::Buffer::getVertexBuffer):
        (gl::Buffer::getIndexBuffer):
        (gl::Buffer::invalidateStaticData):
        * src/libGLESv2/Buffer.h:
        * src/libGLESv2/Context.cpp:
        (gl::Context::Context):
        (gl::Context::~Context):
        (gl::Context::makeCurrent):
        (gl::Context::markAllStateDirty):
        (gl::Context::setFragmentShaderDerivativeHint):
        (gl::Context::setEnableVertexAttribArray):
        (gl::Context::getVertexAttribState):
        (gl::Context::getVertexAttributes):
        (gl::Context::createFence):
        (gl::Context::deleteFence):
        (gl::Context::bindTexture2D):
        (gl::Context::bindTextureCubeMap):
        (gl::Context::getFence):
        (gl::Context::getTexture2D):
        (gl::Context::getTextureCubeMap):
        (gl::Context::getSamplerTexture):
        (gl::Context::getBooleanv):
        (gl::Context::getIntegerv):
        (gl::Context::getQueryParameterInfo):
        (gl::Context::applyRenderTarget):
        (gl::Context::applyState):
        (gl::Context::lookupAttributeMapping):
        (gl::Context::applyVertexBuffer):
        (gl::Context::applyIndexBuffer):
        (gl::Context::readPixels):
        (gl::Context::clear):
        (gl::Context::drawArrays):
        (gl::Context::drawElements):
        (gl::Context::finish):
        (gl::Context::drawClosingLine):
        (gl::Context::getMaximumVaryingVectors):
        (gl::Context::getMaximumFragmentUniformVectors):
        (gl::Context::supportsEventQueries):
        (gl::Context::supportsFloatTextures):
        (gl::Context::supportsFloatLinearFilter):
        (gl::Context::supportsFloatRenderableTextures):
        (gl::Context::supportsHalfFloatTextures):
        (gl::Context::supportsHalfFloatLinearFilter):
        (gl::Context::supportsHalfFloatRenderableTextures):
        (gl::Context::getMaximumRenderbufferDimension):
        (gl::Context::getMaximumTextureDimension):
        (gl::Context::getMaximumCubeTextureDimension):
        (gl::Context::getMaximumTextureLevel):
        (gl::Context::supportsLuminanceTextures):
        (gl::Context::supportsLuminanceAlphaTextures):
        (gl::Context::supports32bitIndices):
        (gl::Context::getIncompleteTexture):
        (gl::Context::setVertexAttrib):
        (gl::Context::initExtensionString):
        (gl::Context::blitFramebuffer):
        * src/libGLESv2/Context.h:
        (gl::VertexAttribute::VertexAttribute):
        (gl::VertexAttribute::typeSize):
        (gl::VertexAttribute::stride):
        * src/libGLESv2/Fence.cpp: Added.
        (gl::Fence::Fence):
        (gl::Fence::~Fence):
        (gl::Fence::isFence):
        (gl::Fence::setFence):
        (gl::Fence::testFence):
        (gl::Fence::finishFence):
        (gl::Fence::getFenceiv):
        * src/libGLESv2/Fence.h: Added.
        * src/libGLESv2/Framebuffer.cpp:
        (gl::Framebuffer::completeness):
        (gl::DefaultFramebuffer::DefaultFramebuffer):
        (gl::DefaultFramebuffer::completeness):
        * src/libGLESv2/Program.cpp:
        (gl::Program::Program):
        (gl::Program::getSamplerMapping):
        (gl::Program::getUniformLocation):
        (gl::Program::setUniform1iv):
        (gl::Program::applyUniforms):
        (gl::Program::packVaryings):
        (gl::Program::linkVaryings):
        (gl::Program::link):
        (gl::Program::defineUniform):
        (gl::Program::createUniform):
        (gl::Program::applyUniform1iv):
        (gl::Program::resetInfoLog):
        (gl::Program::unlink):
        (gl::Program::getActiveAttribute):
        (gl::Program::getActiveUniform):
        (gl::Program::getDxDepthRangeLocation):
        * src/libGLESv2/Program.h:
        * src/libGLESv2/RefCountObject.cpp:
        (gl::RefCountObject::~RefCountObject):
        * src/libGLESv2/Renderbuffer.cpp:
        (gl::RenderbufferStorage::RenderbufferStorage):
        (gl::RenderbufferStorage::isFloatingPoint):
        (gl::Colorbuffer::Colorbuffer):
        (gl::DepthStencilbuffer::DepthStencilbuffer):
        * src/libGLESv2/Renderbuffer.h:
        * src/libGLESv2/Shader.cpp:
        (gl::Shader::Shader):
        (gl::Shader::parseVaryings):
        (gl::Shader::compileToHLSL):
        (gl::VertexShader::parseAttributes):
        * src/libGLESv2/Texture.cpp:
        (gl::Texture::Texture):
        (gl::Texture::isFloatingPoint):
        (gl::Texture::isRenderableFormat):
        (gl::Texture::selectFormat):
        (gl::Texture::loadImageData):
        (gl::Texture::loadAlphaFloatImageData):
        (gl::Texture::loadAlphaHalfFloatImageData):
        (gl::Texture::loadLuminanceImageData):
        (gl::Texture::loadLuminanceFloatImageData):
        (gl::Texture::loadLuminanceHalfFloatImageData):
        (gl::Texture::loadLuminanceAlphaImageData):
        (gl::Texture::loadLuminanceAlphaFloatImageData):
        (gl::Texture::loadLuminanceAlphaHalfFloatImageData):
        (gl::Texture::loadRGBFloatImageData):
        (gl::Texture::loadRGBHalfFloatImageData):
        (gl::Texture::loadRGBAFloatImageData):
        (gl::Texture::loadRGBAHalfFloatImageData):
        (gl::Texture::createSurface):
        (gl::Texture::setImage):
        (gl::Texture::setCompressedImage):
        (gl::Texture::subImage):
        (gl::Texture::subImageCompressed):
        (gl::Texture::copyNonRenderable):
        (gl::Texture::getD3DFormat):
        (gl::Texture::isRenderable):
        (gl::Texture2D::Texture2D):
        (gl::Texture2D::~Texture2D):
        (gl::Texture2D::redefineTexture):
        (gl::Texture2D::setImage):
        (gl::Texture2D::setCompressedImage):
        (gl::Texture2D::copyImage):
        (gl::Texture2D::copySubImage):
        (gl::Texture2D::isComplete):
        (gl::Texture2D::createTexture):
        (gl::Texture2D::convertToRenderTarget):
        (gl::Texture2D::generateMipmaps):
        (gl::Texture2D::getColorbuffer):
        (gl::Texture2D::getRenderTarget):
        (gl::TextureCubeMap::TextureCubeMap):
        (gl::TextureCubeMap::~TextureCubeMap):
        (gl::TextureCubeMap::subImage):
        (gl::TextureCubeMap::subImageCompressed):
        (gl::TextureCubeMap::isComplete):
        (gl::TextureCubeMap::createTexture):
        (gl::TextureCubeMap::convertToRenderTarget):
        (gl::TextureCubeMap::redefineTexture):
        (gl::TextureCubeMap::copyImage):
        (gl::TextureCubeMap::copySubImage):
        (gl::TextureCubeMap::generateMipmaps):
        (gl::TextureCubeMap::getColorbuffer):
        (gl::TextureCubeMap::getRenderTarget):
        (gl::Texture::TextureColorbufferProxy::TextureColorbufferProxy):
        (gl::Texture::TextureColorbufferProxy::isFloatingPoint):
        * src/libGLESv2/Texture.h:
        * src/libGLESv2/geometry/IndexDataManager.cpp:
        (gl::IndexDataManager::IndexDataManager):
        (gl::IndexDataManager::~IndexDataManager):
        (gl::convertIndices):
        (gl::computeRange):
        (gl::IndexDataManager::prepareIndexData):
        (gl::IndexDataManager::indexSize):
        (gl::IndexDataManager::typeSize):
        (gl::IndexBuffer::IndexBuffer):
        (gl::IndexBuffer::~IndexBuffer):
        (gl::IndexBuffer::getBuffer):
        (gl::IndexBuffer::unmap):
        (gl::StreamingIndexBuffer::StreamingIndexBuffer):
        (gl::StreamingIndexBuffer::~StreamingIndexBuffer):
        (gl::StreamingIndexBuffer::map):
        (gl::StreamingIndexBuffer::reserveSpace):
        (gl::StaticIndexBuffer::StaticIndexBuffer):
        (gl::StaticIndexBuffer::~StaticIndexBuffer):
        (gl::StaticIndexBuffer::map):
        (gl::StaticIndexBuffer::reserveSpace):
        (gl::StaticIndexBuffer::lookupType):
        (gl::StaticIndexBuffer::lookupRange):
        (gl::StaticIndexBuffer::addRange):
        * src/libGLESv2/geometry/IndexDataManager.h:
        (gl::IndexBuffer::size):
        * src/libGLESv2/geometry/VertexDataManager.cpp:
        (gl::VertexDataManager::VertexDataManager):
        (gl::VertexDataManager::~VertexDataManager):
        (gl::VertexDataManager::writeAttributeData):
        (gl::VertexDataManager::prepareVertexData):
        (gl::VertexDataManager::spaceRequired):
        (gl::VertexDataManager::checkVertexCaps):
        (gl::VertexDataManager::typeIndex):
        (gl::VertexDataManager::setupAttributes):
        (gl::VertexBuffer::VertexBuffer):
        (gl::VertexBuffer::~VertexBuffer):
        (gl::VertexBuffer::unmap):
        (gl::VertexBuffer::getBuffer):
        (gl::ConstantVertexBuffer::ConstantVertexBuffer):
        (gl::ConstantVertexBuffer::~ConstantVertexBuffer):
        (gl::ArrayVertexBuffer::ArrayVertexBuffer):
        (gl::ArrayVertexBuffer::~ArrayVertexBuffer):
        (gl::ArrayVertexBuffer::addRequiredSpace):
        (gl::ArrayVertexBuffer::addRequiredSpaceFor):
        (gl::StreamingVertexBuffer::StreamingVertexBuffer):
        (gl::StreamingVertexBuffer::~StreamingVertexBuffer):
        (gl::StreamingVertexBuffer::map):
        (gl::StreamingVertexBuffer::reserveRequiredSpace):
        (gl::StaticVertexBuffer::StaticVertexBuffer):
        (gl::StaticVertexBuffer::~StaticVertexBuffer):
        (gl::StaticVertexBuffer::map):
        (gl::StaticVertexBuffer::reserveRequiredSpace):
        (gl::StaticVertexBuffer::lookupAttribute):
        (gl::VertexDataManager::formatConverter):
        * src/libGLESv2/geometry/VertexDataManager.h:
        (gl::ArrayVertexBuffer::size):
        (gl::VertexDataManager::dirtyCurrentValue):
        * src/libGLESv2/geometry/backend.cpp: Removed.
        * src/libGLESv2/geometry/backend.h: Removed.
        * src/libGLESv2/geometry/dx9.cpp: Removed.
        * src/libGLESv2/geometry/dx9.h: Removed.
        * src/libGLESv2/libGLESv2.cpp:
        * src/libGLESv2/libGLESv2.def:
        * src/libGLESv2/libGLESv2.vcproj:
        * src/libGLESv2/utilities.cpp:
        (gl::UniformComponentCount):
        (gl::UniformComponentType):
        (gl::ComputePixelSize):
        (gl::CheckTextureFormatType):
        (gl::IsColorRenderable):
        (gl::IsDepthRenderable):
        (gl::IsStencilRenderable):
        (es2dx::GetAlphaSize):
        (es2dx::GetRedSize):
        (es2dx::GetGreenSize):
        (es2dx::GetBlueSize):
        (es2dx::GetDepthSize):
        (es2dx::ConvertPrimitiveType):
        (dx2es::ConvertBackBufferFormat):
        (dx2es::ConvertDepthStencilFormat):
        * src/libGLESv2/utilities.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

103 files changed:
Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h
Source/ThirdParty/ANGLE/src/common/debug.cpp
Source/ThirdParty/ANGLE/src/common/debug.h
Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/CodeGenHLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/Common.h
Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp
Source/ThirdParty/ANGLE/src/compiler/InfoSink.h
Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp
Source/ThirdParty/ANGLE/src/compiler/Initialize.h
Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp
Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp
Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h
Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp
Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h
Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp
Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h
Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/ShHandle.h
Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp
Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp
Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h
Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h
Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp
Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h
Source/ThirdParty/ANGLE/src/compiler/Types.h
Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp
Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h
Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/glslang.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/glslang.l
Source/ThirdParty/ANGLE/src/compiler/glslang.y
Source/ThirdParty/ANGLE/src/compiler/glslang_lex.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/glslang_tab.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/glslang_tab.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp
Source/ThirdParty/ANGLE/src/compiler/intermediate.h
Source/ThirdParty/ANGLE/src/compiler/localintermediate.h
Source/ThirdParty/ANGLE/src/compiler/osinclude.h
Source/ThirdParty/ANGLE/src/compiler/ossource_nspr.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h
Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c
Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h
Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c
Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h
Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c
Source/ThirdParty/ANGLE/src/compiler/unistd.h [deleted file]
Source/ThirdParty/ANGLE/src/compiler/util.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/compiler/util.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libEGL/Config.cpp
Source/ThirdParty/ANGLE/src/libEGL/Display.cpp
Source/ThirdParty/ANGLE/src/libEGL/Display.h
Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp
Source/ThirdParty/ANGLE/src/libEGL/Surface.h
Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Blit.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h
Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Context.h
Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Program.h
Source/ThirdParty/ANGLE/src/libGLESv2/RefCountObject.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h
Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.h
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.h
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.cpp [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.h [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.cpp [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.h [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def
Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.vcproj
Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm

index 066a930e867e4d4e2c4eba47213df054860e0458..6f91926143f4a1186eff6a72a573900515b12772 100644 (file)
@@ -7,6 +7,22 @@
        objects = {
 
 /* Begin PBXBuildFile section */
+               90D9B10212E11DCB002D4255 /* Compiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0F912E11DCB002D4255 /* Compiler.cpp */; };
+               90D9B10312E11DCB002D4255 /* ExtensionBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */; };
+               90D9B10412E11DCB002D4255 /* glslang_lex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */; };
+               90D9B10512E11DCB002D4255 /* glslang_tab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */; };
+               90D9B10612E11DCB002D4255 /* glslang_tab.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FD12E11DCB002D4255 /* glslang_tab.h */; };
+               90D9B10712E11DCB002D4255 /* glslang.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FE12E11DCB002D4255 /* glslang.h */; };
+               90D9B10912E11DCB002D4255 /* SearchSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */; };
+               90D9B10A12E11DCB002D4255 /* SearchSymbol.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10112E11DCB002D4255 /* SearchSymbol.h */; };
+               90D9B11312E11DD6002D4255 /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10B12E11DD6002D4255 /* util.cpp */; };
+               90D9B11412E11DD6002D4255 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10C12E11DD6002D4255 /* util.h */; };
+               90D9B11512E11DD6002D4255 /* ValidateLimitations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */; };
+               90D9B11612E11DD6002D4255 /* ValidateLimitations.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */; };
+               90D9B11712E11DD6002D4255 /* VariableInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */; };
+               90D9B11812E11DD6002D4255 /* VariableInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B11012E11DD6002D4255 /* VariableInfo.h */; };
+               90D9B11912E11DD6002D4255 /* VersionGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */; };
+               90D9B11A12E11DD6002D4255 /* VersionGLSL.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B11212E11DD6002D4255 /* VersionGLSL.h */; };
                FB39D2711200F35A00088E69 /* CodeGenGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */; };
                FB39D2751200F35A00088E69 /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D2261200F35A00088E69 /* debug.cpp */; };
                FB39D2791200F35A00088E69 /* InfoSink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D22A1200F35A00088E69 /* InfoSink.cpp */; };
                5D7C59C51208C68B001C873E /* ANGLE.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ANGLE.xcconfig; sourceTree = "<group>"; };
                5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
                5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
+               90D9B0F912E11DCB002D4255 /* Compiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Compiler.cpp; sourceTree = "<group>"; };
+               90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionBehavior.h; sourceTree = "<group>"; };
+               90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_lex.cpp; sourceTree = "<group>"; };
+               90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_tab.cpp; sourceTree = "<group>"; };
+               90D9B0FD12E11DCB002D4255 /* glslang_tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang_tab.h; sourceTree = "<group>"; };
+               90D9B0FE12E11DCB002D4255 /* glslang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang.h; sourceTree = "<group>"; };
+               90D9B0FF12E11DCB002D4255 /* ossource_nspr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ossource_nspr.cpp; sourceTree = "<group>"; };
+               90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SearchSymbol.cpp; sourceTree = "<group>"; };
+               90D9B10112E11DCB002D4255 /* SearchSymbol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchSymbol.h; sourceTree = "<group>"; };
+               90D9B10B12E11DD6002D4255 /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cpp; sourceTree = "<group>"; };
+               90D9B10C12E11DD6002D4255 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; };
+               90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValidateLimitations.cpp; sourceTree = "<group>"; };
+               90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidateLimitations.h; sourceTree = "<group>"; };
+               90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VariableInfo.cpp; sourceTree = "<group>"; };
+               90D9B11012E11DD6002D4255 /* VariableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VariableInfo.h; sourceTree = "<group>"; };
+               90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionGLSL.cpp; sourceTree = "<group>"; };
+               90D9B11212E11DD6002D4255 /* VersionGLSL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionGLSL.h; sourceTree = "<group>"; };
                FB39D0D11200F0E300088E69 /* libANGLE.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libANGLE.a; sourceTree = BUILT_PRODUCTS_DIR; };
                FB39D1861200F26200088E69 /* BaseTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTypes.h; sourceTree = "<group>"; };
                FB39D1871200F26200088E69 /* CodeGenGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenGLSL.cpp; sourceTree = "<group>"; };
                FB39D1D11200F26200088E69 /* Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Types.h; sourceTree = "<group>"; };
                FB39D1D21200F26200088E69 /* UnfoldSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = UnfoldSelect.cpp; sourceTree = "<group>"; };
                FB39D1D31200F26200088E69 /* UnfoldSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnfoldSelect.h; sourceTree = "<group>"; };
-               FB39D1D41200F26200088E69 /* unistd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unistd.h; sourceTree = "<group>"; };
                FB39D2211200F35A00088E69 /* BaseTypes.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = BaseTypes.h; sourceTree = "<group>"; };
                FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenGLSL.cpp; sourceTree = "<group>"; };
                FB39D2241200F35A00088E69 /* Common.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = Common.h; sourceTree = "<group>"; };
                FB39D26C1200F35A00088E69 /* Types.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = Types.h; sourceTree = "<group>"; };
                FB39D26D1200F35A00088E69 /* UnfoldSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnfoldSelect.cpp; sourceTree = "<group>"; };
                FB39D26E1200F35A00088E69 /* UnfoldSelect.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = UnfoldSelect.h; sourceTree = "<group>"; };
-               FB39D26F1200F35A00088E69 /* unistd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unistd.h; sourceTree = "<group>"; };
                FB39D2BF1200F3E600088E69 /* ShaderLang.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = ShaderLang.h; sourceTree = "<group>"; };
                FB39D7201201032000088E69 /* glslang.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glslang.cpp; path = DerivedSources/ANGLE/glslang.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                FB39D7211201032000088E69 /* glslang_tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glslang_tab.h; path = DerivedSources/ANGLE/glslang_tab.h; sourceTree = BUILT_PRODUCTS_DIR; };
                                FB39D1D11200F26200088E69 /* Types.h */,
                                FB39D1D21200F26200088E69 /* UnfoldSelect.cpp */,
                                FB39D1D31200F26200088E69 /* UnfoldSelect.h */,
-                               FB39D1D41200F26200088E69 /* unistd.h */,
                        );
                        includeInIndex = 0;
                        name = compiler;
                FB39D2201200F35A00088E69 /* compiler */ = {
                        isa = PBXGroup;
                        children = (
+                               FB39D2441200F35A00088E69 /* preprocessor */,
                                FB39D2211200F35A00088E69 /* BaseTypes.h */,
                                FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */,
                                FB39D2241200F35A00088E69 /* Common.h */,
+                               90D9B0F912E11DCB002D4255 /* Compiler.cpp */,
                                FB39D2251200F35A00088E69 /* ConstantUnion.h */,
                                FB39D2261200F35A00088E69 /* debug.cpp */,
                                FB39D2271200F35A00088E69 /* debug.h */,
+                               90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */,
+                               90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */,
+                               90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */,
+                               90D9B0FD12E11DCB002D4255 /* glslang_tab.h */,
+                               90D9B0FE12E11DCB002D4255 /* glslang.h */,
                                FB39D2281200F35A00088E69 /* glslang.l */,
                                FB39D2291200F35A00088E69 /* glslang.y */,
                                FB39D22A1200F35A00088E69 /* InfoSink.cpp */,
                                FB39D2361200F35A00088E69 /* localintermediate.h */,
                                FB39D2371200F35A00088E69 /* MMap.h */,
                                FB39D2381200F35A00088E69 /* osinclude.h */,
+                               90D9B0FF12E11DCB002D4255 /* ossource_nspr.cpp */,
                                FB39D2391200F35A00088E69 /* ossource_posix.cpp */,
                                FB39D23A1200F35A00088E69 /* ossource_win.cpp */,
                                FB39D23B1200F35A00088E69 /* OutputGLSL.cpp */,
                                FB39D2411200F35A00088E69 /* ParseHelper.h */,
                                FB39D2421200F35A00088E69 /* PoolAlloc.cpp */,
                                FB39D2431200F35A00088E69 /* PoolAlloc.h */,
-                               FB39D2441200F35A00088E69 /* preprocessor */,
                                FB39D2561200F35A00088E69 /* QualifierAlive.cpp */,
                                FB39D2571200F35A00088E69 /* QualifierAlive.h */,
                                FB39D2581200F35A00088E69 /* RemoveTree.cpp */,
                                FB39D2591200F35A00088E69 /* RemoveTree.h */,
+                               90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */,
+                               90D9B10112E11DCB002D4255 /* SearchSymbol.h */,
                                FB39D25A1200F35A00088E69 /* ShaderLang.cpp */,
                                FB39D25B1200F35A00088E69 /* ShHandle.h */,
                                FB39D25C1200F35A00088E69 /* SymbolTable.cpp */,
                                FB39D26C1200F35A00088E69 /* Types.h */,
                                FB39D26D1200F35A00088E69 /* UnfoldSelect.cpp */,
                                FB39D26E1200F35A00088E69 /* UnfoldSelect.h */,
-                               FB39D26F1200F35A00088E69 /* unistd.h */,
+                               90D9B10B12E11DD6002D4255 /* util.cpp */,
+                               90D9B10C12E11DD6002D4255 /* util.h */,
+                               90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */,
+                               90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */,
+                               90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */,
+                               90D9B11012E11DD6002D4255 /* VariableInfo.h */,
+                               90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */,
+                               90D9B11212E11DD6002D4255 /* VersionGLSL.h */,
                        );
                        name = compiler;
                        path = src/compiler;
                        buildActionMask = 2147483647;
                        files = (
                                FB39D76E120110FC00088E69 /* ShaderLang.h in Headers */,
+                               90D9B10312E11DCB002D4255 /* ExtensionBehavior.h in Headers */,
+                               90D9B10612E11DCB002D4255 /* glslang_tab.h in Headers */,
+                               90D9B10712E11DCB002D4255 /* glslang.h in Headers */,
+                               90D9B10A12E11DCB002D4255 /* SearchSymbol.h in Headers */,
+                               90D9B11412E11DD6002D4255 /* util.h in Headers */,
+                               90D9B11612E11DD6002D4255 /* ValidateLimitations.h in Headers */,
+                               90D9B11812E11DD6002D4255 /* VariableInfo.h in Headers */,
+                               90D9B11A12E11DD6002D4255 /* VersionGLSL.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                FB39D2AA1200F35A00088E69 /* SymbolTable.cpp in Sources */,
                                FB39D2AC1200F35A00088E69 /* TranslatorGLSL.cpp in Sources */,
                                FB39D2B11200F35A00088E69 /* UnfoldSelect.cpp in Sources */,
+                               90D9B10212E11DCB002D4255 /* Compiler.cpp in Sources */,
+                               90D9B10412E11DCB002D4255 /* glslang_lex.cpp in Sources */,
+                               90D9B10512E11DCB002D4255 /* glslang_tab.cpp in Sources */,
+                               90D9B10912E11DCB002D4255 /* SearchSymbol.cpp in Sources */,
+                               90D9B11312E11DD6002D4255 /* util.cpp in Sources */,
+                               90D9B11512E11DD6002D4255 /* ValidateLimitations.cpp in Sources */,
+                               90D9B11712E11DD6002D4255 /* VariableInfo.cpp in Sources */,
+                               90D9B11912E11DD6002D4255 /* VersionGLSL.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index bd993b78e8a8178ac2eb0ef4c7ed610476469a7b..e7d8e72eef8ce00316c720197195be4eed013d9c 100644 (file)
@@ -1,3 +1,598 @@
+2011-01-18  Ben Vanik  <ben.vanik@gmail.com>
+
+        Reviewed by Kenneth Russell.
+
+        Updating ANGLE in WebKit to r533.
+        https://bugs.webkit.org/show_bug.cgi?id=47194
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        * include/GLSLANG/ShaderLang.h:
+        * src/common/debug.cpp:
+        (gl::trace):
+        * src/common/debug.h:
+        * src/compiler/CodeGenGLSL.cpp:
+        (ConstructCompiler):
+        * src/compiler/CodeGenHLSL.cpp:
+        (ConstructCompiler):
+        * src/compiler/Common.h:
+        (EncodeSourceLoc):
+        (DecodeSourceLoc):
+        * src/compiler/Compiler.cpp: Added.
+        (TShHandleBase::TShHandleBase):
+        (TShHandleBase::~TShHandleBase):
+        (TCompiler::TCompiler):
+        (TCompiler::~TCompiler):
+        (TCompiler::Init):
+        (TCompiler::compile):
+        (TCompiler::InitBuiltInSymbolTable):
+        (TCompiler::clearResults):
+        (TCompiler::validateLimitations):
+        (TCompiler::collectAttribsUniforms):
+        * src/compiler/ExtensionBehavior.h: Added.
+        * src/compiler/InfoSink.cpp:
+        (TInfoSinkBase::location):
+        * src/compiler/InfoSink.h:
+        (TInfoSinkBase::size):
+        * src/compiler/Initialize.cpp:
+        (BuiltInFunctionsCommon):
+        (BuiltInFunctionsVertex):
+        (BuiltInFunctionsFragment):
+        (StandardUniforms):
+        (DefaultPrecisionVertex):
+        (DefaultPrecisionFragment):
+        (BuiltInConstants):
+        (TBuiltIns::initialize):
+        (IdentifyBuiltIns):
+        (InitExtensionBehavior):
+        * src/compiler/Initialize.h:
+        * src/compiler/IntermTraverse.cpp:
+        (TIntermLoop::traverse):
+        * src/compiler/Intermediate.cpp:
+        (getOperatorString):
+        (TIntermediate::addBinaryMath):
+        (TIntermediate::addLoop):
+        (TIntermediate::postProcess):
+        (TIntermBinary::promote):
+        * src/compiler/OutputGLSL.cpp:
+        (TOutputGLSL::visitUnary):
+        (TOutputGLSL::visitLoop):
+        * src/compiler/OutputHLSL.cpp:
+        (sh::OutputHLSL::OutputHLSL):
+        (sh::OutputHLSL::header):
+        (sh::OutputHLSL::visitBinary):
+        (sh::OutputHLSL::visitUnary):
+        (sh::OutputHLSL::visitAggregate):
+        (sh::OutputHLSL::visitLoop):
+        (sh::OutputHLSL::handleExcessiveLoop):
+        (sh::OutputHLSL::argumentString):
+        * src/compiler/OutputHLSL.h:
+        * src/compiler/ParseHelper.cpp:
+        (ReportInfo):
+        (DefineExtensionMacros):
+        (TParseContext::error):
+        (TParseContext::warning):
+        (TParseContext::reservedErrorCheck):
+        (TParseContext::constructorErrorCheck):
+        (TParseContext::arrayQualifierErrorCheck):
+        (TParseContext::extensionErrorCheck):
+        (TParseContext::areAllChildConst):
+        (PaParseStrings):
+        * src/compiler/ParseHelper.h:
+        (TParseContext::TParseContext):
+        * src/compiler/PoolAlloc.cpp:
+        (InitializeGlobalPools):
+        (FreeGlobalPools):
+        (SetGlobalPoolAllocator):
+        (TPoolAllocator::TPoolAllocator):
+        (TPoolAllocator::~TPoolAllocator):
+        (TAllocation::checkAllocList):
+        * src/compiler/PoolAlloc.h:
+        * src/compiler/SearchSymbol.cpp: Added.
+        (sh::SearchSymbol::SearchSymbol):
+        (sh::SearchSymbol::traverse):
+        (sh::SearchSymbol::visitSymbol):
+        (sh::SearchSymbol::foundMatch):
+        * src/compiler/SearchSymbol.h: Added.
+        * src/compiler/ShHandle.h:
+        (TCompiler::getAsCompiler):
+        (TCompiler::getInfoSink):
+        (TCompiler::getAttribs):
+        (TCompiler::getUniforms):
+        (TCompiler::getShaderType):
+        (TCompiler::getShaderSpec):
+        * src/compiler/ShaderLang.cpp:
+        (getVariableMaxLength):
+        (getVariableInfo):
+        (ShInitBuiltInResources):
+        (ShConstructCompiler):
+        (ShCompile):
+        (ShGetInfo):
+        (ShGetInfoLog):
+        (ShGetObjectCode):
+        (ShGetActiveAttrib):
+        (ShGetActiveUniform):
+        * src/compiler/SymbolTable.cpp:
+        (TSymbolTableLevel::relateToExtension):
+        * src/compiler/SymbolTable.h:
+        (TVariable::shareConstPointer):
+        (TFunction::relateToExtension):
+        (TFunction::getExtension):
+        (TFunction::getParamCount):
+        (TFunction::getParam):
+        (TSymbolTable::getGlobalLevel):
+        (TSymbolTable::relateToOperator):
+        (TSymbolTable::relateToExtension):
+        * src/compiler/TranslatorGLSL.cpp:
+        (writeVersion):
+        (TranslatorGLSL::TranslatorGLSL):
+        (TranslatorGLSL::translate):
+        * src/compiler/TranslatorGLSL.h:
+        * src/compiler/TranslatorHLSL.cpp:
+        (TranslatorHLSL::TranslatorHLSL):
+        (TranslatorHLSL::translate):
+        * src/compiler/TranslatorHLSL.h:
+        * src/compiler/Types.h:
+        (TType::TType):
+        * src/compiler/UnfoldSelect.cpp:
+        (sh::UnfoldSelect::visitSelection):
+        * src/compiler/UnfoldSelect.h:
+        * src/compiler/ValidateLimitations.cpp: Added.
+        (ValidateLimitations::ValidateLimitations):
+        (ValidateLimitations::visitSymbol):
+        (ValidateLimitations::visitConstantUnion):
+        (ValidateLimitations::visitBinary):
+        (ValidateLimitations::visitUnary):
+        (ValidateLimitations::visitSelection):
+        (ValidateLimitations::visitAggregate):
+        (ValidateLimitations::visitLoop):
+        (ValidateLimitations::visitBranch):
+        (ValidateLimitations::error):
+        (ValidateLimitations::withinLoopBody):
+        (ValidateLimitations::isLoopIndex):
+        (ValidateLimitations::validateLoopType):
+        (ValidateLimitations::validateForLoopHeader):
+        (ValidateLimitations::validateForLoopInit):
+        (ValidateLimitations::validateForLoopCond):
+        (ValidateLimitations::validateForLoopExpr):
+        (ValidateLimitations::validateFunctionCall):
+        (ValidateLimitations::validateOperation):
+        (ValidateLimitations::isConstExpr):
+        (ValidateLimitations::isConstIndexExpr):
+        (ValidateLimitations::validateIndexing):
+        * src/compiler/ValidateLimitations.h: Added.
+        (ValidateLimitations::numErrors):
+        * src/compiler/VariableInfo.cpp: Added.
+        (arrayBrackets):
+        (getVariableDataType):
+        (getVariableInfo):
+        (getBuiltInVariableInfo):
+        (getUserDefinedVariableInfo):
+        (CollectAttribsUniforms::CollectAttribsUniforms):
+        (CollectAttribsUniforms::visitSymbol):
+        (CollectAttribsUniforms::visitConstantUnion):
+        (CollectAttribsUniforms::visitBinary):
+        (CollectAttribsUniforms::visitUnary):
+        (CollectAttribsUniforms::visitSelection):
+        (CollectAttribsUniforms::visitAggregate):
+        (CollectAttribsUniforms::visitLoop):
+        (CollectAttribsUniforms::visitBranch):
+        * src/compiler/VariableInfo.h: Added.
+        * src/compiler/VersionGLSL.cpp: Added.
+        (TVersionGLSL::TVersionGLSL):
+        (TVersionGLSL::visitSymbol):
+        (TVersionGLSL::visitConstantUnion):
+        (TVersionGLSL::visitBinary):
+        (TVersionGLSL::visitUnary):
+        (TVersionGLSL::visitSelection):
+        (TVersionGLSL::visitAggregate):
+        (TVersionGLSL::visitLoop):
+        (TVersionGLSL::visitBranch):
+        (TVersionGLSL::updateVersion):
+        * src/compiler/VersionGLSL.h: Added.
+        (TVersionGLSL::getVersion):
+        * src/compiler/generate_glslang_lexer.sh: Added.
+        * src/compiler/generate_glslang_parser.sh: Added.
+        * src/compiler/glslang.h: Added.
+        * src/compiler/glslang.l:
+        * src/compiler/glslang.y:
+        * src/compiler/glslang_lex.cpp: Added.
+        (yy_get_next_buffer):
+        (yy_get_previous_state):
+        (yy_try_NUL_trans):
+        (input):
+        (yyrestart):
+        (yy_switch_to_buffer):
+        (yy_load_buffer_state):
+        (yy_create_buffer):
+        (yy_delete_buffer):
+        (yy_init_buffer):
+        (yy_flush_buffer):
+        (yypush_buffer_state):
+        (yypop_buffer_state):
+        (yyensure_buffer_stack):
+        (yy_scan_buffer):
+        (yy_scan_string):
+        (yy_scan_bytes):
+        (yy_push_state):
+        (yy_pop_state):
+        (yy_top_state):
+        (yy_fatal_error):
+        (yyget_extra):
+        (yyget_lineno):
+        (yyget_column):
+        (yyget_in):
+        (yyget_out):
+        (yyget_leng):
+        (yyget_text):
+        (yyset_extra):
+        (yyset_lineno):
+        (yyset_column):
+        (yyset_in):
+        (yyset_out):
+        (yyget_debug):
+        (yyset_debug):
+        (yyget_lval):
+        (yyset_lval):
+        (yylex_init):
+        (yylex_init_extra):
+        (yy_init_globals):
+        (yylex_destroy):
+        (yy_flex_strncpy):
+        (yy_flex_strlen):
+        (yyalloc):
+        (yyrealloc):
+        (yyfree):
+        (string_input):
+        (check_type):
+        (reserved_word):
+        (yyerror):
+        (glslang_initialize):
+        (glslang_finalize):
+        (glslang_scan):
+        * src/compiler/glslang_tab.cpp: Added.
+        (yytnamerr):
+        (yysyntax_error):
+        (glslang_parse):
+        * src/compiler/glslang_tab.h: Added.
+        * src/compiler/intermOut.cpp:
+        (TOutputTraverser::TOutputTraverser):
+        (OutputTreeText):
+        (TOutputTraverser::visitSymbol):
+        (TOutputTraverser::visitBinary):
+        (TOutputTraverser::visitUnary):
+        (TOutputTraverser::visitAggregate):
+        (TOutputTraverser::visitSelection):
+        (TOutputTraverser::visitConstantUnion):
+        (TOutputTraverser::visitLoop):
+        (TOutputTraverser::visitBranch):
+        (TIntermediate::outputTree):
+        * src/compiler/intermediate.h:
+        (TIntermLoop::TIntermLoop):
+        (TIntermLoop::getType):
+        (TIntermLoop::getInit):
+        (TIntermLoop::getCondition):
+        (TIntermLoop::getExpression):
+        (TIntermLoop::getBody):
+        * src/compiler/localintermediate.h:
+        * src/compiler/osinclude.h:
+        (OS_GetTLSValue):
+        * src/compiler/ossource_nspr.cpp: Added.
+        (OS_AllocTLSIndex):
+        (OS_SetTLSValue):
+        (OS_FreeTLSIndex):
+        * src/compiler/preprocessor/compile.h:
+        * src/compiler/preprocessor/cpp.c:
+        (CPPdefine):
+        (CPPelse):
+        (CPPif):
+        (CPPifdef):
+        (CPPerror):
+        (CPPextension):
+        (readCPPline):
+        * src/compiler/preprocessor/preprocess.h:
+        * src/compiler/preprocessor/scanner.c:
+        (str_getch):
+        (str_ungetch):
+        (ScanFromString):
+        (lFloatConst):
+        (byte_scan):
+        (yylex_CPP):
+        (check_EOF):
+        * src/compiler/preprocessor/scanner.h:
+        * src/compiler/preprocessor/tokens.c:
+        (RecordToken):
+        (ReadToken):
+        * src/compiler/tools: Removed.
+        * src/compiler/unistd.h: Removed.
+        * src/compiler/util.cpp: Added.
+        (atof_dot):
+        * src/compiler/util.h: Added.
+        * src/libEGL/Config.cpp:
+        (egl::Config::set):
+        * src/libEGL/Display.cpp:
+        (egl::Display::Display):
+        (egl::Display::initialize):
+        (egl::Display::terminate):
+        (egl::Display::createDevice):
+        (egl::Display::resetDevice):
+        (egl::Display::createContext):
+        (egl::Display::destroyContext):
+        (egl::Display::getMinSwapInterval):
+        (egl::Display::getMaxSwapInterval):
+        (egl::Display::getDevice):
+        (egl::Display::getFloatTextureSupport):
+        (egl::Display::getHalfFloatTextureSupport):
+        (egl::Display::getLuminanceTextureSupport):
+        (egl::Display::getLuminanceAlphaTextureSupport):
+        (egl::Display::getBufferPool):
+        (egl::Display::getEventQuerySupport):
+        (egl::Display::getDefaultPresentParameters):
+        * src/libEGL/Display.h:
+        * src/libEGL/Surface.cpp:
+        (egl::Surface::Surface):
+        (egl::Surface::~Surface):
+        (egl::Surface::release):
+        (egl::Surface::resetSwapChain):
+        (egl::Surface::writeRecordableFlipState):
+        (egl::Surface::restoreState):
+        (egl::SurfaceWindowProc):
+        (egl::Surface::subclassWindow):
+        (egl::Surface::unsubclassWindow):
+        (egl::Surface::checkForOutOfDateSwapChain):
+        (egl::Surface::convertInterval):
+        (egl::Surface::swap):
+        (egl::Surface::getRenderTarget):
+        (egl::Surface::setSwapInterval):
+        * src/libEGL/Surface.h:
+        * src/libEGL/libEGL.cpp:
+        * src/libGLESv2/Blit.cpp:
+        (gl::Blit::copySurfaceToTexture):
+        (gl::Blit::setCommonBlitState):
+        * src/libGLESv2/Buffer.cpp:
+        (gl::Buffer::Buffer):
+        (gl::Buffer::~Buffer):
+        (gl::Buffer::bufferData):
+        (gl::Buffer::bufferSubData):
+        (gl::Buffer::getVertexBuffer):
+        (gl::Buffer::getIndexBuffer):
+        (gl::Buffer::invalidateStaticData):
+        * src/libGLESv2/Buffer.h:
+        * src/libGLESv2/Context.cpp:
+        (gl::Context::Context):
+        (gl::Context::~Context):
+        (gl::Context::makeCurrent):
+        (gl::Context::markAllStateDirty):
+        (gl::Context::setFragmentShaderDerivativeHint):
+        (gl::Context::setEnableVertexAttribArray):
+        (gl::Context::getVertexAttribState):
+        (gl::Context::getVertexAttributes):
+        (gl::Context::createFence):
+        (gl::Context::deleteFence):
+        (gl::Context::bindTexture2D):
+        (gl::Context::bindTextureCubeMap):
+        (gl::Context::getFence):
+        (gl::Context::getTexture2D):
+        (gl::Context::getTextureCubeMap):
+        (gl::Context::getSamplerTexture):
+        (gl::Context::getBooleanv):
+        (gl::Context::getIntegerv):
+        (gl::Context::getQueryParameterInfo):
+        (gl::Context::applyRenderTarget):
+        (gl::Context::applyState):
+        (gl::Context::lookupAttributeMapping):
+        (gl::Context::applyVertexBuffer):
+        (gl::Context::applyIndexBuffer):
+        (gl::Context::readPixels):
+        (gl::Context::clear):
+        (gl::Context::drawArrays):
+        (gl::Context::drawElements):
+        (gl::Context::finish):
+        (gl::Context::drawClosingLine):
+        (gl::Context::getMaximumVaryingVectors):
+        (gl::Context::getMaximumFragmentUniformVectors):
+        (gl::Context::supportsEventQueries):
+        (gl::Context::supportsFloatTextures):
+        (gl::Context::supportsFloatLinearFilter):
+        (gl::Context::supportsFloatRenderableTextures):
+        (gl::Context::supportsHalfFloatTextures):
+        (gl::Context::supportsHalfFloatLinearFilter):
+        (gl::Context::supportsHalfFloatRenderableTextures):
+        (gl::Context::getMaximumRenderbufferDimension):
+        (gl::Context::getMaximumTextureDimension):
+        (gl::Context::getMaximumCubeTextureDimension):
+        (gl::Context::getMaximumTextureLevel):
+        (gl::Context::supportsLuminanceTextures):
+        (gl::Context::supportsLuminanceAlphaTextures):
+        (gl::Context::supports32bitIndices):
+        (gl::Context::getIncompleteTexture):
+        (gl::Context::setVertexAttrib):
+        (gl::Context::initExtensionString):
+        (gl::Context::blitFramebuffer):
+        * src/libGLESv2/Context.h:
+        (gl::VertexAttribute::VertexAttribute):
+        (gl::VertexAttribute::typeSize):
+        (gl::VertexAttribute::stride):
+        * src/libGLESv2/Fence.cpp: Added.
+        (gl::Fence::Fence):
+        (gl::Fence::~Fence):
+        (gl::Fence::isFence):
+        (gl::Fence::setFence):
+        (gl::Fence::testFence):
+        (gl::Fence::finishFence):
+        (gl::Fence::getFenceiv):
+        * src/libGLESv2/Fence.h: Added.
+        * src/libGLESv2/Framebuffer.cpp:
+        (gl::Framebuffer::completeness):
+        (gl::DefaultFramebuffer::DefaultFramebuffer):
+        (gl::DefaultFramebuffer::completeness):
+        * src/libGLESv2/Program.cpp:
+        (gl::Program::Program):
+        (gl::Program::getSamplerMapping):
+        (gl::Program::getUniformLocation):
+        (gl::Program::setUniform1iv):
+        (gl::Program::applyUniforms):
+        (gl::Program::packVaryings):
+        (gl::Program::linkVaryings):
+        (gl::Program::link):
+        (gl::Program::defineUniform):
+        (gl::Program::createUniform):
+        (gl::Program::applyUniform1iv):
+        (gl::Program::resetInfoLog):
+        (gl::Program::unlink):
+        (gl::Program::getActiveAttribute):
+        (gl::Program::getActiveUniform):
+        (gl::Program::getDxDepthRangeLocation):
+        * src/libGLESv2/Program.h:
+        * src/libGLESv2/RefCountObject.cpp:
+        (gl::RefCountObject::~RefCountObject):
+        * src/libGLESv2/Renderbuffer.cpp:
+        (gl::RenderbufferStorage::RenderbufferStorage):
+        (gl::RenderbufferStorage::isFloatingPoint):
+        (gl::Colorbuffer::Colorbuffer):
+        (gl::DepthStencilbuffer::DepthStencilbuffer):
+        * src/libGLESv2/Renderbuffer.h:
+        * src/libGLESv2/Shader.cpp:
+        (gl::Shader::Shader):
+        (gl::Shader::parseVaryings):
+        (gl::Shader::compileToHLSL):
+        (gl::VertexShader::parseAttributes):
+        * src/libGLESv2/Texture.cpp:
+        (gl::Texture::Texture):
+        (gl::Texture::isFloatingPoint):
+        (gl::Texture::isRenderableFormat):
+        (gl::Texture::selectFormat):
+        (gl::Texture::loadImageData):
+        (gl::Texture::loadAlphaFloatImageData):
+        (gl::Texture::loadAlphaHalfFloatImageData):
+        (gl::Texture::loadLuminanceImageData):
+        (gl::Texture::loadLuminanceFloatImageData):
+        (gl::Texture::loadLuminanceHalfFloatImageData):
+        (gl::Texture::loadLuminanceAlphaImageData):
+        (gl::Texture::loadLuminanceAlphaFloatImageData):
+        (gl::Texture::loadLuminanceAlphaHalfFloatImageData):
+        (gl::Texture::loadRGBFloatImageData):
+        (gl::Texture::loadRGBHalfFloatImageData):
+        (gl::Texture::loadRGBAFloatImageData):
+        (gl::Texture::loadRGBAHalfFloatImageData):
+        (gl::Texture::createSurface):
+        (gl::Texture::setImage):
+        (gl::Texture::setCompressedImage):
+        (gl::Texture::subImage):
+        (gl::Texture::subImageCompressed):
+        (gl::Texture::copyNonRenderable):
+        (gl::Texture::getD3DFormat):
+        (gl::Texture::isRenderable):
+        (gl::Texture2D::Texture2D):
+        (gl::Texture2D::~Texture2D):
+        (gl::Texture2D::redefineTexture):
+        (gl::Texture2D::setImage):
+        (gl::Texture2D::setCompressedImage):
+        (gl::Texture2D::copyImage):
+        (gl::Texture2D::copySubImage):
+        (gl::Texture2D::isComplete):
+        (gl::Texture2D::createTexture):
+        (gl::Texture2D::convertToRenderTarget):
+        (gl::Texture2D::generateMipmaps):
+        (gl::Texture2D::getColorbuffer):
+        (gl::Texture2D::getRenderTarget):
+        (gl::TextureCubeMap::TextureCubeMap):
+        (gl::TextureCubeMap::~TextureCubeMap):
+        (gl::TextureCubeMap::subImage):
+        (gl::TextureCubeMap::subImageCompressed):
+        (gl::TextureCubeMap::isComplete):
+        (gl::TextureCubeMap::createTexture):
+        (gl::TextureCubeMap::convertToRenderTarget):
+        (gl::TextureCubeMap::redefineTexture):
+        (gl::TextureCubeMap::copyImage):
+        (gl::TextureCubeMap::copySubImage):
+        (gl::TextureCubeMap::generateMipmaps):
+        (gl::TextureCubeMap::getColorbuffer):
+        (gl::TextureCubeMap::getRenderTarget):
+        (gl::Texture::TextureColorbufferProxy::TextureColorbufferProxy):
+        (gl::Texture::TextureColorbufferProxy::isFloatingPoint):
+        * src/libGLESv2/Texture.h:
+        * src/libGLESv2/geometry/IndexDataManager.cpp:
+        (gl::IndexDataManager::IndexDataManager):
+        (gl::IndexDataManager::~IndexDataManager):
+        (gl::convertIndices):
+        (gl::computeRange):
+        (gl::IndexDataManager::prepareIndexData):
+        (gl::IndexDataManager::indexSize):
+        (gl::IndexDataManager::typeSize):
+        (gl::IndexBuffer::IndexBuffer):
+        (gl::IndexBuffer::~IndexBuffer):
+        (gl::IndexBuffer::getBuffer):
+        (gl::IndexBuffer::unmap):
+        (gl::StreamingIndexBuffer::StreamingIndexBuffer):
+        (gl::StreamingIndexBuffer::~StreamingIndexBuffer):
+        (gl::StreamingIndexBuffer::map):
+        (gl::StreamingIndexBuffer::reserveSpace):
+        (gl::StaticIndexBuffer::StaticIndexBuffer):
+        (gl::StaticIndexBuffer::~StaticIndexBuffer):
+        (gl::StaticIndexBuffer::map):
+        (gl::StaticIndexBuffer::reserveSpace):
+        (gl::StaticIndexBuffer::lookupType):
+        (gl::StaticIndexBuffer::lookupRange):
+        (gl::StaticIndexBuffer::addRange):
+        * src/libGLESv2/geometry/IndexDataManager.h:
+        (gl::IndexBuffer::size):
+        * src/libGLESv2/geometry/VertexDataManager.cpp:
+        (gl::VertexDataManager::VertexDataManager):
+        (gl::VertexDataManager::~VertexDataManager):
+        (gl::VertexDataManager::writeAttributeData):
+        (gl::VertexDataManager::prepareVertexData):
+        (gl::VertexDataManager::spaceRequired):
+        (gl::VertexDataManager::checkVertexCaps):
+        (gl::VertexDataManager::typeIndex):
+        (gl::VertexDataManager::setupAttributes):
+        (gl::VertexBuffer::VertexBuffer):
+        (gl::VertexBuffer::~VertexBuffer):
+        (gl::VertexBuffer::unmap):
+        (gl::VertexBuffer::getBuffer):
+        (gl::ConstantVertexBuffer::ConstantVertexBuffer):
+        (gl::ConstantVertexBuffer::~ConstantVertexBuffer):
+        (gl::ArrayVertexBuffer::ArrayVertexBuffer):
+        (gl::ArrayVertexBuffer::~ArrayVertexBuffer):
+        (gl::ArrayVertexBuffer::addRequiredSpace):
+        (gl::ArrayVertexBuffer::addRequiredSpaceFor):
+        (gl::StreamingVertexBuffer::StreamingVertexBuffer):
+        (gl::StreamingVertexBuffer::~StreamingVertexBuffer):
+        (gl::StreamingVertexBuffer::map):
+        (gl::StreamingVertexBuffer::reserveRequiredSpace):
+        (gl::StaticVertexBuffer::StaticVertexBuffer):
+        (gl::StaticVertexBuffer::~StaticVertexBuffer):
+        (gl::StaticVertexBuffer::map):
+        (gl::StaticVertexBuffer::reserveRequiredSpace):
+        (gl::StaticVertexBuffer::lookupAttribute):
+        (gl::VertexDataManager::formatConverter):
+        * src/libGLESv2/geometry/VertexDataManager.h:
+        (gl::ArrayVertexBuffer::size):
+        (gl::VertexDataManager::dirtyCurrentValue):
+        * src/libGLESv2/geometry/backend.cpp: Removed.
+        * src/libGLESv2/geometry/backend.h: Removed.
+        * src/libGLESv2/geometry/dx9.cpp: Removed.
+        * src/libGLESv2/geometry/dx9.h: Removed.
+        * src/libGLESv2/libGLESv2.cpp:
+        * src/libGLESv2/libGLESv2.def:
+        * src/libGLESv2/libGLESv2.vcproj:
+        * src/libGLESv2/utilities.cpp:
+        (gl::UniformComponentCount):
+        (gl::UniformComponentType):
+        (gl::ComputePixelSize):
+        (gl::CheckTextureFormatType):
+        (gl::IsColorRenderable):
+        (gl::IsDepthRenderable):
+        (gl::IsStencilRenderable):
+        (es2dx::GetAlphaSize):
+        (es2dx::GetRedSize):
+        (es2dx::GetGreenSize):
+        (es2dx::GetBlueSize):
+        (es2dx::GetDepthSize):
+        (es2dx::ConvertPrimitiveType):
+        (dx2es::ConvertBackBufferFormat):
+        (dx2es::ConvertDepthStencilFormat):
+        * src/libGLESv2/utilities.h:
+
 2011-01-17  Dan Bernstein  <mitz@apple.com>
 
         Rubber-stamped by Mark Rowe.
index e0a5cc8d27c83b20bdac1f36c73f044732f51eb1..d0664e4ca623feec88862b81a9688c839dfbf4c7 100644 (file)
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+// Version number for shader translation API.
+// It is incremented everytime the API changes.
+#define SH_VERSION 103
+
+//
+// The names of the following enums have been derived by replacing GL prefix
+// with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH.
+// The enum values are also equal to the values of their GL counterpart. This
+// is done to make it easier for applications to use the shader library.
+//
+typedef enum {
+  SH_FRAGMENT_SHADER = 0x8B30,
+  SH_VERTEX_SHADER   = 0x8B31
+} ShShaderType;
+
+typedef enum {
+  SH_GLES2_SPEC = 0x8B40,
+  SH_WEBGL_SPEC = 0x8B41
+} ShShaderSpec;
+
+typedef enum {
+  SH_NONE           = 0,
+  SH_INT            = 0x1404,
+  SH_FLOAT          = 0x1406,
+  SH_FLOAT_VEC2     = 0x8B50,
+  SH_FLOAT_VEC3     = 0x8B51,
+  SH_FLOAT_VEC4     = 0x8B52,
+  SH_INT_VEC2       = 0x8B53,
+  SH_INT_VEC3       = 0x8B54,
+  SH_INT_VEC4       = 0x8B55,
+  SH_BOOL           = 0x8B56,
+  SH_BOOL_VEC2      = 0x8B57,
+  SH_BOOL_VEC3      = 0x8B58,
+  SH_BOOL_VEC4      = 0x8B59,
+  SH_FLOAT_MAT2     = 0x8B5A,
+  SH_FLOAT_MAT3     = 0x8B5B,
+  SH_FLOAT_MAT4     = 0x8B5C,
+  SH_SAMPLER_2D     = 0x8B5E,
+  SH_SAMPLER_CUBE   = 0x8B60
+} ShDataType;
+
+typedef enum {
+  SH_INFO_LOG_LENGTH             =  0x8B84,
+  SH_OBJECT_CODE_LENGTH          =  0x8B88,  // GL_SHADER_SOURCE_LENGTH
+  SH_ACTIVE_UNIFORMS             =  0x8B86,
+  SH_ACTIVE_UNIFORM_MAX_LENGTH   =  0x8B87,
+  SH_ACTIVE_ATTRIBUTES           =  0x8B89,
+  SH_ACTIVE_ATTRIBUTE_MAX_LENGTH =  0x8B8A
+} ShShaderInfo;
+
+// Compile options.
+typedef enum {
+  SH_VALIDATE               = 0,
+  SH_VALIDATE_LOOP_INDEXING = 0x0001,
+  SH_INTERMEDIATE_TREE      = 0x0002,
+  SH_OBJECT_CODE            = 0x0004,
+  SH_ATTRIBUTES_UNIFORMS    = 0x0008
+} ShCompileOptions;
+
 //
 // Driver must call this first, once, before doing any other
 // compiler operations.
@@ -25,23 +85,6 @@ int ShInitialize();
 // If the function succeeds, the return value is nonzero, else zero.
 //
 int ShFinalize();
-//
-// Types of languages the compiler can consume.
-//
-typedef enum {
-    EShLangVertex,
-    EShLangFragment,
-    EShLangCount,
-} EShLanguage;
-
-//
-// The language specification compiler conforms to.
-// It currently supports OpenGL ES and WebGL specifications.
-//
-typedef enum {
-    EShSpecGLES2,
-    EShSpecWebGL,
-} EShSpec;
 
 //
 // Implementation dependent built-in resources (constants and extensions).
@@ -62,27 +105,12 @@ typedef struct
     // Extensions.
     // Set to 1 to enable the extension, else 0.
     int OES_standard_derivatives;
-} TBuiltInResource;
+} ShBuiltInResources;
 
 //
 // Initialize built-in resources with minimum expected values.
 //
-void ShInitBuiltInResource(TBuiltInResource* resources);
-
-//
-// Optimization level for the compiler.
-//
-typedef enum {
-    EShOptNoGeneration,
-    EShOptNone,
-    EShOptSimple,       // Optimizations that can be done quickly
-    EShOptFull,         // Optimizations that will take more time
-} EShOptimizationLevel;
-
-enum TDebugOptions {
-    EDebugOpNone               = 0x000,
-    EDebugOpIntermediate       = 0x001,  // Writes intermediate tree into info-log.
-};
+void ShInitBuiltInResources(ShBuiltInResources* resources);
 
 //
 // ShHandle held by but opaque to the driver.  It is allocated,
@@ -96,30 +124,130 @@ typedef void* ShHandle;
 //
 // Driver calls these to create and destroy compiler objects.
 //
-ShHandle ShConstructCompiler(EShLanguage, EShSpec, const TBuiltInResource*);
-void ShDestruct(ShHandle);
+// Returns the handle of constructed compiler.
+// Parameters:
+// type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER.
+// spec: Specifies the language spec the compiler must conform to -
+//       SH_GLES2_SPEC or SH_WEBGL_SPEC.
+// resources: Specifies the built-in resources.
+ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
+                             const ShBuiltInResources* resources);
+void ShDestruct(ShHandle handle);
 
 //
-// The return value of ShCompile is boolean, indicating
-// success or failure.
-//
-// The info-log should be written by ShCompile into 
-// ShHandle, so it can answer future queries.
+// Compiles the given shader source.
+// If the function succeeds, the return value is nonzero, else zero.
+// Parameters:
+// handle: Specifies the handle of compiler to be used.
+// shaderStrings: Specifies an array of pointers to null-terminated strings
+//                containing the shader source code.
+// numStrings: Specifies the number of elements in shaderStrings array.
+// compileOptions: A mask containing the following parameters:
+// SH_VALIDATE: Validates shader to ensure that it conforms to the spec
+//              specified during compiler construction.
+// SH_VALIDATE_LOOP_INDEXING: Validates loop and indexing in the shader to
+//                            ensure that they do not exceed the minimum
+//                            functionality mandated in GLSL 1.0 spec,
+//                            Appendix A, Section 4 and 5.
+//                            There is no need to specify this parameter when
+//                            compiling for WebGL - it is implied.
+// SH_INTERMEDIATE_TREE: Writes intermediate tree to info log.
+//                       Can be queried by calling ShGetInfoLog().
+// SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader.
+//                 Can be queried by calling ShGetObjectCode().
+// SH_ATTRIBUTES_UNIFORMS: Extracts attributes and uniforms.
+//                         Can be queried by calling ShGetActiveAttrib() and
+//                         ShGetActiveUniform().
 //
 int ShCompile(
-    const ShHandle,
+    const ShHandle handle,
     const char* const shaderStrings[],
     const int numStrings,
-    const EShOptimizationLevel,
-    int debugOptions
+    int compileOptions
     );
 
-//
-// All the following return 0 if the information is not
-// available in the object passed down, or the object is bad.
-//
-const char* ShGetInfoLog(const ShHandle);
-const char* ShGetObjectCode(const ShHandle);
+// Returns a parameter from a compiled shader.
+// Parameters:
+// handle: Specifies the compiler
+// pname: Specifies the parameter to query.
+// The following parameters are defined:
+// SH_INFO_LOG_LENGTH: the number of characters in the information log
+//                     including the null termination character.
+// SH_OBJECT_CODE_LENGTH: the number of characters in the object code
+//                        including the null termination character.
+// SH_ACTIVE_ATTRIBUTES: the number of active attribute variables.
+// SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: the length of the longest active attribute
+//                                 variable name including the null
+//                                 termination character.
+// SH_ACTIVE_UNIFORMS: the number of active uniform variables.
+// SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform
+//                               variable name including the null
+//                               termination character.
+// 
+// params: Requested parameter
+void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params);
+
+// Returns nul-terminated information log for a compiled shader.
+// Parameters:
+// handle: Specifies the compiler
+// infoLog: Specifies an array of characters that is used to return
+//          the information log. It is assumed that infoLog has enough memory
+//          to accomodate the information log. The size of the buffer required
+//          to store the returned information log can be obtained by calling
+//          ShGetInfo with SH_INFO_LOG_LENGTH.
+void ShGetInfoLog(const ShHandle handle, char* infoLog);
+
+// Returns null-terminated object code for a compiled shader.
+// Parameters:
+// handle: Specifies the compiler
+// infoLog: Specifies an array of characters that is used to return
+//          the object code. It is assumed that infoLog has enough memory to
+//          accomodate the object code. The size of the buffer required to
+//          store the returned object code can be obtained by calling
+//          ShGetInfo with SH_OBJECT_CODE_LENGTH.
+void ShGetObjectCode(const ShHandle handle, char* objCode);
+
+// Returns information about an active attribute variable.
+// Parameters:
+// handle: Specifies the compiler
+// index: Specifies the index of the attribute variable to be queried.
+// length: Returns the number of characters actually written in the string
+//         indicated by name (excluding the null terminator) if a value other
+//         than NULL is passed.
+// size: Returns the size of the attribute variable.
+// type: Returns the data type of the attribute variable.
+// name: Returns a null terminated string containing the name of the
+//       attribute variable. It is assumed that name has enough memory to
+//       accomodate the attribute variable name. The size of the buffer
+//       required to store the attribute variable name can be obtained by
+//       calling ShGetInfo with SH_ACTIVE_ATTRIBUTE_MAX_LENGTH.
+void ShGetActiveAttrib(const ShHandle handle,
+                       int index,
+                       int* length,
+                       int* size,
+                       ShDataType* type,
+                       char* name);
+
+// Returns information about an active uniform variable.
+// Parameters:
+// handle: Specifies the compiler
+// index: Specifies the index of the uniform variable to be queried.
+// length: Returns the number of characters actually written in the string
+//         indicated by name (excluding the null terminator) if a value
+//         other than NULL is passed.
+// size: Returns the size of the uniform variable.
+// type: Returns the data type of the uniform variable.
+// name: Returns a null terminated string containing the name of the
+//       uniform variable. It is assumed that name has enough memory to
+//       accomodate the uniform variable name. The size of the buffer required
+//       to store the uniform variable name can be obtained by calling
+//       ShGetInfo with SH_ACTIVE_UNIFORMS_MAX_LENGTH.
+void ShGetActiveUniform(const ShHandle handle,
+                        int index,
+                        int* length,
+                        int* size,
+                        ShDataType* type,
+                        char* name);
 
 #ifdef __cplusplus
 }
index d8d6ab89a4d5c53e505396bc2d583b4dc8a2ece3..3de5d4ecee11cb6cd0d249ba23fa27763c1b8dfc 100644 (file)
 #include <stdio.h>
 #include <stdarg.h>
 
+#ifndef TRACE_OUTPUT_FILE
+#define TRACE_OUTPUT_FILE "debug.txt"
+#endif
+
 static bool trace_on = true;
 
 namespace gl
 {
 void trace(const char *format, ...)
 {
+#if !defined(ANGLE_DISABLE_TRACE) 
     if (trace_on)
     {
         if (format)
         {
-            FILE *file = fopen("debug.txt", "a");
+            FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
 
             if (file)
             {
@@ -34,5 +39,6 @@ void trace(const char *format, ...)
             }
         }
     }
+#endif // !defined(ANGLE_DISABLE_TRACE)
 }
 }
index 9a5135bd6873be9909ca2a52d5c0c91650a054d6..2c4ec701a3b45448e8347fffeeefd9280669a732 100644 (file)
@@ -19,7 +19,7 @@ namespace gl
 }
 
 // A macro to output a trace of a function call and its arguments to the debugging log
-#ifndef NDEBUG
+#if !defined(NDEBUG) && !defined(ANGLE_DISABLE_TRACE) 
     #define TRACE(message, ...) gl::trace("trace: %s"message"\n", __FUNCTION__, __VA_ARGS__)
 #else
     #define TRACE(...) ((void)0)
index 855b09206f1931c233c491293d881afa2ea5f171..d140b375f71091001cdde1250cb58b719dccdf6c 100644 (file)
@@ -11,9 +11,9 @@
 // compile object used by higher level code.  It returns
 // a subclass of TCompiler.
 //
-TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec)
+TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec)
 {
-    return new TranslatorGLSL(language, spec);
+    return new TranslatorGLSL(type, spec);
 }
 
 //
index 4db771d887449cc8112c937f094ce8e27f2affa3..e04e7894415917f06d9cdaa1847513f243077134 100644 (file)
@@ -11,9 +11,9 @@
 // compile object used by higher level code.  It returns
 // a subclass of TCompiler.
 //
-TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec)
+TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec)
 {
-    return new TranslatorHLSL(language, spec);
+    return new TranslatorHLSL(type, spec);
 }
 
 //
index 65d0a5183453bdaf3c0bc58b898063b2ab29801e..27a5598290898561d5a4e0c4243b56f846472ddc 100644 (file)
 
 #include "compiler/PoolAlloc.h"
 
+// We need two pieces of information to report errors/warnings - string and
+// line number. We encode these into a single int so that it can be easily
+// incremented/decremented by lexer. The right SOURCE_LOC_LINE_SIZE bits store
+// line number while the rest store the string number. Since the shaders are
+// usually small, we should not run out of memory. SOURCE_LOC_LINE_SIZE
+// can be increased to alleviate this issue.
 typedef int TSourceLoc;
-const unsigned int SourceLocLineMask = 0xffff;
-const unsigned int SourceLocStringShift = 16;
+const unsigned int SOURCE_LOC_LINE_SIZE = 16;  // in bits.
+const unsigned int SOURCE_LOC_LINE_MASK = (1 << SOURCE_LOC_LINE_SIZE) - 1;
+
+inline TSourceLoc EncodeSourceLoc(int string, int line) {
+    return (string << SOURCE_LOC_LINE_SIZE) | (line & SOURCE_LOC_LINE_MASK);
+}
+
+inline void DecodeSourceLoc(TSourceLoc loc, int* string, int* line) {
+    if (string) *string = loc >> SOURCE_LOC_LINE_SIZE;
+    if (line) *line = loc & SOURCE_LOC_LINE_MASK;
+}
 
 //
 // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
@@ -71,6 +86,4 @@ public:
     TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a) {}
 };
 
-typedef TMap<TString, TString> TPragmaTable;
-
 #endif // _COMMON_INCLUDED_
diff --git a/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp b/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp
new file mode 100644 (file)
index 0000000..649b457
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/Initialize.h"
+#include "compiler/ParseHelper.h"
+#include "compiler/ShHandle.h"
+#include "compiler/ValidateLimitations.h"
+
+namespace {
+bool InitializeSymbolTable(
+    const TBuiltInStrings& builtInStrings,
+    ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources,
+    TInfoSink& infoSink, TSymbolTable& symbolTable)
+{
+    TIntermediate intermediate(infoSink);
+    TExtensionBehavior extBehavior;
+    TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, infoSink);
+
+    GlobalParseContext = &parseContext;
+
+    assert(symbolTable.isEmpty());       
+    //
+    // Parse the built-ins.  This should only happen once per
+    // language symbol table.
+    //
+    // Push the symbol table to give it an initial scope.  This
+    // push should not have a corresponding pop, so that built-ins
+    // are preserved, and the test for an empty table fails.
+    //
+    symbolTable.push();
+
+    for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i)
+    {
+        const char* builtInShaders = i->c_str();
+        int builtInLengths = static_cast<int>(i->size());
+        if (builtInLengths <= 0)
+          continue;
+
+        if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0)
+        {
+            infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
+            return false;
+        }
+    }
+
+    IdentifyBuiltIns(type, spec, resources, symbolTable);
+
+    return true;
+}
+
+class TScopedPoolAllocator {
+public:
+    TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop)
+        : mAllocator(allocator), mPushPopAllocator(pushPop) {
+        if (mPushPopAllocator) mAllocator->push();
+        SetGlobalPoolAllocator(mAllocator);
+    }
+    ~TScopedPoolAllocator() {
+        SetGlobalPoolAllocator(NULL);
+        if (mPushPopAllocator) mAllocator->pop();
+    }
+
+private:
+    TPoolAllocator* mAllocator;
+    bool mPushPopAllocator;
+};
+}  // namespace
+
+TShHandleBase::TShHandleBase() {
+    allocator.push();
+    SetGlobalPoolAllocator(&allocator);
+}
+
+TShHandleBase::~TShHandleBase() {
+    SetGlobalPoolAllocator(NULL);
+    allocator.popAll();
+}
+
+TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
+    : shaderType(type),
+      shaderSpec(spec) 
+{
+}
+
+TCompiler::~TCompiler()
+{
+}
+
+bool TCompiler::Init(const ShBuiltInResources& resources)
+{
+    TScopedPoolAllocator scopedAlloc(&allocator, false);
+
+    // Generate built-in symbol table.
+    if (!InitBuiltInSymbolTable(resources))
+        return false;
+    InitExtensionBehavior(resources, extensionBehavior);
+
+    return true;
+}
+
+bool TCompiler::compile(const char* const shaderStrings[],
+                        const int numStrings,
+                        int compileOptions)
+{
+    TScopedPoolAllocator scopedAlloc(&allocator, true);
+    clearResults();
+
+    if (numStrings == 0)
+        return true;
+
+    // If compiling for WebGL, validate loop and indexing as well.
+    if (shaderSpec == SH_WEBGL_SPEC)
+        compileOptions |= SH_VALIDATE_LOOP_INDEXING;
+
+    TIntermediate intermediate(infoSink);
+    TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
+                               shaderType, shaderSpec, infoSink);
+    GlobalParseContext = &parseContext;
+
+    // We preserve symbols at the built-in level from compile-to-compile.
+    // Start pushing the user-defined symbols at global level.
+    symbolTable.push();
+    if (!symbolTable.atGlobalLevel())
+        infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
+
+    // Parse shader.
+    bool success =
+        (PaParseStrings(numStrings, shaderStrings, NULL, &parseContext) == 0) &&
+        (parseContext.treeRoot != NULL);
+    if (success) {
+        TIntermNode* root = parseContext.treeRoot;
+        success = intermediate.postProcess(root);
+
+        if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
+            success = validateLimitations(root);
+
+        if (success && (compileOptions & SH_INTERMEDIATE_TREE))
+            intermediate.outputTree(root);
+
+        if (success && (compileOptions & SH_OBJECT_CODE))
+            translate(root);
+
+        if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS))
+            collectAttribsUniforms(root);
+    }
+
+    // Cleanup memory.
+    intermediate.remove(parseContext.treeRoot);
+    // Ensure symbol table is returned to the built-in level,
+    // throwing away all but the built-ins.
+    while (!symbolTable.atBuiltInLevel())
+        symbolTable.pop();
+
+    return success;
+}
+
+bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources& resources)
+{
+    TBuiltIns builtIns;
+
+    builtIns.initialize(shaderType, shaderSpec, resources);
+    return InitializeSymbolTable(builtIns.getBuiltInStrings(),
+        shaderType, shaderSpec, resources, infoSink, symbolTable);
+}
+
+void TCompiler::clearResults()
+{
+    infoSink.info.erase();
+    infoSink.obj.erase();
+    infoSink.debug.erase();
+
+    attribs.clear();
+    uniforms.clear();
+}
+
+bool TCompiler::validateLimitations(TIntermNode* root) {
+    ValidateLimitations validate(shaderType, infoSink.info);
+    root->traverse(&validate);
+    return validate.numErrors() == 0;
+}
+
+void TCompiler::collectAttribsUniforms(TIntermNode* root)
+{
+    CollectAttribsUniforms collect(attribs, uniforms);
+    root->traverse(&collect);
+}
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h b/Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h
new file mode 100644 (file)
index 0000000..da96c24
--- /dev/null
@@ -0,0 +1,21 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef _EXTENSION_BEHAVIOR_INCLUDED_
+#define _EXTENSION_BEHAVIOR_INCLUDED_
+
+#include "compiler/Common.h"
+
+typedef enum {
+    EBhRequire,
+    EBhEnable,
+    EBhWarn,
+    EBhDisable
+} TBehavior;
+
+typedef TMap<TString, TBehavior> TExtensionBehavior;
+
+#endif // _EXTENSION_TABLE_INCLUDED_
index 317a88f0bc878b41925d47e06c95a202cf06e106..ba32f781f548747f7cd72dbb228632c37e8e2db7 100644 (file)
@@ -32,8 +32,8 @@ void TInfoSinkBase::prefix(TPrefixType message) {
 }
 
 void TInfoSinkBase::location(TSourceLoc loc) {
-    int string = loc >> SourceLocStringShift;
-    int line = loc & SourceLocLineMask;
+    int string = 0, line = 0;
+    DecodeSourceLoc(loc, &string, &line);
 
     TPersistStringStream stream;
     if (line)
index 476277866eec3d8a671682874fa0debff54e1d47..e2224e918d04d3189e81f4af808cf37968baa8d0 100644 (file)
@@ -91,6 +91,7 @@ public:
     }
 
     void erase() { sink.clear(); }
+    int size() { return static_cast<int>(sink.size()); }
 
     const TPersistString& str() const { return sink; }
     const char* c_str() const { return sink.c_str(); }
index 6bfcf4f8d0373d00b50e7670afcad8e75371eb4e..12b53fe64f58b61d7074890b187f2ee4c2c705b3 100644 (file)
@@ -310,15 +310,6 @@ static TString BuiltInFunctionsCommon()
     s.append(TString("bvec3 not(bvec3 x);"));
     s.append(TString("bvec4 not(bvec4 x);"));
 
-    //
-    // Texture Functions.
-    //
-    s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
-
-    s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
-
     //
     // Noise functions.
     //
@@ -342,7 +333,6 @@ static TString BuiltInFunctionsCommon()
     //s.append(TString("vec4 noise4(vec3  x);"));
     //s.append(TString("vec4 noise4(vec4  x);"));
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -351,7 +341,7 @@ static TString BuiltInFunctionsCommon()
 // Prototypes for built-in functions seen by vertex shaders only.
 //
 //============================================================================
-static TString BuiltInFunctionsVertex()
+static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources)
 {
     TString s;
 
@@ -363,12 +353,18 @@ static TString BuiltInFunctionsVertex()
     //
     // Texture Functions.
     //
-    s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
-    s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
-    s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
-    s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
+    if (resources.MaxVertexTextureImageUnits > 0) {
+        s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
+        s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
+        s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
+        s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
+
+        s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
+        s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
+        s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
+        s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
+    }
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -377,34 +373,40 @@ static TString BuiltInFunctionsVertex()
 // Prototypes for built-in functions seen by fragment shaders only.
 //
 //============================================================================
-static TString BuiltInFunctionsFragment()
+static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources)
 {
     TString s;
 
     //
     // Texture Functions.
     //
+    s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
+    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
+    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
+    s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
+
     s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
     s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
     s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
     s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
 
-    //s.append(TString("float dFdx(float p);"));
-    //s.append(TString("vec2  dFdx(vec2  p);"));
-    //s.append(TString("vec3  dFdx(vec3  p);"));
-    //s.append(TString("vec4  dFdx(vec4  p);"));
-
-    //s.append(TString("float dFdy(float p);"));
-    //s.append(TString("vec2  dFdy(vec2  p);"));
-    //s.append(TString("vec3  dFdy(vec3  p);"));
-    //s.append(TString("vec4  dFdy(vec4  p);"));
-
-    s.append(TString("float fwidth(float p);"));
-    s.append(TString("vec2  fwidth(vec2  p);"));
-    s.append(TString("vec3  fwidth(vec3  p);"));
-    s.append(TString("vec4  fwidth(vec4  p);"));
+    if (resources.OES_standard_derivatives) {
+        s.append(TString("float dFdx(float p);"));
+        s.append(TString("vec2  dFdx(vec2  p);"));
+        s.append(TString("vec3  dFdx(vec3  p);"));
+        s.append(TString("vec4  dFdx(vec4  p);"));
+
+        s.append(TString("float dFdy(float p);"));
+        s.append(TString("vec2  dFdy(vec2  p);"));
+        s.append(TString("vec3  dFdy(vec3  p);"));
+        s.append(TString("vec4  dFdy(vec4  p);"));
+
+        s.append(TString("float fwidth(float p);"));
+        s.append(TString("vec2  fwidth(vec2  p);"));
+        s.append(TString("vec3  fwidth(vec3  p);"));
+        s.append(TString("vec4  fwidth(vec4  p);"));
+    }
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -427,7 +429,6 @@ static TString StandardUniforms()
     s.append(TString("};"));
     s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -443,7 +444,6 @@ static TString DefaultPrecisionVertex()
     s.append(TString("precision highp int;"));
     s.append(TString("precision highp float;"));
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -459,7 +459,6 @@ static TString DefaultPrecisionFragment()
     s.append(TString("precision mediump int;"));
     // No default precision for float in fragment shaders
 
-    s.append(TString("\n"));
     return s;
 }
 
@@ -468,7 +467,7 @@ static TString DefaultPrecisionFragment()
 // Implementation dependent built-in constants.
 //
 //============================================================================
-static TString BuiltInConstants(const TBuiltInResource &resources)
+static TString BuiltInConstants(const ShBuiltInResources &resources)
 {
     TStringStream s;
 
@@ -485,20 +484,21 @@ static TString BuiltInConstants(const TBuiltInResource &resources)
     return s.str();
 }
 
-void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInResource& resources)
+void TBuiltIns::initialize(ShShaderType type, ShShaderSpec spec,
+                           const ShBuiltInResources& resources)
 {
-    switch (language) {
-    case EShLangFragment:
+    switch (type) {
+    case SH_FRAGMENT_SHADER:
         builtInStrings.push_back(DefaultPrecisionFragment());
         builtInStrings.push_back(BuiltInFunctionsCommon());
-        builtInStrings.push_back(BuiltInFunctionsFragment());
+        builtInStrings.push_back(BuiltInFunctionsFragment(resources));
         builtInStrings.push_back(StandardUniforms());
         break;
 
-    case EShLangVertex:
+    case SH_VERTEX_SHADER:
         builtInStrings.push_back(DefaultPrecisionVertex());
         builtInStrings.push_back(BuiltInFunctionsCommon());
-        builtInStrings.push_back(BuiltInFunctionsVertex());
+        builtInStrings.push_back(BuiltInFunctionsVertex(resources));
         builtInStrings.push_back(StandardUniforms());
         break;
 
@@ -508,14 +508,16 @@ void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInRes
     builtInStrings.push_back(BuiltInConstants(resources));
 }
 
-void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource& resources, TSymbolTable& symbolTable)
+void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
+                      const ShBuiltInResources& resources,
+                      TSymbolTable& symbolTable)
 {
     //
     // First, insert some special built-in variables that are not in 
     // the built-in header files.
     //
-    switch(language) {
-    case EShLangFragment:
+    switch(type) {
+    case SH_FRAGMENT_SHADER:
         symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"),                   TType(EbtFloat, EbpMedium, EvqFragCoord,   4)));
         symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"),                 TType(EbtBool,  EbpUndefined, EvqFrontFacing, 1)));
         symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"),                   TType(EbtFloat, EbpMedium, EvqFragColor,   4)));
@@ -523,7 +525,7 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource
         symbolTable.insert(*new TVariable(NewPoolTString("gl_PointCoord"),                  TType(EbtFloat, EbpMedium, EvqPointCoord,  2)));
         break;
 
-    case EShLangVertex:
+    case SH_VERTEX_SHADER:
         symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"),    TType(EbtFloat, EbpHigh, EvqPosition,    4)));
         symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"),   TType(EbtFloat, EbpMedium, EvqPointSize,   1)));
         break;
@@ -591,20 +593,26 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource
     symbolTable.relateToOperator("all",          EOpAll);
 
     // Map language-specific operators.
-    switch(language) {
-    case EShLangVertex:
+    switch(type) {
+    case SH_VERTEX_SHADER:
         break;
-    case EShLangFragment:
-        //symbolTable.relateToOperator("dFdx",   EOpDPdx);    // OES_standard_derivatives extension
-        //symbolTable.relateToOperator("dFdy",   EOpDPdy);    // OES_standard_derivatives extension
-        //symbolTable.relateToOperator("fwidth", EOpFwidth);  // OES_standard_derivatives extension
+    case SH_FRAGMENT_SHADER:
+        if (resources.OES_standard_derivatives) {
+            symbolTable.relateToOperator("dFdx",   EOpDFdx);
+            symbolTable.relateToOperator("dFdy",   EOpDFdy);
+            symbolTable.relateToOperator("fwidth", EOpFwidth);
+
+            symbolTable.relateToExtension("dFdx", "GL_OES_standard_derivatives");
+            symbolTable.relateToExtension("dFdy", "GL_OES_standard_derivatives");
+            symbolTable.relateToExtension("fwidth", "GL_OES_standard_derivatives");
+        }
         break;
     default: break;
     }
 
     // Finally add resource-specific variables.
-    switch(language) {
-    case EShLangFragment: {
+    switch(type) {
+    case SH_FRAGMENT_SHADER: {
             // Set up gl_FragData.  The array size.
             TType fragData(EbtFloat, EbpMedium, EvqFragColor,   4, false, true);
             fragData.setArraySize(resources.MaxDrawBuffers);
@@ -615,3 +623,9 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource
     }
 }
 
+void InitExtensionBehavior(const ShBuiltInResources& resources,
+                           TExtensionBehavior& extBehavior)
+{
+    if (resources.OES_standard_derivatives)
+        extBehavior["GL_OES_standard_derivatives"] = EBhDisable;
+}
index c07865982d40678ec3ffc25760698139466dd9b4..8b0adc6b4c23a046aa1d4015f2b01a5059f40379 100644 (file)
@@ -17,17 +17,19 @@ class TBuiltIns {
 public:
     POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
 
-    void initialize(EShLanguage language, EShSpec spec, const TBuiltInResource& resources);
+    void initialize(ShShaderType type, ShShaderSpec spec,
+                    const ShBuiltInResources& resources);
     const TBuiltInStrings& getBuiltInStrings() { return builtInStrings; }
 
 protected:
     TBuiltInStrings builtInStrings;
 };
 
-void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource& resources,
+void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
+                      const ShBuiltInResources& resources,
                       TSymbolTable& symbolTable);
 
-extern "C" int InitPreprocessor(void);
-extern "C" int FinalizePreprocessor(void);
+void InitExtensionBehavior(const ShBuiltInResources& resources,
+                           TExtensionBehavior& extensionBehavior);
 
 #endif // _INITIALIZE_INCLUDED_
index 34a6f3c3a493e6d5b32e249db7b6d9097b31aaa4..a13877f18fb36682c145797a062065bec4f6ce00 100644 (file)
@@ -229,9 +229,9 @@ void TIntermLoop::traverse(TIntermTraverser* it)
 
                if(it->rightToLeft)
                {
-                       if(terminal)
+                       if(expr)
                        {
-                               terminal->traverse(it);
+                               expr->traverse(it);
                        }
 
                        if(body)
@@ -239,16 +239,16 @@ void TIntermLoop::traverse(TIntermTraverser* it)
                                body->traverse(it);
                        }
 
-                       if(test)
+                       if(cond)
                        {
-                               test->traverse(it);
+                               cond->traverse(it);
                        }
                }
                else
                {
-                       if(test)
+                       if(cond)
                        {
-                               test->traverse(it);
+                               cond->traverse(it);
                        }
 
                        if(body)
@@ -256,9 +256,9 @@ void TIntermLoop::traverse(TIntermTraverser* it)
                                body->traverse(it);
                        }
 
-                       if(terminal)
+                       if(expr)
                        {
-                               terminal->traverse(it);
+                               expr->traverse(it);
                        }
                }
 
index 5ebd9192c2d27b0769e85d7dd0b3ab11a33d8f83..ea71234b3954af107c044eb913715a1c39aac34a 100644 (file)
@@ -22,6 +22,101 @@ static TPrecision GetHigherPrecision( TPrecision left, TPrecision right ){
     return left > right ? left : right;
 }
 
+const char* getOperatorString(TOperator op) {
+    switch (op) {
+      case EOpInitialize: return "=";
+      case EOpAssign: return "=";
+      case EOpAddAssign: return "+=";
+      case EOpSubAssign: return "-=";
+      case EOpDivAssign: return "/=";
+
+      // Fall-through.
+      case EOpMulAssign: 
+      case EOpVectorTimesMatrixAssign:
+      case EOpVectorTimesScalarAssign:
+      case EOpMatrixTimesScalarAssign:
+      case EOpMatrixTimesMatrixAssign: return "*=";
+
+      // Fall-through.
+      case EOpIndexDirect:
+      case EOpIndexIndirect: return "[]";
+
+      case EOpIndexDirectStruct: return ".";
+      case EOpVectorSwizzle: return ".";
+      case EOpAdd: return "+";
+      case EOpSub: return "-";
+      case EOpMul: return "*";
+      case EOpDiv: return "/";
+      case EOpMod: UNIMPLEMENTED(); break;
+      case EOpEqual: return "==";
+      case EOpNotEqual: return "!=";
+      case EOpLessThan: return "<";
+      case EOpGreaterThan: return ">";
+      case EOpLessThanEqual: return "<=";
+      case EOpGreaterThanEqual: return ">=";
+
+      // Fall-through.
+      case EOpVectorTimesScalar:
+      case EOpVectorTimesMatrix:
+      case EOpMatrixTimesVector:
+      case EOpMatrixTimesScalar:
+      case EOpMatrixTimesMatrix: return "*";
+
+      case EOpLogicalOr: return "||";
+      case EOpLogicalXor: return "^^";
+      case EOpLogicalAnd: return "&&";
+      case EOpNegative: return "-";
+      case EOpVectorLogicalNot: return "not";
+      case EOpLogicalNot: return "!";
+      case EOpPostIncrement: return "++";
+      case EOpPostDecrement: return "--";
+      case EOpPreIncrement: return "++";
+      case EOpPreDecrement: return "--";
+
+      // Fall-through.
+      case EOpConvIntToBool:
+      case EOpConvFloatToBool: return "bool";
+      // Fall-through.
+      case EOpConvBoolToFloat:
+      case EOpConvIntToFloat: return "float";
+      // Fall-through.
+      case EOpConvFloatToInt:
+      case EOpConvBoolToInt: return "int";
+
+      case EOpRadians: return "radians";
+      case EOpDegrees: return "degrees";
+      case EOpSin: return "sin";
+      case EOpCos: return "cos";
+      case EOpTan: return "tan";
+      case EOpAsin: return "asin";
+      case EOpAcos: return "acos";
+      case EOpAtan: return "atan";
+      case EOpExp: return "exp";
+      case EOpLog: return "log";
+      case EOpExp2: return "exp2";
+      case EOpLog2: return "log2";
+      case EOpSqrt: return "sqrt";
+      case EOpInverseSqrt: return "inversesqrt";
+      case EOpAbs: return "abs";
+      case EOpSign: return "sign";
+      case EOpFloor: return "floor";
+      case EOpCeil: return "ceil";
+      case EOpFract: return "fract";
+      case EOpLength: return "length";
+      case EOpNormalize: return "normalize";
+      case EOpDFdx: return "dFdx";
+      case EOpDFdy: return "dFdy";
+      case EOpFwidth: return "fwidth";
+      case EOpAny: return "any";
+      case EOpAll: return "all";
+
+      default: break;
+    }
+    return "";
+}
+
 ////////////////////////////////////////////////////////////////////////////
 //
 // First set of functions are to help build the intermediate representation.
@@ -51,18 +146,23 @@ TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType
 TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TSymbolTable& symbolTable)
 {
     switch (op) {
+        case EOpEqual:
+        case EOpNotEqual:
+            if (left->isArray())
+                return 0;
+            break;
         case EOpLessThan:
         case EOpGreaterThan:
         case EOpLessThanEqual:
         case EOpGreaterThanEqual:
-            if (left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector() || left->getType().getBasicType() == EbtStruct) {
+            if (left->isMatrix() || left->isArray() || left->isVector() || left->getBasicType() == EbtStruct) {
                 return 0;
             }
             break;
         case EOpLogicalOr:
         case EOpLogicalXor:
         case EOpLogicalAnd:
-            if (left->getType().getBasicType() != EbtBool || left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector()) {
+            if (left->getBasicType() != EbtBool || left->isMatrix() || left->isArray() || left->isVector()) {
                 return 0;
             }
             break;
@@ -70,7 +170,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
         case EOpSub:
         case EOpDiv:
         case EOpMul:
-            if (left->getType().getBasicType() == EbtStruct || left->getType().getBasicType() == EbtBool)
+            if (left->getBasicType() == EbtStruct || left->getBasicType() == EbtBool)
                 return 0;
         default: break;
     }
@@ -78,8 +178,10 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
     //
     // First try converting the children to compatible types.
     //
-
-    if (!(left->getType().getStruct() && right->getType().getStruct())) {
+    if (left->getType().getStruct() && right->getType().getStruct()) {
+        if (left->getType() != right->getType())
+            return 0;
+    } else {
         TIntermTyped* child = addConversion(op, left->getType(), right);
         if (child)
             right = child;
@@ -90,12 +192,8 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
             else
                 return 0;
         }
-    } else {
-        if (left->getType() != right->getType())
-            return 0;
     }
 
-
     //
     // Need a new node holding things together then.  Make
     // one and promote it to the right type.
@@ -107,18 +205,16 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
 
     node->setLeft(left);
     node->setRight(right);
-    if (! node->promote(infoSink))
+    if (!node->promote(infoSink))
         return 0;
 
-    TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
-    TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
-
     //
     // See if we can fold constants.
     //
-
     TIntermTyped* typedReturnNode = 0;
-    if ( leftTempConstant && rightTempConstant) {
+    TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
+    TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
+    if (leftTempConstant && rightTempConstant) {
         typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink);
 
         if (typedReturnNode)
@@ -602,9 +698,9 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc line)
 //
 // Create loop nodes.
 //
-TIntermNode* TIntermediate::addLoop(TIntermNode *init, TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line)
+TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line)
 {
-    TIntermNode* node = new TIntermLoop(init, body, test, terminal, testFirst);
+    TIntermNode* node = new TIntermLoop(type, init, cond, expr, body);
     node->setLine(line);
 
     return node;
@@ -630,7 +726,7 @@ TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expres
 // This is to be executed once the final root is put on top by the parsing
 // process.
 //
-bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
+bool TIntermediate::postProcess(TIntermNode* root)
 {
     if (root == 0)
         return true;
@@ -760,6 +856,12 @@ bool TIntermUnary::promote(TInfoSink&)
 //
 bool TIntermBinary::promote(TInfoSink& infoSink)
 {
+    // This function only handles scalars, vectors, and matrices.
+    if (left->isArray() || right->isArray()) {
+        infoSink.info.message(EPrefixInternalError, "Invalid operation for arrays", getLine());
+        return false;
+    }
+
     // GLSL ES 2.0 does not support implicit type casting.
     // So the basic type should always match.
     if (left->getBasicType() != right->getBasicType())
@@ -781,40 +883,6 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
         getTypePointer()->setQualifier(EvqTemporary);
     }
 
-    //
-    // Array operations.
-    //
-    if (left->isArray() || right->isArray()) {
-        //
-        // Arrays types have to be exact matches.
-        //
-        if (left->getType() != right->getType())
-            return false;
-
-        switch (op) {
-            //
-            // Promote to conditional
-            //
-            case EOpEqual:
-            case EOpNotEqual:
-                setType(TType(EbtBool, EbpUndefined));
-                break;
-
-            //
-            // Set array information.
-            //
-            case EOpAssign:
-            case EOpInitialize:
-                getTypePointer()->setArraySize(left->getType().getArraySize());
-                getTypePointer()->setArrayInformationType(left->getType().getArrayInformationType());
-                break;
-
-            default:
-                return false;
-        }
-        return true;
-    }
-
     int size = std::max(left->getNominalSize(), right->getNominalSize());
 
     //
index fd263b6f31c697d3819ab472371203984d4a9b05..23476f282d598b345bc72bc46387e7335051a0b0 100644 (file)
@@ -374,6 +374,10 @@ bool TOutputGLSL::visitUnary(Visit visit, TIntermUnary* node)
         case EOpLength: writeTriplet(visit, "length(", NULL, ")"); break;
         case EOpNormalize: writeTriplet(visit, "normalize(", NULL, ")"); break;
 
+        case EOpDFdx: writeTriplet(visit, "dFdx(", NULL, ")"); break;
+        case EOpDFdy: writeTriplet(visit, "dFdy(", NULL, ")"); break;
+        case EOpFwidth: writeTriplet(visit, "fwidth(", NULL, ")"); break;
+
         case EOpAny: writeTriplet(visit, "any(", NULL, ")"); break;
         case EOpAll: writeTriplet(visit, "all(", NULL, ")"); break;
 
@@ -608,23 +612,32 @@ bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node)
 
     incrementDepth();
     // Loop header.
-    if (node->testFirst())  // for loop
+    TLoopType loopType = node->getType();
+    if (loopType == ELoopFor)  // for loop
     {
         out << "for (";
         if (node->getInit())
             node->getInit()->traverse(this);
         out << "; ";
 
-        ASSERT(node->getTest() != NULL);
-        node->getTest()->traverse(this);
+        if (node->getCondition())
+            node->getCondition()->traverse(this);
         out << "; ";
 
-        if (node->getTerminal())
-            node->getTerminal()->traverse(this);
+        if (node->getExpression())
+            node->getExpression()->traverse(this);
+        out << ")\n";
+    }
+    else if (loopType == ELoopWhile)  // while loop
+    {
+        out << "while (";
+        ASSERT(node->getCondition() != NULL);
+        node->getCondition()->traverse(this);
         out << ")\n";
     }
     else  // do-while loop
     {
+        ASSERT(loopType == ELoopDoWhile);
         out << "do\n";
     }
 
@@ -632,11 +645,11 @@ bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node)
     visitCodeBlock(node->getBody());
 
     // Loop footer.
-    if (!node->testFirst())  // while loop
+    if (loopType == ELoopDoWhile)  // do-while loop
     {
         out << "while (";
-        ASSERT(node->getTest() != NULL);
-        node->getTest()->traverse(this);
+        ASSERT(node->getCondition() != NULL);
+        node->getCondition()->traverse(this);
         out << ");\n";
     }
     decrementDepth();
index 8b8a4e6c62e9290d868abb242743a33d92e1de97..57e99d2d8268133163a8606022101f4c69438ddb 100644 (file)
@@ -9,6 +9,7 @@
 #include "compiler/debug.h"
 #include "compiler/InfoSink.h"
 #include "compiler/UnfoldSelect.h"
+#include "compiler/SearchSymbol.h"
 
 #include <stdio.h>
 #include <algorithm>
@@ -64,7 +65,7 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr
 
     mScopeDepth = 0;
 
-    mArgumentIndex = 0;
+    mUniqueIndex = 0;
 }
 
 OutputHLSL::~OutputHLSL()
@@ -96,7 +97,7 @@ int OutputHLSL::vectorSize(const TType &type) const
 
 void OutputHLSL::header()
 {
-    EShLanguage language = mContext.language;
+    ShShaderType shaderType = mContext.shaderType;
     TInfoSinkBase &out = mHeader;
 
     for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++)
@@ -109,7 +110,7 @@ void OutputHLSL::header()
         out << *constructor;
     }
 
-    if (language == EShLangFragment)
+    if (shaderType == SH_FRAGMENT_SHADER)
     {
         TString uniforms;
         TString varyings;
@@ -361,7 +362,8 @@ void OutputHLSL::header()
                "    float diff;\n"
                "};\n"
                "\n"
-               "uniform gl_DepthRangeParameters gl_DepthRange;\n"
+               "uniform float3 dx_DepthRange;"
+               "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
                "\n";
     }
 
@@ -653,7 +655,39 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
     switch (node->getOp())
     {
       case EOpAssign:                  outputTriplet(visit, "(", " = ", ")");           break;
-      case EOpInitialize:              outputTriplet(visit, "", " = ", "");             break;
+      case EOpInitialize:
+        if (visit == PreVisit)
+        {
+            // GLSL allows to write things like "float x = x;" where a new variable x is defined
+            // and the value of an existing variable x is assigned. HLSL uses C semantics (the
+            // new variable is created before the assignment is evaluated), so we need to convert
+            // this to "float t = x, x = t;".
+
+            TIntermSymbol *symbolNode = node->getLeft()->getAsSymbolNode();
+            TIntermTyped *expression = node->getRight();
+
+            sh::SearchSymbol searchSymbol(symbolNode->getSymbol());
+            expression->traverse(&searchSymbol);
+            bool sameSymbol = searchSymbol.foundMatch();
+
+            if (sameSymbol)
+            {
+                // Type already printed
+                out << "t" + str(mUniqueIndex) + " = ";
+                expression->traverse(this);
+                out << ", ";
+                symbolNode->traverse(this);
+                out << " = t" + str(mUniqueIndex);
+
+                mUniqueIndex++;
+                return false;
+            }
+        }
+        else if (visit == InVisit)
+        {
+            out << " = ";
+        }
+        break;
       case EOpAddAssign:               outputTriplet(visit, "(", " += ", ")");          break;
       case EOpSubAssign:               outputTriplet(visit, "(", " -= ", ")");          break;
       case EOpMulAssign:               outputTriplet(visit, "(", " *= ", ")");          break;
@@ -933,9 +967,9 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
       case EOpFract:            outputTriplet(visit, "frac(", "", ")");      break;
       case EOpLength:           outputTriplet(visit, "length(", "", ")");    break;
       case EOpNormalize:        outputTriplet(visit, "normalize(", "", ")"); break;
-//    case EOpDPdx:             outputTriplet(visit, "ddx(", "", ")");       break;
-//    case EOpDPdy:             outputTriplet(visit, "ddy(", "", ")");       break;
-//    case EOpFwidth:           outputTriplet(visit, "fwidth(", "", ")");    break;        
+      case EOpDFdx:             outputTriplet(visit, "ddx(", "", ")");       break;
+      case EOpDFdy:             outputTriplet(visit, "ddy(", "", ")");       break;
+      case EOpFwidth:           outputTriplet(visit, "fwidth(", "", ")");    break;        
       case EOpAny:              outputTriplet(visit, "any(", "", ")");       break;
       case EOpAll:              outputTriplet(visit, "all(", "", ")");       break;
       default: UNREACHABLE();
@@ -946,7 +980,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
 
 bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
 {
-    EShLanguage language = mContext.language;
+    ShShaderType shaderType = mContext.shaderType;
     TInfoSinkBase &out = mBody;
 
     switch (node->getOp())
@@ -1392,7 +1426,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
 
     TInfoSinkBase &out = mBody;
 
-    if (!node->testFirst())
+    if (node->getType() == ELoopDoWhile)
     {
         out << "do\n"
                "{\n";
@@ -1404,14 +1438,14 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
             mUnfoldSelect->traverse(node->getInit());
         }
         
-        if (node->getTest())
+        if (node->getCondition())
         {
-            mUnfoldSelect->traverse(node->getTest());
+            mUnfoldSelect->traverse(node->getCondition());
         }
         
-        if (node->getTerminal())
+        if (node->getExpression())
         {
-            mUnfoldSelect->traverse(node->getTerminal());
+            mUnfoldSelect->traverse(node->getExpression());
         }
 
         out << "for(";
@@ -1423,16 +1457,16 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
 
         out << "; ";
 
-        if (node->getTest())
+        if (node->getCondition())
         {
-            node->getTest()->traverse(this);
+            node->getCondition()->traverse(this);
         }
 
         out << "; ";
 
-        if (node->getTerminal())
+        if (node->getExpression())
         {
-            node->getTerminal()->traverse(this);
+            node->getExpression()->traverse(this);
         }
 
         out << ")\n"
@@ -1446,11 +1480,11 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
 
     out << "}\n";
 
-    if (!node->testFirst())
+    if (node->getType() == ELoopDoWhile)
     {
         out << "while(\n";
 
-        node->getTest()->traverse(this);
+        node->getCondition()->traverse(this);
 
         out << ")";
     }
@@ -1565,9 +1599,9 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
     }
 
     // Parse comparator and limit value
-    if (index != NULL && node->getTest())
+    if (index != NULL && node->getCondition())
     {
-        TIntermBinary *test = node->getTest()->getAsBinaryNode();
+        TIntermBinary *test = node->getCondition()->getAsBinaryNode();
         
         if (test && test->getLeft()->getAsSymbolNode()->getId() == index->getId())
         {
@@ -1585,10 +1619,10 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
     }
 
     // Parse increment
-    if (index != NULL && comparator != EOpNull && node->getTerminal())
+    if (index != NULL && comparator != EOpNull && node->getExpression())
     {
-        TIntermBinary *binaryTerminal = node->getTerminal()->getAsBinaryNode();
-        TIntermUnary *unaryTerminal = node->getTerminal()->getAsUnaryNode();
+        TIntermBinary *binaryTerminal = node->getExpression()->getAsBinaryNode();
+        TIntermUnary *unaryTerminal = node->getExpression()->getAsUnaryNode();
         
         if (binaryTerminal)
         {
@@ -1711,7 +1745,7 @@ TString OutputHLSL::argumentString(const TIntermSymbol *symbol)
 
     if (name.empty())   // HLSL demands named arguments, also for prototypes
     {
-        name = "x" + str(mArgumentIndex++);
+        name = "x" + str(mUniqueIndex++);
     }
     else
     {
index dc3c482d4a0b820e82a0eeb882779c0c84fa071e..ddbd077be47e4d04941ed2ba87ffff30361b3883 100644 (file)
@@ -120,7 +120,7 @@ class OutputHLSL : public TIntermTraverser
     ScopeBracket mScopeBracket;
     unsigned int mScopeDepth;
 
-    int mArgumentIndex;   // For creating unique argument names
+    int mUniqueIndex;   // For creating unique names
 };
 }
 
index 407226bc2f034841dbd18beed0a3cc94de416bf0..53f3fa845b4398114cd3815e21e635e266f91135 100644 (file)
@@ -9,9 +9,35 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#include "compiler/glslang.h"
 #include "compiler/osinclude.h"
 #include "compiler/InitializeParseContext.h"
 
+extern "C" {
+extern int InitPreprocessor();
+extern int FinalizePreprocessor();
+extern void PredefineIntMacro(const char *name, int value);
+}
+
+static void ReportInfo(TInfoSinkBase& sink,
+                       TPrefixType type, TSourceLoc loc,
+                       const char* reason, const char* token, 
+                       const char* extraInfo)
+{
+    /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
+    sink.prefix(type);
+    sink.location(loc);
+    sink << "'" << token <<  "' : " << reason << " " << extraInfo << "\n";
+}
+
+static void DefineExtensionMacros(const TExtensionBehavior& extBehavior)
+{
+    for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
+         iter != extBehavior.end(); ++iter) {
+        PredefineIntMacro(iter->first.c_str(), 1);
+    }
+}
+
 ///////////////////////////////////////////////////////////////////////
 //
 // Sub- vector and matrix fields
@@ -176,24 +202,32 @@ void TParseContext::recover()
 //
 // Used by flex/bison to output all syntax and parsing errors.
 //
-void TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, 
-                          const char *szExtraInfoFormat, ...)
+void TParseContext::error(TSourceLoc loc,
+                          const char* reason, const char* token, 
+                          const char* extraInfoFormat, ...)
 {
-    char szExtraInfo[400];
+    char extraInfo[512];
     va_list marker;
+    va_start(marker, extraInfoFormat);
+    vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker);
 
-    va_start(marker, szExtraInfoFormat);
+    ReportInfo(infoSink.info, EPrefixError, loc, reason, token, extraInfo);
 
-    vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker);
+    va_end(marker);
+    ++numErrors;
+}
 
-    /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
-    infoSink.info.prefix(EPrefixError);
-    infoSink.info.location(nLine);
-    infoSink.info << "'" << szToken <<  "' : " << szReason << " " << szExtraInfo << "\n";
+void TParseContext::warning(TSourceLoc loc,
+                            const char* reason, const char* token,
+                            const char* extraInfoFormat, ...) {
+    char extraInfo[512];
+    va_list marker;
+    va_start(marker, extraInfoFormat);
+    vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker);
 
-    va_end(marker);
+    ReportInfo(infoSink.info, EPrefixWarning, loc, reason, token, extraInfo);
 
-    ++numErrors;
+    va_end(marker);
 }
 
 //
@@ -415,7 +449,7 @@ bool TParseContext::reservedErrorCheck(int line, const TString& identifier)
             error(line, reservedErrMsg, "gl_", "");
             return true;
         }
-        if (spec == EShSpecWebGL) {
+        if (shaderSpec == SH_WEBGL_SPEC) {
             if (identifier.substr(0, 6) == TString("webgl_")) {
                 error(line, reservedErrMsg, "webgl_", "");
                 return true;
@@ -471,17 +505,18 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
     bool matrixInMatrix = false;
     bool arrayArg = false;
     for (int i = 0; i < function.getParamCount(); ++i) {
-        size += function[i].type->getObjectSize();
+        const TParameter& param = function.getParam(i);
+        size += param.type->getObjectSize();
         
-        if (constructingMatrix && function[i].type->isMatrix())
+        if (constructingMatrix && param.type->isMatrix())
             matrixInMatrix = true;
         if (full)
             overFull = true;
         if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
             full = true;
-        if (function[i].type->getQualifier() != EvqConst)
+        if (param.type->getQualifier() != EvqConst)
             constType = false;
-        if (function[i].type->isArray())
+        if (param.type->isArray())
             arrayArg = true;
     }
     
@@ -510,7 +545,7 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
         return true;
     }
     
-    if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->size() != function.getParamCount()) {
+    if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->size()) != function.getParamCount()) {
         error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");
         return true;
     }
@@ -674,14 +709,11 @@ bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size)
 //
 bool TParseContext::arrayQualifierErrorCheck(int line, TPublicType type)
 {
-    if (type.qualifier == EvqAttribute) {
+    if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqConst)) {
         error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str(), "");
         return true;
     }
 
-    if (type.qualifier == EvqConst && extensionErrorCheck(line, "GL_3DL_array_objects"))
-        return true;
-
     return false;
 }
 
@@ -886,16 +918,22 @@ bool TParseContext::paramErrorCheck(int line, TQualifier qualifier, TQualifier p
     return false;
 }
 
-bool TParseContext::extensionErrorCheck(int line, const char* extension)
-{       
-    if (extensionBehavior[extension] == EBhWarn) {
-        infoSink.info.message(EPrefixWarning, ("extension " + TString(extension) + " is being used").c_str(), line);
-        return false;
+bool TParseContext::extensionErrorCheck(int line, const TString& extension)
+{
+    TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension);
+    if (iter == extensionBehavior.end()) {
+        error(line, "extension", extension.c_str(), "is not supported");
+        return true;
     }
-    if (extensionBehavior[extension] == EBhDisable) {
-        error(line, "extension", extension, "is disabled");
+    if (iter->second == EBhDisable) {
+        error(line, "extension", extension.c_str(), "is disabled");
         return true;
     }
+    if (iter->second == EBhWarn) {
+        TString msg = "extension " + extension + " is being used";
+        infoSink.info.message(EPrefixWarning, msg.c_str(), line);
+        return false;
+    }
 
     return false;
 }
@@ -1021,6 +1059,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu
 
 bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode)
 {
+    ASSERT(aggrNode != NULL);
     if (!aggrNode->isConstructor())
         return false;
 
@@ -1028,13 +1067,10 @@ bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode)
 
     // check if all the child nodes are constants so that they can be inserted into 
     // the parent node
-    if (aggrNode) {
-        TIntermSequence &childSequenceVector = aggrNode->getSequence() ;
-        for (TIntermSequence::iterator p = childSequenceVector.begin(); 
-                                    p != childSequenceVector.end(); p++) {
-            if (!(*p)->getAsTyped()->getAsConstantUnion())
-                return false;
-        }
+    TIntermSequence &sequence = aggrNode->getSequence() ;
+    for (TIntermSequence::iterator p = sequence.begin(); p != sequence.end(); ++p) {
+        if (!(*p)->getAsTyped()->getAsConstantUnion())
+            return false;
     }
 
     return allConstant;
@@ -1379,16 +1415,29 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
 }
 
 //
-// Initialize all supported extensions to disable
+// Parse an array of strings using yyparse.
 //
-void TParseContext::initializeExtensionBehavior()
-{
-    //
-    // example code: extensionBehavior["test"] = EBhDisable; // where "test" is the name of 
-    // supported extension
-    //
-    extensionBehavior["GL_ARB_texture_rectangle"] = EBhRequire;
-    extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
+// Returns 0 for success.
+//
+int PaParseStrings(int count, const char* const string[], const int length[],
+                   TParseContext* context) {
+    if ((count == 0) || (string == NULL))
+        return 1;
+
+    // setup preprocessor.
+    if (InitPreprocessor())
+        return 1;
+    DefineExtensionMacros(context->extensionBehavior);
+
+    if (glslang_initialize(context))
+        return 1;
+
+    glslang_scan(count, string, length, context);
+    int error = glslang_parse(context);
+
+    glslang_finalize(context);
+    FinalizePreprocessor();
+    return (error == 0) && (context->numErrors == 0) ? 0 : 1;
 }
 
 OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
index 792333fdf0748bed4a39f9d94288867bd8771299..cb6e0d0d4850c3dfff90bff8cdfba7c67724946a 100644 (file)
@@ -6,9 +6,10 @@
 #ifndef _PARSER_HELPER_INCLUDED_
 #define _PARSER_HELPER_INCLUDED_
 
+#include "compiler/ExtensionBehavior.h"
+#include "compiler/localintermediate.h"
 #include "compiler/ShHandle.h"
 #include "compiler/SymbolTable.h"
-#include "compiler/localintermediate.h"
 
 struct TMatrixFields {
     bool wholeRow;
@@ -17,13 +18,6 @@ struct TMatrixFields {
     int col;
 };
 
-typedef enum {
-    EBhRequire,
-    EBhEnable,
-    EBhWarn,
-    EBhDisable
-} TBehavior;
-
 struct TPragma {
     TPragma(bool o, bool d) : optimize(o), debug(d) { }
     bool optimize;
@@ -36,15 +30,16 @@ struct TPragma {
 // they can be passed to the parser without needing a global.
 //
 struct TParseContext {
-    TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage l, EShSpec s, TInfoSink& is) :
-            intermediate(interm), symbolTable(symt), infoSink(is), language(l), spec(s), treeRoot(0),
+    TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, TInfoSink& is) :
+            intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), treeRoot(0),
             recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
-            inTypeParen(false), contextPragma(true, false) {  }
+            inTypeParen(false), scanner(NULL), contextPragma(true, false) {  }
     TIntermediate& intermediate; // to hold and build a parse tree
     TSymbolTable& symbolTable;   // symbol table that goes with the language currently being parsed
+    TExtensionBehavior extensionBehavior;  // mapping between supported extensions and current behavior.
     TInfoSink& infoSink;
-    EShLanguage language;        // vertex or fragment language (future: pack or unpack)
-    EShSpec spec;                // The language specification compiler conforms to - GLES2 or WebGL.
+    ShShaderType shaderType;              // vertex or fragment language (future: pack or unpack)
+    ShShaderSpec shaderSpec;              // The language specification compiler conforms to - GLES2 or WebGL.
     TIntermNode* treeRoot;       // root of parse tree being created
     bool recoveredFromError;     // true if a parse error has occurred, but we continue to parse
     int numErrors;
@@ -53,11 +48,11 @@ struct TParseContext {
     bool inTypeParen;            // true if in parentheses, looking only for an identifier
     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
     bool functionReturnsValue;   // true if a non-void function has a return
-    TMap<TString, TBehavior> extensionBehavior;
-    void initializeExtensionBehavior();
 
-    void error(TSourceLoc, const char *szReason, const char *szToken,
-               const char *szExtraInfoFormat, ...);
+    void error(TSourceLoc loc, const char *reason, const char* token,
+               const char* extraInfoFormat, ...);
+    void warning(TSourceLoc loc, const char* reason, const char* token,
+                 const char* extraInfoFormat, ...);
     bool reservedErrorCheck(int line, const TString& identifier);
     void recover();
 
@@ -86,7 +81,7 @@ struct TParseContext {
     bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
     bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);
     bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
-    bool extensionErrorCheck(int line, const char*);
+    bool extensionErrorCheck(int line, const TString&);
     const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
     bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
                             TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
@@ -100,16 +95,14 @@ struct TParseContext {
     TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
     TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
     bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
+    void* scanner;
     struct TPragma contextPragma;
     TString HashErrMsg;
     bool AfterEOF;
 };
 
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
-void PaReservedWord();
-int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
-int PaParseComment(int &lineno, TParseContext&);
-void setInitialState();
+int PaParseStrings(int count, const char* const string[], const int length[],
+                   TParseContext* context);
 
 typedef TParseContext* TParseContextPointer;
 extern TParseContextPointer& GetGlobalParseContext();
index 7e348ca97039ca47766aff2050d44e4cd16fba7c..93e21e40185f4e10ee3c7f4001edceee4ace842e 100644 (file)
@@ -22,14 +22,10 @@ void InitializeGlobalPools()
     if (globalPools)
         return;
 
-    TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true);
-
     TThreadGlobalPools* threadData = new TThreadGlobalPools();
-    
-    threadData->globalPoolAllocator = globalPoolAllocator;
-        
-    OS_SetTLSValue(PoolIndex, threadData);     
-    globalPoolAllocator->push();
+    threadData->globalPoolAllocator = 0;
+
+    OS_SetTLSValue(PoolIndex, threadData);
 }
 
 void FreeGlobalPools()
@@ -38,9 +34,7 @@ void FreeGlobalPools()
     TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));    
     if (!globalPools)
         return;
-    
-    GlobalPoolAllocator.popAll();
-    delete &GlobalPoolAllocator;       
     delete globalPools;
 }
 
@@ -66,7 +60,7 @@ TPoolAllocator& GetGlobalPoolAllocator()
     return *threadData->globalPoolAllocator;
 }
 
-void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
+void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator)
 {
     TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
 
@@ -77,13 +71,13 @@ void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
 // Implement the functionality of the TPoolAllocator class, which
 // is documented in PoolAlloc.h.
 //
-TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) : 
-    global(g),
+TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) : 
     pageSize(growthIncrement),
     alignment(allocationAlignment),
     freeList(0),
     inUseList(0),
-    numCalls(0)
+    numCalls(0),
+    totalBytes(0)
 {
     //
     // Don't allow page sizes we know are smaller than all common
@@ -123,24 +117,14 @@ TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignm
 
 TPoolAllocator::~TPoolAllocator()
 {
-    if (!global) {
-        //
-        // Then we know that this object is not being 
-        // allocated after other, globally scoped objects
-        // that depend on it.  So we can delete the "in use" memory.
-        //
-        while (inUseList) {
-            tHeader* next = inUseList->nextPage;
-            inUseList->~tHeader();
-            delete [] reinterpret_cast<char*>(inUseList);
-            inUseList = next;
-        }
+    while (inUseList) {
+        tHeader* next = inUseList->nextPage;
+        inUseList->~tHeader();
+        delete [] reinterpret_cast<char*>(inUseList);
+        inUseList = next;
     }
 
-    //
-    // Always delete the free list memory - it can't be being
-    // (correctly) referenced, whether the pool allocator was
-    // global or not.  We should not check the guard blocks
+    // We should not check the guard blocks
     // here, because we did it already when the block was
     // placed into the free list.
     //
@@ -315,4 +299,4 @@ void TAllocation::checkAllocList() const
 {
     for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
         alloc->check();
-}
+}
\ No newline at end of file
index 645db78d775a3aa35a8c2bdc7c9cbc604e51957a..051dc00e0a7e6456fb5ca396e4c9024ccebbc57d 100644 (file)
@@ -115,7 +115,7 @@ private:
 //
 class TPoolAllocator {
 public:
-    TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);
+    TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16);
 
     //
     // Don't call the destructor just to free up the memory, call pop()
@@ -194,7 +194,6 @@ protected:
         return TAllocation::offsetAllocation(memory);
     }
 
-    bool global;            // should be true if this object is globally scoped
     size_t pageSize;        // granularity of allocation from the OS
     size_t alignment;       // all returned allocations will be aligned at 
                             // this granularity, which will be a power of 2
@@ -220,18 +219,15 @@ private:
 // different times.  But a simple use is to have a global pop
 // with everyone using the same global allocator.
 //
-typedef TPoolAllocator* PoolAllocatorPointer;
 extern TPoolAllocator& GetGlobalPoolAllocator();
+extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator);
 #define GlobalPoolAllocator GetGlobalPoolAllocator()
 
-
 struct TThreadGlobalPools
 {
     TPoolAllocator* globalPoolAllocator;
 };
 
-void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
-
 //
 // This STL compatible allocator is intended to be used as the allocator
 // parameter to templatized STL containers, like vector and map.
@@ -301,4 +297,4 @@ protected:
     TPoolAllocator& allocator;
 };
 
-#endif // _POOLALLOC_INCLUDED_
+#endif // _POOLALLOC_INCLUDED_
\ No newline at end of file
diff --git a/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp
new file mode 100644 (file)
index 0000000..9368f1a
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// SearchSymbol is an AST traverser to detect the use of a given symbol name
+//
+
+#include "compiler/SearchSymbol.h"
+
+#include "compiler/InfoSink.h"
+#include "compiler/OutputHLSL.h"
+
+namespace sh
+{
+SearchSymbol::SearchSymbol(const TString &symbol) : mSymbol(symbol)
+{
+    match = false;
+}
+
+void SearchSymbol::traverse(TIntermNode *node)
+{
+    node->traverse(this);
+}
+
+void SearchSymbol::visitSymbol(TIntermSymbol *symbolNode)
+{
+    if (symbolNode->getSymbol() == mSymbol)
+    {
+        match = true;
+    }
+}
+
+bool SearchSymbol::foundMatch() const
+{
+    return match;
+}
+}
diff --git a/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h
new file mode 100644 (file)
index 0000000..6bc0b90
--- /dev/null
@@ -0,0 +1,33 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// SearchSymbol is an AST traverser to detect the use of a given symbol name
+//
+
+#ifndef COMPILER_SEARCHSYMBOL_H_
+#define COMPILER_SEARCHSYMBOL_H_
+
+#include "compiler/intermediate.h"
+#include "compiler/ParseHelper.h"
+
+namespace sh
+{
+class SearchSymbol : public TIntermTraverser
+{
+  public:
+    SearchSymbol(const TString &symbol);
+
+    void traverse(TIntermNode *node);
+    void visitSymbol(TIntermSymbol *symbolNode);
+
+    bool foundMatch() const;
+
+  protected:
+    const TString &mSymbol;
+    bool match;
+};
+}
+
+#endif   // COMPILER_SEARCHSYMBOL_H_
index 5ef5d30cf8b40f13f81aeb86f14b87f593e2e7d4..e65c1eef64775bf2aa90354fc80b36bd9f6cbcae 100644 (file)
 
 #include "GLSLANG/ShaderLang.h"
 
+#include "compiler/ExtensionBehavior.h"
 #include "compiler/InfoSink.h"
 #include "compiler/SymbolTable.h"
+#include "compiler/VariableInfo.h"
 
 class TCompiler;
-class TIntermNode;
 
 //
 // The base class used to back handles returned to the driver.
 //
 class TShHandleBase {
 public:
-    TShHandleBase() { }
-    virtual ~TShHandleBase() { }
+    TShHandleBase();
+    virtual ~TShHandleBase();
     virtual TCompiler* getAsCompiler() { return 0; }
+
+protected:
+    // Memory allocator. Allocates and tracks memory required by the compiler.
+    // Deallocates all memory when compiler is destructed.
+    TPoolAllocator allocator;
 };
 
 //
@@ -38,27 +44,49 @@ public:
 //
 class TCompiler : public TShHandleBase {
 public:
-    TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { }
-    virtual ~TCompiler() { }
-
-    EShLanguage getLanguage() const { return language; }
-    EShSpec getSpec() const { return spec; }
-    TSymbolTable& getSymbolTable() { return symbolTable; }
-    TInfoSink& getInfoSink() { return infoSink; }
+    TCompiler(ShShaderType type, ShShaderSpec spec);
+    virtual ~TCompiler();
+    virtual TCompiler* getAsCompiler() { return this; }
 
-    virtual bool compile(TIntermNode* root) = 0;
+    bool Init(const ShBuiltInResources& resources);
+    bool compile(const char* const shaderStrings[],
+                 const int numStrings,
+                 int compileOptions);
 
-    virtual TCompiler* getAsCompiler() { return this; }
+    // Get results of the last compilation.
+    TInfoSink& getInfoSink() { return infoSink; }
+    const TVariableInfoList& getAttribs() const { return attribs; }
+    const TVariableInfoList& getUniforms() const { return uniforms; }
 
 protected:
-    EShLanguage language;
-    EShSpec spec;
+    ShShaderType getShaderType() const { return shaderType; }
+    ShShaderSpec getShaderSpec() const { return shaderSpec; }
+    // Initialize symbol-table with built-in symbols.
+    bool InitBuiltInSymbolTable(const ShBuiltInResources& resources);
+    // Clears the results from the previous compilation.
+    void clearResults();
+    // Returns true if the given shader does not exceed the minimum
+    // functionality mandated in GLSL 1.0 spec Appendix A.
+    bool validateLimitations(TIntermNode* root);
+    // Collect info for all attribs and uniforms.
+    void collectAttribsUniforms(TIntermNode* root);
+    // Translate to object code.
+    virtual void translate(TIntermNode* root) = 0;
+
+private:
+    ShShaderType shaderType;
+    ShShaderSpec shaderSpec;
 
     // Built-in symbol table for the given language, spec, and resources.
     // It is preserved from compile-to-compile.
     TSymbolTable symbolTable;
-    // Output sink.
-    TInfoSink infoSink;
+    // Built-in extensions with default behavior.
+    TExtensionBehavior extensionBehavior;
+
+    // Results of compilation.
+    TInfoSink infoSink;  // Output sink.
+    TVariableInfoList attribs;  // Active attributes in the compiled shader.
+    TVariableInfoList uniforms;  // Active uniforms in the compiled shader.
 };
 
 //
@@ -70,7 +98,7 @@ protected:
 // destroy the machine dependent objects, which contain the
 // above machine independent information.
 //
-TCompiler* ConstructCompiler(EShLanguage, EShSpec);
+TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec);
 void DeleteCompiler(TCompiler*);
 
-#endif // _SHHANDLE_INCLUDED_
+#endif // _SHHANDLE_INCLUDED_
\ No newline at end of file
index e0c646ae46e76f6213590dfede1cd157a3c0578b..6cac61df6bd030fee4fd6f61dddb5f92cbe0e711 100644 (file)
 
 #include "GLSLANG/ShaderLang.h"
 
-#include "compiler/Initialize.h"
 #include "compiler/InitializeDll.h"
-#include "compiler/ParseHelper.h"
 #include "compiler/ShHandle.h"
-#include "compiler/SymbolTable.h"
 
-static bool InitializeSymbolTable(
-        const TBuiltInStrings& builtInStrings,
-        EShLanguage language, EShSpec spec, const TBuiltInResource& resources,
-        TInfoSink& infoSink, TSymbolTable& symbolTable)
-{
-    TIntermediate intermediate(infoSink);
-    TParseContext parseContext(symbolTable, intermediate, language, spec, infoSink);
-
-    GlobalParseContext = &parseContext;
-
-    setInitialState();
-
-    assert(symbolTable.isEmpty());       
-    //
-    // Parse the built-ins.  This should only happen once per
-    // language symbol table.
-    //
-    // Push the symbol table to give it an initial scope.  This
-    // push should not have a corresponding pop, so that built-ins
-    // are preserved, and the test for an empty table fails.
-    //
-    symbolTable.push();
-    
-    //Initialize the Preprocessor
-    if (InitPreprocessor())
-    {
-        infoSink.info.message(EPrefixInternalError,  "Unable to intialize the Preprocessor");
-        return false;
-    }
+//
+// This is the platform independent interface between an OGL driver
+// and the shading language compiler.
+//
 
-    for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i)
+static int getVariableMaxLength(const TVariableInfoList& varList)
+{
+    TString::size_type maxLen = 0;
+    for (TVariableInfoList::const_iterator i = varList.begin();
+         i != varList.end(); ++i)
     {
-        const char* builtInShaders[1];
-        int builtInLengths[1];
-
-        builtInShaders[0] = (*i).c_str();
-        builtInLengths[0] = (int) (*i).size();
-
-        if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0)
-        {
-            infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
-            return false;
-        }
+        maxLen = std::max(maxLen, i->name.size());
     }
-
-    IdentifyBuiltIns(language, spec, resources, symbolTable);
-
-    FinalizePreprocessor();
-
-    return true;
+    // Add 1 to include null-termination character.
+    return static_cast<int>(maxLen) + 1;
 }
 
-static bool GenerateBuiltInSymbolTable(
-        EShLanguage language, EShSpec spec, const TBuiltInResource& resources,
-        TInfoSink& infoSink, TSymbolTable& symbolTable)
+static void getVariableInfo(ShShaderInfo varType,
+                            const ShHandle handle,
+                            int index,
+                            int* length,
+                            int* size,
+                            ShDataType* type,
+                            char* name)
 {
-    TBuiltIns builtIns;
+    if (!handle || !size || !type || !name)
+        return;
+    ASSERT((varType == SH_ACTIVE_ATTRIBUTES) ||
+           (varType == SH_ACTIVE_UNIFORMS));
 
-    builtIns.initialize(language, spec, resources);
-    return InitializeSymbolTable(builtIns.getBuiltInStrings(), language, spec, resources, infoSink, symbolTable);
-}
+    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+    TCompiler* compiler = base->getAsCompiler();
+    if (compiler == 0)
+        return;
 
-//
-// This is the platform independent interface between an OGL driver
-// and the shading language compiler.
-//
+    const TVariableInfoList& varList = varType == SH_ACTIVE_ATTRIBUTES ?
+        compiler->getAttribs() : compiler->getUniforms();
+    if (index < 0 || index >= static_cast<int>(varList.size()))
+        return;
+
+    const TVariableInfo& varInfo = varList[index];
+    if (length) *length = varInfo.name.size();
+    *size = varInfo.size;
+    *type = varInfo.type;
+    strcpy(name, varInfo.name.c_str());
+}
 
 //
 // Driver must call this first, once, before doing any other
@@ -110,7 +87,7 @@ int ShFinalize()
 //
 // Initialize built-in resources with minimum expected values.
 //
-void ShInitBuiltInResource(TBuiltInResource* resources)
+void ShInitBuiltInResources(ShBuiltInResources* resources)
 {
     // Constants.
     resources->MaxVertexAttribs = 8;
@@ -129,18 +106,19 @@ void ShInitBuiltInResource(TBuiltInResource* resources)
 //
 // Driver calls these to create and destroy compiler objects.
 //
-ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources)
+ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
+                             const ShBuiltInResources* resources)
 {
     if (!InitThread())
         return 0;
 
-    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, spec));
+    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec));
     TCompiler* compiler = base->getAsCompiler();
     if (compiler == 0)
         return 0;
 
     // Generate built-in symbol table.
-    if (!GenerateBuiltInSymbolTable(language, spec, *resources, compiler->getInfoSink(), compiler->getSymbolTable())) {
+    if (!compiler->Init(*resources)) {
         ShDestruct(base);
         return 0;
     }
@@ -170,9 +148,7 @@ int ShCompile(
     const ShHandle handle,
     const char* const shaderStrings[],
     const int numStrings,
-    const EShOptimizationLevel optLevel,
-    int debugOptions
-    )
+    int compileOptions)
 {
     if (!InitThread())
         return 0;
@@ -184,128 +160,95 @@ int ShCompile(
     TCompiler* compiler = base->getAsCompiler();
     if (compiler == 0)
         return 0;
-    
-    GlobalPoolAllocator.push();
-    TInfoSink& infoSink = compiler->getInfoSink();
-    infoSink.info.erase();
-    infoSink.debug.erase();
-    infoSink.obj.erase();
-
-    if (numStrings == 0)
-        return 1;
-
-    TIntermediate intermediate(infoSink);
-    TSymbolTable& symbolTable = compiler->getSymbolTable();
-
-    TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->getSpec(), infoSink);
-    parseContext.initializeExtensionBehavior();
-    GlobalParseContext = &parseContext;
-    setInitialState();
-
-    InitPreprocessor();
-    //
-    // Parse the application's shaders.  All the following symbol table
-    // work will be throw-away, so push a new allocation scope that can
-    // be thrown away, then push a scope for the current shader's globals.
-    //
-    bool success = true;
-
-    symbolTable.push();
-    if (!symbolTable.atGlobalLevel())
-        parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
-
-    int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext);
-    if (ret)
-        success = false;
-
-    if (success && parseContext.treeRoot) {
-        if (optLevel == EShOptNoGeneration)
-            parseContext.infoSink.info.message(EPrefixNone, "No errors.  No code generation was requested.");
-        else {
-            success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
-
-            if (success) {
-
-                if (debugOptions & EDebugOpIntermediate)
-                    intermediate.outputTree(parseContext.treeRoot);
-
-                //
-                // Call the machine dependent compiler
-                //
-                if (!compiler->compile(parseContext.treeRoot))
-                    success = false;
-            }
-        }
-    } else if (!success) {
-        parseContext.infoSink.info.prefix(EPrefixError);
-        parseContext.infoSink.info << parseContext.numErrors << " compilation errors.  No code generated.\n\n";
-        success = false;
-        if (debugOptions & EDebugOpIntermediate)
-            intermediate.outputTree(parseContext.treeRoot);
-    } else if (!parseContext.treeRoot) {
-        parseContext.error(1, "Unexpected end of file.", "", "");
-        parseContext.infoSink.info << parseContext.numErrors << " compilation errors.  No code generated.\n\n";
-        success = false;
-        if (debugOptions & EDebugOpIntermediate)
-            intermediate.outputTree(parseContext.treeRoot);
-    }
 
-    intermediate.remove(parseContext.treeRoot);
+    bool success = compiler->compile(shaderStrings, numStrings, compileOptions);
+    return success ? 1 : 0;
+}
 
-    //
-    // Ensure symbol table is returned to the built-in level,
-    // throwing away all but the built-ins.
-    //
-    while (!symbolTable.atBuiltInLevel())
-        symbolTable.pop();
+void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params)
+{
+    if (!handle || !params)
+        return;
 
-    FinalizePreprocessor();
-    //
-    // Throw away all the temporary memory used by the compilation process.
-    //
-    GlobalPoolAllocator.pop();
+    TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+    TCompiler* compiler = base->getAsCompiler();
+    if (!compiler) return;
 
-    return success ? 1 : 0;
+    switch(pname)
+    {
+    case SH_INFO_LOG_LENGTH:
+        *params = compiler->getInfoSink().info.size() + 1;
+        break;
+    case SH_OBJECT_CODE_LENGTH:
+        *params = compiler->getInfoSink().obj.size() + 1;
+        break;
+    case SH_ACTIVE_UNIFORMS:
+        *params = compiler->getUniforms().size();
+        break;
+    case SH_ACTIVE_UNIFORM_MAX_LENGTH:
+        *params = getVariableMaxLength(compiler->getUniforms());
+        break;
+    case SH_ACTIVE_ATTRIBUTES:
+        *params = compiler->getAttribs().size();
+        break;
+    case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
+        *params = getVariableMaxLength(compiler->getAttribs());
+        break;
+
+    default: UNREACHABLE();
+    }
 }
 
 //
 // Return any compiler log of messages for the application.
 //
-const char* ShGetInfoLog(const ShHandle handle)
+void ShGetInfoLog(const ShHandle handle, char* infoLog)
 {
-    if (!InitThread())
-        return 0;
-
-    if (handle == 0)
-        return 0;
+    if (!handle || !infoLog)
+        return;
 
     TShHandleBase* base = static_cast<TShHandleBase*>(handle);
-    TInfoSink* infoSink = 0;
-
-    if (base->getAsCompiler())
-        infoSink = &(base->getAsCompiler()->getInfoSink());
+    TCompiler* compiler = base->getAsCompiler();
+    if (!compiler) return;
 
-    infoSink->info << infoSink->debug.c_str();
-    return infoSink->info.c_str();
+    TInfoSink& infoSink = compiler->getInfoSink();
+    strcpy(infoLog, infoSink.info.c_str());
 }
 
 //
 // Return any object code.
 //
-const char* ShGetObjectCode(const ShHandle handle)
+void ShGetObjectCode(const ShHandle handle, char* objCode)
 {
-    if (!InitThread())
-        return 0;
-
-    if (handle == 0)
-        return 0;
+    if (!handle || !objCode)
+        return;
 
     TShHandleBase* base = static_cast<TShHandleBase*>(handle);
-    TInfoSink* infoSink;
+    TCompiler* compiler = base->getAsCompiler();
+    if (!compiler) return;
 
-    if (base->getAsCompiler())
-        infoSink = &(base->getAsCompiler()->getInfoSink());
+    TInfoSink& infoSink = compiler->getInfoSink();
+    strcpy(objCode, infoSink.obj.c_str());
+}
 
-    return infoSink->obj.c_str();
+void ShGetActiveAttrib(const ShHandle handle,
+                       int index,
+                       int* length,
+                       int* size,
+                       ShDataType* type,
+                       char* name)
+{
+    getVariableInfo(SH_ACTIVE_ATTRIBUTES,
+                    handle, index, length, size, type, name);
+}
+
+void ShGetActiveUniform(const ShHandle handle,
+                        int index,
+                        int* length,
+                        int* size,
+                        ShDataType* type,
+                        char* name)
+{
+    getVariableInfo(SH_ACTIVE_UNIFORMS,
+                    handle, index, length, size, type, name);
 }
index 1b08667fc1d5eb8409bb5102e48571749028b260..02817d44716079e29c241ad08c8446ec6811895b 100644 (file)
@@ -140,6 +140,22 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
     }
 }
 
+//
+// Change all function entries in the table with the non-mangled name
+// to be related to the provided built-in extension. This is a low
+// performance operation, and only intended for symbol tables that
+// live across a large number of compiles.
+//
+void TSymbolTableLevel::relateToExtension(const char* name, const TString& ext)
+{
+    for (tLevel::iterator it = level.begin(); it != level.end(); ++it) {
+        if (it->second->isFunction()) {
+            TFunction* function = static_cast<TFunction*>(it->second);
+            if (function->getName() == name)
+                function->relateToExtension(ext);
+        }
+    }
+}
 
 TSymbol::TSymbol(const TSymbol& copyOf)
 {
index b1a80b5b31f0e303d402076357f516b6b4f7246d..38bc6575936166a64813a46f990961a30cbe8d90 100644 (file)
@@ -94,7 +94,10 @@ public:
 
     void shareConstPointer( ConstantUnion *constArray)
     {
-        delete unionArray;
+        if (unionArray == constArray)
+            return;
+
+        delete[] unionArray;
         unionArray = constArray;  
     }
     TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
@@ -156,14 +159,18 @@ public:
 
     const TString& getMangledName() const { return mangledName; }
     const TType& getReturnType() const { return returnType; }
+
     void relateToOperator(TOperator o) { op = o; }
     TOperator getBuiltInOp() const { return op; }
+
+    void relateToExtension(const TString& ext) { extension = ext; }
+    const TString& getExtension() const { return extension; }
+
     void setDefined() { defined = true; }
     bool isDefined() { return defined; }
 
-    int getParamCount() const { return static_cast<int>(parameters.size()); }    
-    TParameter& operator [](int i)       { return parameters[i]; }
-    const TParameter& operator [](int i) const { return parameters[i]; }
+    int getParamCount() const { return static_cast<int>(parameters.size()); }  
+    const TParameter& getParam(int i) const { return parameters[i]; }
 
     virtual void dump(TInfoSink &infoSink) const;
     TFunction(const TFunction&, TStructureMap& remapper);
@@ -175,6 +182,7 @@ protected:
     TType returnType;
     TString mangledName;
     TOperator op;
+    TString extension;
     bool defined;
 };
 
@@ -221,6 +229,7 @@ public:
     }
 
     void relateToOperator(const char* name, TOperator op);
+    void relateToExtension(const char* name, const TString& ext);
     void dump(TInfoSink &infoSink) const;
     TSymbolTableLevel* clone(TStructureMap& remapper);
 
@@ -289,8 +298,16 @@ public:
         return symbol;
     }
 
-    TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 2); return table[1]; }
-    void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
+    TSymbolTableLevel* getGlobalLevel() {
+        assert(table.size() >= 2);
+        return table[1];
+    }
+    void relateToOperator(const char* name, TOperator op) {
+        table[0]->relateToOperator(name, op);
+    }
+    void relateToExtension(const char* name, const TString& ext) {
+        table[0]->relateToExtension(name, ext);
+    }
     int getMaxSymbolId() { return uniqueId; }
     void dump(TInfoSink &infoSink) const;
     void copyTable(const TSymbolTable& copyOf);
index 7b8d9036d89b080405c267c0ab82adfd8f1e5f8b..7a63ae1f057bbb57ca134d7fdacec40bff5f6463 100644 (file)
@@ -7,14 +7,31 @@
 #include "compiler/TranslatorGLSL.h"
 
 #include "compiler/OutputGLSL.h"
+#include "compiler/VersionGLSL.h"
 
-TranslatorGLSL::TranslatorGLSL(EShLanguage lang, EShSpec spec)
-    : TCompiler(lang, spec) {
+static void writeVersion(ShShaderType type, TIntermNode* root,
+                         TInfoSinkBase& sink) {
+    TVersionGLSL versionGLSL(type);
+    root->traverse(&versionGLSL);
+    int version = versionGLSL.getVersion();
+    // We need to write version directive only if it is greater than 110.
+    // If there is no version directive in the shader, 110 is implied.
+    if (version > 110) {
+        sink << "#version " << version << "\n";
+    }
 }
 
-bool TranslatorGLSL::compile(TIntermNode* root) {
-    TOutputGLSL outputGLSL(infoSink.obj);
-    root->traverse(&outputGLSL);
+TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
+    : TCompiler(type, spec) {
+}
+
+void TranslatorGLSL::translate(TIntermNode* root) {
+    TInfoSinkBase& sink = getInfoSink().obj;
 
-    return true;
+    // Write GLSL version.
+    writeVersion(getShaderType(), root, sink);
+
+    // Write translated shader.
+    TOutputGLSL outputGLSL(sink);
+    root->traverse(&outputGLSL);
 }
index 973e39a459fe5a8662155715f353628a9342acd6..c2ce06d192f0fc61dabd536d2049ffb9edef3a63 100644 (file)
 
 class TranslatorGLSL : public TCompiler {
 public:
-    TranslatorGLSL(EShLanguage lang, EShSpec spec);
-    virtual bool compile(TIntermNode* root);
+    TranslatorGLSL(ShShaderType type, ShShaderSpec spec);
+
+protected:
+    virtual void translate(TIntermNode* root);
 };
 
 #endif  // COMPILER_TRANSLATORGLSL_H_
index 3a1e52d4b01994a9a4ebc843dc165d6264a89b00..96d7f1077f7a9cad38a44ecc8c30b52094b03633 100644 (file)
@@ -8,17 +8,15 @@
 
 #include "compiler/OutputHLSL.h"
 
-TranslatorHLSL::TranslatorHLSL(EShLanguage lang, EShSpec spec)
-    : TCompiler(lang, spec)
+TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec)
+    : TCompiler(type, spec)
 {
 }
 
-bool TranslatorHLSL::compile(TIntermNode *root)
+void TranslatorHLSL::translate(TIntermNode *root)
 {
     TParseContext& parseContext = *GetGlobalParseContext();
     sh::OutputHLSL outputHLSL(parseContext);
 
     outputHLSL.output();
-    
-    return true;
 }
index 38a5f0cedab61043b43ca5fd8df5a89b58b32bc7..c3f672ba9198a3ee269462ba28bc170754b30a1f 100644 (file)
 
 class TranslatorHLSL : public TCompiler {
 public:
-    TranslatorHLSL(EShLanguage lang, EShSpec spec);
-    virtual bool compile(TIntermNode* root);
+    TranslatorHLSL(ShShaderType type, ShShaderSpec spec);
+
+protected:
+    virtual void translate(TIntermNode* root);
 };
 
 #endif  // COMPILER_TRANSLATORHLSL_H_
index 897b28ffe8c46136b9fbbd586d9bf70977f4a1fe..d0fcc08b9bcd51333e21f6bed00b48c67a3c79b8 100644 (file)
@@ -85,12 +85,12 @@ public:
     TType() {}
     TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
             type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
-            structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
+            maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
     {
     }
     explicit TType(const TPublicType &p) :
             type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
-            structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
+            maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
     {
         if (p.userDef) {
             structure = p.userDef->getStruct();
@@ -99,7 +99,7 @@ public:
     }
     TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
             type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
-            structure(userDef), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0)
+            maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), fieldName(0), mangled(0)
     {
         typeName = NewPoolTString(n.c_str());
     }
index 20035fe91a110bced38c3a554935e24217ba6385..a36c3931ec01a00903d036f48b3cfede55f30970 100644 (file)
@@ -3,6 +3,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
+// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements
+//
 
 #include "compiler/UnfoldSelect.h"
 
@@ -44,7 +46,7 @@ bool UnfoldSelect::visitSelection(Visit visit, TIntermSelection *node)
                "}\n"
                "else\n"
                "{\n";
-        node->getCondition()->traverse(this);
+        node->getFalseBlock()->traverse(this);
         out << "    t" << i << " = ";
         node->getFalseBlock()->traverse(mOutputHLSL);
         out << ";\n"
index 68b2e8a163a3ea0ec4c10c8ec032ca3a4d09331f..de296e4428dac58b16b6719b984e44626a538a20 100644 (file)
@@ -3,6 +3,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
+// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements
+//
 
 #ifndef COMPILER_UNFOLDSELECT_H_
 #define COMPILER_UNFOLDSELECT_H_
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp
new file mode 100644 (file)
index 0000000..886f693
--- /dev/null
@@ -0,0 +1,468 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/ValidateLimitations.h"
+#include "compiler/InfoSink.h"
+#include "compiler/ParseHelper.h"
+
+namespace {
+bool IsLoopIndex(const TIntermSymbol* symbol, const TLoopStack& stack) {
+    for (TLoopStack::const_iterator i = stack.begin(); i != stack.end(); ++i) {
+        if (i->index.id == symbol->getId())
+            return true;
+    }
+    return false;
+}
+
+// Traverses a node to check if it represents a constant index expression.
+// Definition:
+// constant-index-expressions are a superset of constant-expressions.
+// Constant-index-expressions can include loop indices as defined in
+// GLSL ES 1.0 spec, Appendix A, section 4.
+// The following are constant-index-expressions:
+// - Constant expressions
+// - Loop indices as defined in section 4
+// - Expressions composed of both of the above
+class ValidateConstIndexExpr : public TIntermTraverser {
+public:
+    ValidateConstIndexExpr(const TLoopStack& stack)
+        : mValid(true), mLoopStack(stack) {}
+
+    // Returns true if the parsed node represents a constant index expression.
+    bool isValid() const { return mValid; }
+
+    virtual void visitSymbol(TIntermSymbol* symbol) {
+        // Only constants and loop indices are allowed in a
+        // constant index expression.
+        if (mValid) {
+            mValid = (symbol->getQualifier() == EvqConst) ||
+                     IsLoopIndex(symbol, mLoopStack);
+        }
+    }
+    virtual void visitConstantUnion(TIntermConstantUnion*) {}
+    virtual bool visitBinary(Visit, TIntermBinary*) { return true; }
+    virtual bool visitUnary(Visit, TIntermUnary*) { return true; }
+    virtual bool visitSelection(Visit, TIntermSelection*) { return true; }
+    virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; }
+    virtual bool visitLoop(Visit, TIntermLoop*) { return true; }
+    virtual bool visitBranch(Visit, TIntermBranch*) { return true; }
+
+private:
+    bool mValid;
+    const TLoopStack& mLoopStack;
+};
+}  // namespace
+
+ValidateLimitations::ValidateLimitations(ShShaderType shaderType,
+                                         TInfoSinkBase& sink)
+    : mShaderType(shaderType),
+      mSink(sink),
+      mNumErrors(0)
+{
+}
+
+void ValidateLimitations::visitSymbol(TIntermSymbol*)
+{
+}
+
+void ValidateLimitations::visitConstantUnion(TIntermConstantUnion*)
+{
+}
+
+bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node)
+{
+    // Check if loop index is modified in the loop body.
+    validateOperation(node, node->getLeft());
+
+    // Check indexing.
+    switch (node->getOp()) {
+      case EOpIndexDirect:
+      case EOpIndexIndirect:
+        validateIndexing(node);
+        break;
+      default: break;
+    }
+    return true;
+}
+
+bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node)
+{
+    // Check if loop index is modified in the loop body.
+    validateOperation(node, node->getOperand());
+
+    return true;
+}
+
+bool ValidateLimitations::visitSelection(Visit, TIntermSelection*)
+{
+    return true;
+}
+
+bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node)
+{
+    switch (node->getOp()) {
+      case EOpFunctionCall:
+        validateFunctionCall(node);
+        break;
+      default:
+        break;
+    }
+    return true;
+}
+
+bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node)
+{
+    if (!validateLoopType(node))
+        return false;
+
+    TLoopInfo info;
+    memset(&info, 0, sizeof(TLoopInfo));
+    if (!validateForLoopHeader(node, &info))
+        return false;
+
+    TIntermNode* body = node->getBody();
+    if (body != NULL) {
+        mLoopStack.push_back(info);
+        body->traverse(this);
+        mLoopStack.pop_back();
+    }
+
+    // The loop is fully processed - no need to visit children.
+    return false;
+}
+
+bool ValidateLimitations::visitBranch(Visit, TIntermBranch*)
+{
+    return true;
+}
+
+void ValidateLimitations::error(TSourceLoc loc,
+                                const char *reason, const char* token)
+{
+    mSink.prefix(EPrefixError);
+    mSink.location(loc);
+    mSink << "'" << token << "' : " << reason << "\n";
+    ++mNumErrors;
+}
+
+bool ValidateLimitations::withinLoopBody() const
+{
+    return !mLoopStack.empty();
+}
+
+bool ValidateLimitations::isLoopIndex(const TIntermSymbol* symbol) const
+{
+    return IsLoopIndex(symbol, mLoopStack);
+}
+
+bool ValidateLimitations::validateLoopType(TIntermLoop* node) {
+    TLoopType type = node->getType();
+    if (type == ELoopFor)
+        return true;
+
+    // Reject while and do-while loops.
+    error(node->getLine(),
+          "This type of loop is not allowed",
+          type == ELoopWhile ? "while" : "do");
+    return false;
+}
+
+bool ValidateLimitations::validateForLoopHeader(TIntermLoop* node,
+                                                TLoopInfo* info)
+{
+    ASSERT(node->getType() == ELoopFor);
+
+    //
+    // The for statement has the form:
+    //    for ( init-declaration ; condition ; expression ) statement
+    //
+    if (!validateForLoopInit(node, info))
+        return false;
+    if (!validateForLoopCond(node, info))
+        return false;
+    if (!validateForLoopExpr(node, info))
+        return false;
+
+    return true;
+}
+
+bool ValidateLimitations::validateForLoopInit(TIntermLoop* node,
+                                              TLoopInfo* info)
+{
+    TIntermNode* init = node->getInit();
+    if (init == NULL) {
+        error(node->getLine(), "Missing init declaration", "for");
+        return false;
+    }
+
+    //
+    // init-declaration has the form:
+    //     type-specifier identifier = constant-expression
+    //
+    TIntermAggregate* decl = init->getAsAggregate();
+    if ((decl == NULL) || (decl->getOp() != EOpDeclaration)) {
+        error(init->getLine(), "Invalid init declaration", "for");
+        return false;
+    }
+    // To keep things simple do not allow declaration list.
+    TIntermSequence& declSeq = decl->getSequence();
+    if (declSeq.size() != 1) {
+        error(decl->getLine(), "Invalid init declaration", "for");
+        return false;
+    }
+    TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
+    if ((declInit == NULL) || (declInit->getOp() != EOpInitialize)) {
+        error(decl->getLine(), "Invalid init declaration", "for");
+        return false;
+    }
+    TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
+    if (symbol == NULL) {
+        error(declInit->getLine(), "Invalid init declaration", "for");
+        return false;
+    }
+    // The loop index has type int or float.
+    TBasicType type = symbol->getBasicType();
+    if ((type != EbtInt) && (type != EbtFloat)) {
+        error(symbol->getLine(),
+              "Invalid type for loop index", getBasicString(type));
+        return false;
+    }
+    // The loop index is initialized with constant expression.
+    if (!isConstExpr(declInit->getRight())) {
+        error(declInit->getLine(),
+              "Loop index cannot be initialized with non-constant expression",
+              symbol->getSymbol().c_str());
+        return false;
+    }
+
+    info->index.id = symbol->getId();
+    return true;
+}
+
+bool ValidateLimitations::validateForLoopCond(TIntermLoop* node,
+                                              TLoopInfo* info)
+{
+    TIntermNode* cond = node->getCondition();
+    if (cond == NULL) {
+        error(node->getLine(), "Missing condition", "for");
+        return false;
+    }
+    //
+    // condition has the form:
+    //     loop_index relational_operator constant_expression
+    //
+    TIntermBinary* binOp = cond->getAsBinaryNode();
+    if (binOp == NULL) {
+        error(node->getLine(), "Invalid condition", "for");
+        return false;
+    }
+    // Loop index should be to the left of relational operator.
+    TIntermSymbol* symbol = binOp->getLeft()->getAsSymbolNode();
+    if (symbol == NULL) {
+        error(binOp->getLine(), "Invalid condition", "for");
+        return false;
+    }
+    if (symbol->getId() != info->index.id) {
+        error(symbol->getLine(),
+              "Expected loop index", symbol->getSymbol().c_str());
+        return false;
+    }
+    // Relational operator is one of: > >= < <= == or !=.
+    switch (binOp->getOp()) {
+      case EOpEqual:
+      case EOpNotEqual:
+      case EOpLessThan:
+      case EOpGreaterThan:
+      case EOpLessThanEqual:
+      case EOpGreaterThanEqual:
+        break;
+      default:
+        error(binOp->getLine(),
+              "Invalid relational operator",
+              getOperatorString(binOp->getOp()));
+        break;
+    }
+    // Loop index must be compared with a constant.
+    if (!isConstExpr(binOp->getRight())) {
+        error(binOp->getLine(),
+              "Loop index cannot be compared with non-constant expression",
+              symbol->getSymbol().c_str());
+        return false;
+    }
+
+    return true;
+}
+
+bool ValidateLimitations::validateForLoopExpr(TIntermLoop* node,
+                                              TLoopInfo* info)
+{
+    TIntermNode* expr = node->getExpression();
+    if (expr == NULL) {
+        error(node->getLine(), "Missing expression", "for");
+        return false;
+    }
+
+    // for expression has one of the following forms:
+    //     loop_index++
+    //     loop_index--
+    //     loop_index += constant_expression
+    //     loop_index -= constant_expression
+    //     ++loop_index
+    //     --loop_index
+    // The last two forms are not specified in the spec, but I am assuming
+    // its an oversight.
+    TIntermUnary* unOp = expr->getAsUnaryNode();
+    TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode();
+
+    TOperator op = EOpNull;
+    TIntermSymbol* symbol = NULL;
+    if (unOp != NULL) {
+        op = unOp->getOp();
+        symbol = unOp->getOperand()->getAsSymbolNode();
+    } else if (binOp != NULL) {
+        op = binOp->getOp();
+        symbol = binOp->getLeft()->getAsSymbolNode();
+    }
+
+    // The operand must be loop index.
+    if (symbol == NULL) {
+        error(expr->getLine(), "Invalid expression", "for");
+        return false;
+    }
+    if (symbol->getId() != info->index.id) {
+        error(symbol->getLine(),
+              "Expected loop index", symbol->getSymbol().c_str());
+        return false;
+    }
+
+    // The operator is one of: ++ -- += -=.
+    switch (op) {
+        case EOpPostIncrement:
+        case EOpPostDecrement:
+        case EOpPreIncrement:
+        case EOpPreDecrement:
+            ASSERT((unOp != NULL) && (binOp == NULL));
+            break;
+        case EOpAddAssign:
+        case EOpSubAssign:
+            ASSERT((unOp == NULL) && (binOp != NULL));
+            break;
+        default:
+            error(expr->getLine(), "Invalid operator", getOperatorString(op));
+            return false;
+    }
+
+    // Loop index must be incremented/decremented with a constant.
+    if (binOp != NULL) {
+        if (!isConstExpr(binOp->getRight())) {
+            error(binOp->getLine(),
+                  "Loop index cannot be modified by non-constant expression",
+                  symbol->getSymbol().c_str());
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node)
+{
+    ASSERT(node->getOp() == EOpFunctionCall);
+
+    // If not within loop body, there is nothing to check.
+    if (!withinLoopBody())
+        return true;
+
+    // List of param indices for which loop indices are used as argument.
+    typedef std::vector<int> ParamIndex;
+    ParamIndex pIndex;
+    TIntermSequence& params = node->getSequence();
+    for (TIntermSequence::size_type i = 0; i < params.size(); ++i) {
+        TIntermSymbol* symbol = params[i]->getAsSymbolNode();
+        if (symbol && isLoopIndex(symbol))
+            pIndex.push_back(i);
+    }
+    // If none of the loop indices are used as arguments,
+    // there is nothing to check.
+    if (pIndex.empty())
+        return true;
+
+    bool valid = true;
+    TSymbolTable& symbolTable = GlobalParseContext->symbolTable;
+    TSymbol* symbol = symbolTable.find(node->getName());
+    ASSERT(symbol && symbol->isFunction());
+    TFunction* function = static_cast<TFunction*>(symbol);
+    for (ParamIndex::const_iterator i = pIndex.begin();
+         i != pIndex.end(); ++i) {
+        const TParameter& param = function->getParam(*i);
+        TQualifier qual = param.type->getQualifier();
+        if ((qual == EvqOut) || (qual == EvqInOut)) {
+            error(params[*i]->getLine(),
+                  "Loop index cannot be used as argument to a function out or inout parameter",
+                  params[*i]->getAsSymbolNode()->getSymbol().c_str());
+            valid = false;
+        }
+    }
+
+    return valid;
+}
+
+bool ValidateLimitations::validateOperation(TIntermOperator* node,
+                                            TIntermNode* operand) {
+    // Check if loop index is modified in the loop body.
+    if (!withinLoopBody() || !node->modifiesState())
+        return true;
+
+    const TIntermSymbol* symbol = operand->getAsSymbolNode();
+    if (symbol && isLoopIndex(symbol)) {
+        error(node->getLine(),
+              "Loop index cannot be statically assigned to within the body of the loop",
+              symbol->getSymbol().c_str());
+    }
+    return true;
+}
+
+bool ValidateLimitations::isConstExpr(TIntermNode* node)
+{
+    ASSERT(node != NULL);
+    return node->getAsConstantUnion() != NULL;
+}
+
+bool ValidateLimitations::isConstIndexExpr(TIntermNode* node)
+{
+    ASSERT(node != NULL);
+
+    ValidateConstIndexExpr validate(mLoopStack);
+    node->traverse(&validate);
+    return validate.isValid();
+}
+
+bool ValidateLimitations::validateIndexing(TIntermBinary* node)
+{
+    ASSERT((node->getOp() == EOpIndexDirect) ||
+           (node->getOp() == EOpIndexIndirect));
+
+    bool valid = true;
+    TIntermTyped* index = node->getRight();
+    // The index expression must have integral type.
+    if (!index->isScalar() || (index->getBasicType() != EbtInt)) {
+        error(index->getLine(),
+              "Index expression must have integral type",
+              index->getCompleteString().c_str());
+        valid = false;
+    }
+    // The index expession must be a constant-index-expression unless
+    // the operand is a uniform in a vertex shader.
+    TIntermTyped* operand = node->getLeft();
+    bool skip = (mShaderType == SH_VERTEX_SHADER) &&
+                (operand->getQualifier() == EvqUniform);
+    if (!skip && !isConstIndexExpr(index)) {
+        error(index->getLine(), "Index expression must be constant", "[]");
+        valid = false;
+    }
+    return valid;
+}
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h
new file mode 100644 (file)
index 0000000..a4f5a28
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// 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.
+//
+
+#include "GLSLANG/ShaderLang.h"
+#include "compiler/intermediate.h"
+
+class TInfoSinkBase;
+
+struct TLoopInfo {
+    struct TIndex {
+        int id;  // symbol id.
+    } index;
+};
+typedef TVector<TLoopInfo> TLoopStack;
+
+// Traverses intermediate tree to ensure that the shader does not exceed the
+// minimum functionality mandated in GLSL 1.0 spec, Appendix A.
+class ValidateLimitations : public TIntermTraverser {
+public:
+    ValidateLimitations(ShShaderType shaderType, TInfoSinkBase& sink);
+
+    int numErrors() const { return mNumErrors; }
+
+    virtual void visitSymbol(TIntermSymbol*);
+    virtual void visitConstantUnion(TIntermConstantUnion*);
+    virtual bool visitBinary(Visit, TIntermBinary*);
+    virtual bool visitUnary(Visit, TIntermUnary*);
+    virtual bool visitSelection(Visit, TIntermSelection*);
+    virtual bool visitAggregate(Visit, TIntermAggregate*);
+    virtual bool visitLoop(Visit, TIntermLoop*);
+    virtual bool visitBranch(Visit, TIntermBranch*);
+
+private:
+    void error(TSourceLoc loc, const char *reason, const char* token);
+
+    bool withinLoopBody() const;
+    bool isLoopIndex(const TIntermSymbol* symbol) const;
+    bool validateLoopType(TIntermLoop* node);
+    bool validateForLoopHeader(TIntermLoop* node, TLoopInfo* info);
+    bool validateForLoopInit(TIntermLoop* node, TLoopInfo* info);
+    bool validateForLoopCond(TIntermLoop* node, TLoopInfo* info);
+    bool validateForLoopExpr(TIntermLoop* node, TLoopInfo* info);
+    // Returns true if none of the loop indices is used as the argument to
+    // the given function out or inout parameter.
+    bool validateFunctionCall(TIntermAggregate* node);
+    bool validateOperation(TIntermOperator* node, TIntermNode* operand);
+
+    // Returns true if indexing does not exceed the minimum functionality
+    // mandated in GLSL 1.0 spec, Appendix A, Section 5.
+    bool isConstExpr(TIntermNode* node);
+    bool isConstIndexExpr(TIntermNode* node);
+    bool validateIndexing(TIntermBinary* node);
+
+    ShShaderType mShaderType;
+    TInfoSinkBase& mSink;
+    int mNumErrors;
+    TLoopStack mLoopStack;
+};
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp
new file mode 100644 (file)
index 0000000..ad2e08f
--- /dev/null
@@ -0,0 +1,210 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/VariableInfo.h"
+
+static TString arrayBrackets(int index)
+{
+    TStringStream stream;
+    stream << "[" << index << "]";
+    return stream.str();
+}
+
+// Returns the data type for an attribute or uniform.
+static ShDataType getVariableDataType(const TType& type)
+{
+    switch (type.getBasicType()) {
+      case EbtFloat:
+          if (type.isMatrix()) {
+              switch (type.getNominalSize()) {
+                case 2: return SH_FLOAT_MAT2;
+                case 3: return SH_FLOAT_MAT3;
+                case 4: return SH_FLOAT_MAT4;
+                default: UNREACHABLE();
+              }
+          } else if (type.isVector()) {
+              switch (type.getNominalSize()) {
+                case 2: return SH_FLOAT_VEC2;
+                case 3: return SH_FLOAT_VEC3;
+                case 4: return SH_FLOAT_VEC4;
+                default: UNREACHABLE();
+              }
+          } else {
+              return SH_FLOAT;
+          }
+      case EbtInt:
+          if (type.isMatrix()) {
+              UNREACHABLE();
+          } else if (type.isVector()) {
+              switch (type.getNominalSize()) {
+                case 2: return SH_INT_VEC2;
+                case 3: return SH_INT_VEC3;
+                case 4: return SH_INT_VEC4;
+                default: UNREACHABLE();
+              }
+          } else {
+              return SH_INT;
+          }
+      case EbtBool:
+          if (type.isMatrix()) {
+              UNREACHABLE();
+          } else if (type.isVector()) {
+              switch (type.getNominalSize()) {
+                case 2: return SH_BOOL_VEC2;
+                case 3: return SH_BOOL_VEC3;
+                case 4: return SH_BOOL_VEC4;
+                default: UNREACHABLE();
+              }
+          } else {
+              return SH_BOOL;
+          }
+      case EbtSampler2D: return SH_SAMPLER_2D;
+      case EbtSamplerCube: return SH_SAMPLER_CUBE;
+      default: UNREACHABLE();
+    }
+    return SH_NONE;
+}
+
+static void getBuiltInVariableInfo(const TType& type,
+                                   const TString& name,
+                                   TVariableInfoList& infoList);
+static void getUserDefinedVariableInfo(const TType& type,
+                                       const TString& name,
+                                       TVariableInfoList& infoList);
+
+// Returns info for an attribute or uniform.
+static void getVariableInfo(const TType& type,
+                            const TString& name,
+                            TVariableInfoList& infoList)
+{
+    if (type.getBasicType() == EbtStruct) {
+        if (type.isArray()) {
+            for (int i = 0; i < type.getArraySize(); ++i) {
+                TString lname = name + arrayBrackets(i);
+                getUserDefinedVariableInfo(type, lname, infoList);
+            }
+        } else {
+            getUserDefinedVariableInfo(type, name, infoList);
+        }
+    } else {
+        getBuiltInVariableInfo(type, name, infoList);
+    }
+}
+
+void getBuiltInVariableInfo(const TType& type,
+                            const TString& name,
+                            TVariableInfoList& infoList)
+{
+    ASSERT(type.getBasicType() != EbtStruct);
+
+    TVariableInfo varInfo;
+    if (type.isArray()) {
+        varInfo.name = (name + "[0]").c_str();
+        varInfo.size = type.getArraySize();
+    } else {
+        varInfo.name = name.c_str();
+        varInfo.size = 1;
+    }
+    varInfo.type = getVariableDataType(type);
+    infoList.push_back(varInfo);
+}
+
+void getUserDefinedVariableInfo(const TType& type,
+                                const TString& name,
+                                TVariableInfoList& infoList)
+{
+    ASSERT(type.getBasicType() == EbtStruct);
+
+    TString lname = name + ".";
+    const TTypeList* structure = type.getStruct();
+    for (size_t i = 0; i < structure->size(); ++i) {
+        const TType* fieldType = (*structure)[i].type;
+        getVariableInfo(*fieldType,
+                        lname + fieldType->getFieldName(),
+                        infoList);
+    }
+}
+
+CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs,
+                                               TVariableInfoList& uniforms)
+    : mAttribs(attribs),
+      mUniforms(uniforms)
+{
+}
+
+// We are only interested in attribute and uniform variable declaration.
+void CollectAttribsUniforms::visitSymbol(TIntermSymbol*)
+{
+}
+
+void CollectAttribsUniforms::visitConstantUnion(TIntermConstantUnion*)
+{
+}
+
+bool CollectAttribsUniforms::visitBinary(Visit, TIntermBinary*)
+{
+    return false;
+}
+
+bool CollectAttribsUniforms::visitUnary(Visit, TIntermUnary*)
+{
+    return false;
+}
+
+bool CollectAttribsUniforms::visitSelection(Visit, TIntermSelection*)
+{
+    return false;
+}
+
+bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node)
+{
+    bool visitChildren = false;
+
+    switch (node->getOp())
+    {
+    case EOpSequence:
+        // We need to visit sequence children to get to variable declarations.
+        visitChildren = true;
+        break;
+    case EOpDeclaration: {
+        const TIntermSequence& sequence = node->getSequence();
+        TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier();
+        if (qualifier == EvqAttribute || qualifier == EvqUniform)
+        {
+            TVariableInfoList& infoList = qualifier == EvqAttribute ?
+                mAttribs : mUniforms;
+            for (TIntermSequence::const_iterator i = sequence.begin();
+                 i != sequence.end(); ++i)
+            {
+                const TIntermSymbol* variable = (*i)->getAsSymbolNode();
+                // The only case in which the sequence will not contain a
+                // TIntermSymbol node is initialization. It will contain a
+                // TInterBinary node in that case. Since attributes and unifroms
+                // cannot be initialized in a shader, we must have only
+                // TIntermSymbol nodes in the sequence.
+                ASSERT(variable != NULL);
+                getVariableInfo(variable->getType(), variable->getSymbol(),
+                                infoList);
+            }
+        }
+        break;
+    }
+    default: break;
+    }
+
+    return visitChildren;
+}
+
+bool CollectAttribsUniforms::visitLoop(Visit, TIntermLoop*)
+{
+    return false;
+}
+
+bool CollectAttribsUniforms::visitBranch(Visit, TIntermBranch*)
+{
+    return false;
+}
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h
new file mode 100644 (file)
index 0000000..15a5c57
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "GLSLANG/ShaderLang.h"
+#include "compiler/intermediate.h"
+
+// Provides information about a variable.
+// It is currently being used to store info about active attribs and uniforms.
+struct TVariableInfo {
+    TPersistString name;
+    ShDataType type;
+    int size;
+};
+typedef std::vector<TVariableInfo> TVariableInfoList;
+
+// Traverses intermediate tree to collect all attributes and uniforms.
+class CollectAttribsUniforms : public TIntermTraverser {
+public:
+    CollectAttribsUniforms(TVariableInfoList& attribs,
+                           TVariableInfoList& uniforms);
+
+    virtual void visitSymbol(TIntermSymbol*);
+    virtual void visitConstantUnion(TIntermConstantUnion*);
+    virtual bool visitBinary(Visit, TIntermBinary*);
+    virtual bool visitUnary(Visit, TIntermUnary*);
+    virtual bool visitSelection(Visit, TIntermSelection*);
+    virtual bool visitAggregate(Visit, TIntermAggregate*);
+    virtual bool visitLoop(Visit, TIntermLoop*);
+    virtual bool visitBranch(Visit, TIntermBranch*);
+
+private:
+    TVariableInfoList& mAttribs;
+    TVariableInfoList& mUniforms;
+};
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp
new file mode 100644 (file)
index 0000000..3f87820
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/VersionGLSL.h"
+
+static const int GLSL_VERSION_110 = 110;
+static const int GLSL_VERSION_120 = 120;
+
+// We need to scan for two things:
+// 1. "invariant" keyword: This can occur in both - vertex and fragment shaders
+//    but only at the global scope.
+// 2. "gl_PointCoord" built-in variable: This can only occur in fragment shader
+//    but inside any scope.
+// So we need to scan the entire fragment shader but only the global scope
+// of vertex shader.
+//
+// TODO(alokp): The following two cases of invariant decalaration get lost
+// during parsing - they do not get carried over to the intermediate tree.
+// Handle these cases:
+// 1. When a pragma is used to force all output variables to be invariant:
+//    - #pragma STDGL invariant(all)
+// 2. When a previously decalared or built-in variable is marked invariant:
+//    - invariant gl_Position;
+//    - varying vec3 color; invariant color;
+//
+TVersionGLSL::TVersionGLSL(ShShaderType type)
+    : mShaderType(type),
+      mVersion(GLSL_VERSION_110)
+{
+}
+
+void TVersionGLSL::visitSymbol(TIntermSymbol* node)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+
+    if (node->getSymbol() == "gl_PointCoord")
+        updateVersion(GLSL_VERSION_120);
+}
+
+void TVersionGLSL::visitConstantUnion(TIntermConstantUnion*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+}
+
+bool TVersionGLSL::visitBinary(Visit, TIntermBinary*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+    return true;
+}
+
+bool TVersionGLSL::visitUnary(Visit, TIntermUnary*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+    return true;
+}
+
+bool TVersionGLSL::visitSelection(Visit, TIntermSelection*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+    return true;
+}
+
+bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate* node)
+{
+    // We need to scan the entire fragment shader but only the global scope
+    // of vertex shader.
+    bool visitChildren = mShaderType == SH_FRAGMENT_SHADER ? true : false;
+
+    switch (node->getOp()) {
+      case EOpSequence:
+        // We need to visit sequence children to get to global or inner scope.
+        visitChildren = true;
+        break;
+      case EOpDeclaration: {
+        const TIntermSequence& sequence = node->getSequence();
+        TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier();
+        if ((qualifier == EvqInvariantVaryingIn) ||
+            (qualifier == EvqInvariantVaryingOut)) {
+            updateVersion(GLSL_VERSION_120);
+        }
+        break;
+      }
+      default: break;
+    }
+
+    return visitChildren;
+}
+
+bool TVersionGLSL::visitLoop(Visit, TIntermLoop*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+    return true;
+}
+
+bool TVersionGLSL::visitBranch(Visit, TIntermBranch*)
+{
+    ASSERT(mShaderType == SH_FRAGMENT_SHADER);
+    return true;
+}
+
+void TVersionGLSL::updateVersion(int version)
+{
+    mVersion = std::max(version, mVersion);
+}
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h
new file mode 100644 (file)
index 0000000..64d002b
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef COMPILER_VERSIONGLSL_H_
+#define COMPILER_VERSIONGLSL_H_
+
+#include "GLSLANG/ShaderLang.h"
+#include "compiler/intermediate.h"
+
+// Traverses the intermediate tree to return the minimum GLSL version
+// required to legally access all built-in features used in the shader.
+// GLSL 1.1 which is mandated by OpenGL 2.0 provides:
+//   - #version and #extension to declare version and extensions.
+//   - built-in functions refract, exp, and log.
+//   - updated step() to compare x < edge instead of x <= edge.
+// GLSL 1.2 which is mandated by OpenGL 2.1 provides:
+//   - many changes to reduce differences when compared to the ES specification.
+//   - invariant keyword and its support.
+//   - c++ style name hiding rules.
+//   - built-in variable gl_PointCoord for fragment shaders.
+//
+class TVersionGLSL : public TIntermTraverser {
+public:
+    TVersionGLSL(ShShaderType type);
+
+    // Returns 120 if "invariant" keyword or "gl_PointCoord" is used
+    // in the shader. Else 110 is returned.
+    int getVersion() { return mVersion; }
+
+    virtual void visitSymbol(TIntermSymbol*);
+    virtual void visitConstantUnion(TIntermConstantUnion*);
+    virtual bool visitBinary(Visit, TIntermBinary*);
+    virtual bool visitUnary(Visit, TIntermUnary*);
+    virtual bool visitSelection(Visit, TIntermSelection*);
+    virtual bool visitAggregate(Visit, TIntermAggregate*);
+    virtual bool visitLoop(Visit, TIntermLoop*);
+    virtual bool visitBranch(Visit, TIntermBranch*);
+
+protected:
+    void updateVersion(int version);
+
+private:
+    ShShaderType mShaderType;
+    int mVersion;
+};
+
+#endif  // COMPILER_VERSIONGLSL_H_
diff --git a/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh
new file mode 100644 (file)
index 0000000..268479d
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+# 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.
+
+# Generates GLSL ES lexer - glslang_lex.cpp
+
+script_dir=$(dirname $0)
+input_file=$script_dir/glslang.l
+output_file=$script_dir/glslang_lex.cpp
+flex --noline --nounistd --outfile=$output_file $input_file
diff --git a/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh
new file mode 100644 (file)
index 0000000..889f5c0
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+# 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.
+
+# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp
+
+script_dir=$(dirname $0)
+input_file=$script_dir/glslang.y
+output_header=$script_dir/glslang_tab.h
+output_source=$script_dir/glslang_tab.cpp
+bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang.h b/Source/ThirdParty/ANGLE/src/compiler/glslang.h
new file mode 100644 (file)
index 0000000..26f1457
--- /dev/null
@@ -0,0 +1,16 @@
+//
+// 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.
+//
+
+struct TParseContext;
+extern int glslang_initialize(TParseContext* context);
+extern int glslang_finalize(TParseContext* context);
+
+extern void glslang_scan(int count,
+                         const char* const string[],
+                         const int length[],
+                         TParseContext* context);
+extern int glslang_parse(TParseContext* context);
+
index 02c226f8f51fa709fc648c213e118a545e09a652..5a7c5d52a50f6ca86dcd0763fb099094be29189d 100644 (file)
@@ -4,34 +4,29 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
-*/
-/* Based on
-ANSI C grammar, Lex specification
-
-In 1985, Jeff Lee published this Lex specification together with a Yacc 
-grammar for the April 30, 1985 ANSI C draft.  Tom Stockfisch reposted 
-both to net.sources in 1987; that original, as mentioned in the answer 
-to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net, 
-file usenet/net.sources/ansi.c.grammar.Z. 
 
-I intend to keep this version as close to the current C Standard grammar 
-as possible; please let me know if you discover discrepancies. 
+This file contains the Lex specification for GLSL ES.
+Based on ANSI C grammar, Lex specification:
+http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
 
-Jutta Degener, 1995 
+IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
+WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
 */
 
-D           [0-9]
-L           [a-zA-Z_]
-H           [a-fA-F0-9]
-E           [Ee][+-]?{D}+
-O           [0-7]
+%top{
+//
+// 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.
+//
 
-%option nounput 
-%{
-#include <stdio.h>
-#include <stdlib.h>
+// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
+}
 
+%{
+#include "compiler/glslang.h"
 #include "compiler/ParseHelper.h"
+#include "compiler/util.h"
 #include "glslang_tab.h"
 
 /* windows only pragma */
@@ -39,407 +34,304 @@ O           [0-7]
 #pragma warning(disable : 4102)
 #endif
 
-int yy_input(char* buf, int max_size);
-
-extern int yyparse(void*);
-#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
-#define parseContext (*((TParseContext*)(parseContextLocal)))
-#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
+#define YY_USER_ACTION yylval->lex.line = yylineno;
+#define YY_INPUT(buf, result, max_size) \
+    result = string_input(buf, max_size, yyscanner);
 
+static int string_input(char* buf, int max_size, yyscan_t yyscanner);
+static int check_type(yyscan_t yyscanner);
+static int reserved_word(yyscan_t yyscanner);
 %}
 
-/*
-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 never-interactive
-%x FIELDS
+%option noyywrap nounput never-interactive
+%option yylineno reentrant bison-bridge
+%option stack
+%option extra-type="TParseContext*"
+%x COMMENT FIELDS
 
+D           [0-9]
+L           [a-zA-Z_]
+H           [a-fA-F0-9]
+E           [Ee][+-]?{D}+
+O           [0-7]
 
 %%
-<*>"//"[^\n]*"\n"     { /* ?? carriage and/or line-feed? */ };
-
-"invariant"    {  pyylval->lex.line = yylineno; return(INVARIANT); }
-"highp"        {  pyylval->lex.line = yylineno; return(HIGH_PRECISION); }
-"mediump"      {  pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); }
-"lowp"         {  pyylval->lex.line = yylineno; return(LOW_PRECISION); }
-"precision"    {  pyylval->lex.line = yylineno; return(PRECISION); }
-
-"attribute"    {  pyylval->lex.line = yylineno; return(ATTRIBUTE); }
-"const"        {  pyylval->lex.line = yylineno; return(CONST_QUAL); }
-"uniform"      {  pyylval->lex.line = yylineno; return(UNIFORM); }
-"varying"      {  pyylval->lex.line = yylineno; return(VARYING); }
-
-"break"        {  pyylval->lex.line = yylineno; return(BREAK); }
-"continue"     {  pyylval->lex.line = yylineno; return(CONTINUE); }
-"do"           {  pyylval->lex.line = yylineno; return(DO); }
-"for"          {  pyylval->lex.line = yylineno; return(FOR); }
-"while"        {  pyylval->lex.line = yylineno; return(WHILE); }
-
-"if"           {  pyylval->lex.line = yylineno; return(IF); }
-"else"         {  pyylval->lex.line = yylineno; return(ELSE); }
-
-"in"           {  pyylval->lex.line = yylineno; return(IN_QUAL); }
-"out"          {  pyylval->lex.line = yylineno; return(OUT_QUAL); }
-"inout"        {  pyylval->lex.line = yylineno; return(INOUT_QUAL); }
-
-"float"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }
-"int"          {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }
-"void"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }
-"bool"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }
-"true"         {  pyylval->lex.line = yylineno; pyylval->lex.b = true;  return(BOOLCONSTANT); }
-"false"        {  pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
-
-"discard"      {  pyylval->lex.line = yylineno; return(DISCARD); }
-"return"       {  pyylval->lex.line = yylineno; return(RETURN); }
-
-"mat2"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }
-"mat3"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }
-"mat4"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }
-
-"vec2"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
-"vec3"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
-"vec4"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
-"ivec2"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
-"ivec3"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
-"ivec4"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
-"bvec2"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
-"bvec3"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
-"bvec4"        {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
-
-"sampler2D"       {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
-"samplerCube"     {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
-
-"struct"       {  pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(STRUCT); }
-
-"asm"          {  PaReservedWord(); return 0; }
-
-"class"        {  PaReservedWord(); return 0; }
-"union"        {  PaReservedWord(); return 0; }
-"enum"         {  PaReservedWord(); return 0; }
-"typedef"      {  PaReservedWord(); return 0; }
-"template"     {  PaReservedWord(); return 0; }
-"this"         {  PaReservedWord(); return 0; }
-"packed"       {  PaReservedWord(); return 0; }
-
-"goto"         {  PaReservedWord(); return 0; }
-"switch"       {  PaReservedWord(); return 0; }
-"default"      {  PaReservedWord(); return 0; }
-
-"inline"       {  PaReservedWord(); return 0; }
-"noinline"     {  PaReservedWord(); return 0; }
-"volatile"     {  PaReservedWord(); return 0; }
-"public"       {  PaReservedWord(); return 0; }
-"static"       {  PaReservedWord(); return 0; }
-"extern"       {  PaReservedWord(); return 0; }
-"external"     {  PaReservedWord(); return 0; }
-"interface"    {  PaReservedWord(); return 0; }
-
-"long"         {  PaReservedWord(); return 0; }
-"short"        {  PaReservedWord(); return 0; }
-"double"       {  PaReservedWord(); return 0; }
-"half"         {  PaReservedWord(); return 0; }
-"fixed"        {  PaReservedWord(); return 0; }
-"unsigned"     {  PaReservedWord(); return 0; }
-
-"input"        {  PaReservedWord(); return 0; }
-"output"       {  PaReservedWord(); return 0; }
-
-"hvec2"        {  PaReservedWord(); return 0; }
-"hvec3"        {  PaReservedWord(); return 0; }
-"hvec4"        {  PaReservedWord(); return 0; }
-"fvec2"        {  PaReservedWord(); return 0; }
-"fvec3"        {  PaReservedWord(); return 0; }
-"fvec4"        {  PaReservedWord(); return 0; }
-"dvec2"        {  PaReservedWord(); return 0; }
-"dvec3"        {  PaReservedWord(); return 0; }
-"dvec4"        {  PaReservedWord(); return 0; }
-
-"sizeof"       {  PaReservedWord(); return 0; }
-"cast"         {  PaReservedWord(); return 0; }
-
-"namespace"    {  PaReservedWord(); return 0; }
-"using"        {  PaReservedWord(); return 0; }
-
-{L}({L}|{D})*       {  
-   pyylval->lex.line = yylineno; 
-   pyylval->lex.string = NewPoolTString(yytext); 
-   return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); 
+
+%{
+    TParseContext* context = yyextra;
+%}
+
+    /* Single-line comments */
+"//"[^\n]* ;
+
+    /* Multi-line comments */
+"/*"           { yy_push_state(COMMENT, yyscanner); }
+<COMMENT>. |
+<COMMENT>\n ;
+<COMMENT>"*/"  { yy_pop_state(yyscanner); }
+
+"invariant"    { return(INVARIANT); }
+"highp"        { return(HIGH_PRECISION); }
+"mediump"      { return(MEDIUM_PRECISION); }
+"lowp"         { return(LOW_PRECISION); }
+"precision"    { return(PRECISION); }
+
+"attribute"    { return(ATTRIBUTE); }
+"const"        { return(CONST_QUAL); }
+"uniform"      { return(UNIFORM); }
+"varying"      { return(VARYING); }
+
+"break"        { return(BREAK); }
+"continue"     { return(CONTINUE); }
+"do"           { return(DO); }
+"for"          { return(FOR); }
+"while"        { return(WHILE); }
+
+"if"           { return(IF); }
+"else"         { return(ELSE); }
+
+"in"           { return(IN_QUAL); }
+"out"          { return(OUT_QUAL); }
+"inout"        { return(INOUT_QUAL); }
+
+"float"        { context->lexAfterType = true; return(FLOAT_TYPE); }
+"int"          { context->lexAfterType = true; return(INT_TYPE); }
+"void"         { context->lexAfterType = true; return(VOID_TYPE); }
+"bool"         { context->lexAfterType = true; return(BOOL_TYPE); }
+"true"         { yylval->lex.b = true;  return(BOOLCONSTANT); }
+"false"        { yylval->lex.b = false; return(BOOLCONSTANT); }
+
+"discard"      { return(DISCARD); }
+"return"       { return(RETURN); }
+
+"mat2"         { context->lexAfterType = true; return(MATRIX2); }
+"mat3"         { context->lexAfterType = true; return(MATRIX3); }
+"mat4"         { context->lexAfterType = true; return(MATRIX4); }
+
+"vec2"         { context->lexAfterType = true; return (VEC2); }
+"vec3"         { context->lexAfterType = true; return (VEC3); }
+"vec4"         { context->lexAfterType = true; return (VEC4); }
+"ivec2"        { context->lexAfterType = true; return (IVEC2); }
+"ivec3"        { context->lexAfterType = true; return (IVEC3); }
+"ivec4"        { context->lexAfterType = true; return (IVEC4); }
+"bvec2"        { context->lexAfterType = true; return (BVEC2); }
+"bvec3"        { context->lexAfterType = true; return (BVEC3); }
+"bvec4"        { context->lexAfterType = true; return (BVEC4); }
+
+"sampler2D"       { context->lexAfterType = true; return SAMPLER2D; }
+"samplerCube"     { context->lexAfterType = true; return SAMPLERCUBE; }
+
+"struct"       { context->lexAfterType = true; return(STRUCT); }
+
+"asm"          { return reserved_word(yyscanner); }
+
+"class"        { return reserved_word(yyscanner); }
+"union"        { return reserved_word(yyscanner); }
+"enum"         { return reserved_word(yyscanner); }
+"typedef"      { return reserved_word(yyscanner); }
+"template"     { return reserved_word(yyscanner); }
+"this"         { return reserved_word(yyscanner); }
+"packed"       { return reserved_word(yyscanner); }
+
+"goto"         { return reserved_word(yyscanner); }
+"switch"       { return reserved_word(yyscanner); }
+"default"      { return reserved_word(yyscanner); }
+
+"inline"       { return reserved_word(yyscanner); }
+"noinline"     { return reserved_word(yyscanner); }
+"volatile"     { return reserved_word(yyscanner); }
+"public"       { return reserved_word(yyscanner); }
+"static"       { return reserved_word(yyscanner); }
+"extern"       { return reserved_word(yyscanner); }
+"external"     { return reserved_word(yyscanner); }
+"interface"    { return reserved_word(yyscanner); }
+
+"long"         { return reserved_word(yyscanner); }
+"short"        { return reserved_word(yyscanner); }
+"double"       { return reserved_word(yyscanner); }
+"half"         { return reserved_word(yyscanner); }
+"fixed"        { return reserved_word(yyscanner); }
+"unsigned"     { return reserved_word(yyscanner); }
+
+"input"        { return reserved_word(yyscanner); }
+"output"       { return reserved_word(yyscanner); }
+
+"hvec2"        { return reserved_word(yyscanner); }
+"hvec3"        { return reserved_word(yyscanner); }
+"hvec4"        { return reserved_word(yyscanner); }
+"fvec2"        { return reserved_word(yyscanner); }
+"fvec3"        { return reserved_word(yyscanner); }
+"fvec4"        { return reserved_word(yyscanner); }
+"dvec2"        { return reserved_word(yyscanner); }
+"dvec3"        { return reserved_word(yyscanner); }
+"dvec4"        { return reserved_word(yyscanner); }
+
+"sizeof"       { return reserved_word(yyscanner); }
+"cast"         { return reserved_word(yyscanner); }
+
+"namespace"    { return reserved_word(yyscanner); }
+"using"        { return reserved_word(yyscanner); }
+
+{L}({L}|{D})*       {
+   yylval->lex.string = NewPoolTString(yytext); 
+   return check_type(yyscanner);
 }
 
-0[xX]{H}+         { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-0{O}+             { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-0{D}+             { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
-{D}+              { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
-
-{D}+{E}           { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-"."{D}+({E})?     { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
-
-"/*"            {  int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }   
-
-"+="            {  pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
-"-="            {  pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
-"*="            {  pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
-"/="            {  pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
-"%="            {  pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
-"<<="           {  pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
-">>="           {  pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
-"&="            {  pyylval->lex.line = yylineno; return(AND_ASSIGN); }
-"^="            {  pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
-"|="            {  pyylval->lex.line = yylineno; return(OR_ASSIGN); }
-
-"++"            {  pyylval->lex.line = yylineno; return(INC_OP); }
-"--"            {  pyylval->lex.line = yylineno; return(DEC_OP); }
-"&&"            {  pyylval->lex.line = yylineno; return(AND_OP); }
-"||"            {  pyylval->lex.line = yylineno; return(OR_OP); }
-"^^"            {  pyylval->lex.line = yylineno; return(XOR_OP); }
-"<="            {  pyylval->lex.line = yylineno; return(LE_OP); }
-">="            {  pyylval->lex.line = yylineno; return(GE_OP); }
-"=="            {  pyylval->lex.line = yylineno; return(EQ_OP); }
-"!="            {  pyylval->lex.line = yylineno; return(NE_OP); }
-"<<"            {  pyylval->lex.line = yylineno; return(LEFT_OP); }
-">>"            {  pyylval->lex.line = yylineno; return(RIGHT_OP); }
-";"         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
-("{"|"<%")      {  pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
-("}"|"%>")      {  pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
-","         {  pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
-":"         {  pyylval->lex.line = yylineno; return(COLON); }
-"="         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
-"("         {  pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
-")"         {  pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
-("["|"<:")      {  pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
-("]"|":>")      {  pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
+0[xX]{H}+         { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+0{O}+             { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+0{D}+             { context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;}
+{D}+              { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+
+{D}+{E}           { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
+{D}+"."{D}*({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
+"."{D}+({E})?     { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
+
+"+="            {  return(ADD_ASSIGN); }
+"-="            {  return(SUB_ASSIGN); }
+"*="            {  return(MUL_ASSIGN); }
+"/="            {  return(DIV_ASSIGN); }
+"%="            {  return(MOD_ASSIGN); }
+"<<="           {  return(LEFT_ASSIGN); }
+">>="           {  return(RIGHT_ASSIGN); }
+"&="            {  return(AND_ASSIGN); }
+"^="            {  return(XOR_ASSIGN); }
+"|="            {  return(OR_ASSIGN); }
+
+"++"            {  return(INC_OP); }
+"--"            {  return(DEC_OP); }
+"&&"            {  return(AND_OP); }
+"||"            {  return(OR_OP); }
+"^^"            {  return(XOR_OP); }
+"<="            {  return(LE_OP); }
+">="            {  return(GE_OP); }
+"=="            {  return(EQ_OP); }
+"!="            {  return(NE_OP); }
+"<<"            {  return(LEFT_OP); }
+">>"            {  return(RIGHT_OP); }
+";"             { context->lexAfterType = false; return(SEMICOLON); }
+("{"|"<%")      { context->lexAfterType = false; return(LEFT_BRACE); }
+("}"|"%>")      { return(RIGHT_BRACE); }
+","         { if (context->inTypeParen) context->lexAfterType = false; return(COMMA); }
+":"         { return(COLON); }
+"="         { context->lexAfterType = false; return(EQUAL); }
+"("         { context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); }
+")"         { context->inTypeParen = false; return(RIGHT_PAREN); }
+("["|"<:")      { return(LEFT_BRACKET); }
+("]"|":>")      { return(RIGHT_BRACKET); }
 "."         { BEGIN(FIELDS);  return(DOT); }
-"!"         {  pyylval->lex.line = yylineno; return(BANG); }
-"-"         {  pyylval->lex.line = yylineno; return(DASH); }
-"~"         {  pyylval->lex.line = yylineno; return(TILDE); }
-"+"         {  pyylval->lex.line = yylineno; return(PLUS); }
-"*"         {  pyylval->lex.line = yylineno; return(STAR); }
-"/"         {  pyylval->lex.line = yylineno; return(SLASH); }
-"%"         {  pyylval->lex.line = yylineno; return(PERCENT); }
-"<"         {  pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
-">"         {  pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
-"|"         {  pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
-"^"         {  pyylval->lex.line = yylineno; return(CARET); }
-"&"         {  pyylval->lex.line = yylineno; return(AMPERSAND); }
-"?"         {  pyylval->lex.line = yylineno; return(QUESTION); }
+"!"         { return(BANG); }
+"-"         { return(DASH); }
+"~"         { return(TILDE); }
+"+"         { return(PLUS); }
+"*"         { return(STAR); }
+"/"         { return(SLASH); }
+"%"         { return(PERCENT); }
+"<"         { return(LEFT_ANGLE); }
+">"         { return(RIGHT_ANGLE); }
+"|"         { return(VERTICAL_BAR); }
+"^"         { return(CARET); }
+"&"         { return(AMPERSAND); }
+"?"         { return(QUESTION); }
 
 <FIELDS>{L}({L}|{D})* { 
-BEGIN(INITIAL);      
-    pyylval->lex.line = yylineno;     
-    pyylval->lex.string = NewPoolTString(yytext); 
-    return FIELD_SELECTION; }
+    BEGIN(INITIAL);
+    yylval->lex.string = NewPoolTString(yytext); 
+    return FIELD_SELECTION;
+}
 <FIELDS>[ \t\v\f\r] {}
 
 [ \t\v\n\f\r]   {  }
-<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
-<*>.    { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
-          return 0; }
+<*><<EOF>>      { context->AfterEOF = true; yyterminate(); }
+<*>.            { context->warning(yylineno, "Unknown char", yytext, ""); return 0; }
 
 %%
 
-
-//Including Pre-processor.
 extern "C" {
-  #include "compiler/preprocessor/preprocess.h"
-} 
-
-//
-// The YY_INPUT macro just calls this.  Maybe this could be just put into
-// the macro directly.
-//
-
-int yy_input(char* buf, int max_size)
-{
-    int len;
-
-    if ((len = yylex_CPP(buf, max_size)) == 0)
-        return 0;
-    if (len >= max_size) 
-        YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-
-    buf[len] = ' ';
-       return len+1;
-}
-
-
-//
-// Parse an array of strings using yyparse.  We set up globals used by
-// yywrap.
-//
-// Returns 0 for success, as per yyparse().
-//
-int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)
-{
-    int argv0len;
-    
-    ScanFromString(argv[0]); 
-    
-    //Storing the Current Compiler Parse context into the cpp structure.
-       cpp->pC = (void*)&parseContextLocal;
-       
-       if (!argv || argc == 0)
-        return 1;
-    
-    for (int i = 0; i < argc; ++i) {
-        if (!argv[i]) {
-            parseContextLocal.error(0, "Null shader source string", "", "");
-            parseContextLocal.recover();
-            return 1;
-        }
-    }
-    
-    if (!strLen) {
-        argv0len = (int) strlen(argv[0]);
-        strLen   = &argv0len;
-    }
-    yyrestart(0);
-    (&parseContextLocal)->AfterEOF = false;
-    cpp->PaWhichStr = 0;
-    cpp->PaArgv     = argv;
-    cpp->PaArgc     = argc;
-    cpp->PaStrLen   = strLen;
-    cpp->pastFirstStatement = 0;
-    yylineno   = 1;
-   
-    if (*cpp->PaStrLen >= 0) {    
-        int ret = yyparse((void*)(&parseContextLocal));
-        if (ret || cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
-             return 1;
-        else
-             return 0;
-    }
-    else
-        return 0;
-}
-
-void yyerror(const char *s) 
-{
-    if (((TParseContext *)cpp->pC)->AfterEOF) {
-        if (cpp->tokensBeforeEOF == 1) {
-            GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
-            GlobalParseContext->recover();
-        }
-    } else {
-        GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");
-        GlobalParseContext->recover();
-    }            
-}
+// Preprocessor interface.
+#include "compiler/preprocessor/preprocess.h"
 
-void PaReservedWord()
-{
-    GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
-    GlobalParseContext->recover();
-}
-
-int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
-{
-    symbol = parseContextLocal.symbolTable.find(id);
-    if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
-        TVariable* variable = static_cast<TVariable*>(symbol);
-        if (variable->isUserType()) {
-            parseContextLocal.lexAfterType = true;
-            return TYPE_NAME;
-        }
-    }
-    
-    return IDENTIFIER;
-}
-
-int PaParseComment(int &lineno, TParseContext& parseContextLocal)
-{
-    int transitionFlag = 0;
-    int nextChar;
-    
-    while (transitionFlag != 2) {
-        nextChar = yyinput();
-        if (nextChar == '\n')
-             lineno++;
-        switch (nextChar) {
-        case '*' :
-            transitionFlag = 1;
-            break;
-        case '/' :  /* if star is the previous character, then it is the end of comment */
-            if (transitionFlag == 1) {
-                return 1 ;
-            }
-            break;
-        case EOF :
-            /* Raise error message here */
-            parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
-            GlobalParseContext->recover();
-            return YY_NULL; 
-        default :  /* Any other character will be a part of the comment */
-            transitionFlag = 0;
-        }
-    }
-    return 1;
-}
-
-extern "C" {
+#define SETUP_CONTEXT(pp) \
+    TParseContext* context = (TParseContext*) pp->pC; \
+    struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
 
+// Preprocessor callbacks.
 void CPPDebugLogMsg(const char *msg)
 {
-    ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
+    SETUP_CONTEXT(cpp);
+    context->infoSink.debug.message(EPrefixNone, msg);
 }
 
 void CPPWarningToInfoLog(const char *msg)
 {
-    ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); 
+    SETUP_CONTEXT(cpp);
+    context->warning(yylineno, msg, "", "");
 }
 
 void CPPShInfoLogMsg(const char *msg)
 {
-    ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
-    GlobalParseContext->recover();
+    SETUP_CONTEXT(cpp);
+    context->error(yylineno, msg, "", "");
+    context->recover();
 }
 
 void CPPErrorToInfoLog(char *msg)
 {
-    ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
-    GlobalParseContext->recover();
+    SETUP_CONTEXT(cpp);
+    context->error(yylineno, msg, "", "");
+    context->recover();
 }
 
 void SetLineNumber(int line)
 {
-    yylineno &= ~SourceLocLineMask;
-    yylineno |= line;
+    SETUP_CONTEXT(cpp);
+    int string = 0;
+    DecodeSourceLoc(yylineno, &string, NULL);
+    yylineno = EncodeSourceLoc(string, line);
 }
 
 void SetStringNumber(int string)
 {
-    yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
+    SETUP_CONTEXT(cpp);
+    int line = 0;
+    DecodeSourceLoc(yylineno, NULL, &line);
+    yylineno = EncodeSourceLoc(string, line);
 }
 
-int GetStringNumber(void)
+int GetStringNumber()
 {
-    return yylineno >> 16;
+    SETUP_CONTEXT(cpp);
+    int string = 0;
+    DecodeSourceLoc(yylineno, &string, NULL);
+    return string;
 }
 
-int GetLineNumber(void)
+int GetLineNumber()
 {
-    return yylineno & SourceLocLineMask;
+    SETUP_CONTEXT(cpp);
+    int line = 0;
+    DecodeSourceLoc(yylineno, NULL, &line);
+    return line;
 }
 
-void IncLineNumber(void)
+void IncLineNumber()
 {
-    if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
-        ++yylineno;
+    SETUP_CONTEXT(cpp);
+    int string = 0, line = 0;
+    DecodeSourceLoc(yylineno, &string, &line);
+    yylineno = EncodeSourceLoc(string, ++line);
 }
 
-void DecLineNumber(void)
+void DecLineNumber()
 {
-    if ((yylineno & SourceLocLineMask) > 0)
-        --yylineno;
+    SETUP_CONTEXT(cpp);
+    int string = 0, line = 0;
+    DecodeSourceLoc(yylineno, &string, &line);
+    yylineno = EncodeSourceLoc(string, --line);
 }
 
 void HandlePragma(const char **tokens, int numTokens)
-{    
+{
+    SETUP_CONTEXT(cpp);
     if (!strcmp(tokens[0], "optimize")) {
         if (numTokens != 4) {
             CPPShInfoLogMsg("optimize pragma syntax is incorrect");
@@ -452,9 +344,9 @@ void HandlePragma(const char **tokens, int numTokens)
         }
             
         if (!strcmp(tokens[2], "on"))
-            ((TParseContext *)cpp->pC)->contextPragma.optimize = true;
+            context->contextPragma.optimize = true;
         else if (!strcmp(tokens[2], "off"))
-            ((TParseContext *)cpp->pC)->contextPragma.optimize = false;
+            context->contextPragma.optimize = false;
         else {
             CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
             return;
@@ -476,9 +368,9 @@ void HandlePragma(const char **tokens, int numTokens)
         }
             
         if (!strcmp(tokens[2], "on"))
-            ((TParseContext *)cpp->pC)->contextPragma.debug = true;
+            context->contextPragma.debug = true;
         else if (!strcmp(tokens[2], "off"))
-            ((TParseContext *)cpp->pC)->contextPragma.debug = false;
+            context->contextPragma.debug = false;
         else {
             CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
             return;
@@ -489,7 +381,6 @@ void HandlePragma(const char **tokens, int numTokens)
             return;
         }
     } else {
-
 #ifdef PRAGMA_TABLE
         //
         // implementation specific pragma
@@ -524,21 +415,24 @@ void HandlePragma(const char **tokens, int numTokens)
 
 void StoreStr(char *string)
 {
+    SETUP_CONTEXT(cpp);
     TString strSrc;
     strSrc = TString(string);
 
-    ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
+    context->HashErrMsg = context->HashErrMsg + " " + strSrc;
 }
 
 const char* GetStrfromTStr(void)
 {
-    cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
+    SETUP_CONTEXT(cpp);
+    cpp->ErrMsg = context->HashErrMsg.c_str();
     return cpp->ErrMsg;
 }
 
 void ResetTString(void)
 {
-    ((TParseContext *)cpp->pC)->HashErrMsg = "";
+    SETUP_CONTEXT(cpp);
+    context->HashErrMsg = "";
 }
 
 TBehavior GetBehavior(const char* behavior)
@@ -557,8 +451,9 @@ TBehavior GetBehavior(const char* behavior)
     }        
 }
 
-void  updateExtensionBehavior(const char* extName, const char* behavior)
+void updateExtensionBehavior(const char* extName, const char* behavior)
 {
+    SETUP_CONTEXT(cpp);
     TBehavior behaviorVal = GetBehavior(behavior);
     TMap<TString, TBehavior>:: iterator iter;
     TString msg;
@@ -569,12 +464,12 @@ void  updateExtensionBehavior(const char* extName, const char* behavior)
             CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");  
             return;
         } else {
-            for (iter =  ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
+            for (iter = context->extensionBehavior.begin(); iter != context->extensionBehavior.end(); ++iter)
                 iter->second = behaviorVal;
         }        
     } else {
-        iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
-        if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
+        iter = context->extensionBehavior.find(TString(extName));
+        if (iter == context->extensionBehavior.end()) {
             switch (behaviorVal) {
             case EBhRequire:
                 CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());  
@@ -583,7 +478,7 @@ void  updateExtensionBehavior(const char* extName, const char* behavior)
             case EBhWarn:
             case EBhDisable:
                 msg = TString("extension '") + extName + "' is not supported";
-                ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); 
+                context->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); 
                 break;
             }
             return;
@@ -591,10 +486,85 @@ void  updateExtensionBehavior(const char* extName, const char* behavior)
             iter->second = behaviorVal;
     }
 }
-        
 }  // extern "C"
 
-void setInitialState()
-{
-    yy_start = 1;
+int string_input(char* buf, int max_size, yyscan_t yyscanner) {
+    int len;
+
+    if ((len = yylex_CPP(buf, max_size)) == 0)
+        return 0;
+    if (len >= max_size) 
+        YY_FATAL_ERROR("input buffer overflow, can't enlarge buffer because scanner uses REJECT");
+
+    buf[len] = ' ';
+    return len+1;
+}
+
+int check_type(yyscan_t yyscanner) {
+    struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
+    
+    int token = IDENTIFIER;
+    TSymbol* symbol = yyextra->symbolTable.find(yytext);
+    if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
+        TVariable* variable = static_cast<TVariable*>(symbol);
+        if (variable->isUserType()) {
+            yyextra->lexAfterType = true;
+            token = TYPE_NAME;
+        }
+    }
+    yylval->lex.symbol = symbol;
+    return token;
+}
+
+int reserved_word(yyscan_t yyscanner) {
+    struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
+
+    yyextra->error(yylineno, "Illegal use of reserved word", yytext, "");
+    yyextra->recover();
+    return 0;
 }
+
+void yyerror(TParseContext* context, const char* reason) {
+    struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
+
+    if (context->AfterEOF) {
+        context->error(yylineno, reason, "unexpected EOF", "");
+    } else {
+        context->error(yylineno, reason, yytext, "");
+    }
+    context->recover();
+}
+
+int glslang_initialize(TParseContext* context) {
+    yyscan_t scanner = NULL;
+    if (yylex_init_extra(context, &scanner))
+        return 1;
+
+    context->scanner = scanner;
+    return 0;
+}
+
+int glslang_finalize(TParseContext* context) {
+    yyscan_t scanner = context->scanner;
+    if (scanner == NULL) return 0;
+    
+    context->scanner = NULL;
+    return yylex_destroy(scanner);
+}
+
+void glslang_scan(int count, const char* const string[], const int length[],
+                  TParseContext* context) {
+    yyrestart(NULL, context->scanner);
+    yyset_lineno(EncodeSourceLoc(0, 1), context->scanner);
+    context->AfterEOF = false;
+    
+    // Init preprocessor.
+    cpp->pC = context;
+    cpp->PaWhichStr = 0;
+    cpp->PaArgv     = string;
+    cpp->PaArgc     = count;
+    cpp->PaStrLen   = length;
+    cpp->pastFirstStatement = 0;
+    ScanFromString(string[0]);
+}
+
index d0d29df45132f45ff904d86dbdf7089ca5acb099..5eae4b56ce5a097d2ad36e0b2fee70e004da0579 100644 (file)
@@ -1,89 +1,38 @@
+/*
 //
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
-/**
- * This is bison grammar and production code for parsing the OpenGL 2.0 shading
- * languages.
- */
-%{
-
-/* Based on:
-ANSI C Yacc grammar
+This file contains the Yacc grammar for GLSL ES.
+Based on ANSI C Yacc grammar:
+http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
 
-In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
-matching Lex specification) for the April 30, 1985 draft version of the
-ANSI C standard.  Tom Stockfisch reposted it to net.sources in 1987; that
-original, as mentioned in the answer to question 17.25 of the comp.lang.c
-FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
+IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh,
+WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
+*/
 
-I intend to keep this version as close to the current C Standard grammar as
-possible; please let me know if you discover discrepancies.
+%{
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
 
-Jutta Degener, 1995
-*/
+// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
 
 #include "compiler/SymbolTable.h"
 #include "compiler/ParseHelper.h"
 #include "GLSLANG/ShaderLang.h"
 
-#define YYPARSE_PARAM parseContextLocal
-/*
-TODO(alokp): YYPARSE_PARAM_DECL is only here to support old bison.exe in
-compiler/tools. Remove it when we can exclusively use the newer version.
-*/
-#define YYPARSE_PARAM_DECL void*
-#define parseContext ((TParseContext*)(parseContextLocal))
-#define YYLEX_PARAM parseContextLocal
-#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
-extern void yyerror(const char*);
-
-#define FRAG_VERT_ONLY(S, L) {                                                  \
-    if (parseContext->language != EShLangFragment &&                             \
-        parseContext->language != EShLangVertex) {                               \
-        parseContext->error(L, " supported in vertex/fragment shaders only ", S, "", "");   \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
-
-#define VERTEX_ONLY(S, L) {                                                     \
-    if (parseContext->language != EShLangVertex) {                               \
-        parseContext->error(L, " supported in vertex shaders only ", S, "", "");            \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
-
-#define FRAG_ONLY(S, L) {                                                       \
-    if (parseContext->language != EShLangFragment) {                             \
-        parseContext->error(L, " supported in fragment shaders only ", S, "", "");          \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
-
-#define PACK_ONLY(S, L) {                                                       \
-    if (parseContext->language != EShLangPack) {                                 \
-        parseContext->error(L, " supported in pack shaders only ", S, "", "");              \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
+#define YYLEX_PARAM context->scanner
+%}
 
-#define UNPACK_ONLY(S, L) {                                                     \
-    if (parseContext->language != EShLangUnpack) {                               \
-        parseContext->error(L, " supported in unpack shaders only ", S, "", "");            \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
+%expect 1 /* One shift reduce conflict because of if | else */
+%pure-parser
+%parse-param {TParseContext* context}
 
-#define PACK_UNPACK_ONLY(S, L) {                                                \
-    if (parseContext->language != EShLangUnpack &&                               \
-        parseContext->language != EShLangPack) {                                 \
-        parseContext->error(L, " supported in pack/unpack shaders only ", S, "", "");       \
-        parseContext->recover();                                                            \
-    }                                                                           \
-}
-%}
 %union {
     struct {
         TSourceLoc line;
@@ -117,11 +66,32 @@ extern void yyerror(const char*);
 }
 
 %{
-    extern int yylex(YYSTYPE*, void*);
+extern int yylex(YYSTYPE* yylval_param, void* yyscanner);
+extern void yyerror(TParseContext* context, const char* reason);
+
+#define FRAG_VERT_ONLY(S, L) {  \
+    if (context->shaderType != SH_FRAGMENT_SHADER &&  \
+        context->shaderType != SH_VERTEX_SHADER) {  \
+        context->error(L, " supported in vertex/fragment shaders only ", S, "", "");  \
+        context->recover();  \
+    }  \
+}
+
+#define VERTEX_ONLY(S, L) {  \
+    if (context->shaderType != SH_VERTEX_SHADER) {  \
+        context->error(L, " supported in vertex shaders only ", S, "", "");  \
+        context->recover();  \
+    }  \
+}
+
+#define FRAG_ONLY(S, L) {  \
+    if (context->shaderType != SH_FRAGMENT_SHADER) {  \
+        context->error(L, " supported in fragment shaders only ", S, "", "");  \
+        context->recover();  \
+    }  \
+}
 %}
 
-%pure_parser /* Just in case is called from multiple threads */
-%expect 1 /* One shift reduce conflict because of if | else */
 %token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
 %token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
 %token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN
@@ -185,17 +155,17 @@ variable_identifier
         const TSymbol* symbol = $1.symbol;
         const TVariable* variable;
         if (symbol == 0) {
-            parseContext->error($1.line, "undeclared identifier", $1.string->c_str(), "");
-            parseContext->recover();
+            context->error($1.line, "undeclared identifier", $1.string->c_str(), "");
+            context->recover();
             TType type(EbtFloat, EbpUndefined);
             TVariable* fakeVariable = new TVariable($1.string, type);
-            parseContext->symbolTable.insert(*fakeVariable);
+            context->symbolTable.insert(*fakeVariable);
             variable = fakeVariable;
         } else {
             // This identifier can only be a variable type symbol
             if (! symbol->isVariable()) {
-                parseContext->error($1.line, "variable expected", $1.string->c_str(), "");
-                parseContext->recover();
+                context->error($1.line, "variable expected", $1.string->c_str(), "");
+                context->recover();
             }
             variable = static_cast<const TVariable*>(symbol);
         }
@@ -206,9 +176,9 @@ variable_identifier
         if (variable->getType().getQualifier() == EvqConst ) {
             ConstantUnion* constArray = variable->getConstPointer();
             TType t(variable->getType());
-            $$ = parseContext->intermediate.addConstantUnion(constArray, t, $1.line);
+            $$ = context->intermediate.addConstantUnion(constArray, t, $1.line);
         } else
-            $$ = parseContext->intermediate.addSymbol(variable->getUniqueId(),
+            $$ = context->intermediate.addSymbol(variable->getUniqueId(),
                                                      variable->getName(),
                                                      variable->getType(), $1.line);
     }
@@ -224,22 +194,22 @@ primary_expression
         // check for overflow for constants
         //
         if (abs($1.i) >= (1 << 16)) {
-            parseContext->error($1.line, " integer constant overflow", "", "");
-            parseContext->recover();
+            context->error($1.line, " integer constant overflow", "", "");
+            context->recover();
         }
         ConstantUnion *unionArray = new ConstantUnion[1];
         unionArray->setIConst($1.i);
-        $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line);
+        $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line);
     }
     | FLOATCONSTANT {
         ConstantUnion *unionArray = new ConstantUnion[1];
         unionArray->setFConst($1.f);
-        $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
+        $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
     }
     | BOOLCONSTANT {
         ConstantUnion *unionArray = new ConstantUnion[1];
         unionArray->setBConst($1.b);
-        $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line);
+        $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line);
     }
     | LEFT_PAREN expression RIGHT_PAREN {
         $$ = $2;
@@ -253,57 +223,57 @@ postfix_expression
     | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
         if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {
             if ($1->getAsSymbolNode())
-                parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
+                context->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
             else
-                parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
-            parseContext->recover();
+                context->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
+            context->recover();
         }
         if ($1->getType().getQualifier() == EvqConst && $3->getQualifier() == EvqConst) {
             if ($1->isArray()) { // constant folding for arrays
-                $$ = parseContext->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
+                $$ = context->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
             } else if ($1->isVector()) {  // constant folding for vectors
                 TVectorFields fields;
                 fields.num = 1;
                 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);
+                $$ = context->addConstVectorNode(fields, $1, $2.line);
             } else if ($1->isMatrix()) { // constant folding for matrices
-                $$ = parseContext->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
+                $$ = context->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
             }
         } else {
             if ($3->getQualifier() == EvqConst) {
                 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->recover();
+                    context->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
+                    context->recover();
                 } else {
                     if ($1->isArray()) {
                         if ($1->getType().getArraySize() == 0) {
                             if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) {
-                                if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line))
-                                    parseContext->recover();
+                                if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line))
+                                    context->recover();
                             } else {
-                                if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
-                                    parseContext->recover();
+                                if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
+                                    context->recover();
                             }
                         } else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= $1->getType().getArraySize()) {
-                            parseContext->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
-                            parseContext->recover();
+                            context->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
+                            context->recover();
                         }
                     }
-                    $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
+                    $$ = context->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
                 }
             } else {
                 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->recover();
+                    context->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
+                    context->recover();
                 }
 
-                $$ = parseContext->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
+                $$ = context->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
             }
         }
         if ($$ == 0) {
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setFConst(0.0f);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line);
         } else if ($1->isArray()) {
             if ($1->getType().getStruct())
                 $$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName()));
@@ -328,22 +298,22 @@ postfix_expression
     }
     | postfix_expression DOT FIELD_SELECTION {
         if ($1->isArray()) {
-            parseContext->error($3.line, "cannot apply dot operator to an array", ".", "");
-            parseContext->recover();
+            context->error($3.line, "cannot apply dot operator to an array", ".", "");
+            context->recover();
         }
 
         if ($1->isVector()) {
             TVectorFields fields;
-            if (! parseContext->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
+            if (! context->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
                 fields.num = 1;
                 fields.offsets[0] = 0;
-                parseContext->recover();
+                context->recover();
             }
 
             if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields
-                $$ = parseContext->addConstVectorNode(fields, $1, $3.line);
+                $$ = context->addConstVectorNode(fields, $1, $3.line);
                 if ($$ == 0) {
-                    parseContext->recover();
+                    context->recover();
                     $$ = $1;
                 }
                 else
@@ -352,47 +322,47 @@ postfix_expression
                 if (fields.num == 1) {
                     ConstantUnion *unionArray = new ConstantUnion[1];
                     unionArray->setIConst(fields.offsets[0]);
-                    TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
-                    $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+                    TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
+                    $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
                     $$->setType(TType($1->getBasicType(), $1->getPrecision()));
                 } else {
                     TString vectorString = *$3.string;
-                    TIntermTyped* index = parseContext->intermediate.addSwizzle(fields, $3.line);
-                    $$ = parseContext->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
+                    TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line);
+                    $$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
                     $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size()));
                 }
             }
         } else if ($1->isMatrix()) {
             TMatrixFields fields;
-            if (! parseContext->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
+            if (! context->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
                 fields.wholeRow = false;
                 fields.wholeCol = false;
                 fields.row = 0;
                 fields.col = 0;
-                parseContext->recover();
+                context->recover();
             }
 
             if (fields.wholeRow || fields.wholeCol) {
-                parseContext->error($2.line, " non-scalar fields not implemented yet", ".", "");
-                parseContext->recover();
+                context->error($2.line, " non-scalar fields not implemented yet", ".", "");
+                context->recover();
                 ConstantUnion *unionArray = new ConstantUnion[1];
                 unionArray->setIConst(0);
-                TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
-                $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
+                $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
                 $$->setType(TType($1->getBasicType(), $1->getPrecision(),EvqTemporary, $1->getNominalSize()));
             } else {
                 ConstantUnion *unionArray = new ConstantUnion[1];
                 unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row);
-                TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
-                $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
+                $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
                 $$->setType(TType($1->getBasicType(), $1->getPrecision()));
             }
         } else if ($1->getBasicType() == EbtStruct) {
             bool fieldFound = false;
             const TTypeList* fields = $1->getType().getStruct();
             if (fields == 0) {
-                parseContext->error($2.line, "structure has no fields", "Internal Error", "");
-                parseContext->recover();
+                context->error($2.line, "structure has no fields", "Internal Error", "");
+                context->recover();
                 $$ = $1;
             } else {
                 unsigned int i;
@@ -404,9 +374,9 @@ postfix_expression
                 }
                 if (fieldFound) {
                     if ($1->getType().getQualifier() == EvqConst) {
-                        $$ = parseContext->addConstStruct(*$3.string, $1, $2.line);
+                        $$ = context->addConstStruct(*$3.string, $1, $2.line);
                         if ($$ == 0) {
-                            parseContext->recover();
+                            context->recover();
                             $$ = $1;
                         }
                         else {
@@ -418,40 +388,40 @@ postfix_expression
                     } else {
                         ConstantUnion *unionArray = new ConstantUnion[1];
                         unionArray->setIConst(i);
-                        TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
-                        $$ = parseContext->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
+                        TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
+                        $$ = context->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
                         $$->setType(*(*fields)[i].type);
                     }
                 } else {
-                    parseContext->error($2.line, " no such field in structure", $3.string->c_str(), "");
-                    parseContext->recover();
+                    context->error($2.line, " no such field in structure", $3.string->c_str(), "");
+                    context->recover();
                     $$ = $1;
                 }
             }
         } else {
-            parseContext->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
-            parseContext->recover();
+            context->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
+            context->recover();
             $$ = $1;
         }
         // don't delete $3.string, it's from the pool
     }
     | postfix_expression INC_OP {
-        if (parseContext->lValueErrorCheck($2.line, "++", $1))
-            parseContext->recover();
-        $$ = parseContext->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext->symbolTable);
+        if (context->lValueErrorCheck($2.line, "++", $1))
+            context->recover();
+        $$ = context->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->unaryOpError($2.line, "++", $1->getCompleteString());
-            parseContext->recover();
+            context->unaryOpError($2.line, "++", $1->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
     | postfix_expression DEC_OP {
-        if (parseContext->lValueErrorCheck($2.line, "--", $1))
-            parseContext->recover();
-        $$ = parseContext->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext->symbolTable);
+        if (context->lValueErrorCheck($2.line, "--", $1))
+            context->recover();
+        $$ = context->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->unaryOpError($2.line, "--", $1->getCompleteString());
-            parseContext->recover();
+            context->unaryOpError($2.line, "--", $1->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
@@ -459,8 +429,8 @@ postfix_expression
 
 integer_expression
     : expression {
-        if (parseContext->integerErrorCheck($1, "[]"))
-            parseContext->recover();
+        if (context->integerErrorCheck($1, "[]"))
+            context->recover();
         $$ = $1;
     }
     ;
@@ -478,18 +448,18 @@ function_call
             // Their parameters will be verified algorithmically.
             //
             TType type(EbtVoid, EbpUndefined);  // use this to get the type back
-            if (parseContext->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
+            if (context->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
                 $$ = 0;
             } else {
                 //
                 // It's a constructor, of type 'type'.
                 //
-                $$ = parseContext->addConstructor($1.intermNode, &type, op, fnCall, $1.line);
+                $$ = context->addConstructor($1.intermNode, &type, op, fnCall, $1.line);
             }
 
             if ($$ == 0) {
-                parseContext->recover();
-                $$ = parseContext->intermediate.setAggregateOperator(0, op, $1.line);
+                context->recover();
+                $$ = context->intermediate.setAggregateOperator(0, op, $1.line);
             }
             $$->setType(type);
         } else {
@@ -498,12 +468,15 @@ function_call
             //
             const TFunction* fnCandidate;
             bool builtIn;
-            fnCandidate = parseContext->findFunction($1.line, fnCall, &builtIn);
+            fnCandidate = context->findFunction($1.line, fnCall, &builtIn);
             if (fnCandidate) {
                 //
-                // A declared function.  But, it might still map to a built-in
-                // operation.
+                // A declared function.
                 //
+                if (builtIn && !fnCandidate->getExtension().empty() &&
+                    context->extensionErrorCheck($1.line, fnCandidate->getExtension())) {
+                    context->recover();
+                }
                 op = fnCandidate->getBuiltInOp();
                 if (builtIn && op != EOpNull) {
                     //
@@ -513,20 +486,20 @@ function_call
                         //
                         // Treat it like a built-in unary operator.
                         //
-                        $$ = parseContext->intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext->symbolTable);
+                        $$ = context->intermediate.addUnaryMath(op, $1.intermNode, 0, context->symbolTable);
                         if ($$ == 0)  {
-                            parseContext->error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
+                            context->error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
                                 "built in unary operator function.  Type: %s",
                                 static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str());
                             YYERROR;
                         }
                     } else {
-                        $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
+                        $$ = context->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
                     }
                 } else {
                     // This is a real function call
 
-                    $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
+                    $$ = context->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
                     $$->setType(fnCandidate->getReturnType());
 
                     // this is how we know whether the given function is a builtIn function or a user defined function
@@ -537,16 +510,14 @@ function_call
                     $$->getAsAggregate()->setName(fnCandidate->getMangledName());
 
                     TQualifier qual;
-                    TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier();
                     for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
-                        qual = (*fnCandidate)[i].type->getQualifier();
+                        qual = fnCandidate->getParam(i).type->getQualifier();
                         if (qual == EvqOut || qual == EvqInOut) {
-                            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->recover();
+                            if (context->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
+                                context->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
+                                context->recover();
                             }
                         }
-                        qualifierList.push_back(qual);
                     }
                 }
                 $$->setType(fnCandidate->getReturnType());
@@ -555,8 +526,8 @@ function_call
                 // Put on a dummy node for error recovery
                 ConstantUnion *unionArray = new ConstantUnion[1];
                 unionArray->setFConst(0.0f);
-                $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
-                parseContext->recover();
+                $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
+                context->recover();
             }
         }
         delete fnCall;
@@ -568,8 +539,8 @@ function_call_or_method
         $$ = $1;
     }
     | postfix_expression DOT function_call_generic {
-        parseContext->error($3.line, "methods are not supported", "", "");
-        parseContext->recover();
+        context->error($3.line, "methods are not supported", "", "");
+        context->recover();
         $$ = $3;
     }
     ;
@@ -607,7 +578,7 @@ function_call_header_with_parameters
         TParameter param = { 0, new TType($3->getType()) };
         $1.function->addParameter(param);
         $$.function = $1.function;
-        $$.intermNode = parseContext->intermediate.growAggregate($1.intermNode, $3, $2.line);
+        $$.intermNode = context->intermediate.growAggregate($1.intermNode, $3, $2.line);
     }
     ;
 
@@ -625,19 +596,16 @@ function_identifier
         // Constructor
         //
         if ($1.array) {
-            if (parseContext->extensionErrorCheck($1.line, "GL_3DL_array_objects")) {
-                parseContext->recover();
-                $1.setArray(false);
-            }
+            // Constructors for arrays are not allowed.
+            context->error($1.line, "cannot construct this type", "array", "");
+            context->recover();
+            $1.setArray(false);
         }
 
+        TOperator op = EOpNull;
         if ($1.userDef) {
-            TString tempString = "";
-            TType type($1);
-            TFunction *function = new TFunction(&tempString, type, EOpConstructStruct);
-            $$ = function;
+            op = EOpConstructStruct;
         } else {
-            TOperator op = EOpNull;
             switch ($1.type) {
             case EbtFloat:
                 if ($1.matrix) {
@@ -671,29 +639,30 @@ function_identifier
                 case 4:       FRAG_VERT_ONLY("bvec4", $1.line); op = EOpConstructBVec4; break;
                 }
                 break;
+            default: break;
             }
             if (op == EOpNull) {
-                parseContext->error($1.line, "cannot construct this type", getBasicString($1.type), "");
-                parseContext->recover();
+                context->error($1.line, "cannot construct this type", getBasicString($1.type), "");
+                context->recover();
                 $1.type = EbtFloat;
                 op = EOpConstructFloat;
             }
-            TString tempString = "";
-            TType type($1);
-            TFunction *function = new TFunction(&tempString, type, op);
-            $$ = function;
         }
+        TString tempString;
+        TType type($1);
+        TFunction *function = new TFunction(&tempString, type, op);
+        $$ = function;
     }
     | IDENTIFIER {
-        if (parseContext->reservedErrorCheck($1.line, *$1.string))
-            parseContext->recover();
+        if (context->reservedErrorCheck($1.line, *$1.string))
+            context->recover();
         TType type(EbtVoid, EbpUndefined);
         TFunction *function = new TFunction($1.string, type);
         $$ = function;
     }
     | FIELD_SELECTION {
-        if (parseContext->reservedErrorCheck($1.line, *$1.string))
-            parseContext->recover();
+        if (context->reservedErrorCheck($1.line, *$1.string))
+            context->recover();
         TType type(EbtVoid, EbpUndefined);
         TFunction *function = new TFunction($1.string, type);
         $$ = function;
@@ -705,28 +674,28 @@ unary_expression
         $$ = $1;
     }
     | INC_OP unary_expression {
-        if (parseContext->lValueErrorCheck($1.line, "++", $2))
-            parseContext->recover();
-        $$ = parseContext->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext->symbolTable);
+        if (context->lValueErrorCheck($1.line, "++", $2))
+            context->recover();
+        $$ = context->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->unaryOpError($1.line, "++", $2->getCompleteString());
-            parseContext->recover();
+            context->unaryOpError($1.line, "++", $2->getCompleteString());
+            context->recover();
             $$ = $2;
         }
     }
     | DEC_OP unary_expression {
-        if (parseContext->lValueErrorCheck($1.line, "--", $2))
-            parseContext->recover();
-        $$ = parseContext->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext->symbolTable);
+        if (context->lValueErrorCheck($1.line, "--", $2))
+            context->recover();
+        $$ = context->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->unaryOpError($1.line, "--", $2->getCompleteString());
-            parseContext->recover();
+            context->unaryOpError($1.line, "--", $2->getCompleteString());
+            context->recover();
             $$ = $2;
         }
     }
     | unary_operator unary_expression {
         if ($1.op != EOpNull) {
-            $$ = parseContext->intermediate.addUnaryMath($1.op, $2, $1.line, parseContext->symbolTable);
+            $$ = context->intermediate.addUnaryMath($1.op, $2, $1.line, context->symbolTable);
             if ($$ == 0) {
                 const char* errorOp = "";
                 switch($1.op) {
@@ -734,8 +703,8 @@ unary_expression
                 case EOpLogicalNot: errorOp = "!"; break;
                 default: break;
                 }
-                parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString());
-                parseContext->recover();
+                context->unaryOpError($1.line, errorOp, $2->getCompleteString());
+                context->recover();
                 $$ = $2;
             }
         } else
@@ -755,19 +724,19 @@ multiplicative_expression
     : unary_expression { $$ = $1; }
     | multiplicative_expression STAR unary_expression {
         FRAG_VERT_ONLY("*", $2.line);
-        $$ = parseContext->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
     | multiplicative_expression SLASH unary_expression {
         FRAG_VERT_ONLY("/", $2.line);
-        $$ = parseContext->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
@@ -776,18 +745,18 @@ multiplicative_expression
 additive_expression
     : multiplicative_expression { $$ = $1; }
     | additive_expression PLUS multiplicative_expression {
-        $$ = parseContext->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
     | additive_expression DASH multiplicative_expression {
-        $$ = parseContext->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $1;
         }
     }
@@ -800,43 +769,43 @@ shift_expression
 relational_expression
     : shift_expression { $$ = $1; }
     | relational_expression LEFT_ANGLE shift_expression {
-        $$ = parseContext->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     | relational_expression RIGHT_ANGLE shift_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     | relational_expression LE_OP shift_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     | relational_expression GE_OP shift_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     ;
@@ -844,26 +813,24 @@ relational_expression
 equality_expression
     : relational_expression { $$ = $1; }
     | equality_expression EQ_OP relational_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
-        } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
-            parseContext->recover();
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+        }
     }
     | equality_expression NE_OP relational_expression {
-        $$ = parseContext->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
-        } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
-            parseContext->recover();
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+        }
     }
     ;
 
@@ -882,13 +849,13 @@ inclusive_or_expression
 logical_and_expression
     : inclusive_or_expression { $$ = $1; }
     | logical_and_expression AND_OP inclusive_or_expression {
-        $$ = parseContext->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     ;
@@ -896,13 +863,13 @@ logical_and_expression
 logical_xor_expression
     : logical_and_expression { $$ = $1; }
     | logical_xor_expression XOR_OP logical_and_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     ;
@@ -910,13 +877,13 @@ logical_xor_expression
 logical_or_expression
     : logical_xor_expression { $$ = $1; }
     | logical_or_expression OR_OP logical_xor_expression  {
-        $$ = parseContext->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext->symbolTable);
+        $$ = context->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, context->symbolTable);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             ConstantUnion *unionArray = new ConstantUnion[1];
             unionArray->setBConst(false);
-            $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
+            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
         }
     }
     ;
@@ -924,16 +891,16 @@ logical_or_expression
 conditional_expression
     : logical_or_expression { $$ = $1; }
     | logical_or_expression QUESTION expression COLON assignment_expression {
-       if (parseContext->boolErrorCheck($2.line, $1))
-            parseContext->recover();
+       if (context->boolErrorCheck($2.line, $1))
+            context->recover();
 
-        $$ = parseContext->intermediate.addSelection($1, $3, $5, $2.line);
+        $$ = context->intermediate.addSelection($1, $3, $5, $2.line);
         if ($3->getType() != $5->getType())
             $$ = 0;
 
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
+            context->recover();
             $$ = $5;
         }
     }
@@ -942,15 +909,14 @@ conditional_expression
 assignment_expression
     : conditional_expression { $$ = $1; }
     | unary_expression assignment_operator assignment_expression {
-        if (parseContext->lValueErrorCheck($2.line, "assign", $1))
-            parseContext->recover();
-        $$ = parseContext->intermediate.addAssign($2.op, $1, $3, $2.line);
+        if (context->lValueErrorCheck($2.line, "assign", $1))
+            context->recover();
+        $$ = context->intermediate.addAssign($2.op, $1, $3, $2.line);
         if ($$ == 0) {
-            parseContext->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $1;
-        } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects"))
-            parseContext->recover();
+        }
     }
     ;
 
@@ -967,10 +933,10 @@ expression
         $$ = $1;
     }
     | expression COMMA assignment_expression {
-        $$ = parseContext->intermediate.addComma($1, $3, $2.line);
+        $$ = context->intermediate.addComma($1, $3, $2.line);
         if ($$ == 0) {
-            parseContext->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
-            parseContext->recover();
+            context->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
+            context->recover();
             $$ = $3;
         }
     }
@@ -978,8 +944,8 @@ expression
 
 constant_expression
     : conditional_expression {
-        if (parseContext->constErrorCheck($1))
-            parseContext->recover();
+        if (context->constErrorCheck($1))
+            context->recover();
         $$ = $1;
     }
     ;
@@ -994,16 +960,16 @@ declaration
         
         for (int i = 0; i < function.getParamCount(); i++)
         {
-            TParameter &param = function[i];
+            const TParameter &param = function.getParam(i);
             if (param.name != 0)
             {
                 TVariable *variable = new TVariable(param.name, *param.type);
                 
-                prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line);
+                prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line);
             }
             else
             {
-                prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
+                prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
             }
         }
         
@@ -1016,7 +982,7 @@ declaration
         $$ = $1.intermAggregate;
     }
     | PRECISION precision_qualifier type_specifier_no_prec SEMICOLON {
-        parseContext->symbolTable.setDefaultPrecision( $3.type, $2 );
+        context->symbolTable.setDefaultPrecision( $3.type, $2 );
         $$ = 0;
     }
     ;
@@ -1031,16 +997,16 @@ function_prototype
         //
         // 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*>(context->symbolTable.find($1->getMangledName()));
         if (prevDec) {
             if (prevDec->getReturnType() != $1->getReturnType()) {
-                parseContext->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
-                parseContext->recover();
+                context->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
+                context->recover();
             }
             for (int i = 0; i < prevDec->getParamCount(); ++i) {
-                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->recover();
+                if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) {
+                    context->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), "");
+                    context->recover();
                 }
             }
         }
@@ -1053,7 +1019,7 @@ function_prototype
         $$.function = $1;
         $$.line = $2.line;
 
-        parseContext->symbolTable.insert(*$$.function);
+        context->symbolTable.insert(*$$.function);
     }
     ;
 
@@ -1085,8 +1051,8 @@ function_header_with_parameters
             //
             // This parameter > first is void
             //
-            parseContext->error($2.line, "cannot be an argument type except for '(void)'", "void", "");
-            parseContext->recover();
+            context->error($2.line, "cannot be an argument type except for '(void)'", "void", "");
+            context->recover();
             delete $3.param.type;
         } else {
             // Add the parameter
@@ -1099,12 +1065,12 @@ function_header_with_parameters
 function_header
     : fully_specified_type IDENTIFIER LEFT_PAREN {
         if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) {
-            parseContext->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
-            parseContext->recover();
+            context->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
+            context->recover();
         }
         // make sure a sampler is not involved as well...
-        if (parseContext->structQualifierErrorCheck($2.line, $1))
-            parseContext->recover();
+        if (context->structQualifierErrorCheck($2.line, $1))
+            context->recover();
 
         // Add the function as a prototype after parsing it (we do not support recursion)
         TFunction *function;
@@ -1118,26 +1084,26 @@ parameter_declarator
     // Type + name
     : type_specifier IDENTIFIER {
         if ($1.type == EbtVoid) {
-            parseContext->error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
-            parseContext->recover();
+            context->error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
+            context->recover();
         }
-        if (parseContext->reservedErrorCheck($2.line, *$2.string))
-            parseContext->recover();
+        if (context->reservedErrorCheck($2.line, *$2.string))
+            context->recover();
         TParameter param = {$2.string, new TType($1)};
         $$.line = $2.line;
         $$.param = param;
     }
     | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
         // Check that we can make an array out of this type
-        if (parseContext->arrayTypeErrorCheck($3.line, $1))
-            parseContext->recover();
+        if (context->arrayTypeErrorCheck($3.line, $1))
+            context->recover();
 
-        if (parseContext->reservedErrorCheck($2.line, *$2.string))
-            parseContext->recover();
+        if (context->reservedErrorCheck($2.line, *$2.string))
+            context->recover();
 
         int size;
-        if (parseContext->arraySizeErrorCheck($3.line, $4, size))
-            parseContext->recover();
+        if (context->arraySizeErrorCheck($3.line, $4, size))
+            context->recover();
         $1.setArray(true, size);
 
         TType* type = new TType($1);
@@ -1158,30 +1124,30 @@ parameter_declaration
     //
     : type_qualifier parameter_qualifier parameter_declarator {
         $$ = $3;
-        if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
-            parseContext->recover();
+        if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
+            context->recover();
     }
     | parameter_qualifier parameter_declarator {
         $$ = $2;
-        if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
-            parseContext->recover();
-        if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
-            parseContext->recover();
+        if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
+            context->recover();
+        if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
+            context->recover();
     }
     //
     // Only type
     //
     | type_qualifier parameter_qualifier parameter_type_specifier {
         $$ = $3;
-        if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
-            parseContext->recover();
+        if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
+            context->recover();
     }
     | parameter_qualifier parameter_type_specifier {
         $$ = $2;
-        if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
-            parseContext->recover();
-        if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
-            parseContext->recover();
+        if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
+            context->recover();
+        if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
+            context->recover();
     }
     ;
 
@@ -1212,152 +1178,83 @@ init_declarator_list
         $$ = $1;
         
         if ($$.type.precision == EbpUndefined) {
-            $$.type.precision = parseContext->symbolTable.getDefaultPrecision($1.type.type);
-            if (parseContext->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
-                parseContext->recover();
+            $$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type);
+            if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
+                context->recover();
             }
         }
     }
     | 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 = context->intermediate.growAggregate($1.intermNode, context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line);
         
-        if (parseContext->structQualifierErrorCheck($3.line, $$.type))
-            parseContext->recover();
+        if (context->structQualifierErrorCheck($3.line, $$.type))
+            context->recover();
 
-        if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
-            parseContext->recover();
+        if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
+            context->recover();
 
-        if (parseContext->nonInitErrorCheck($3.line, *$3.string, $$.type))
-            parseContext->recover();
+        if (context->nonInitErrorCheck($3.line, *$3.string, $$.type))
+            context->recover();
     }
     | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
-        if (parseContext->structQualifierErrorCheck($3.line, $1.type))
-            parseContext->recover();
+        if (context->structQualifierErrorCheck($3.line, $1.type))
+            context->recover();
 
-        if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
-            parseContext->recover();
+        if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
+            context->recover();
 
         $$ = $1;
 
-        if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
-            parseContext->recover();
+        if (context->arrayTypeErrorCheck($4.line, $1.type) || context->arrayQualifierErrorCheck($4.line, $1.type))
+            context->recover();
         else {
             $1.type.setArray(true);
             TVariable* variable;
-            if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
-                parseContext->recover();
+            if (context->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
+                context->recover();
         }
     }
     | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
-        if (parseContext->structQualifierErrorCheck($3.line, $1.type))
-            parseContext->recover();
+        if (context->structQualifierErrorCheck($3.line, $1.type))
+            context->recover();
 
-        if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
-            parseContext->recover();
+        if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
+        &nb