Pass 1 at building on linux: remove compile errors from machine independent.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20536 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-02-11 22:36:01 +00:00
parent dadf945fd7
commit 54d8cda95e
24 changed files with 176 additions and 172 deletions

View File

@ -73,12 +73,12 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
static EShLanguage FindLanguage(char *lang);
bool CompileFile(char *fileName, ShHandle, int, const TBuiltInResource*);
bool CompileFile(const char *fileName, ShHandle, int, const TBuiltInResource*);
void usage();
void FreeFileData(char **data);
char** ReadFileData(char *fileName);
void InfoLogMsg(char* msg, const char* name, const int num);
int ShOutputMultipleStrings(char ** );
char** ReadFileData(const char *fileName);
void InfoLogMsg(const char* msg, const char* name, const int num);
int ShOutputMultipleStrings(const char *);
//Added to accomodate the multiple strings.
int OutputMultipleStrings = 1;
@ -134,7 +134,7 @@ int C_DECL main(int argc, char* argv[])
case 'i': debugOptions |= EDebugOpIntermediate; break;
case 'a': debugOptions |= EDebugOpAssembly; break;
#endif
case 'c': if(!ShOutputMultipleStrings(++argv))
case 'c': if(!ShOutputMultipleStrings((++argv)[0]))
return EFailUsage;
--argc; break;
case 'm': debugOptions |= EDebugOpLinkMaps; break;
@ -234,7 +234,7 @@ static EShLanguage FindLanguage(char *name)
//
// Read a file's data into a string, and compile it using ShCompile
//
bool CompileFile(char *fileName, ShHandle compiler, int debugOptions, const TBuiltInResource *resources)
bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, const TBuiltInResource *resources)
{
int ret;
char **data = ReadFileData(fileName);
@ -278,7 +278,7 @@ void usage()
// Malloc a string of sufficient size and read a string into it.
//
# define MAX_SOURCE_STRINGS 5
char** ReadFileData(char *fileName)
char** ReadFileData(const char *fileName)
{
FILE *in;
int errorCode = fopen_s(&in, fileName, "r");
@ -345,15 +345,15 @@ void FreeFileData(char **data)
void InfoLogMsg(char* msg, const char* name, const int num)
void InfoLogMsg(const char* msg, const char* name, const int num)
{
printf(num >= 0 ? "#### %s %s %d INFO LOG ####\n" :
"#### %s %s INFO LOG ####\n", msg, name, num);
}
int ShOutputMultipleStrings(char **argv)
int ShOutputMultipleStrings(const char *argv)
{
if(!(abs(OutputMultipleStrings = atoi(*argv)))||((OutputMultipleStrings >5 || OutputMultipleStrings < 1)? 1:0)){
if(!(abs(OutputMultipleStrings = atoi(argv)))||((OutputMultipleStrings >5 || OutputMultipleStrings < 1)? 1:0)){
printf("Invalid Command Line Argument after -c option.\n"
"Usage: -c <integer> where integer =[1,5]\n"
"This option must be specified before the input file path\n");

View File

@ -39,10 +39,14 @@
#ifdef _WIN32
#include <basetsd.h>
#define snprintf sprintf_s
#define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
#elif defined (solaris)
#define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args))
#include <sys/int_types.h>
#define UINT_PTR uintptr_t
#else
#define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args))
#include <stdint.h>
#define UINT_PTR uintptr_t
#endif
@ -60,11 +64,10 @@
#include <list>
#include <string>
#include <stdio.h>
#include <assert.h>
typedef int TSourceLoc;
#include <assert.h>
#include "PoolAlloc.h"
//
@ -171,9 +174,9 @@ __inline TPersistString FormatSourceLoc(const TSourceLoc loc)
int line = loc & SourceLocLineMask;
if (line)
sprintf_s(locText, maxSize, "%d:%d", string, line);
snprintf(locText, maxSize, "%d:%d", string, line);
else
sprintf_s(locText, maxSize, "%d:? ", string);
snprintf(locText, maxSize, "%d:? ", string);
return TPersistString(locText);
}

View File

@ -73,7 +73,7 @@ public:
TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(const unsigned int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
sprintf_s(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
"%f" : "%g", n);
append(buf);
return *this; }

View File

@ -104,7 +104,7 @@ public:
}
private:
void checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const;
void checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const;
// Find offsets to pre and post guard blocks, and user data buffer
unsigned char* preGuard() const { return mem + headerSize(); }

View File

@ -140,7 +140,7 @@ public:
};
typedef std::map<TTypeList*, TTypeList*> TStructureMap;
typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
typedef std::map<TTypeList*, TTypeList*>::const_iterator TStructureMapIterator;
//
// Base class for things that have a type.
//
@ -178,7 +178,7 @@ public:
TType(const TType& type) { *this = type; }
void copyType(const TType& copyOf, TStructureMap& remapper)
void copyType(const TType& copyOf, const TStructureMap& remapper)
{
type = copyOf.type;
qualifier = copyOf.qualifier;
@ -226,7 +226,7 @@ public:
arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
}
TType* clone(TStructureMap& remapper)
TType* clone(const TStructureMap& remapper)
{
TType *newType = new TType();
newType->copyType(*this, remapper);
@ -294,7 +294,7 @@ public:
void setArrayInformationType(TType* t) { arrayInformationType = t; }
TType* getArrayInformationType() { return arrayInformationType; }
virtual bool isVector() const { return vectorSize > 1; }
static char* getBasicString(TBasicType t) {
static const char* getBasicString(TBasicType t) {
switch (t) {
case EbtVoid: return "void"; break;
case EbtFloat: return "float"; break;

View File

@ -36,6 +36,8 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <string.h>
#endif
void TInfoSinkBase::append(const char *s)

View File

@ -732,40 +732,40 @@ void TBuiltIns::initialize(const TBuiltInResource &resources)
//
const int maxSize = 80;
char builtInConstant[maxSize];
sprintf_s(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
snprintf(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
snprintf(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
snprintf(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
snprintf(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf_s(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
snprintf(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
s.append(TString(builtInConstant));
//
@ -949,11 +949,3 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBu
default: break;
}
}
char* GetPreprocessorBuiltinString()
{
static char *PreprocessorBuiltinString = "#define GL_ARB_texture_rectangle 1\n"
"#define GL_3DL_array_objects 1\n";
return PreprocessorBuiltinString;
}

View File

@ -56,7 +56,6 @@ void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
bool GenerateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);
bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);
char* GetPreprocessorBuiltinString();
extern "C" int InitPreprocessor(void);
extern "C" int FinalizePreprocessor(void);

View File

@ -544,14 +544,14 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, T
return right;
} else {
TIntermTyped *commaAggregate = growAggregate(left, right, line);
commaAggregate->getAsAggregate()->setOperator(EOpComma);
commaAggregate->getAsAggregate()->setOperator(EOpComma);
commaAggregate->setType(right->getType());
commaAggregate->getTypePointer()->getQualifier().storage = EvqTemporary;
return commaAggregate;
}
}
TIntermTyped* TIntermediate::addMethod(TIntermTyped* object, TType& type, const TString* name, TSourceLoc line)
TIntermTyped* TIntermediate::addMethod(TIntermTyped* object, const TType& type, const TString* name, TSourceLoc line)
{
TIntermMethod* method = new TIntermMethod(object, type, *name);
method->setLine(line);
@ -1217,7 +1217,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
case EbtInt:
if (rightUnionArray[i] == 0) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
tempConstArray[i].setIConst(INT_MAX);
tempConstArray[i].setIConst(0xEFFFFFFF);
} else
tempConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
break;

View File

@ -13,7 +13,7 @@ OBJECTS= Initialize.o IntermTraverse.o \
RemoveTree.o ShaderLang.o intermOut.o parseConst.o SymbolTable.o \
InfoSink.o
SRCS= Gen_glslang.cpp Gen_glslang_tab.cpp Initialize.cpp IntermTraverse.cpp \
SRCS= gen_glslang.cpp gen_glslang_tab.cpp Initialize.cpp IntermTraverse.cpp \
Intermediate.cpp ParseHelper.cpp PoolAlloc.cp QualifierAlive.cpp \
RemoveTree.cpp ShaderLang.cpp SymbolTable.cpp intermOut.cpp \
parseConst.cpp InfoSink.cpp
@ -24,27 +24,27 @@ default: all
all: $(SHAREDOBJECT)
$(SHAREDOBJECT): Gen_glslang.o Gen_glslang_tab.o $(OBJECTS) \
$(SHAREDOBJECT): gen_glslang.o gen_glslang_tab.o $(OBJECTS) \
$(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION)
$(CC) -fPIC -shared -lc -o $@ $(OBJECTS) $(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION) Gen_glslang.o Gen_glslang_tab.o
$(CC) -fPIC -shared -lc -o $@ $(OBJECTS) $(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION) gen_glslang.o gen_glslang_tab.o
Gen_glslang.o : Gen_glslang.cpp glslang_tab.h
$(CC) -c $(INCLUDE) Gen_glslang.cpp -o $@
gen_glslang.o : gen_glslang.cpp glslang_tab.h
$(CC) -c $(INCLUDE) gen_glslang.cpp -o $@
Gen_glslang_tab.o : Gen_glslang_tab.cpp
$(CC) -c $(INCLUDE) Gen_glslang_tab.cpp -o $@
gen_glslang_tab.o : gen_glslang_tab.cpp
$(CC) -c $(INCLUDE) gen_glslang_tab.cpp -o $@
Gen_glslang.cpp: glslang.l
@echo Generating Gen_glslang.cpp
gen_glslang.cpp: glslang.l
@echo Generating gen_glslang.cpp
@dos2unix glslang.l
flex glslang.l
Gen_glslang_tab.cpp glslang_tab.h: glslang.y
@echo Generating Gen_glslang_tab.cpp
gen_glslang_tab.cpp glslang_tab.h: glslang.y
@echo Generating gen_glslang_tab.cpp
@dos2unix glslang.y
bison -t -v -d glslang.y
mv glslang.tab.c Gen_glslang_tab.cpp
mv glslang.tab.h glslang_tab.h
mv glslang.tab.c gen_glslang_tab.cpp
mv glslang.tab.h glslang_tab.cpp.h
%.o : %.cpp
$(CC) $(CPPFLAGS) -c $<
@ -72,7 +72,7 @@ depend:
#
.PHONY : clean
clean :
$(RM) *.o *.a Gen_glslang_tab.cpp Gen_glslang.cpp glslang_tab.h glslang.output
$(RM) *.o *.a gen_glslang_tab.cpp gen_glslang.cpp glslang_tab.h glslang.output
$(RM) ./lib/*.so
cd $(INCPREPROCESSOR); make clean
cd $(INCCODEGEN); make clean
@ -81,27 +81,27 @@ clean :
# DO NOT DELETE
Gen_glslang.o: ParseHelper.h ../Include/ShHandle.h
Gen_glslang.o: ../Public/ShaderLang.h ../Include/InfoSink.h
Gen_glslang.o: ../Include/Common.h ../Include/PoolAlloc.h SymbolTable.h
Gen_glslang.o: ../Include/Common.h ../Include/intermediate.h
Gen_glslang.o: ../Include/Types.h ../Include/BaseTypes.h
Gen_glslang.o: ../Include/ConstantUnion.h ../Include/InfoSink.h
Gen_glslang.o: localintermediate.h ../Include/intermediate.h
Gen_glslang.o: ../Public/ShaderLang.h glslang_tab.h ./unistd.h
Gen_glslang.o: ./preprocessor/preprocess.h ./preprocessor/slglobals.h
Gen_glslang.o: ./preprocessor/memory.h ./preprocessor/atom.h
Gen_glslang.o: ./preprocessor/scanner.h ./preprocessor/parser.h
Gen_glslang.o: ./preprocessor/cpp.h ./preprocessor/tokens.h
Gen_glslang.o: ./preprocessor/symbols.h ./preprocessor/compile.h
Gen_glslang_tab.o: SymbolTable.h ../Include/Common.h
Gen_glslang_tab.o: ../Include/intermediate.h ../Include/Common.h
Gen_glslang_tab.o: ../Include/PoolAlloc.h ../Include/Types.h
Gen_glslang_tab.o: ../Include/BaseTypes.h ../Include/ConstantUnion.h
Gen_glslang_tab.o: ../Include/InfoSink.h ParseHelper.h ../Include/ShHandle.h
Gen_glslang_tab.o: ../Public/ShaderLang.h
Gen_glslang_tab.o: ../Include/InfoSink.h localintermediate.h
Gen_glslang_tab.o: ../Include/intermediate.h ../Public/ShaderLang.h
gen_glslang.o: ParseHelper.h ../Include/ShHandle.h
gen_glslang.o: ../Public/ShaderLang.h ../Include/InfoSink.h
gen_glslang.o: ../Include/Common.h ../Include/PoolAlloc.h SymbolTable.h
gen_glslang.o: ../Include/Common.h ../Include/intermediate.h
gen_glslang.o: ../Include/Types.h ../Include/BaseTypes.h
gen_glslang.o: ../Include/ConstantUnion.h ../Include/InfoSink.h
gen_glslang.o: localintermediate.h ../Include/intermediate.h
gen_glslang.o: ../Public/ShaderLang.h glslang_tab.h ./unistd.h
gen_glslang.o: ./preprocessor/preprocess.h ./preprocessor/slglobals.h
gen_glslang.o: ./preprocessor/memory.h ./preprocessor/atom.h
gen_glslang.o: ./preprocessor/scanner.h ./preprocessor/parser.h
gen_glslang.o: ./preprocessor/cpp.h ./preprocessor/tokens.h
gen_glslang.o: ./preprocessor/symbols.h ./preprocessor/compile.h
gen_glslang_tab.o: SymbolTable.h ../Include/Common.h
gen_glslang_tab.o: ../Include/intermediate.h ../Include/Common.h
gen_glslang_tab.o: ../Include/PoolAlloc.h ../Include/Types.h
gen_glslang_tab.o: ../Include/BaseTypes.h ../Include/ConstantUnion.h
gen_glslang_tab.o: ../Include/InfoSink.h ParseHelper.h ../Include/ShHandle.h
gen_glslang_tab.o: ../Public/ShaderLang.h
gen_glslang_tab.o: ../Include/InfoSink.h localintermediate.h
gen_glslang_tab.o: ../Include/intermediate.h ../Public/ShaderLang.h
Initialize.o: ../Include/intermediate.h Initialize.h
Initialize.o: ../Include/ResourceLimits.h ../Include/Common.h
Initialize.o: ../Include/PoolAlloc.h ../Include/ShHandle.h

View File

@ -245,7 +245,7 @@ void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const c
va_start(marker, szExtraInfoFormat);
_vsnprintf_s(szExtraInfo, maxSize, sizeof(szExtraInfo), szExtraInfoFormat, marker);
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, marker);
/* VC++ format: file(linenum) : error #: 'token' : extrainfo */
infoSink.info.prefix(EPrefixError);
@ -269,7 +269,7 @@ void TParseContext::assignError(int line, const char* op, TString left, TString
//
// Same error message for all places unary operations don't work.
//
void TParseContext::unaryOpError(int line, char* op, TString operand)
void TParseContext::unaryOpError(int line, const char* op, TString operand)
{
error(line, " wrong operand type", op,
"no operation '%s' exists that takes an operand of type %s (or there is no acceptable conversion)",
@ -279,7 +279,7 @@ void TParseContext::unaryOpError(int line, char* op, TString operand)
//
// Same error message for all binary operations don't work.
//
void TParseContext::binaryOpError(int line, char* op, TString left, TString right)
void TParseContext::binaryOpError(int line, const char* op, TString left, TString right)
{
error(line, " wrong operand types:", op,
"no operation '%s' exists that takes a left-hand operand of type '%s' and "
@ -326,7 +326,7 @@ void TParseContext::variableErrorCheck(TIntermTyped*& nodePtr)
//
// Returns true if the was an error.
//
bool TParseContext::lValueErrorCheck(int line, char* op, TIntermTyped* node)
bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* node)
{
TIntermSymbol* symNode = node->getAsSymbolNode();
TIntermBinary* binaryNode = node->getAsBinaryNode();
@ -373,7 +373,7 @@ bool TParseContext::lValueErrorCheck(int line, char* op, TIntermTyped* node)
if (symNode != 0)
symbol = symNode->getSymbol().c_str();
char* message = 0;
const char* message = 0;
switch (node->getQualifier().storage) {
case EvqConst: message = "can't modify a const"; break;
case EvqConstReadOnly: message = "can't modify a const"; break;
@ -453,7 +453,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
//
// Returns true if the was an error.
//
bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)
bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
{
if (node->getBasicType() == EbtInt && node->getVectorSize() == 1)
return false;
@ -469,7 +469,7 @@ bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)
//
// Returns true if the was an error.
//
bool TParseContext::globalErrorCheck(int line, bool global, char* token)
bool TParseContext::globalErrorCheck(int line, bool global, const char* token)
{
if (global)
return false;

View File

@ -104,13 +104,13 @@ struct TParseContext {
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
void assignError(int line, const char* op, TString left, TString right);
void unaryOpError(int line, char* op, TString operand);
void binaryOpError(int line, char* op, TString left, TString right);
void unaryOpError(int line, const char* op, TString operand);
void binaryOpError(int line, const char* op, TString left, TString right);
void variableErrorCheck(TIntermTyped*& nodePtr);
bool lValueErrorCheck(int line, char* op, TIntermTyped*);
bool lValueErrorCheck(int line, const char* op, TIntermTyped*);
bool constErrorCheck(TIntermTyped* node);
bool integerErrorCheck(TIntermTyped* node, char* token);
bool globalErrorCheck(int line, bool global, char* token);
bool integerErrorCheck(TIntermTyped* node, const char* token);
bool globalErrorCheck(int line, bool global, const char* token);
bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);
bool arraySizeErrorCheck(int line, TIntermTyped* expr, int& size);
bool arrayQualifierErrorCheck(int line, TPublicType type);

View File

@ -188,7 +188,7 @@ const unsigned char TAllocation::userDataFill = 0xcd;
//
// Check a single guard block for damage
//
void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const
void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const
{
for (int x = 0; x < guardBlockSize; x++) {
if (blockMem[x] != val) {
@ -196,7 +196,7 @@ void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, ch
char assertMsg[80];
// We don't print the assert message. It's here just to be helpful.
sprintf_s(assertMsg, maxSize, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
snprintf(assertMsg, maxSize, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
locText, size, data());
assert(0 && "PoolAlloc: Damage in guard block");
}

View File

@ -32,6 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE.
//
#ifdef USE_QUALIFIER_ALIVE
#include "../Include/intermediate.h"
class TAliveTraverser : public TIntermTraverser {
@ -89,3 +91,5 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
return true;
}
#endif

View File

@ -90,7 +90,7 @@ void TType::buildMangledName(TString& mangledName)
if (arraySizes) {
const int maxSize = 10;
char buf[maxSize];
sprintf_s(buf, maxSize, "%d", arraySizes->front());
snprintf(buf, maxSize, "%d", arraySizes->front());
mangledName += '[';
mangledName += buf;
mangledName += ']';
@ -213,7 +213,7 @@ TVariable* TVariable::clone(TStructureMap& remapper)
return variable;
}
TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
TFunction::TFunction(const TFunction& copyOf, const TStructureMap& remapper) : TSymbol(copyOf)
{
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
TParameter param;

View File

@ -142,7 +142,7 @@ protected:
struct TParameter {
TString *name;
TType* type;
void copyParam(const TParameter& param, TStructureMap& remapper) {
void copyParam(const TParameter& param, const TStructureMap& remapper) {
name = NewPoolTString(param.name->c_str());
type = param.type->clone(remapper);
}
@ -158,12 +158,13 @@ public:
returnType(TType(EbtVoid)),
op(o),
defined(false) { }
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
TSymbol(name),
returnType(retType),
mangledName(*name + '('),
op(tOp),
defined(false) { }
TFunction(const TFunction&, const TStructureMap& remapper);
virtual ~TFunction();
virtual bool isFunction() const { return true; }
@ -185,7 +186,6 @@ public:
const TParameter& operator [](int i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const;
TFunction(const TFunction&, TStructureMap& remapper);
virtual TFunction* clone(TStructureMap& remapper);
protected:

View File

@ -153,7 +153,7 @@ void TParseContext::requireNotRemoved(int line, EProfile callingProfile, int rem
if (version >= removedVersion) {
const int maxSize = 60;
char buf[maxSize];
sprintf_s(buf, maxSize, "%s profile; removed in version %d", ProfileName[profile], removedVersion);
snprintf(buf, maxSize, "%s profile; removed in version %d", ProfileName[profile], removedVersion);
error(line, "no longer supported in", featureDesc, buf);
recover();
}

View File

@ -69,10 +69,10 @@ LF [lL][fF]
#include "ParseHelper.h"
#include "glslang_tab.cpp.h"
int PaIdentOrReserved(bool reserved, TParseContext&, int line, char* text, YYSTYPE* pyylval);
int PaPrecisionKeyword(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword);
int PaMatNxM(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword);
int PaDMat(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword);
int PaIdentOrReserved(bool reserved, TParseContext&, int line, const char* text, YYSTYPE* pyylval);
int PaPrecisionKeyword(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);
int PaMatNxM(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);
int PaDMat(TParseContext&, int line, const char* text, YYSTYPE* pyylval, int keyword);
/* windows only pragma */
#ifdef _MSC_VER
@ -80,9 +80,9 @@ int PaDMat(TParseContext&, int line, char* text, YYSTYPE* pyylval, int keyword);
#endif
int yy_input(char* buf, int max_size);
TSourceLoc yylineno;
#ifdef _WIN32
TSourceLoc yylineno;
extern int yyparse(TParseContext&);
#define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
#else
@ -507,9 +507,9 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon
void yyerror(char *s)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
if (parseContext.AfterEOF) {
if (pc.AfterEOF) {
if (cpp->tokensBeforeEOF == 1) {
GlobalParseContext->error(yylineno, "", "pre-mature EOF", s, "");
GlobalParseContext->recover();
@ -540,7 +540,7 @@ int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbo
return IDENTIFIER;
}
int PaIdentOrReserved(bool reserved, TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval)
int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* text, YYSTYPE* pyylval)
{
if (reserved)
PaReservedWord();
@ -548,45 +548,45 @@ int PaIdentOrReserved(bool reserved, TParseContext& parseContext, int line, char
pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);
}
int PaPrecisionKeyword(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword)
int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword)
{
if (parseContext.profile == EEsProfile || parseContext.version >= 130)
if (pc.profile == EEsProfile || pc.version >= 130)
return keyword;
pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);
}
int PaMatNxM(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword)
int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword)
{
if (parseContext.version > 110)
if (pc.version > 110)
return keyword;
pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);
}
int PaDMat(TParseContext& parseContext, int line, char* text, YYSTYPE* pyylval, int keyword)
int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int keyword)
{
if (parseContext.profile == EEsProfile && parseContext.version >= 300) {
if (pc.profile == EEsProfile && pc.version >= 300) {
PaReservedWord();
return 0;
}
if (parseContext.profile != EEsProfile && parseContext.version >= 400)
if (pc.profile != EEsProfile && pc.version >= 400)
return keyword;
pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
return PaIdentOrType(*pyylval->lex.string, pc, pyylval->lex.symbol);
}
int PaParseComment(int& lineno, TParseContext& parseContextLocal)
@ -623,31 +623,31 @@ extern "C" {
void CPPDebugLogMsg(const char *msg)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
parseContext.infoSink.debug.message(EPrefixNone, msg);
pc.infoSink.debug.message(EPrefixNone, msg);
}
void CPPWarningToInfoLog(const char *msg)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
parseContext.infoSink.info.message(EPrefixWarning, msg, yylineno);
pc.infoSink.info.message(EPrefixWarning, msg, yylineno);
}
void CPPShInfoLogMsg(const char *msg)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
parseContext.error(yylineno,"", "",msg,"");
pc.error(yylineno,"", "",msg,"");
GlobalParseContext->recover();
}
void CPPErrorToInfoLog(char *msg)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
parseContext.error(yylineno, "CPP error:", "",msg,"");
pc.error(yylineno, "CPP error:", "",msg,"");
GlobalParseContext->recover();
}
@ -686,7 +686,7 @@ void DecLineNumber(void)
void HandlePragma(const char **tokens, int numTokens)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) {
@ -700,9 +700,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
parseContext.contextPragma.optimize = true;
pc.contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
parseContext.contextPragma.optimize = false;
pc.contextPragma.optimize = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return;
@ -724,9 +724,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
parseContext.contextPragma.debug = true;
pc.contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
parseContext.contextPragma.debug = false;
pc.contextPragma.debug = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return;
@ -772,39 +772,39 @@ void HandlePragma(const char **tokens, int numTokens)
void StoreStr(char *string)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
TString strSrc;
strSrc = TString(string);
parseContext.HashErrMsg = parseContext.HashErrMsg + " " + strSrc;
pc.HashErrMsg = pc.HashErrMsg + " " + strSrc;
}
const char* GetStrfromTStr(void)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
cpp->ErrMsg = parseContext.HashErrMsg.c_str();
cpp->ErrMsg = pc.HashErrMsg.c_str();
return cpp->ErrMsg;
}
void ResetTString(void)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
parseContext.HashErrMsg = "";
pc.HashErrMsg = "";
}
void SetVersion(int version)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.setVersion(version);
TParseContext& pc = *((TParseContext *)cpp->pC);
pc.setVersion(version);
}
void SetProfile(EProfile profile)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.setProfile(profile);
TParseContext& pc = *((TParseContext *)cpp->pC);
pc.setProfile(profile);
}
TBehavior GetBehavior(const char* behavior)
@ -825,7 +825,7 @@ TBehavior GetBehavior(const char* behavior)
void updateExtensionBehavior(const char* extName, const char* behavior)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TParseContext& pc = *((TParseContext *)cpp->pC);
TBehavior behaviorVal = GetBehavior(behavior);
TMap<TString, TBehavior>:: iterator iter;
TString msg;
@ -836,12 +836,12 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
return;
} else {
for (iter = parseContext.extensionBehavior.begin(); iter != parseContext.extensionBehavior.end(); ++iter)
for (iter = pc.extensionBehavior.begin(); iter != pc.extensionBehavior.end(); ++iter)
iter->second = behaviorVal;
}
} else {
iter = parseContext.extensionBehavior.find(TString(extName));
if (iter == parseContext.extensionBehavior.end()) {
iter = pc.extensionBehavior.find(TString(extName));
if (iter == pc.extensionBehavior.end()) {
switch (behaviorVal) {
case EBhRequire:
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
@ -850,7 +850,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
case EBhWarn:
case EBhDisable:
msg = TString("extension '") + extName + "' is not supported";
parseContext.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
break;
}
return;

View File

@ -792,7 +792,8 @@ function_identifier
if ($$.function == 0) {
// error recover
$$.function = new TFunction(&TString(""), TType(EbtVoid), EOpNull);
TString empty("");
$$.function = new TFunction(&empty, TType(EbtVoid), EOpNull);
}
}
;
@ -826,11 +827,11 @@ unary_expression
if ($1.op != EOpNull) {
$$ = parseContext.intermediate.addUnaryMath($1.op, $2, $1.line, parseContext.symbolTable);
if ($$ == 0) {
char* errorOp = "";
char errorOp[2] = {0, 0};
switch($1.op) {
case EOpNegative: errorOp = "-"; break;
case EOpLogicalNot: errorOp = "!"; break;
case EOpBitwiseNot: errorOp = "~"; break;
case EOpNegative: errorOp[0] = '-'; break;
case EOpLogicalNot: errorOp[0] = '!'; break;
case EOpBitwiseNot: errorOp[0] = '~'; break;
default: break;
}
parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString());

View File

@ -63,21 +63,21 @@ TString TType::getCompleteString() const
char *end = &buf[maxSize];
if (qualifier.storage != EvqTemporary && qualifier.storage != EvqGlobal)
p += sprintf_s(p, end - p, "%s ", getStorageQualifierString());
p += snprintf(p, end - p, "%s ", getStorageQualifierString());
if (arraySizes) {
if (arraySizes->front() == 0)
p += sprintf_s(p, end - p, "unsized array of ");
p += snprintf(p, end - p, "unsized array of ");
else
p += sprintf_s(p, end - p, "%d-element array of ", arraySizes->front());
p += snprintf(p, end - p, "%d-element array of ", arraySizes->front());
}
if (qualifier.precision != EpqNone)
p += sprintf_s(p, end - p, "%s ", getPrecisionQualifierString());
p += snprintf(p, end - p, "%s ", getPrecisionQualifierString());
if (matrixCols > 0)
p += sprintf_s(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows);
p += snprintf(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows);
else if (vectorSize > 1)
p += sprintf_s(p, end - p, "%d-component vector of ", vectorSize);
p += snprintf(p, end - p, "%d-component vector of ", vectorSize);
sprintf_s(p, end - p, "%s", getBasicString());
snprintf(p, end - p, "%s", getBasicString());
return TString(buf);
}
@ -113,7 +113,7 @@ void OutputSymbol(TIntermSymbol* node, TIntermTraverser* it)
const int maxSize = 100;
char buf[maxSize];
sprintf_s(buf, maxSize, "'%s' (%s)\n",
snprintf(buf, maxSize, "'%s' (%s)\n",
node->getSymbol().c_str(),
node->getCompleteString().c_str());
@ -398,7 +398,7 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{
const int maxSize = 300;
char buf[maxSize];
sprintf_s(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
snprintf(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
out.debug << buf << "\n";
}
@ -407,7 +407,7 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{
const int maxSize = 300;
char buf[maxSize];
sprintf_s(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getDConst(), "const double");
snprintf(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getDConst(), "const double");
out.debug << buf << "\n";
}
@ -416,7 +416,7 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{
const int maxSize = 300;
char buf[maxSize];
sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
snprintf(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
out.debug << buf << "\n";
}

View File

@ -65,7 +65,7 @@ public:
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, TType&, const TString*, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);

View File

@ -84,7 +84,7 @@ bool ParseBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)
if (qualifier != EvqConst) {
const int maxSize = 200;
char buf[maxSize];
sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
snprintf(buf, maxSize, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true;
@ -102,7 +102,7 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
const int maxSize = 200;
char buf[maxSize];
sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
snprintf(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true;
@ -116,7 +116,7 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse
if (!node->isConstructor() && node->getOp() != EOpComma) {
const int maxSize = 200;
char buf[maxSize];
sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
snprintf(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
oit->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true;

View File

@ -75,7 +75,7 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
# include "slglobals.h"
#include "slglobals.h"
extern CPPStruct *cpp;
int InitCPPStruct(void);
int InitScanner(CPPStruct *cpp);

View File

@ -77,7 +77,10 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// tokens.c
//
#define _CRT_SECURE_NO_WARNINGS
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#define snprintf sprintf_s
#endif
#include <assert.h>
#include <stdlib.h>
@ -447,10 +450,10 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
switch (token) {
case CPP_IDENTIFIER:
case CPP_TYPEIDENTIFIER:
sprintf_s(str, maxSize, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
snprintf(str, maxSize, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
break;
case CPP_STRCONSTANT:
sprintf_s(str, maxSize, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
snprintf(str, maxSize, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
break;
case CPP_FLOATCONSTANT:
//printf("%g9.6 ", yylvalpp->sc_fval);
@ -460,9 +463,9 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
break;
default:
if (token >= 127)
sprintf_s(str, maxSize, "%s ", GetAtomString(atable, token));
snprintf(str, maxSize, "%s ", GetAtomString(atable, token));
else
sprintf_s(str, maxSize, "%c", token);
snprintf(str, maxSize, "%c", token);
break;
}
CPPDebugLogMsg(str);