INCLUDE = -I. -I../glslang -I../glslang/Include -I../glslang/OSDependent/Linux -I../glslang/MachineIndependent
WARNINGS = -Wall -Wwrite-strings -Wpointer-arith -Wcast-align -Wstrict-prototypes \
-Wnested-externs
-DEFINE = -Dlinux -D__i386__
-
+
CPP = g++
-CPPOPTIONS = -O3 -Wno-deprecated -D_ALT_NS=1
-CPPOPTIONS = -g -Wno-deprecated -D_ALT_NS=1
-CPPFLAGS = $(CPPOPTIONS) $(DEFINE) $(INCLUDE)
+CPPOPTIONS = -O3 -Wno-deprecated -D_ALT_NS=1 -fPIC
+CPPOPTIONS = -g -Wno-deprecated -D_ALT_NS=1 -fPIC
+CPPFLAGS = $(CPPOPTIONS) $(INCLUDE)
#
# Linking related
cd $(OBJECTPATH); make all
%.o : %.cpp
- $(CC) -c $<
+ $(CC) -g -c $<
#
# Cleanup
#include "./../glslang/Include/ShHandle.h"
#include "./../glslang/Public/ShaderLang.h"
#include <string.h>
+#include <stdlib.h>
#include <math.h>
#ifdef _WIN32
}
+#ifndef _WIN32
+
+#include <errno.h>
+
+int fopen_s(
+ FILE** pFile,
+ const char *filename,
+ const char *mode
+)
+{
+ if (!pFile || !filename || !mode) {
+ return EINVAL;
+ }
+
+ FILE* f = fopen(filename, mode);
+ if (! f) {
+ if (errno != 0) {
+ return errno;
+ } else {
+ return ENOENT;
+ }
+ }
+ *pFile = f;
+
+ return 0;
+}
+
+#endif
+
//
// Malloc a string of sufficient size and read a string into it.
//
-# define MAX_SOURCE_STRINGS 5
char** ReadFileData(const char *fileName)
{
FILE *in;
int errorCode = fopen_s(&in, fileName, "r");
char *fdata;
int count = 0;
- char**return_data=(char**)malloc(MAX_SOURCE_STRINGS+1);
+ const int maxSourceStrings = 5;
+ char** return_data = (char**)malloc(maxSourceStrings+1);
//return_data[MAX_SOURCE_STRINGS]=NULL;
if (errorCode) {
SRCS=CodeGen.cpp Link.cpp
+CPPFLAGS = -fPIC
+
default : all
all : libCodeGen.a
ranlib $@
%.o : %.cpp
- $(CC) -c $<
+ $(CC) -c $(CPPFLAGS) $<
#
# Cleanup
return true;
break;
+ case EbtUint:
+ if (constant.uConst == uConst)
+ return true;
+
+ break;
case EbtFloat:
if (constant.fConst == fConst)
return true;
return true;
break;
+ default:
+ assert(false && "Default missing");
}
return false;
//
#include <stddef.h>
+#include <string.h>
#include <vector>
// If we are using guard blocks, we must track each indivual
case EbtFloat: break;
case EbtInt: s.append("i"); break;
case EbtUint: s.append("u"); break;
+ default: break; // some compilers want this
}
if (image)
s.append("image");
case EsdCube: s.append("Cube"); break;
case EsdRect: s.append("2DRect"); break;
case EsdBuffer: s.append("Buffer"); break;
+ default: break; // some compilers want this
}
if (ms)
s.append("MS");
}
}
- TString TType::getCompleteString() const
+ TString getCompleteString() const
{
const int maxSize = 200;
char buf[maxSize];
case EShLangTessEvaluation:
case EShLangGeometry:
// TODO: support these stages
+
+ default:
+ assert(false && "Language not supported");
break;
}
case EOpMul:
if (left->getType().getBasicType() == EbtStruct || left->getType().getBasicType() == EbtBool || left->getType().isArray())
return 0;
+ default: break; // some compilers want this
}
//
case EOpNegative:
if (child->getType().getBasicType() == EbtStruct || child->getType().isArray())
return 0;
+ default: break; // some compilers want this
}
//
case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break;
case EOpConstructDouble: newType = EbtDouble; break;
+ default: break; // some compilers want this
}
if (newType != EbtVoid) {
case EOpConstructFloat:
case EOpConstructDouble:
return child;
+ default: break; // some compilers want this
}
TIntermConstantUnion *childTempConstant = 0;
OBJECTS= Initialize.o IntermTraverse.o \
Intermediate.o ParseHelper.o PoolAlloc.o QualifierAlive.o \
RemoveTree.o ShaderLang.o intermOut.o parseConst.o SymbolTable.o \
- InfoSink.o
+ InfoSink.o Versions.o Constant.o
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
-CPPFLAGS=$(DEFINE) $(INCLUDE)
+ parseConst.cpp InfoSink.cpp Versions.cpp Constant.cpp
+CPPFLAGS=$(DEFINE) $(INCLUDE) -fPIC
SHAREDOBJECT=./lib/libglslang.so
default: all
$(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 -o $@ -rdynamic -Wl,-whole-archive $(OBJECTS) $(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION) gen_glslang.o gen_glslang_tab.o -Wl,-no-whole-archive
gen_glslang.o : gen_glslang.cpp glslang_tab.h
- $(CC) -c $(INCLUDE) gen_glslang.cpp -o $@
+ $(CC) -fPIC -c $(INCLUDE) gen_glslang.cpp -o $@
gen_glslang_tab.o : gen_glslang_tab.cpp
- $(CC) -c $(INCLUDE) gen_glslang_tab.cpp -o $@
+ $(CC) -fPIC -c $(INCLUDE) gen_glslang_tab.cpp -o $@
gen_glslang.cpp: glslang.l
@echo Generating gen_glslang.cpp
parseConst.o: localintermediate.h ../Include/intermediate.h
parseConst.o: ../Public/ShaderLang.h
InfoSink.o: ../Include/InfoSink.h
+Versions.o: ParseHelper.h Versions.h ../Include/ShHandle.h SymbolTable.h localintermediate.h
+Constant.o: localintermediate.h ../Include/intermediate.h ../Public/ShaderLang.h SymbolTable.h Versions.h
case EvqPointCoord:
profileRequires(symbol->getLine(), ENoProfile, 120, 0, "gl_PointCoord");
break;
+ default: break; // some compilers want this
}
}
}
error(line, "cannot use 'inout' at global scope", "", "");
return true;
+ default: break; // some compilers want this
}
return false;
// This is the platform independent interface between an OGL driver
// and the shading language compiler/linker.
//
-
+#include <string.h>
#include "SymbolTable.h"
#include "ParseHelper.h"
switch (sampler.type) {
case EbtInt: mangledName += "i"; break;
case EbtUint: mangledName += "u"; break;
+ default: break; // some compilers want this
}
if (sampler.image)
mangledName += "I";
case EsdCube: mangledName += "C"; break;
case EsdRect: mangledName += "R2"; break;
case EsdBuffer: mangledName += "B"; break;
+ default: break; // some compilers want this
}
break;
case EbtStruct:
case EBhEnable:
okay = true;
break;
+ default: break; // some compilers want this
}
}
msg = TString("extension '") + extName + "' is not supported";\r
pc.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);\r
break;\r
+ default:\r
+ assert(0 && "unexpected behaviorVal");\r
}\r
\r
return;\r
case 2: op = EOpConstructMat2x2; break;\r
case 3: op = EOpConstructMat2x3; break;\r
case 4: op = EOpConstructMat2x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
case 3:\r
case 2: op = EOpConstructMat3x2; break;\r
case 3: op = EOpConstructMat3x3; break;\r
case 4: op = EOpConstructMat3x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
case 4:\r
case 2: op = EOpConstructMat4x2; break;\r
case 3: op = EOpConstructMat4x3; break;\r
case 4: op = EOpConstructMat4x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
+ default: break; // some compilers want this\r
}\r
} else {\r
switch($1.vectorSize) {\r
case 2: op = EOpConstructVec2; break;\r
case 3: op = EOpConstructVec3; break;\r
case 4: op = EOpConstructVec4; break;\r
+ default: break; // some compilers want this\r
}\r
}\r
break;\r
case 2: op = EOpConstructDMat2x2; break;\r
case 3: op = EOpConstructDMat2x3; break;\r
case 4: op = EOpConstructDMat2x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
case 3:\r
case 2: op = EOpConstructDMat3x2; break;\r
case 3: op = EOpConstructDMat3x3; break;\r
case 4: op = EOpConstructDMat3x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
case 4:\r
case 2: op = EOpConstructDMat4x2; break;\r
case 3: op = EOpConstructDMat4x3; break;\r
case 4: op = EOpConstructDMat4x4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
}\r
case 2: op = EOpConstructDVec2; break;\r
case 3: op = EOpConstructDVec3; break;\r
case 4: op = EOpConstructDVec4; break;\r
+ default: break; // some compilers want this\r
}\r
}\r
break;\r
case 2: op = EOpConstructIVec2; break;\r
case 3: op = EOpConstructIVec3; break;\r
case 4: op = EOpConstructIVec4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
case EbtBool:\r
case 2: op = EOpConstructBVec2; break;\r
case 3: op = EOpConstructBVec3; break;\r
case 4: op = EOpConstructBVec4; break;\r
+ default: break; // some compilers want this\r
}\r
break;\r
+ default: break; // some compilers want this\r
}\r
if (op == EOpNull) {\r
parseContext.error($1.line, "cannot construct this type", TType::getBasicString($1.type), "");\r
case EOpNegative: errorOp[0] = '-'; break;\r
case EOpLogicalNot: errorOp[0] = '!'; break;\r
case EOpBitwiseNot: errorOp[0] = '~'; break;\r
- default: break;\r
+ default: break; // some compilers want this\r
}\r
parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString());\r
parseContext.recover();\r
INCLUDE = -I../
-CC = g++
+CC = gcc
-CPPFLAGS=$(DEFINE) $(INCLUDE)
+CPPFLAGS=$(DEFINE) $(INCLUDE) -fPIC
OBJECTS = atom.o cpp.o cppstruct.o memory.o scanner.o symbols.o tokens.o
AR=ar
ranlib $@
%.o : %.c
- $(CC) $(CPPFLAGS) -c $<
+ $(CC) -c $(CPPFLAGS) $<
#
# Cleanup
static SourceLoc ifloc; /* outermost #if */
+int ChkCorrectElseNesting(void);
+int PredefineMacro(char *);
+void FreeMacro(MacroSymbol *);
+
int InitCPP(void)
{
char buffer[64], *t;
#include "tokens.h"
#include "Versions.h"
-int InitCPP(void);
-int FinalCPP(void);
-int readCPPline(yystypepp * yylvalpp);
-int MacroExpand(int atom, yystypepp * yylvalpp);
-int ChkCorrectElseNesting(void);
-
typedef struct MacroSymbol {
int argc;
int *args;
unsigned undef:1;
} MacroSymbol;
-void FreeMacro(MacroSymbol *);
-int PredefineMacro(char *);
+int InitCPP(void);
+int FinalCPP(void);
+int readCPPline(yystypepp * yylvalpp);
+int MacroExpand(int atom, yystypepp * yylvalpp);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
void CPPDebugLogMsg(const char *msg); // Prints information into debug log
void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log
void updateExtensionBehavior(const char* extName, const char* behavior);
int FreeCPP(void);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif // !(defined(__CPP_H)
#include <stdlib.h>
#include <string.h>
-#ifdef __STDC99__
+#ifdef _WIN32
#include <stdint.h>
#elif defined (_WIN64)
typedef unsigned __int64 uintptr_t;
int ScanFromString(char *s)
{
- StringInputSrc *in = malloc(sizeof(StringInputSrc));
+ StringInputSrc *in = (StringInputSrc *)malloc(sizeof(StringInputSrc));
memset(in, 0, sizeof(StringInputSrc));
in->p = s;
in->base.line = 1;
#include "parser.h"
// Not really atom table stuff but needed first...
+#ifdef __cplusplus
+extern "C" {
+#endif
typedef struct SourceLoc_Rec {
unsigned short file, line;
void IncLineNumber(void);
void DecLineNumber(void);
int FreeScanner(void); // Free the cpp scanner
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // !(defined(__SCANNER_H)
Scope *GlobalScope = NULL;
static void unlinkScope(void *_scope) {
- Scope *scope = _scope;
+ Scope *scope = (Scope*)_scope;
if (scope->next)
scope->next->prev = scope->prev;
{
Scope *lScope;
- lScope = mem_Alloc(pool, sizeof(Scope));
+ lScope = (Scope*)mem_Alloc(pool, sizeof(Scope));
lScope->pool = pool;
lScope->parent = NULL;
lScope->funScope = NULL;
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
{
const char *s;
- unsigned char *str=NULL;
+ char *str = NULL;
if (token > 256)
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
break;
case CPP_FLOATCONSTANT:
case CPP_INTCONSTANT:
- str=yylvalpp->symbol_name;
+ str = yylvalpp->symbol_name;
while (*str){
- lAddByte(pTok,(unsigned char) *str);
- *str++;
+ lAddByte(pTok, (unsigned char) *str);
+ str++;
}
lAddByte(pTok, 0);
break;
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
{
- TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
+ TokenInputSrc *in = (TokenInputSrc *) malloc(sizeof(TokenInputSrc));
memset(in, 0, sizeof(TokenInputSrc));
in->base.name = name;
in->base.prev = cpp->currentInput;
return token;
}
+typedef int (*scanFnPtr_t)(struct InputSrc *, yystypepp *);
+
void UngetToken(int token, yystypepp * yylvalpp) {
- UngotToken *t = malloc(sizeof(UngotToken));
+ UngotToken *t = (UngotToken *) malloc(sizeof(UngotToken));
memset(t, 0, sizeof(UngotToken));
t->token = token;
t->lval = *yylvalpp;
- t->base.scan = (void *)reget_token;
+ t->base.scan = (scanFnPtr_t)reget_token;
t->base.prev = cpp->currentInput;
t->base.name = cpp->currentInput->name;
t->base.line = cpp->currentInput->line;
INCLUDE = -I. -I../.. -I../../Include -I../../../OGLCompilersDLL
WARNINGS = -Wall -Wwrite-strings -Wpointer-arith -Wcast-align -Wstrict-prototypes \
-Wnested-externs
-DEFINE = -Dlinux -D__i386__
CPP = g++
-CPPOPTIONS = -O3 -Wno-deprecated -D_ALT_NS=1
-CPPOPTIONS = -g -Wno-deprecated -D_ALT_NS=1
-CPPFLAGS = $(CPPOPTIONS) $(DEFINE) $(INCLUDE)
+CPPOPTIONS = -O3 -Wno-deprecated -D_ALT_NS=1 -fPIC
+CPPOPTIONS = -g -Wno-deprecated -D_ALT_NS=1 -fPIC
+CPPFLAGS = $(CPPOPTIONS) $(INCLUDE)
#
# Linking related