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:
John Kessenich 2013-10-04 02:27:06 +00:00
Родитель 61c2d1410a
Коммит e50441ad94
12 изменённых файлов: 106 добавлений и 105 удалений

Просмотреть файл

@ -32,7 +32,7 @@
//POSSIBILITY OF SUCH DAMAGE.
//
#include "Include/InfoSink.h"
#include "../Include/InfoSink.h"
#include <string.h>

Просмотреть файл

@ -53,7 +53,7 @@ TBuiltIns::TBuiltIns()
prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u";
postfixes[2] = "2";
postfixes[3] = "3";
postfixes[4] = "4";
@ -399,8 +399,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("bvec4 isinf(vec4 x);");
}
if (profile == EEsProfile && version >= 300 ||
profile != EEsProfile && version >= 330) {
if ((profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && version >= 330)) {
s.append("int floatBitsToInt(float value);");
s.append("ivec2 floatBitsToInt(vec2 value);");
s.append("ivec3 floatBitsToInt(vec3 value);");
@ -422,8 +422,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("vec4 uintBitsToFloat(uvec4 value);");
}
if (profile == EEsProfile && version >= 300 ||
profile != EEsProfile && version >= 400) {
if ((profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && version >= 400)) {
s.append( "highp uint packSnorm2x16 (vec2);");
s.append( "highp vec2 unpackSnorm2x16 (highp uint);");
s.append( "highp uint packUnorm2x16 (vec2);");
@ -503,7 +503,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("float determinant(mat2 m);");
s.append("float determinant(mat3 m);");
s.append("float determinant(mat4 m);");
s.append("mat2 inverse(mat2 m);");
s.append("mat3 inverse(mat3 m);");
s.append("mat4 inverse(mat4 m);");
@ -587,8 +587,9 @@ void TBuiltIns::initialize(int version, EProfile profile)
// Original-style texture functions existing in both stages.
// (Per-stage functions below.)
//
if (profile == EEsProfile && version == 100 ||
profile == ECompatibilityProfile || version < FirstProfileVersion) {
if ((profile == EEsProfile && version == 100) ||
profile == ECompatibilityProfile ||
version < FirstProfileVersion) {
s.append("vec4 texture2D(sampler2D, vec2);");
s.append("vec4 texture2DProj(sampler2D, vec3);");
@ -597,13 +598,13 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("vec4 textureCube(samplerCube, vec3);");
}
if (profile != EEsProfile &&
if (profile != EEsProfile &&
(profile == ECompatibilityProfile || version < FirstProfileVersion)) {
s.append("vec4 texture1D(sampler1D, float);");
s.append("vec4 texture1DProj(sampler1D, vec2);");
s.append("vec4 texture1DProj(sampler1D, vec4);");
s.append("vec4 texture3D(sampler3D, vec3);");
s.append("vec4 texture3DProj(sampler3D, vec4);");
@ -1016,7 +1017,7 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
// enumerate all the types
for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler
if (image > 0 && version < 420)
continue;
@ -1055,11 +1056,11 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
//
// Now, make all the function prototypes for the type we just built...
//
//
TSampler sampler;
sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
shadow ? true : false,
sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
shadow ? true : false,
ms ? true : false);
if (image)
sampler.image = true;
@ -1067,10 +1068,10 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
TString typeName = sampler.getString();
addQueryFunctions(sampler, typeName, version, profile);
if (image)
addImageFunctions(sampler, typeName, version, profile);
else
else
addSamplingFunctions(sampler, typeName, version, profile);
}
}
@ -1192,7 +1193,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
continue;
if (extraProj && (sampler.dim == Esd3D || sampler.shadow))
continue;
TString s;
// return type
@ -1229,14 +1230,14 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
else {
s.append(",");
TBasicType t = fetch ? EbtInt : EbtFloat;
if (totalDims == 1)
if (totalDims == 1)
s.append(TType::getBasicString(t));
else {
s.append(prefixes[t]);
s.append("vec");
s.append(postfixes[totalDims]);
}
}
}
if (bias && compare)
continue;
@ -1331,7 +1332,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
s.append(builtInConstant);
@ -1350,7 +1351,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
s.append(builtInConstant);
}
@ -1507,7 +1508,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
case EShLangCompute:
// TODO: desktop functionality: support new stages
break;
default:
assert(false && "Language not supported");
break;
@ -1526,7 +1527,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.relateToOperator("outerProduct", EOpOuterProduct);
symbolTable.relateToOperator("transpose", EOpTranspose);
if (version >= 150) {
symbolTable.relateToOperator("determinant", EOpDeterminant);
symbolTable.relateToOperator("determinant", EOpDeterminant);
symbolTable.relateToOperator("inverse", EOpMatrixInverse);
}
}
@ -1637,7 +1638,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
break;
default:
default:
assert(false && "Language not supported");
}
}

