Make some portability improvements identified by Christophe: A few size_t, a couple "../Include", and a whole bunch of parenthesizing "(A && B) || (C && D)", because some compilers don't believe humans know && is higher precedence than ||.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23379 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
61c2d1410a
commit
e50441ad94
@ -32,7 +32,7 @@
|
|||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Include/InfoSink.h"
|
#include "../Include/InfoSink.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -399,8 +399,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||||||
s.append("bvec4 isinf(vec4 x);");
|
s.append("bvec4 isinf(vec4 x);");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile == EEsProfile && version >= 300 ||
|
if ((profile == EEsProfile && version >= 300) ||
|
||||||
profile != EEsProfile && version >= 330) {
|
(profile != EEsProfile && version >= 330)) {
|
||||||
s.append("int floatBitsToInt(float value);");
|
s.append("int floatBitsToInt(float value);");
|
||||||
s.append("ivec2 floatBitsToInt(vec2 value);");
|
s.append("ivec2 floatBitsToInt(vec2 value);");
|
||||||
s.append("ivec3 floatBitsToInt(vec3 value);");
|
s.append("ivec3 floatBitsToInt(vec3 value);");
|
||||||
@ -422,8 +422,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||||||
s.append("vec4 uintBitsToFloat(uvec4 value);");
|
s.append("vec4 uintBitsToFloat(uvec4 value);");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile == EEsProfile && version >= 300 ||
|
if ((profile == EEsProfile && version >= 300) ||
|
||||||
profile != EEsProfile && version >= 400) {
|
(profile != EEsProfile && version >= 400)) {
|
||||||
s.append( "highp uint packSnorm2x16 (vec2);");
|
s.append( "highp uint packSnorm2x16 (vec2);");
|
||||||
s.append( "highp vec2 unpackSnorm2x16 (highp uint);");
|
s.append( "highp vec2 unpackSnorm2x16 (highp uint);");
|
||||||
s.append( "highp uint packUnorm2x16 (vec2);");
|
s.append( "highp uint packUnorm2x16 (vec2);");
|
||||||
@ -587,8 +587,9 @@ void TBuiltIns::initialize(int version, EProfile profile)
|
|||||||
// Original-style texture functions existing in both stages.
|
// Original-style texture functions existing in both stages.
|
||||||
// (Per-stage functions below.)
|
// (Per-stage functions below.)
|
||||||
//
|
//
|
||||||
if (profile == EEsProfile && version == 100 ||
|
if ((profile == EEsProfile && version == 100) ||
|
||||||
profile == ECompatibilityProfile || version < FirstProfileVersion) {
|
profile == ECompatibilityProfile ||
|
||||||
|
version < FirstProfileVersion) {
|
||||||
s.append("vec4 texture2D(sampler2D, vec2);");
|
s.append("vec4 texture2D(sampler2D, vec2);");
|
||||||
|
|
||||||
s.append("vec4 texture2DProj(sampler2D, vec3);");
|
s.append("vec4 texture2DProj(sampler2D, vec3);");
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#ifndef _INITIALIZE_INCLUDED_
|
#ifndef _INITIALIZE_INCLUDED_
|
||||||
#define _INITIALIZE_INCLUDED_
|
#define _INITIALIZE_INCLUDED_
|
||||||
|
|
||||||
#include "Include/ResourceLimits.h"
|
#include "../Include/ResourceLimits.h"
|
||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
#include "../Include/ShHandle.h"
|
#include "../Include/ShHandle.h"
|
||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
|
@ -645,7 +645,7 @@ TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* r
|
|||||||
{
|
{
|
||||||
TIntermAggregate* aggNode = growAggregate(left, right);
|
TIntermAggregate* aggNode = growAggregate(left, right);
|
||||||
if (aggNode)
|
if (aggNode)
|
||||||
aggNode->setLoc(loc);
|
aggNode->setLoc(loc);
|
||||||
|
|
||||||
return aggNode;
|
return aggNode;
|
||||||
}
|
}
|
||||||
@ -926,8 +926,8 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
|
|||||||
numErrors += unit.numErrors;
|
numErrors += unit.numErrors;
|
||||||
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
|
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
|
||||||
|
|
||||||
if (profile != EEsProfile && unit.profile == EEsProfile ||
|
if ((profile != EEsProfile && unit.profile == EEsProfile) ||
|
||||||
profile == EEsProfile && unit.profile != EEsProfile)
|
(profile == EEsProfile && unit.profile != EEsProfile))
|
||||||
error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n");
|
error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n");
|
||||||
|
|
||||||
if (unit.treeRoot == 0)
|
if (unit.treeRoot == 0)
|
||||||
@ -985,10 +985,10 @@ void TIntermediate::mergeBodies(TInfoSink& infoSink, TIntermSequence& globals, c
|
|||||||
void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects)
|
void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects)
|
||||||
{
|
{
|
||||||
// Error check and merge the linker objects (duplicates should not be merged)
|
// Error check and merge the linker objects (duplicates should not be merged)
|
||||||
unsigned int initialNumLinkerObjects = linkerObjects.size();
|
std::size_t initialNumLinkerObjects = linkerObjects.size();
|
||||||
for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) {
|
for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) {
|
||||||
bool merge = true;
|
bool merge = true;
|
||||||
for (unsigned int linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
|
for (std::size_t linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
|
||||||
TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode();
|
TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode();
|
||||||
TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
|
TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
|
||||||
assert(symbol && unitSymbol);
|
assert(symbol && unitSymbol);
|
||||||
@ -1379,8 +1379,8 @@ bool TIntermBinary::promote()
|
|||||||
case EOpInclusiveOrAssign:
|
case EOpInclusiveOrAssign:
|
||||||
case EOpExclusiveOrAssign:
|
case EOpExclusiveOrAssign:
|
||||||
// Check for integer-only operands.
|
// Check for integer-only operands.
|
||||||
if ( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint ||
|
if (( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint) ||
|
||||||
right->getBasicType() != EbtInt && right->getBasicType() != EbtUint)
|
(right->getBasicType() != EbtInt && right->getBasicType() != EbtUint))
|
||||||
return false;
|
return false;
|
||||||
if (left->isMatrix() || right->isMatrix())
|
if (left->isMatrix() || right->isMatrix())
|
||||||
return false;
|
return false;
|
||||||
@ -1557,8 +1557,8 @@ bool TIntermBinary::promote()
|
|||||||
case EOpSubAssign:
|
case EOpSubAssign:
|
||||||
case EOpDivAssign:
|
case EOpDivAssign:
|
||||||
case EOpModAssign:
|
case EOpModAssign:
|
||||||
if (left->isMatrix() && right->isVector() ||
|
if ((left->isMatrix() && right->isVector()) ||
|
||||||
left->isVector() && right->isMatrix() ||
|
(left->isVector() && right->isMatrix()) ||
|
||||||
left->getBasicType() != right->getBasicType())
|
left->getBasicType() != right->getBasicType())
|
||||||
return false;
|
return false;
|
||||||
if (left->isMatrix() && right->isMatrix() && (left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows()))
|
if (left->isMatrix() && right->isMatrix() && (left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows()))
|
||||||
|
@ -119,7 +119,7 @@ const char* TParseContext::getPreamble()
|
|||||||
//
|
//
|
||||||
// Returns true for successful acceptance of the shader, false if any errors.
|
// Returns true for successful acceptance of the shader, false if any errors.
|
||||||
//
|
//
|
||||||
bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], int lengths[], int numStrings)
|
bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], size_t lengths[], int numStrings)
|
||||||
{
|
{
|
||||||
// empty shaders are okay
|
// empty shaders are okay
|
||||||
if (! strings || numStrings == 0 || lengths[0] == 0)
|
if (! strings || numStrings == 0 || lengths[0] == 0)
|
||||||
@ -141,7 +141,7 @@ bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], i
|
|||||||
ppContext.setShaderStrings(strings, lengths, numStrings);
|
ppContext.setShaderStrings(strings, lengths, numStrings);
|
||||||
|
|
||||||
// TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens
|
// TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens
|
||||||
int len = 0;
|
size_t len = 0;
|
||||||
while (strings[0][len] == ' ' ||
|
while (strings[0][len] == ' ' ||
|
||||||
strings[0][len] == '\t' ||
|
strings[0][len] == '\t' ||
|
||||||
strings[0][len] == '\n' ||
|
strings[0][len] == '\n' ||
|
||||||
@ -469,8 +469,8 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
|
|||||||
} else {
|
} else {
|
||||||
if (index->getQualifier().storage == EvqConst) {
|
if (index->getQualifier().storage == EvqConst) {
|
||||||
int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
|
int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
|
||||||
if (! base->isArray() && (base->isVector() && base->getType().getVectorSize() <= indexValue ||
|
if (! base->isArray() && ((base->isVector() && base->getType().getVectorSize() <= indexValue) ||
|
||||||
base->isMatrix() && base->getType().getMatrixCols() <= indexValue))
|
(base->isMatrix() && base->getType().getMatrixCols() <= indexValue)))
|
||||||
error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst());
|
error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||||
if (base->isArray()) {
|
if (base->isArray()) {
|
||||||
if (base->getType().getArraySize() == 0) {
|
if (base->getType().getArraySize() == 0) {
|
||||||
@ -1441,8 +1441,8 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
|
|||||||
|
|
||||||
if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) {
|
if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) {
|
||||||
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
|
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
|
||||||
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
|
if ((language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat) ||
|
||||||
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
|
(language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat)) {
|
||||||
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
|
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1496,11 +1496,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
|
|||||||
// Storage qualification
|
// Storage qualification
|
||||||
if (dst.storage == EvqTemporary || dst.storage == EvqGlobal)
|
if (dst.storage == EvqTemporary || dst.storage == EvqGlobal)
|
||||||
dst.storage = src.storage;
|
dst.storage = src.storage;
|
||||||
else if (dst.storage == EvqIn && src.storage == EvqOut ||
|
else if ((dst.storage == EvqIn && src.storage == EvqOut) ||
|
||||||
dst.storage == EvqOut && src.storage == EvqIn)
|
(dst.storage == EvqOut && src.storage == EvqIn))
|
||||||
dst.storage = EvqInOut;
|
dst.storage = EvqInOut;
|
||||||
else if (dst.storage == EvqIn && src.storage == EvqConst ||
|
else if ((dst.storage == EvqIn && src.storage == EvqConst) ||
|
||||||
dst.storage == EvqConst && src.storage == EvqIn)
|
(dst.storage == EvqConst && src.storage == EvqIn))
|
||||||
dst.storage = EvqConstReadOnly;
|
dst.storage = EvqConstReadOnly;
|
||||||
else if (src.storage != EvqTemporary)
|
else if (src.storage != EvqTemporary)
|
||||||
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
|
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
|
||||||
@ -1508,7 +1508,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
|
|||||||
// Precision qualifiers
|
// Precision qualifiers
|
||||||
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
|
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
|
||||||
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
|
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
|
||||||
if (dst.precision == EpqNone || force && src.precision != EpqNone)
|
if (dst.precision == EpqNone || (force && src.precision != EpqNone))
|
||||||
dst.precision = src.precision;
|
dst.precision = src.precision;
|
||||||
|
|
||||||
// Layout qualifiers
|
// Layout qualifiers
|
||||||
@ -1678,16 +1678,16 @@ void TParseContext::arrayDimError(TSourceLoc loc)
|
|||||||
|
|
||||||
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
|
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
|
||||||
{
|
{
|
||||||
if (sizes1 && sizes2 ||
|
if ((sizes1 && sizes2) ||
|
||||||
sizes1 && sizes1->isArrayOfArrays() ||
|
(sizes1 && sizes1->isArrayOfArrays()) ||
|
||||||
sizes2 && sizes2->isArrayOfArrays())
|
(sizes2 && sizes2->isArrayOfArrays()))
|
||||||
arrayDimError(loc);
|
arrayDimError(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
|
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
|
||||||
{
|
{
|
||||||
if (type && type->isArray() && sizes2 ||
|
if ((type && type->isArray() && sizes2) ||
|
||||||
sizes2 && sizes2->isArrayOfArrays())
|
(sizes2 && sizes2->isArrayOfArrays()))
|
||||||
arrayDimError(loc);
|
arrayDimError(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1815,18 +1815,18 @@ TVariable* TParseContext::redeclareBuiltin(TSourceLoc loc, const TString& identi
|
|||||||
|
|
||||||
// Potentially redeclaring a built-in variable...
|
// Potentially redeclaring a built-in variable...
|
||||||
|
|
||||||
if (identifier == "gl_FragDepth" && version >= 420 ||
|
if ((identifier == "gl_FragDepth" && version >= 420) ||
|
||||||
identifier == "gl_PerVertex" && version >= 410 ||
|
(identifier == "gl_PerVertex" && version >= 410) ||
|
||||||
identifier == "gl_PerFragment" && version >= 410 ||
|
(identifier == "gl_PerFragment" && version >= 410) ||
|
||||||
identifier == "gl_FragCoord" && version >= 150 ||
|
(identifier == "gl_FragCoord" && version >= 150) ||
|
||||||
identifier == "gl_ClipDistance" && version >= 130 ||
|
(identifier == "gl_ClipDistance" && version >= 130) ||
|
||||||
identifier == "gl_FrontColor" && version >= 130 ||
|
(identifier == "gl_FrontColor" && version >= 130) ||
|
||||||
identifier == "gl_BackColor" && version >= 130 ||
|
(identifier == "gl_BackColor" && version >= 130) ||
|
||||||
identifier == "gl_FrontSecondaryColor" && version >= 130 ||
|
(identifier == "gl_FrontSecondaryColor" && version >= 130) ||
|
||||||
identifier == "gl_BackSecondaryColor" && version >= 130 ||
|
(identifier == "gl_BackSecondaryColor" && version >= 130) ||
|
||||||
identifier == "gl_SecondaryColor" && version >= 130 ||
|
(identifier == "gl_SecondaryColor" && version >= 130) ||
|
||||||
identifier == "gl_Color" && version >= 130 && language == EShLangFragment ||
|
(identifier == "gl_Color" && version >= 130 && language == EShLangFragment) ||
|
||||||
identifier == "gl_TexCoord") {
|
identifier == "gl_TexCoord") {
|
||||||
|
|
||||||
// Find the existing symbol, if any.
|
// Find the existing symbol, if any.
|
||||||
bool builtIn;
|
bool builtIn;
|
||||||
@ -2347,7 +2347,7 @@ void TParseContext::addBlock(TSourceLoc loc, TTypeList& typeList, const TString*
|
|||||||
TQualifier memberQualifier = typeList[member].type->getQualifier();
|
TQualifier memberQualifier = typeList[member].type->getQualifier();
|
||||||
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockDefaults.storage)
|
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockDefaults.storage)
|
||||||
error(loc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), "");
|
error(loc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), "");
|
||||||
if (currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation() || memberQualifier.isAuxiliary())
|
if ((currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation()) || memberQualifier.isAuxiliary())
|
||||||
error(loc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), "");
|
error(loc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), "");
|
||||||
|
|
||||||
TBasicType basicType = typeList[member].type->getBasicType();
|
TBasicType basicType = typeList[member].type->getBasicType();
|
||||||
@ -2570,7 +2570,7 @@ TIntermNode* TParseContext::addSwitch(TSourceLoc loc, TIntermTyped* expression,
|
|||||||
wrapupSwitchSubsequence(lastStatements, 0);
|
wrapupSwitchSubsequence(lastStatements, 0);
|
||||||
|
|
||||||
if (expression == 0 ||
|
if (expression == 0 ||
|
||||||
expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint ||
|
(expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint) ||
|
||||||
expression->getType().isArray() || expression->getType().isMatrix() || expression->getType().isVector())
|
expression->getType().isArray() || expression->getType().isMatrix() || expression->getType().isVector())
|
||||||
error(loc, "condition must be a scalar integer expression", "switch", "");
|
error(loc, "condition must be a scalar integer expression", "switch", "");
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool parseShaderStrings(TPpContext&, char* strings[], int strLen[], int numStrings);
|
bool parseShaderStrings(TPpContext&, char* strings[], size_t strLen[], int numStrings);
|
||||||
void parserError(const char *s); // for bison's yyerror
|
void parserError(const char *s); // for bison's yyerror
|
||||||
|
|
||||||
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
|
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "../Include/PoolAlloc.h"
|
#include "../Include/PoolAlloc.h"
|
||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
|
|
||||||
#include "Include/InitializeGlobals.h"
|
#include "../Include/InitializeGlobals.h"
|
||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
|
|
||||||
namespace glslang {
|
namespace glslang {
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Scan.h"
|
#include "Scan.h"
|
||||||
#include "Include/Types.h"
|
#include "../Include/Types.h"
|
||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
#include "glslang_tab.cpp.h"
|
#include "glslang_tab.cpp.h"
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
@ -579,8 +579,8 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
|
|
||||||
case SWITCH:
|
case SWITCH:
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 130)
|
(parseContext.profile != EEsProfile && parseContext.version < 130))
|
||||||
reservedWord();
|
reservedWord();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -637,8 +637,8 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
|
|
||||||
case LAYOUT:
|
case LAYOUT:
|
||||||
case SHARED:
|
case SHARED:
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 140)
|
(parseContext.profile != EEsProfile && parseContext.version < 140))
|
||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -789,7 +789,7 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
case SAMPLER2DRECTSHADOW:
|
case SAMPLER2DRECTSHADOW:
|
||||||
afterType = true;
|
afterType = true;
|
||||||
if (parseContext.profile == EEsProfile ||
|
if (parseContext.profile == EEsProfile ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 140)
|
(parseContext.profile != EEsProfile && parseContext.version < 140))
|
||||||
reservedWord();
|
reservedWord();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -797,8 +797,8 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
afterType = true;
|
afterType = true;
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version == 300)
|
if (parseContext.profile == EEsProfile && parseContext.version == 300)
|
||||||
reservedWord();
|
reservedWord();
|
||||||
else if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 130)
|
(parseContext.profile != EEsProfile && parseContext.version < 130))
|
||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -806,8 +806,8 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
return es30ReservedFromGLSL(130);
|
return es30ReservedFromGLSL(130);
|
||||||
|
|
||||||
case SMOOTH:
|
case SMOOTH:
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 130)
|
(parseContext.profile != EEsProfile && parseContext.version < 130))
|
||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -825,7 +825,7 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
|
|
||||||
case PRECISE:
|
case PRECISE:
|
||||||
if (parseContext.profile == EEsProfile ||
|
if (parseContext.profile == EEsProfile ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 400)
|
(parseContext.profile != EEsProfile && parseContext.version < 400))
|
||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
@ -835,15 +835,15 @@ int TScanContext::tokenizeIdentifier()
|
|||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
case PACKED:
|
case PACKED:
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < 330)
|
(parseContext.profile != EEsProfile && parseContext.version < 330))
|
||||||
return reservedWord();
|
return reservedWord();
|
||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
|
|
||||||
case RESOURCE:
|
case RESOURCE:
|
||||||
{
|
{
|
||||||
bool reserved = parseContext.profile == EEsProfile && parseContext.version >= 300 ||
|
bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version >= 420;
|
(parseContext.profile != EEsProfile && parseContext.version >= 420);
|
||||||
return identifierOrReserved(reserved);
|
return identifierOrReserved(reserved);
|
||||||
}
|
}
|
||||||
case SUPERP:
|
case SUPERP:
|
||||||
@ -906,8 +906,8 @@ int TScanContext::identifierOrReserved(bool reserved)
|
|||||||
// but then got reserved by ES 3.0.
|
// but then got reserved by ES 3.0.
|
||||||
int TScanContext::es30ReservedFromGLSL(int version)
|
int TScanContext::es30ReservedFromGLSL(int version)
|
||||||
{
|
{
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < version) {
|
(parseContext.profile != EEsProfile && parseContext.version < version)) {
|
||||||
if (parseContext.forwardCompatible)
|
if (parseContext.forwardCompatible)
|
||||||
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
|
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
|
||||||
|
|
||||||
@ -922,8 +922,8 @@ int TScanContext::es30ReservedFromGLSL(int version)
|
|||||||
// showed up, both in an es version and a non-ES version.
|
// showed up, both in an es version and a non-ES version.
|
||||||
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
|
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
|
||||||
{
|
{
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version < esVersion ||
|
if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version < nonEsVersion) {
|
(parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
|
||||||
if (parseContext.forwardCompatible)
|
if (parseContext.forwardCompatible)
|
||||||
parseContext.warn(loc, "using future keyword", tokenText, "");
|
parseContext.warn(loc, "using future keyword", tokenText, "");
|
||||||
|
|
||||||
@ -983,8 +983,8 @@ int TScanContext::firstGenerationImage()
|
|||||||
if (parseContext.profile != EEsProfile && parseContext.version >= 420)
|
if (parseContext.profile != EEsProfile && parseContext.version >= 420)
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
if (parseContext.profile == EEsProfile && parseContext.version >= 300 ||
|
if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
|
||||||
parseContext.profile != EEsProfile && parseContext.version >= 130) {
|
(parseContext.profile != EEsProfile && parseContext.version >= 130)) {
|
||||||
reservedWord();
|
reservedWord();
|
||||||
|
|
||||||
return keyword;
|
return keyword;
|
||||||
|
@ -44,7 +44,7 @@ namespace glslang {
|
|||||||
//
|
//
|
||||||
class TInputScanner {
|
class TInputScanner {
|
||||||
public:
|
public:
|
||||||
TInputScanner(int n, const char* const i[], int L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { }
|
TInputScanner(int n, const char* const i[], size_t L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { }
|
||||||
|
|
||||||
// return of -1 means end of strings,
|
// return of -1 means end of strings,
|
||||||
// anything else is the next character
|
// anything else is the next character
|
||||||
@ -65,7 +65,7 @@ public:
|
|||||||
void advance()
|
void advance()
|
||||||
{
|
{
|
||||||
++currentChar;
|
++currentChar;
|
||||||
if (currentChar >= lengths[currentSource]) {
|
if (currentChar >= static_cast<int>(lengths[currentSource])) {
|
||||||
++currentSource;
|
++currentSource;
|
||||||
currentChar = 0;
|
currentChar = 0;
|
||||||
while (currentSource < numSources && lengths[currentSource] == 0)
|
while (currentSource < numSources && lengths[currentSource] == 0)
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
int numSources; // number of strings in source
|
int numSources; // number of strings in source
|
||||||
const char* const *sources; // array of strings
|
const char* const *sources; // array of strings
|
||||||
const int *lengths; // length of each string
|
const size_t *lengths; // length of each string
|
||||||
int currentSource;
|
int currentSource;
|
||||||
int currentChar;
|
int currentChar;
|
||||||
};
|
};
|
||||||
|
@ -139,7 +139,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
|
|||||||
symbolTable.push();
|
symbolTable.push();
|
||||||
|
|
||||||
const char* builtInShaders[2];
|
const char* builtInShaders[2];
|
||||||
int builtInLengths[2];
|
size_t builtInLengths[2];
|
||||||
builtInShaders[0] = builtIns.c_str();
|
builtInShaders[0] = builtIns.c_str();
|
||||||
builtInLengths[0] = builtIns.size();
|
builtInLengths[0] = builtIns.size();
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ bool CompileDeferred(
|
|||||||
GetThreadPoolAllocator().push();
|
GetThreadPoolAllocator().push();
|
||||||
|
|
||||||
// move to length-based strings, rather than null-terminated strings
|
// move to length-based strings, rather than null-terminated strings
|
||||||
int* lengths = new int[numStrings];
|
size_t* lengths = new size_t[numStrings];
|
||||||
for (int s = 0; s < numStrings; ++s) {
|
for (int s = 0; s < numStrings; ++s) {
|
||||||
if (inputLengths == 0 || inputLengths[s] < 0)
|
if (inputLengths == 0 || inputLengths[s] < 0)
|
||||||
lengths[s] = strlen(shaderStrings[s]);
|
lengths[s] = strlen(shaderStrings[s]);
|
||||||
|
@ -103,7 +103,7 @@ TPpContext::~TPpContext()
|
|||||||
FreeScanner();
|
FreeScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPpContext::setPreamble(const char* p, int l)
|
void TPpContext::setPreamble(const char* p, size_t l)
|
||||||
{
|
{
|
||||||
if (p && l > 0) {
|
if (p && l > 0) {
|
||||||
// preAmble could be a hard-coded string; make writable copy
|
// preAmble could be a hard-coded string; make writable copy
|
||||||
@ -116,7 +116,7 @@ void TPpContext::setPreamble(const char* p, int l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPpContext::setShaderStrings(char* s[], int l[], int n)
|
void TPpContext::setShaderStrings(char* s[], size_t l[], int n)
|
||||||
{
|
{
|
||||||
strings = s;
|
strings = s;
|
||||||
lengths = l;
|
lengths = l;
|
||||||
|
@ -102,8 +102,8 @@ public:
|
|||||||
TPpContext(TParseContext&);
|
TPpContext(TParseContext&);
|
||||||
virtual ~TPpContext();
|
virtual ~TPpContext();
|
||||||
|
|
||||||
void setPreamble(const char* preamble, int length);
|
void setPreamble(const char* preamble, size_t length);
|
||||||
void setShaderStrings(char* strings[], int lengths[], int numStrings);
|
void setShaderStrings(char* strings[], size_t lengths[], int numStrings);
|
||||||
|
|
||||||
const char* tokenize(TPpToken* yylvalpp);
|
const char* tokenize(TPpToken* yylvalpp);
|
||||||
|
|
||||||
@ -219,12 +219,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
|
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
|
||||||
int preambleLength;
|
int preambleLength;
|
||||||
char** strings; // official strings of shader, starting a string 0 line 1
|
char** strings; // official strings of shader, starting a string 0 line 1
|
||||||
int* lengths;
|
size_t* lengths;
|
||||||
int numStrings; // how many official strings there are
|
int numStrings; // how many official strings there are
|
||||||
int currentString; // which string we're currently parsing (-1 for preamble)
|
int currentString; // which string we're currently parsing (-1 for preamble)
|
||||||
|
|
||||||
// Scanner data:
|
// Scanner data:
|
||||||
int mostRecentToken; // Most recent token seen by the scanner
|
int mostRecentToken; // Most recent token seen by the scanner
|
||||||
|
Loading…
x
Reference in New Issue
Block a user