Просмотреть файл

@ -37,7 +37,7 @@
#ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_
#include "Include/ResourceLimits.h"
#include "../Include/ResourceLimits.h"
#include "../Include/Common.h"
#include "../Include/ShHandle.h"
#include "SymbolTable.h"

Просмотреть файл

@ -645,7 +645,7 @@ TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* r
{
TIntermAggregate* aggNode = growAggregate(left, right);
if (aggNode)
aggNode->setLoc(loc);
aggNode->setLoc(loc);
return aggNode;
}
@ -926,8 +926,8 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
numErrors += unit.numErrors;
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
if (profile != EEsProfile && unit.profile == EEsProfile ||
profile == EEsProfile && unit.profile != EEsProfile)
if ((profile != EEsProfile && unit.profile == EEsProfile) ||
(profile == EEsProfile && unit.profile != EEsProfile))
error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n");
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)
{
// 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) {
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* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
assert(symbol && unitSymbol);
@ -1379,8 +1379,8 @@ bool TIntermBinary::promote()
case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign:
// Check for integer-only operands.
if ( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint ||
right->getBasicType() != EbtInt && right->getBasicType() != EbtUint)
if (( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint) ||
(right->getBasicType() != EbtInt && right->getBasicType() != EbtUint))
return false;
if (left->isMatrix() || right->isMatrix())
return false;
@ -1557,8 +1557,8 @@ bool TIntermBinary::promote()
case EOpSubAssign:
case EOpDivAssign:
case EOpModAssign:
if (left->isMatrix() && right->isVector() ||
left->isVector() && right->isMatrix() ||
if ((left->isMatrix() && right->isVector()) ||
(left->isVector() && right->isMatrix()) ||
left->getBasicType() != right->getBasicType())
return false;
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.
//
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
if (! strings || numStrings == 0 || lengths[0] == 0)
@ -141,7 +141,7 @@ bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], i
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
int len = 0;
size_t len = 0;
while (strings[0][len] == ' ' ||
strings[0][len] == '\t' ||
strings[0][len] == '\n' ||
@ -469,8 +469,8 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
} else {
if (index->getQualifier().storage == EvqConst) {
int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
if (! base->isArray() && (base->isVector() && base->getType().getVectorSize() <= indexValue ||
base->isMatrix() && base->getType().getMatrixCols() <= indexValue))
if (! base->isArray() && ((base->isVector() && base->getType().getVectorSize() <= indexValue) ||
(base->isMatrix() && base->getType().getMatrixCols() <= indexValue)))
error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst());
if (base->isArray()) {
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) {
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
if ((language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat) ||
(language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat)) {
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
return;
@ -1496,11 +1496,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Storage qualification
if (dst.storage == EvqTemporary || dst.storage == EvqGlobal)
dst.storage = src.storage;
else if (dst.storage == EvqIn && src.storage == EvqOut ||
dst.storage == EvqOut && src.storage == EvqIn)
else if ((dst.storage == EvqIn && src.storage == EvqOut) ||
(dst.storage == EvqOut && src.storage == EvqIn))
dst.storage = EvqInOut;
else if (dst.storage == EvqIn && src.storage == EvqConst ||
dst.storage == EvqConst && src.storage == EvqIn)
else if ((dst.storage == EvqIn && src.storage == EvqConst) ||
(dst.storage == EvqConst && src.storage == EvqIn))
dst.storage = EvqConstReadOnly;
else if (src.storage != EvqTemporary)
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
@ -1508,7 +1508,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Precision qualifiers
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
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;
// Layout qualifiers
@ -1678,16 +1678,16 @@ void TParseContext::arrayDimError(TSourceLoc loc)
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
{
if (sizes1 && sizes2 ||
sizes1 && sizes1->isArrayOfArrays() ||
sizes2 && sizes2->isArrayOfArrays())
if ((sizes1 && sizes2) ||
(sizes1 && sizes1->isArrayOfArrays()) ||
(sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc);
}
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
{
if (type && type->isArray() && sizes2 ||
sizes2 && sizes2->isArrayOfArrays())
if ((type && type->isArray() && sizes2) ||
(sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc);
}
@ -1815,18 +1815,18 @@ TVariable* TParseContext::redeclareBuiltin(TSourceLoc loc, const TString& identi
// Potentially redeclaring a built-in variable...
if (identifier == "gl_FragDepth" && version >= 420 ||
identifier == "gl_PerVertex" && version >= 410 ||
identifier == "gl_PerFragment" && version >= 410 ||
identifier == "gl_FragCoord" && version >= 150 ||
identifier == "gl_ClipDistance" && version >= 130 ||
identifier == "gl_FrontColor" && version >= 130 ||
identifier == "gl_BackColor" && version >= 130 ||
identifier == "gl_FrontSecondaryColor" && version >= 130 ||
identifier == "gl_BackSecondaryColor" && version >= 130 ||
identifier == "gl_SecondaryColor" && version >= 130 ||
identifier == "gl_Color" && version >= 130 && language == EShLangFragment ||
identifier == "gl_TexCoord") {
if ((identifier == "gl_FragDepth" && version >= 420) ||
(identifier == "gl_PerVertex" && version >= 410) ||
(identifier == "gl_PerFragment" && version >= 410) ||
(identifier == "gl_FragCoord" && version >= 150) ||
(identifier == "gl_ClipDistance" && version >= 130) ||
(identifier == "gl_FrontColor" && version >= 130) ||
(identifier == "gl_BackColor" && version >= 130) ||
(identifier == "gl_FrontSecondaryColor" && version >= 130) ||
(identifier == "gl_BackSecondaryColor" && version >= 130) ||
(identifier == "gl_SecondaryColor" && version >= 130) ||
(identifier == "gl_Color" && version >= 130 && language == EShLangFragment) ||
identifier == "gl_TexCoord") {
// Find the existing symbol, if any.
bool builtIn;
@ -2347,7 +2347,7 @@ void TParseContext::addBlock(TSourceLoc loc, TTypeList& typeList, const TString*
TQualifier memberQualifier = typeList[member].type->getQualifier();
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(), "");
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(), "");
TBasicType basicType = typeList[member].type->getBasicType();
@ -2570,7 +2570,7 @@ TIntermNode* TParseContext::addSwitch(TSourceLoc loc, TIntermTyped* expression,
wrapupSwitchSubsequence(lastStatements, 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())
error(loc, "condition must be a scalar integer expression", "switch", "");

Просмотреть файл

@ -63,7 +63,7 @@ public:
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
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 C_DECL error(TSourceLoc, const char *szReason, const char *szToken,

Просмотреть файл

@ -35,7 +35,7 @@
#include "../Include/PoolAlloc.h"
#include "../Include/Common.h"
#include "Include/InitializeGlobals.h"
#include "../Include/InitializeGlobals.h"
#include "osinclude.h"
namespace glslang {

Просмотреть файл

@ -41,7 +41,7 @@
#include <string.h>
#include "Scan.h"
#include "Include/Types.h"
#include "../Include/Types.h"
#include "SymbolTable.h"
#include "glslang_tab.cpp.h"
#include "ParseHelper.h"
@ -579,8 +579,8 @@ int TScanContext::tokenizeIdentifier()
case SWITCH:
case DEFAULT:
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < 130)
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
reservedWord();
return keyword;
@ -637,8 +637,8 @@ int TScanContext::tokenizeIdentifier()
case LAYOUT:
case SHARED:
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < 140)
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 140))
return identifierOrType();
return keyword;
@ -789,7 +789,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER2DRECTSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile ||
parseContext.profile != EEsProfile && parseContext.version < 140)
(parseContext.profile != EEsProfile && parseContext.version < 140))
reservedWord();
return keyword;
@ -797,8 +797,8 @@ int TScanContext::tokenizeIdentifier()
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version == 300)
reservedWord();
else if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < 130)
else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType();
return keyword;
@ -806,8 +806,8 @@ int TScanContext::tokenizeIdentifier()
return es30ReservedFromGLSL(130);
case SMOOTH:
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < 130)
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType();
return keyword;
@ -825,7 +825,7 @@ int TScanContext::tokenizeIdentifier()
case PRECISE:
if (parseContext.profile == EEsProfile ||
parseContext.profile != EEsProfile && parseContext.version < 400)
(parseContext.profile != EEsProfile && parseContext.version < 400))
return identifierOrType();
return keyword;
@ -835,15 +835,15 @@ int TScanContext::tokenizeIdentifier()
return keyword;
case PACKED:
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < 330)
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 330))
return reservedWord();
return identifierOrType();
case RESOURCE:
{
bool reserved = parseContext.profile == EEsProfile && parseContext.version >= 300 ||
parseContext.profile != EEsProfile && parseContext.version >= 420;
bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
(parseContext.profile != EEsProfile && parseContext.version >= 420);
return identifierOrReserved(reserved);
}
case SUPERP:
@ -906,8 +906,8 @@ int TScanContext::identifierOrReserved(bool reserved)
// but then got reserved by ES 3.0.
int TScanContext::es30ReservedFromGLSL(int version)
{
if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
parseContext.profile != EEsProfile && parseContext.version < version) {
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < version)) {
if (parseContext.forwardCompatible)
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.
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
{
if (parseContext.profile == EEsProfile && parseContext.version < esVersion ||
parseContext.profile != EEsProfile && parseContext.version < nonEsVersion) {
if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
(parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
@ -983,8 +983,8 @@ int TScanContext::firstGenerationImage()
if (parseContext.profile != EEsProfile && parseContext.version >= 420)
return keyword;
if (parseContext.profile == EEsProfile && parseContext.version >= 300 ||
parseContext.profile != EEsProfile && parseContext.version >= 130) {
if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
(parseContext.profile != EEsProfile && parseContext.version >= 130)) {
reservedWord();
return keyword;

Просмотреть файл

@ -37,14 +37,14 @@
#include "Versions.h"
namespace glslang {
//
// A character scanner that seamlessly, on read-only strings, reads across an
// array of strings without assuming null termination.
//
class TInputScanner {
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,
// anything else is the next character
@ -65,7 +65,7 @@ public:
void advance()
{
++currentChar;
if (currentChar >= lengths[currentSource]) {
if (currentChar >= static_cast<int>(lengths[currentSource])) {
++currentSource;
currentChar = 0;
while (currentSource < numSources && lengths[currentSource] == 0)
@ -100,7 +100,7 @@ public:
protected:
int numSources; // number of strings in source
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 currentChar;
};

Просмотреть файл

@ -139,7 +139,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
symbolTable.push();
const char* builtInShaders[2];
int builtInLengths[2];
size_t builtInLengths[2];
builtInShaders[0] = builtIns.c_str();
builtInLengths[0] = builtIns.size();
@ -430,7 +430,7 @@ bool CompileDeferred(
GetThreadPoolAllocator().push();
// 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) {
if (inputLengths == 0 || inputLengths[s] < 0)
lengths[s] = strlen(shaderStrings[s]);

Просмотреть файл

@ -103,7 +103,7 @@ TPpContext::~TPpContext()
FreeScanner();
}
void TPpContext::setPreamble(const char* p, int l)
void TPpContext::setPreamble(const char* p, size_t l)
{
if (p && l > 0) {
// 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;
lengths = l;

Просмотреть файл

@ -102,8 +102,8 @@ public:
TPpContext(TParseContext&);
virtual ~TPpContext();
void setPreamble(const char* preamble, int length);
void setShaderStrings(char* strings[], int lengths[], int numStrings);
void setPreamble(const char* preamble, size_t length);
void setShaderStrings(char* strings[], size_t lengths[], int numStrings);
const char* tokenize(TPpToken* yylvalpp);
@ -219,12 +219,12 @@ public:
};
protected:
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
int preambleLength;
char** strings; // official strings of shader, starting a string 0 line 1
int* lengths;
int numStrings; // how many official strings there are
int currentString; // which string we're currently parsing (-1 for preamble)
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
int preambleLength;
char** strings; // official strings of shader, starting a string 0 line 1
size_t* lengths;
int numStrings; // how many official strings there are
int currentString; // which string we're currently parsing (-1 for preamble)
// Scanner data:
int mostRecentToken; // Most recent token seen by the scanner