update against 03-Feb-2005 release

This commit is contained in:
Michal Krol 2005-03-18 14:28:02 +00:00
parent 5b641a516e
commit 2fb2e27e28
58 changed files with 12973 additions and 11757 deletions

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -45,8 +45,6 @@
#define UINT_PTR uintptr_t #define UINT_PTR uintptr_t
#endif #endif
#include <assert.h>
/* windows only pragma */ /* windows only pragma */
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4786) // Don't warn about too long identifiers #pragma warning(disable : 4786) // Don't warn about too long identifiers
@ -73,6 +71,7 @@
typedef int TSourceLoc; typedef int TSourceLoc;
#include <assert.h>
#include "PoolAlloc.h" #include "PoolAlloc.h"
// //
@ -194,7 +193,7 @@ public :
// //
typedef pool_allocator<char> TStringAllocator; typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString; typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
inline TString* NewPoolTString(char* s) inline TString* NewPoolTString(const char* s)
{ {
void* memory = GlobalPoolAllocator.allocate(sizeof(TString)); void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
return new(memory) TString(s); return new(memory) TString(s);
@ -253,13 +252,12 @@ inline const TString String(const int i, const int base = 10)
{ {
char text[16]; // 32 bit ints are at most 10 digits in base 10 char text[16]; // 32 bit ints are at most 10 digits in base 10
// we assume base 10 or 16 for all cases #ifdef _WIN32
if (base == 10) itoa(i, text, base);
sprintf(text, "%d", i); #else
else if (base == 16) // we assume base 10 for all cases
sprintf(text, "%x", i); sprintf(text, "%d", i);
else #endif
assert (!"String(int): unsupported base");
return text; return text;
} }
@ -281,5 +279,7 @@ __inline TPersistString FormatSourceLoc(const TSourceLoc loc)
return TPersistString(locText); return TPersistString(locText);
} }
typedef TMap<TString, TString> TPragmaTable;
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
#endif // _COMMON_INCLUDED_ #endif // _COMMON_INCLUDED_

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -84,8 +84,8 @@ public:
} }
void check() const { void check() const {
checkGuardBlock(preGuard(), (unsigned char) (guardBlockBeginVal), "before"); checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
checkGuardBlock(postGuard(), (unsigned char) (guardBlockEndVal), "after"); checkGuardBlock(postGuard(), guardBlockEndVal, "after");
} }
void checkAllocList() const; void checkAllocList() const;
@ -113,21 +113,16 @@ private:
unsigned char* mem; // beginning of our allocation (pts to header) unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain TAllocation* prevAlloc; // prior allocation in the chain
enum { // Support MSVC++ 6.0
guardBlockBeginVal = 0xfb, const static unsigned char guardBlockBeginVal;
guardBlockEndVal = 0xfe, const static unsigned char guardBlockEndVal;
userDataFill = 0xcd const static unsigned char userDataFill;
};
# ifdef GUARD_BLOCKS # ifdef GUARD_BLOCKS
enum { const static size_t guardBlockSize;
guardBlockSize = 16
};
inline static size_t headerSize() { return sizeof(TAllocation); } inline static size_t headerSize() { return sizeof(TAllocation); }
# else # else
enum { const static size_t guardBlockSize;
guardBlockSize = 0
};
inline static size_t headerSize() { return 0; } inline static size_t headerSize() { return 0; }
# endif # endif
}; };
@ -254,13 +249,10 @@ private:
// //
typedef TPoolAllocator* PoolAllocatorPointer; typedef TPoolAllocator* PoolAllocatorPointer;
extern TPoolAllocator& GetGlobalPoolAllocator(); extern TPoolAllocator& GetGlobalPoolAllocator();
extern PoolAllocatorPointer& GetCompilerPoolAllocator();
#define GlobalPoolAllocator GetGlobalPoolAllocator() #define GlobalPoolAllocator GetGlobalPoolAllocator()
#define CompilerPoolAllocator GetCompilerPoolAllocator()
struct TThreadGlobalPools struct TThreadGlobalPools
{ {
TPoolAllocator* globalPoolAllocator; TPoolAllocator* globalPoolAllocator;
TPoolAllocator* compilerPoolAllocator;
}; };
// //

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -35,6 +35,10 @@
#ifndef _RESOURCE_LIMITS_INCLUDED_ #ifndef _RESOURCE_LIMITS_INCLUDED_
#define _RESOURCE_LIMITS_INCLUDED_ #define _RESOURCE_LIMITS_INCLUDED_
#ifdef __cplusplus
extern "C" {
#endif
struct TBuiltInResource { struct TBuiltInResource {
int maxLights; int maxLights;
int maxClipPlanes; int maxClipPlanes;
@ -49,4 +53,9 @@ struct TBuiltInResource {
int maxFragmentUniformComponents; int maxFragmentUniformComponents;
int maxDrawBuffers; int maxDrawBuffers;
}; };
#ifdef __cplusplus
}
#endif
#endif // _RESOURCE_LIMITS_INCLUDED_ #endif // _RESOURCE_LIMITS_INCLUDED_

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -101,32 +101,10 @@ public:
virtual TCompiler* getAsCompiler() { return this; } virtual TCompiler* getAsCompiler() { return this; }
virtual bool linkable() { return haveValidObjectCode; } virtual bool linkable() { return haveValidObjectCode; }
// Initialize our private pool for a new compilation, and
// return it.
virtual TPoolAllocator& getNewCompilationAllocator()
{
// We do a pop and push on the compiler pool, because compile can
// be called repeatedly on the same compiler handle. Each time,
// we want to pop away the results of any previous compile. We
// could do that with popAll, but this is a somewhat smaller
// hammer.
compilerPool.pop();
compilerPool.push();
return compilerPool;
}
TPoolAllocator& getCompilerPoolAllocator() { return compilerPool; }
TInfoSink& infoSink; TInfoSink& infoSink;
protected: protected:
EShLanguage language; EShLanguage language;
bool haveValidObjectCode; bool haveValidObjectCode;
// This is a per-compiler-object pool allocator. Allocations
// who's lifetime need not extend beyond the lifetime of the
// compiler itself can use this private pool.
TPoolAllocator compilerPool;
}; };
// //

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -74,6 +74,8 @@ public:
int line; int line;
}; };
typedef std::map<TTypeList*, TTypeList*> TStructureMap;
typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
// //
// Base class for things that have a type. // Base class for things that have a type.
// //
@ -82,33 +84,91 @@ public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) : explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0), type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0) structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), typeName(0), mangled(0), fieldName(0)
{ } { }
explicit TType(TPublicType p) : explicit TType(TPublicType p) :
type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0), type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0) structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
{ {
if (p.userDef) { if (p.userDef) {
structure = p.userDef->getStruct(); structure = p.userDef->getStruct();
structureSize = setStructSize(p.userDef->getStruct()); structureSize = setStructSize(p.userDef->getStruct());
typeName = p.userDef->getTypeName(); typeName = NewPoolTString(p.userDef->getTypeName().c_str());
} }
} }
explicit TType(TTypeList* userDef, TString n) : explicit TType(TTypeList* userDef, TString n) :
type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0), type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
structure(userDef), typeName(n), maxArraySize(0), arrayInformationType(0) { structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {
structureSize = setStructSize(userDef); structureSize = setStructSize(userDef);
typeName = NewPoolTString(n.c_str());
} }
explicit TType() {}
virtual ~TType() {} virtual ~TType() {}
TType (const TType& type) { *this = type; } TType (const TType& type) { *this = type; }
void copyType(const TType& copyOf, TStructureMap& remapper)
{
type = copyOf.type;
qualifier = copyOf.qualifier;
size = copyOf.size;
matrix = copyOf.matrix;
array = copyOf.array;
arraySize = copyOf.arraySize;
TStructureMapIterator iter;
if (copyOf.structure) {
if ((iter = remapper.find(structure)) == remapper.end()) {
// create the new structure here
structure = NewPoolTTypeList();
for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
TTypeLine typeLine;
typeLine.line = (*copyOf.structure)[i].line;
typeLine.type = (*copyOf.structure)[i].type->clone(remapper);
structure->push_back(typeLine);
}
} else {
structure = iter->second;
}
} else
structure = 0;
fieldName = 0;
if (copyOf.fieldName)
fieldName = NewPoolTString(copyOf.fieldName->c_str());
typeName = 0;
if (copyOf.typeName)
typeName = NewPoolTString(copyOf.typeName->c_str());
mangled = 0;
if (copyOf.mangled)
mangled = NewPoolTString(copyOf.mangled->c_str());
structureSize = copyOf.structureSize;
maxArraySize = copyOf.maxArraySize;
assert (copyOf.arrayInformationType == 0);
arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
}
TType* clone(TStructureMap& remapper)
{
TType *newType = new TType();
newType->copyType(*this, remapper);
return newType;
}
int setStructSize(TTypeList* userDef) int setStructSize(TTypeList* userDef)
{ {
int stSize = 0; int stSize = 0;
for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) { for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
if (((*tl).type)->isArray()) { if (((*tl).type)->isArray()) {
if (((*tl).type)->getStruct()) {
int structSize = setStructSize(((*tl).type)->getStruct());
stSize += structSize * ((*tl).type)->getArraySize();
} else {
stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize(); stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();
}
} else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){ } else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
stSize += ((*tl).type)->getInstanceSize(); stSize += ((*tl).type)->getInstanceSize();
} else if (((*tl).type)->getStruct()) { } else if (((*tl).type)->getStruct()) {
@ -132,10 +192,20 @@ public:
structure = userDef->getStruct(); structure = userDef->getStruct();
// leave array information intact. // leave array information intact.
} }
virtual void setTypeName(const TString& n) { typeName = n; } virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
virtual void setFieldName(const TString& n) { fieldName = n; } virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
virtual const TString& getTypeName() const { return typeName; } virtual const TString& getTypeName() const
virtual const TString& getFieldName() const { return fieldName; } {
assert (typeName);
return *typeName;
}
virtual const TString& getFieldName() const
{
assert (fieldName);
return *fieldName;
}
virtual TBasicType getBasicType() const { return type; } virtual TBasicType getBasicType() const { return type; }
virtual TQualifier getQualifier() const { return qualifier; } virtual TQualifier getQualifier() const { return qualifier; }
virtual void changeQualifier(TQualifier q) { qualifier = q; } virtual void changeQualifier(TQualifier q) { qualifier = q; }
@ -152,8 +222,8 @@ public:
return size; return size;
} }
virtual bool isMatrix() const { return matrix; } virtual bool isMatrix() const { return matrix ? true : false; }
virtual bool isArray() const { return array; } virtual bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; } int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; } void setArraySize(int s) { array = true; arraySize = s; }
void setMaxArraySize (int s) { maxArraySize = s; } void setMaxArraySize (int s) { maxArraySize = s; }
@ -180,14 +250,16 @@ public:
const char* getBasicString() const { return TType::getBasicString(type); } const char* getBasicString() const { return TType::getBasicString(type); }
const char* getQualifierString() const { return ::getQualifierString(qualifier); } const char* getQualifierString() const { return ::getQualifierString(qualifier); }
TTypeList* getStruct() { return structure; } TTypeList* getStruct() { return structure; }
int getStructSize() { return structureSize; } int getStructSize() const { return structureSize; }
TTypeList* getStruct() const { return structure; } TTypeList* getStruct() const { return structure; }
TString& getMangledName() { TString& getMangledName() {
if (mangled.size() == 0) { if (!mangled) {
buildMangledName(mangled); mangled = NewPoolTString("");
mangled+=';'; buildMangledName(*mangled);
*mangled+=';';
} }
return mangled;
return *mangled;
} }
bool operator==(const TType& right) const { bool operator==(const TType& right) const {
return type == right.type && return type == right.type &&
@ -203,21 +275,22 @@ public:
TString getCompleteString() const; TString getCompleteString() const;
protected: protected:
TBasicType type; void buildMangledName(TString&);
TQualifier qualifier;
int size; // size of vector or matrix, not size of array
bool matrix;
bool array;
int arraySize; int arraySize;
TTypeList* structure; // 0 unless this is a struct TTypeList* structure; // 0 unless this is a struct
TString fieldName; // for structure field names TString *fieldName; // for structure field names
TString typeName; // for structure field type name TString *typeName; // for structure field type name
TString mangled; TString *mangled;
int structureSize; int structureSize;
int maxArraySize; int maxArraySize;
TType* arrayInformationType; TType* arrayInformationType;
void buildMangledName(TString&); TQualifier qualifier : 7;
TBasicType type : 6;
int size : 8; // size of vector or matrix, not size of array
unsigned int matrix : 1;
unsigned int array : 1;
}; };
#endif // _TYPES_INCLUDED_ #endif // _TYPES_INCLUDED_

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -51,7 +51,6 @@
// //
// Operators used by the high-level (parse tree) representation. // Operators used by the high-level (parse tree) representation.
// //
enum TOperator { enum TOperator {
EOpNull, // if in a node, should only mean a node is still being built EOpNull, // if in a node, should only mean a node is still being built
EOpSequence, // denotes a list of statements, or parameters, etc. EOpSequence, // denotes a list of statements, or parameters, etc.
@ -379,7 +378,7 @@ public:
virtual bool promote(TInfoSink&) { return true; } virtual bool promote(TInfoSink&) { return true; }
protected: protected:
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {} TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
TIntermOperator(TOperator o, TType t) : TIntermTyped(t), op(o) {} TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
TOperator op; TOperator op;
}; };
@ -406,7 +405,7 @@ protected:
// //
class TIntermUnary : public TIntermOperator { class TIntermUnary : public TIntermOperator {
public: public:
TIntermUnary(TOperator o, TType t) : TIntermOperator(o, t), operand(0) {} TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {} TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
virtual void traverse(TIntermTraverser*); virtual void traverse(TIntermTraverser*);
virtual void setOperand(TIntermTyped* o) { operand = o; } virtual void setOperand(TIntermTyped* o) { operand = o; }
@ -423,8 +422,9 @@ typedef TVector<int> TQualifierList;
// //
class TIntermAggregate : public TIntermOperator { class TIntermAggregate : public TIntermOperator {
public: public:
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false) { } TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
TIntermAggregate(TOperator o) : TIntermOperator(o) { } TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
~TIntermAggregate() { delete pragmaTable; }
virtual TIntermAggregate* getAsAggregate() { return this; } virtual TIntermAggregate* getAsAggregate() { return this; }
virtual void setOperator(TOperator o) { op = o; } virtual void setOperator(TOperator o) { op = o; }
virtual TIntermSequence& getSequence() { return sequence; } virtual TIntermSequence& getSequence() { return sequence; }
@ -434,11 +434,22 @@ public:
virtual void setUserDefined() { userDefined = true; } virtual void setUserDefined() { userDefined = true; }
virtual bool isUserDefined() { return userDefined; } virtual bool isUserDefined() { return userDefined; }
virtual TQualifierList& getQualifier() { return qualifier; } virtual TQualifierList& getQualifier() { return qualifier; }
void setOptimize(bool o) { optimize = o; }
void setDebug(bool d) { debug = d; }
bool getOptimize() { return optimize; }
bool getDebug() { return debug; }
void addToPragmaTable(const TPragmaTable& pTable);
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
protected: protected:
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermSequence sequence; TIntermSequence sequence;
TQualifierList qualifier; TQualifierList qualifier;
TString name; TString name;
bool userDefined; // used for user defined function names bool userDefined; // used for user defined function names
bool optimize;
bool debug;
TPragmaTable *pragmaTable;
}; };
// //
@ -448,7 +459,7 @@ class TIntermSelection : public TIntermTyped {
public: public:
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) : TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {} TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, TType type) : TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {} TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
virtual void traverse(TIntermTraverser*); virtual void traverse(TIntermTraverser*);
virtual TIntermNode* getCondition() const { return condition; } virtual TIntermNode* getCondition() const { return condition; }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -57,7 +57,7 @@ void TInfoSinkBase::append(const char *s)
void TInfoSinkBase::append(int count, char c) void TInfoSinkBase::append(int count, char c)
{ {
if (outputStream & EString) { if (outputStream & EString) {
checkMem(1); checkMem(count);
sink.append(count, c); sink.append(count, c);
} }

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -40,9 +40,8 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
#include "Initialize.h" #include "Initialize.h"
#include <assert.h>
void TBuiltIns::initialize(TBuiltInResource &resources) void TBuiltIns::initialize()
{ {
// //
// Initialize all the built-in strings for parsing. // Initialize all the built-in strings for parsing.
@ -355,53 +354,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
// Texture Functions. // Texture Functions.
// //
s.append(TString("vec4 texture1D(sampler1D sampler, float coord);")); s.append(TString("vec4 texture1D(sampler1D sampler, float coord);"));
s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);")); s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);")); s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);")); s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);")); s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);"));
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);")); s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);"));
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);")); s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);")); s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);"));
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);")); s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);"));
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);")); s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);"));
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);")); s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);"));
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));
s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));
s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));
// //
// Noise functions. // Noise functions.
@ -442,6 +414,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
// //
s.append(TString("vec4 ftransform();")); s.append(TString("vec4 ftransform();"));
//
// Texture Functions.
//
s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));
s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));
s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));
s.append(TString("\n")); s.append(TString("\n"));
} }
{ {
@ -453,6 +445,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
TString& s = BuiltInFunctionsFragment; TString& s = BuiltInFunctionsFragment;
//
// Texture Functions.
//
s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));
s.append(TString("float dFdx(float p);")); s.append(TString("float dFdx(float p);"));
s.append(TString("vec2 dFdx(vec2 p);")); s.append(TString("vec2 dFdx(vec2 p);"));
s.append(TString("vec3 dFdx(vec3 p);")); s.append(TString("vec3 dFdx(vec3 p);"));
@ -479,46 +491,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
TString& s = StandardUniforms; TString& s = StandardUniforms;
//
// Implementation dependent constants. The example values below
// are the minimum values allowed for these maximums.
//
char builtInConstant[80];
sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
s.append(TString(builtInConstant));
// //
// OpenGL'uniform' state. Page numbers are in reference to version // OpenGL'uniform' state. Page numbers are in reference to version
@ -531,7 +503,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
s.append(TString("uniform mat4 gl_ModelViewMatrix;")); s.append(TString("uniform mat4 gl_ModelViewMatrix;"));
s.append(TString("uniform mat4 gl_ProjectionMatrix;")); s.append(TString("uniform mat4 gl_ProjectionMatrix;"));
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;")); s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;"));
s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));
// //
// Derived matrix state that provides inverse and transposed versions // Derived matrix state that provides inverse and transposed versions
@ -542,17 +513,14 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;")); s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));
s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;")); s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;")); s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;"));
s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));
s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;")); s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;"));
s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;")); s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;"));
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;")); s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;"));
s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));
s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;")); s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;"));
s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;")); s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;"));
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;")); s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));
s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
// //
// Normal scaling p. 39. // Normal scaling p. 39.
@ -569,10 +537,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
s.append(TString("};")); s.append(TString("};"));
s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;")); s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
//
// Clip planes p. 42.
//
s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));
// //
// Point Size, p. 66, 67. // Point Size, p. 66, 67.
@ -623,7 +587,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
s.append(TString(" float quadraticAttenuation;"));// K2 s.append(TString(" float quadraticAttenuation;"));// K2
s.append(TString("};")); s.append(TString("};"));
s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
s.append(TString("struct gl_LightModelParameters {")); s.append(TString("struct gl_LightModelParameters {"));
s.append(TString(" vec4 ambient;")); // Acs s.append(TString(" vec4 ambient;")); // Acs
@ -648,21 +611,8 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
s.append(TString(" vec4 specular;")); // Scm * Scli s.append(TString(" vec4 specular;")); // Scm * Scli
s.append(TString("};")); s.append(TString("};"));
s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));
s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));
//
// Textureg Environment and Generation, p. 152, p. 40-42.
//
s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));
s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));
// //
// Fog p. 161 // Fog p. 161
@ -751,7 +701,121 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
builtInStrings[EShLangVertex].push_back(StandardUniforms); builtInStrings[EShLangVertex].push_back(StandardUniforms);
} }
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInResource &resources)
void TBuiltIns::initialize(const TBuiltInResource &resources)
{
//
// Initialize all the built-in strings for parsing.
//
TString StandardUniforms;
{
//============================================================================
//
// Standard Uniforms
//
//============================================================================
TString& s = StandardUniforms;
//
// Implementation dependent constants. The example values below
// are the minimum values allowed for these maximums.
//
char builtInConstant[80];
sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
s.append(TString(builtInConstant));
sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
s.append(TString(builtInConstant));
//
// OpenGL'uniform' state. Page numbers are in reference to version
// 1.4 of the OpenGL specification.
//
//
// Matrix state. p. 31, 32, 37, 39, 40.
//
s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));
//
// Derived matrix state that provides inverse and transposed versions
// of the matrices above.
//
s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));
s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));
s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
//
// Clip planes p. 42.
//
s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));
//
// Light State p 50, 53, 55.
//
s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
//
// Derived state from products of light.
//
s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));
s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));
//
// Textureg Environment and Generation, p. 152, p. 40-42.
//
s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));
s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));
s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));
s.append(TString("\n"));
}
builtInStrings[EShLangFragment].push_back(StandardUniforms);
builtInStrings[EShLangVertex].push_back(StandardUniforms);
}
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
{ {
// //
// First, insert some special built-in variables that are not in // First, insert some special built-in variables that are not in
@ -765,10 +829,6 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInR
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4))); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4)));
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1))); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1)));
// Set up gl_FragData. The array size.
TType fragData(EbtFloat, EvqFragColor, 4, false, true);
fragData.setArraySize(resources.maxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
} }
break; break;
@ -863,6 +923,26 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInR
symbolTable.relateToOperator("writeOutput", EOpWriteOutput); symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
symbolTable.relateToOperator("readPixel", EOpReadPixel); symbolTable.relateToOperator("readPixel", EOpReadPixel);
break; break;
default: assert (true && "Language not supported"); default: assert (false && "Language not supported");
}
}
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
{
//
// First, insert some special built-in variables that are not in
// the built-in header files.
//
switch(language) {
case EShLangFragment: {
// Set up gl_FragData. The array size.
TType fragData(EbtFloat, EvqFragColor, 4, false, true);
fragData.setArraySize(resources.maxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
}
break;
default: break;
} }
} }

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -45,12 +45,14 @@ typedef TVector<TString> TBuiltInStrings;
class TBuiltIns { class TBuiltIns {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
void initialize(TBuiltInResource &resources); void initialize();
void initialize(const TBuiltInResource& resources);
TBuiltInStrings* getBuiltInStrings() { return builtInStrings; } TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
protected: protected:
TBuiltInStrings builtInStrings[EShLangCount]; TBuiltInStrings builtInStrings[EShLangCount];
}; };
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, TBuiltInResource &resources); void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
#endif // _INITIALIZE_INCLUDED_ #endif // _INITIALIZE_INCLUDED_

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -40,7 +40,6 @@
#include "localintermediate.h" #include "localintermediate.h"
#include "QualifierAlive.h" #include "QualifierAlive.h"
#include "RemoveTree.h" #include "RemoveTree.h"
#include <assert.h>
#include <float.h> #include <float.h>
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -230,7 +229,7 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
node->setLeft(base); node->setLeft(base);
node->setRight(index); node->setRight(index);
// caller should set the type // caller should set the type
return node; return node;
} }
@ -446,12 +445,17 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
bool allConstant = true; bool allConstant = true;
// check to see if there is an aggregate node // check to see if there is an aggregate node
if (node->getAsAggregate()) { if (node->getAsAggregate()) {
if (node->getAsAggregate()->getOp() != EOpFunctionCall) {
// if the aggregate node is a constructor or a comma operator, look at its children, if they are constant
// convert them into the right type
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ; TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
for (TIntermSequence::iterator p = sequenceVector.begin(); for (TIntermSequence::iterator p = sequenceVector.begin();
p != sequenceVector.end(); p++) { p != sequenceVector.end(); p++) {
if (!(*p)->getAsTyped()->getAsConstantUnion()) if (!(*p)->getAsTyped()->getAsConstantUnion())
allConstant = false; allConstant = false;
} }
} else
allConstant = false;
} }
if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ; TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
@ -559,10 +563,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
return 0; return 0;
} }
newNode = new TIntermUnary(newOp, TType(promoteTo, EvqTemporary, TType type(promoteTo, EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());
node->getNominalSize(), newNode = new TIntermUnary(newOp, type);
node->isMatrix(),
node->isArray()));
newNode->setLine(node->getLine()); newNode->setLine(node->getLine());
newNode->setOperand(node); newNode->setOperand(node);
@ -648,6 +650,20 @@ TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nod
return node; return node;
} }
TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
{
if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) {
return right;
} else {
TIntermTyped *commaAggregate = growAggregate(left, right, line);
commaAggregate->getAsAggregate()->setOperator(EOpComma);
commaAggregate->setType(right->getType());
commaAggregate->getTypePointer()->changeQualifier(EvqTemporary);
return commaAggregate;
}
}
// //
// For "?:" test nodes. There are three children; a condition, // For "?:" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are specified // a true path, and a false path. The two paths are specified
@ -768,15 +784,6 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
if (aggRoot && aggRoot->getOp() == EOpNull) if (aggRoot && aggRoot->getOp() == EOpNull)
aggRoot->setOperator(EOpSequence); aggRoot->setOperator(EOpSequence);
//
// Other things...
//
if (language == EShLangVertex && !QualifierWritten(root, EvqPosition)) {
infoSink.info.message(EPrefixError, "gl_Position must be written by all paths through a vertex shader.");
return false;
}
return true; return true;
} }
@ -785,8 +792,8 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
// //
void TIntermediate::remove(TIntermNode* root) void TIntermediate::remove(TIntermNode* root)
{ {
if (root) if (root)
RemoveAllTreeNodes(root); RemoveAllTreeNodes(root);
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -1062,7 +1069,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
case EOpAdd: case EOpAdd:
case EOpSub: case EOpSub:
case EOpDiv: case EOpDiv:
case EOpMod: case EOpMod:
case EOpAddAssign: case EOpAddAssign:
case EOpSubAssign: case EOpSubAssign:
case EOpDivAssign: case EOpDivAssign:
@ -1074,7 +1081,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix())); setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));
break; break;
case EOpEqual: case EOpEqual:
case EOpNotEqual: case EOpNotEqual:
case EOpLessThan: case EOpLessThan:
case EOpGreaterThan: case EOpGreaterThan:
@ -1116,7 +1123,7 @@ default:
return true; return true;
} }
bool compareStructure(TType leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index) bool compareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index)
{ {
TTypeList* fields = leftNodeType.getStruct(); TTypeList* fields = leftNodeType.getStruct();
@ -1172,131 +1179,144 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
TIntermConstantUnion *node = constantNode->getAsConstantUnion(); TIntermConstantUnion *node = constantNode->getAsConstantUnion();
TIntermConstantUnion *newNode; TIntermConstantUnion *newNode;
constUnion* tempConstArray; constUnion* tempConstArray;
int i;
switch(op) { switch(op) {
case EOpAdd: case EOpAdd:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break; switch (this->getType().getBasicType()) {
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break; case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
default: case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpMatrixTimesScalar: case EOpMatrixTimesScalar:
case EOpVectorTimesScalar: case EOpVectorTimesScalar:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break; switch (this->getType().getBasicType()) {
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break; case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
default: case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpSub: case EOpSub:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: switch (this->getType().getBasicType()) {
if (leftOperand) case EbtFloat:
tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst; if (leftOperand)
else tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst; else
break; tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
case EbtInt:
if (leftOperand)
tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
else
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
break; break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine()); case EbtInt:
return 0; if (leftOperand)
tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
else
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpDiv: case EOpDiv:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: switch (this->getType().getBasicType()) {
if (leftOperand) { case EbtFloat:
if (node->getUnionArrayPointer()->fConst == 0.0) { if (leftOperand) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); if (node->getUnionArrayPointer()->fConst == 0.0) {
tempConstArray[i].fConst = FLT_MAX; infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
} else tempConstArray[i].fConst = FLT_MAX;
tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst; } else
} else { tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
if (unionArray[i].fConst == 0.0) { } else {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); if (unionArray[i].fConst == 0.0) {
tempConstArray[i].fConst = FLT_MAX; infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
} else tempConstArray[i].fConst = FLT_MAX;
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst; } else
} tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
break; }
break;
case EbtInt: case EbtInt:
if (leftOperand) { if (leftOperand) {
if (node->getUnionArrayPointer()->iConst == 0) { if (node->getUnionArrayPointer()->iConst == 0) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
tempConstArray[i].iConst = INT_MAX; tempConstArray[i].iConst = INT_MAX;
} else } else
tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst; tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
} else { } else {
if (unionArray[i].iConst == 0) { if (unionArray[i].iConst == 0) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
tempConstArray[i].iConst = INT_MAX; tempConstArray[i].iConst = INT_MAX;
} else } else
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst; tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst;
}
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
return 0;
} }
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
return 0;
} }
} }
break; break;
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
return 0;
}
} }
} }
break; break;
@ -1316,68 +1336,69 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
TIntermConstantUnion *tempNode; TIntermConstantUnion *tempNode;
int index = 0; int index = 0;
bool boolNodeFlag = false; bool boolNodeFlag = false;
int i;
switch(op) { switch(op) {
case EOpAdd: case EOpAdd:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break; switch (this->getType().getBasicType()) {
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break; case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
default: case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpSub: case EOpSub:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: switch (this->getType().getBasicType()) {
if (leftOperand) case EbtFloat:
tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst; if (leftOperand)
else tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst; else
break; tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
case EbtInt:
if (leftOperand)
tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;
else
tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst;
break; break;
default: case EbtInt:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine()); if (leftOperand)
return 0; tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;
else
tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst;
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpMul: case EOpMul:
{ if (this->isVector()) { // two vectors multiplied together
if (this->isVector()) { // two vectors multiplied together int size = this->getSize();
int size = this->getSize(); tempConstArray = new constUnion[size];
tempConstArray = new constUnion[size];
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
switch (this->getType().getBasicType()) { switch (this->getType().getBasicType()) {
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break; case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break; case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
default: default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine()); infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
return 0; return 0;
}
} }
} }
} }
break; break;
case EOpMatrixTimesMatrix: case EOpMatrixTimesMatrix:
{ if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) { infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine()); return 0;
return 0; }
} {// support MSVC++6.0
int size = this->getNominalSize(); int size = this->getNominalSize();
tempConstArray = new constUnion[size*size]; tempConstArray = new constUnion[size*size];
for (int row = 0; row < size; row++) { for (int row = 0; row < size; row++) {
@ -1392,42 +1413,44 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
break; break;
case EOpDiv: case EOpDiv:
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtFloat: switch (this->getType().getBasicType()) {
if (leftOperand) { case EbtFloat:
if (rightUnionArray[i].fConst == 0.0) { if (leftOperand) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); if (rightUnionArray[i].fConst == 0.0) {
tempConstArray[i].fConst = FLT_MAX; infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
} else tempConstArray[i].fConst = FLT_MAX;
tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst; } else
} else { tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
if (unionArray[i].fConst == 0.0) { } else {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); if (unionArray[i].fConst == 0.0) {
tempConstArray[i].fConst = FLT_MAX; infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
} else tempConstArray[i].fConst = FLT_MAX;
tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst; } else
} tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
break; }
break;
case EbtInt: case EbtInt:
if (leftOperand) { if (leftOperand) {
if (rightUnionArray[i].iConst == 0) { if (rightUnionArray[i].iConst == 0) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
tempConstArray[i].iConst = INT_MAX; tempConstArray[i].iConst = INT_MAX;
} else } else
tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst; tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
} else { } else {
if (unionArray[i].iConst == 0) { if (unionArray[i].iConst == 0) {
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine()); infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
tempConstArray[i].iConst = INT_MAX; tempConstArray[i].iConst = INT_MAX;
} else } else
tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst; tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst;
}
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
return 0;
} }
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
return 0;
} }
} }
break; break;
@ -1438,14 +1461,15 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
return 0; return 0;
} }
tempConstArray = new constUnion[this->getNominalSize()]; tempConstArray = new constUnion[this->getNominalSize()];
{
for (int size = this->getNominalSize(), i = 0; i < size; i++) { {// support MSVC++6.0
tempConstArray[i].fConst = 0.0; for (int size = this->getNominalSize(), i = 0; i < size; i++) {
for (int j = 0; j < size; j++) { tempConstArray[i].fConst = 0.0;
tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst); for (int j = 0; j < size; j++) {
} tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst);
} }
} }
}
tempNode = new TIntermConstantUnion(tempConstArray, node->getType()); tempNode = new TIntermConstantUnion(tempConstArray, node->getType());
tempNode->setLine(this->getLine()); tempNode->setLine(this->getLine());
@ -1459,48 +1483,54 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
} }
tempConstArray = new constUnion[this->getNominalSize()]; tempConstArray = new constUnion[this->getNominalSize()];
{ {// support MSVC++6.0
for (int size = this->getNominalSize(), i = 0; i < size; i++) { for (int size = this->getNominalSize(), i = 0; i < size; i++) {
tempConstArray[i].fConst = 0.0; tempConstArray[i].fConst = 0.0;
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++) {
tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst); tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
} }
} }
} }
break; break;
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
return 0;
}
} }
} }
break; break;
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[this->getSize()]; tempConstArray = new constUnion[this->getSize()];
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
switch (this->getType().getBasicType()) { for (int i = 0; i < this->getSize(); i++) {
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break; switch (this->getType().getBasicType()) {
default: case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine()); default:
return 0; infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
return 0;
}
} }
} }
break; break;
@ -1509,27 +1539,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
switch (this->getType().getBasicType()) { switch (this->getType().getBasicType()) {
case EbtFloat: case EbtFloat:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].fConst != rightUnionArray[i].fConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].fConst != rightUnionArray[i].fConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
case EbtInt: case EbtInt:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].iConst != rightUnionArray[i].iConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].iConst != rightUnionArray[i].iConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
case EbtBool: case EbtBool:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].bConst != rightUnionArray[i].bConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].bConst != rightUnionArray[i].bConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
@ -1559,27 +1595,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
case EOpNotEqual: case EOpNotEqual:
switch (this->getType().getBasicType()) { switch (this->getType().getBasicType()) {
case EbtFloat: case EbtFloat:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].fConst == rightUnionArray[i].fConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].fConst == rightUnionArray[i].fConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
case EbtInt: case EbtInt:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].iConst == rightUnionArray[i].iConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].iConst == rightUnionArray[i].iConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
case EbtBool: case EbtBool:
for (i = 0; i < this->getSize(); i++) { {// support MSVC++6.0
if (unionArray[i].bConst == rightUnionArray[i].bConst) { for (int i = 0; i < this->getSize(); i++) {
boolNodeFlag = true; if (unionArray[i].bConst == rightUnionArray[i].bConst) {
break; // break out of for loop boolNodeFlag = true;
break; // break out of for loop
}
} }
} }
break; break;
@ -1945,7 +1987,8 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
} }
} }
TType t = node->getType();
const TType& t = node->getType();
return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine()); return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
} }
@ -2027,31 +2070,40 @@ bool TIntermediate::removeMatrixConstNode(TIntermSequence &parentSequence, TType
TIntermSequence::iterator parentNodeIter; TIntermSequence::iterator parentNodeIter;
TIntermSequence &childSequence = child->getSequence(); TIntermSequence &childSequence = child->getSequence();
int i;
switch (child->getOp()) { switch (child->getOp()) {
case EOpConstructMat2: case EOpConstructMat2:
case EOpConstructMat3: case EOpConstructMat3:
case EOpConstructMat4: case EOpConstructMat4:
for (i = 0; i < child->getType().getInstanceSize(); i++) { {// support MSVC++6.0
constUnion* constantUnion = new constUnion[1]; for (int i = 0; i < child->getType().getInstanceSize(); i++) {
if (i % (child->getType().getNominalSize() + 1) == 0) { constUnion* constantUnion = new constUnion[1];
*constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer()); if (i % (child->getType().getNominalSize() + 1) == 0) {
} else { *constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
switch (parentType.getBasicType()) { } else {
case EbtInt: constantUnion->iConst = 0; break; switch (parentType.getBasicType()) {
case EbtFloat: constantUnion->fConst = 0.0; break; case EbtInt: constantUnion->iConst = 0; break;
case EbtBool: constantUnion->bConst = false; break; case EbtFloat: constantUnion->fConst = 0.0; break;
case EbtBool: constantUnion->bConst = false; break;
}
} }
TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
childSequence[0]->getAsConstantUnion()->getType());
constant->setLine(child->getLine());
parentNodeIter = parentSequence.begin() + offset + i;
parentSequence.insert(parentNodeIter, constant);
} }
TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
childSequence[0]->getAsConstantUnion()->getType());
constant->setLine(child->getLine());
parentNodeIter = parentSequence.begin() + offset + i;
parentSequence.insert(parentNodeIter, constant);
} }
return true; return true;
default: default:
return false; return false;
} }
} }
void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
{
assert (!pragmaTable);
pragmaTable = new TPragmaTable();
*pragmaTable = pTable;
}

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -54,25 +54,62 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
return false; return false;
} }
bool tooBig = false; enum {
exyzw,
ergba,
estpq
} fieldSet[4];
for (int i = 0; i < fields.num; ++i) { for (int i = 0; i < fields.num; ++i) {
switch (compString[i]) { switch (compString[i]) {
case 'x': case 'r': case 's': case '0': case 'x':
fields.offsets[i] = 0; fields.offsets[i] = 0;
fieldSet[i] = exyzw;
break; break;
case 'y': case 'g': case 't': case '1': case 'r':
fields.offsets[i] = 0;
fieldSet[i] = ergba;
break;
case 's':
fields.offsets[i] = 0;
fieldSet[i] = estpq;
break;
case 'y':
fields.offsets[i] = 1; fields.offsets[i] = 1;
fieldSet[i] = exyzw;
break; break;
case 'z': case 'b': case 'p': case '2': case 'g':
if (vecSize < 3) fields.offsets[i] = 1;
tooBig = true; fieldSet[i] = ergba;
break;
case 't':
fields.offsets[i] = 1;
fieldSet[i] = estpq;
break;
case 'z':
fields.offsets[i] = 2; fields.offsets[i] = 2;
fieldSet[i] = exyzw;
break; break;
case 'w': case 'a': case 'q': case '3': case 'b':
if (vecSize < 4) fields.offsets[i] = 2;
tooBig = true; fieldSet[i] = ergba;
break;
case 'p':
fields.offsets[i] = 2;
fieldSet[i] = estpq;
break;
case 'w':
fields.offsets[i] = 3; fields.offsets[i] = 3;
fieldSet[i] = exyzw;
break;
case 'a':
fields.offsets[i] = 3;
fieldSet[i] = ergba;
break;
case 'q':
fields.offsets[i] = 3;
fieldSet[i] = estpq;
break; break;
default: default:
error(line, "illegal vector field selection", compString.c_str(), ""); error(line, "illegal vector field selection", compString.c_str(), "");
@ -80,11 +117,20 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
} }
} }
if (tooBig) { for (int i = 0; i < fields.num; ++i) {
if (fields.offsets[i] >= vecSize) {
error(line, "vector field selection out of range", compString.c_str(), ""); error(line, "vector field selection out of range", compString.c_str(), "");
return false; return false;
} }
if (i > 0) {
if (fieldSet[i] != fieldSet[i-1]) {
error(line, "illegal - vector component fields not from the same set", compString.c_str(), "");
return false;
}
}
}
return true; return true;
} }
@ -970,7 +1016,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOpe
TTypeList::iterator list; TTypeList::iterator list;
TTypeList* structure = 0; // Store the information (vector) about the return type of the structure. TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
if (op == EOpConstructStruct) { if (op == EOpConstructStruct) {
TType ttype = fnCall->getReturnType(); const TType& ttype = fnCall->getReturnType();
structure = ttype.getStruct(); structure = ttype.getStruct();
list = (*structure).begin(); list = (*structure).begin();
} }

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -52,6 +52,13 @@ typedef enum {
EBhDisable EBhDisable
} TBehavior; } TBehavior;
struct TPragma {
TPragma(bool o, bool d) : optimize(o), debug(d) { }
bool optimize;
bool debug;
TPragmaTable pragmaTable;
};
// //
// The following are extra variables needed during parsing, grouped together so // The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global. // they can be passed to the parser without needing a global.
@ -60,7 +67,7 @@ struct TParseContext {
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) : TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false) { } inTypeParen(false), contextPragma(true, false) { }
TIntermediate& intermediate; // to hold and build a parse tree TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
TInfoSink& infoSink; TInfoSink& infoSink;
@ -113,8 +120,7 @@ struct TParseContext {
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
typedef std::map<TString, TString> PragmaStringMap; struct TPragma contextPragma;
PragmaStringMap PragmaTable;
TString HashErrMsg; TString HashErrMsg;
bool AfterEOF; bool AfterEOF;
}; };

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -34,7 +34,6 @@
#include "../Include/PoolAlloc.h" #include "../Include/PoolAlloc.h"
#include "../Include/Common.h" #include "../Include/Common.h"
#include <assert.h>
#include "Include/InitializeGlobals.h" #include "Include/InitializeGlobals.h"
#include "osinclude.h" #include "osinclude.h"
@ -52,7 +51,6 @@ void InitializeGlobalPools()
TThreadGlobalPools* threadData = new TThreadGlobalPools(); TThreadGlobalPools* threadData = new TThreadGlobalPools();
threadData->globalPoolAllocator = globalPoolAllocator; threadData->globalPoolAllocator = globalPoolAllocator;
threadData->compilerPoolAllocator = 0;
OS_SetTLSValue(PoolIndex, threadData); OS_SetTLSValue(PoolIndex, threadData);
globalPoolAllocator->push(); globalPoolAllocator->push();
@ -99,13 +97,6 @@ void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
threadData->globalPoolAllocator = poolAllocator; threadData->globalPoolAllocator = poolAllocator;
} }
PoolAllocatorPointer& GetCompilerPoolAllocator()
{
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
return threadData->compilerPoolAllocator;
}
// //
// Implement the functionality of the TPoolAllocator class, which // Implement the functionality of the TPoolAllocator class, which
// is documented in PoolAlloc.h. // is documented in PoolAlloc.h.
@ -191,6 +182,16 @@ TPoolAllocator::~TPoolAllocator()
} }
} }
// Support MSVC++ 6.0
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd;
# ifdef GUARD_BLOCKS
const size_t TAllocation::guardBlockSize = 16;
# else
const size_t TAllocation::guardBlockSize = 0;
# endif
// //
// Check a single guard block for damage // Check a single guard block for damage

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -51,9 +51,15 @@ extern "C" int InitPreprocessor(void);
extern "C" int FinalizePreprocessor(void); extern "C" int FinalizePreprocessor(void);
extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator); extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink&); bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, TBuiltInResource &resources); bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);
void GenerateResources(TBuiltInResource& resources);
//
// A symbol table for each language. Each has a different
// set of built-ins, and we want to preserve that from
// compile to compile.
//
TSymbolTable SymbolTables[EShLangCount];
TPoolAllocator* PerProcessGPA = 0; TPoolAllocator* PerProcessGPA = 0;
// //
@ -68,8 +74,6 @@ TPoolAllocator* PerProcessGPA = 0;
int ShInitialize() int ShInitialize()
{ {
TInfoSink infoSink; TInfoSink infoSink;
TBuiltInResource resources;
GenerateResources(resources);
bool ret = true; bool ret = true;
if (!InitProcess()) if (!InitProcess())
@ -79,13 +83,29 @@ int ShInitialize()
// we need to have thread synchronization code around the initialization of per process // we need to have thread synchronization code around the initialization of per process
// global pool allocator // global pool allocator
if (!PerProcessGPA) { if (!PerProcessGPA) {
TPoolAllocator *builtInPoolAllocator = new TPoolAllocator(true);
builtInPoolAllocator->push();
TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
SetGlobalPoolAllocatorPtr(builtInPoolAllocator);
TSymbolTable symTables[EShLangCount];
generateBuiltInSymbolTable(0, infoSink, symTables);
PerProcessGPA = new TPoolAllocator(true); PerProcessGPA = new TPoolAllocator(true);
PerProcessGPA->push(); PerProcessGPA->push();
TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
SetGlobalPoolAllocatorPtr(PerProcessGPA); SetGlobalPoolAllocatorPtr(PerProcessGPA);
ret = generateBuiltInSymbolTable(resources, infoSink);
SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);
SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);
SetGlobalPoolAllocatorPtr(gPoolAllocator); SetGlobalPoolAllocatorPtr(gPoolAllocator);
symTables[EShLangVertex].pop();
symTables[EShLangFragment].pop();
builtInPoolAllocator->popAll();
delete builtInPoolAllocator;
} }
return ret ? 1 : 0; return ret ? 1 : 0;
@ -141,13 +161,6 @@ void ShDestruct(ShHandle handle)
DeleteUniformMap(base->getAsUniformMap()); DeleteUniformMap(base->getAsUniformMap());
} }
//
// A symbol table for each language. Each has a different
// set of built-ins, and we want to preserve that from
// compile to compile.
//
TSymbolTable SymbolTables[EShLangCount];
// //
// Cleanup symbol tables // Cleanup symbol tables
// //
@ -160,88 +173,86 @@ int __fastcall ShFinalize()
return 1; return 1;
} }
//
// This method is required only for Sh interface, not for OGLC interface
//
void GenerateResources(TBuiltInResource& resources)
{
resources.maxLights = 32;
resources.maxClipPlanes = 6;
resources.maxTextureUnits = 32;
resources.maxTextureCoords = 32;
resources.maxVertexAttribs = 64;
resources.maxVertexUniformComponents = 4096;
resources.maxVaryingFloats = 64;
resources.maxVertexTextureImageUnits = 32;
resources.maxCombinedTextureImageUnits = 32;
resources.maxTextureImageUnits = 32;
resources.maxFragmentUniformComponents = 4096;
resources.maxDrawBuffers = 32;
}
// //
// This function should be called only once by the Master Dll. Currently, this is being called for each thread // This function should be called only once by the Master Dll. Currently, this is being called for each thread
// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called // which is incorrect. This is required to keep the Sh interface working for now and will eventually be called
// from master dll once. // from master dll once.
// //
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink& infoSink) bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable* symbolTables, EShLanguage language)
{ {
TBuiltIns builtIns; TBuiltIns builtIns;
builtIns.initialize(resources);
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources); if (resources) {
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources); builtIns.initialize(*resources);
initializeSymbolTable(builtIns.getBuiltInStrings(), language, infoSink, resources, symbolTables);
} else {
builtIns.initialize();
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources, symbolTables);
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources, symbolTables);
}
return true; return true;
} }
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, TBuiltInResource &resources) bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource* resources, TSymbolTable* symbolTables)
{ {
TIntermediate intermediate(infoSink); TIntermediate intermediate(infoSink);
TSymbolTable& symbolTable = SymbolTables[language]; TSymbolTable* symbolTable;
TParseContext parseContext(symbolTable, intermediate, language, infoSink);
if (resources)
symbolTable = symbolTables;
else
symbolTable = &symbolTables[language];
TParseContext parseContext(*symbolTable, intermediate, language, infoSink);
GlobalParseContext = &parseContext; GlobalParseContext = &parseContext;
setInitialState(); setInitialState();
if (symbolTable.isEmpty()) { assert (symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
// //
// Parse the built-ins. This should only happen once per // Parse the built-ins. This should only happen once per
// language symbol table. // language symbol table.
// //
// Push the symbol table to give it an initial scope. This // Push the symbol table to give it an initial scope. This
// push should not have a corresponding pop, so that built-ins // push should not have a corresponding pop, so that built-ins
// are preserved, and the test for an empty table fails. // are preserved, and the test for an empty table fails.
// //
symbolTable.push(); symbolTable->push();
//Initialize the Preprocessor //Initialize the Preprocessor
int ret = InitPreprocessor(); int ret = InitPreprocessor();
if (ret) { if (ret) {
infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor"); infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
return false;
}
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
i != BuiltInStrings[parseContext.language].end();
++i) {
const char* builtInShaders[1];
int builtInLengths[1];
builtInShaders[0] = (*i).c_str();
builtInLengths[0] = (int) (*i).size();
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
return false; return false;
} }
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
i != BuiltInStrings[parseContext.language].end();
++i) {
const char* builtInShaders[1];
int builtInLengths[1];
builtInShaders[0] = (*i).c_str();
builtInLengths[0] = (int) (*i).size();
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
return false;
}
}
IdentifyBuiltIns(parseContext.language, symbolTable, resources);
FinalizePreprocessor();
} }
if (resources) {
IdentifyBuiltIns(parseContext.language, *symbolTable, *resources);
} else {
IdentifyBuiltIns(parseContext.language, *symbolTable);
}
FinalizePreprocessor();
return true; return true;
} }
@ -258,6 +269,7 @@ int ShCompile(
const char* const shaderStrings[], const char* const shaderStrings[],
const int numStrings, const int numStrings,
const EShOptimizationLevel optLevel, const EShOptimizationLevel optLevel,
const TBuiltInResource* resources,
int debugOptions int debugOptions
) )
{ {
@ -272,6 +284,7 @@ int ShCompile(
if (compiler == 0) if (compiler == 0)
return 0; return 0;
GlobalPoolAllocator.push();
compiler->infoSink.info.erase(); compiler->infoSink.info.erase();
compiler->infoSink.debug.erase(); compiler->infoSink.debug.erase();
@ -280,6 +293,9 @@ int ShCompile(
TIntermediate intermediate(compiler->infoSink); TIntermediate intermediate(compiler->infoSink);
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]); TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
generateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink); TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
parseContext.initializeExtensionBehavior(); parseContext.initializeExtensionBehavior();
@ -294,7 +310,7 @@ int ShCompile(
// be thrown away, then push a scope for the current shader's globals. // be thrown away, then push a scope for the current shader's globals.
// //
bool success = true; bool success = true;
GlobalPoolAllocator.push();
symbolTable.push(); symbolTable.push();
if (!symbolTable.atGlobalLevel()) if (!symbolTable.atGlobalLevel())
parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
@ -306,41 +322,39 @@ int ShCompile(
if (ret) if (ret)
success = false; success = false;
if (! ret && parseContext.treeRoot) { if (success && parseContext.treeRoot) {
if (parseContext.recoveredFromError) { if (optLevel == EShOptNoGeneration)
parseContext.infoSink.info.prefix(EPrefixError); parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n"; else {
success = false; success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
if (debugOptions & EDebugOpIntermediate)
intermediate.outputTree(parseContext.treeRoot);
} else {
if (optLevel == EShOptNoGeneration)
parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
else {
success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
if (success) { if (success) {
if (debugOptions & EDebugOpIntermediate) if (debugOptions & EDebugOpIntermediate)
intermediate.outputTree(parseContext.treeRoot); intermediate.outputTree(parseContext.treeRoot);
// //
// Call the machine dependent compiler // Call the machine dependent compiler
// //
if (! compiler->compile(parseContext.treeRoot)) if (! compiler->compile(parseContext.treeRoot))
success = false; success = false;
}
} }
} }
} else if (!success) {
parseContext.infoSink.info.prefix(EPrefixError);
parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n";
success = false;
if (debugOptions & EDebugOpIntermediate)
intermediate.outputTree(parseContext.treeRoot);
} }
intermediate.remove(parseContext.treeRoot); intermediate.remove(parseContext.treeRoot);
// //
// Ensure symbol table is returned to the built-in level, // Ensure symbol table is returned to the built-in level,
// throwing away all but the built-ins. // throwing away all but the built-ins.
// //
while (! symbolTable.atBuiltInLevel()) while (! symbolTable.atSharedBuiltInLevel())
symbolTable.pop(); symbolTable.pop();
FinalizePreprocessor(); FinalizePreprocessor();
@ -397,21 +411,22 @@ int ShLinkExt(
return 0; return 0;
THandleList cObjects; THandleList cObjects;
int i;
for (i = 0; i < numHandles; ++i) { {// support MSVC++6.0
if (compHandles[i] == 0) for (int i = 0; i < numHandles; ++i) {
return 0; if (compHandles[i] == 0)
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]); return 0;
if (base->getAsLinker()) { TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
cObjects.push_back(base->getAsLinker()); if (base->getAsLinker()) {
cObjects.push_back(base->getAsLinker());
}
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
if (cObjects[i] == 0)
return 0;
} }
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
if (cObjects[i] == 0)
return 0;
} }
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle); TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
@ -422,11 +437,13 @@ int ShLinkExt(
linker->infoSink.info.erase(); linker->infoSink.info.erase();
for (i = 0; i < numHandles; ++i) { {// support MSVC++6.0
if (cObjects[i]->getAsCompiler()) { for (int i = 0; i < numHandles; ++i) {
if (! cObjects[i]->getAsCompiler()->linkable()) { if (cObjects[i]->getAsCompiler()) {
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code."); if (! cObjects[i]->getAsCompiler()->linkable()) {
return 0; linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
return 0;
}
} }
} }
} }
@ -554,7 +571,7 @@ int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
if (handle == 0) if (handle == 0)
return 0; return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0) if (linker == 0)
return 0; return 0;

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -53,8 +53,6 @@ void TType::buildMangledName(TString& mangledName)
else if (isVector()) else if (isVector())
mangledName += 'v'; mangledName += 'v';
unsigned int i;
switch (type) { switch (type) {
case EbtFloat: mangledName += 'f'; break; case EbtFloat: mangledName += 'f'; break;
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
@ -67,10 +65,13 @@ void TType::buildMangledName(TString& mangledName)
case EbtSampler2DShadow: mangledName += "sS2"; break; case EbtSampler2DShadow: mangledName += "sS2"; break;
case EbtStruct: case EbtStruct:
mangledName += "struct-"; mangledName += "struct-";
mangledName += typeName; if (typeName)
for (i = 0; i < structure->size(); ++i) { mangledName += *typeName;
mangledName += '-'; {// support MSVC++6.0
(*structure)[i].type->buildMangledName(mangledName); for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName);
}
} }
default: default:
break; break;
@ -124,8 +125,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const
// //
TFunction::~TFunction() TFunction::~TFunction()
{ {
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i) for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
delete (*i).type; delete (*i).type;
} }
// //
@ -133,8 +134,8 @@ TFunction::~TFunction()
// //
TSymbolTableLevel::~TSymbolTableLevel() TSymbolTableLevel::~TSymbolTableLevel()
{ {
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
delete (*it).second; delete (*it).second;
} }
// //
@ -154,3 +155,81 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
} }
} }
} }
TSymbol::TSymbol(const TSymbol& copyOf)
{
name = NewPoolTString(copyOf.name->c_str());
uniqueId = copyOf.uniqueId;
}
TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
{
type.copyType(copyOf.type, remapper);
userType = copyOf.userType;
// for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL
assert(copyOf.arrayInformationType == 0);
arrayInformationType = 0;
if (copyOf.unionArray) {
assert(!copyOf.type.getStruct());
assert(copyOf.type.getInstanceSize() == 1);
unionArray = new constUnion[1];
switch (type.getBasicType()) {
case EbtFloat: unionArray[0].fConst = copyOf.unionArray[0].fConst; break;
case EbtInt: unionArray[0].iConst = copyOf.unionArray[0].iConst; break;
case EbtBool: unionArray[0].bConst = copyOf.unionArray[0].bConst; break;
default:
assert (false && "Unknown type");
}
} else
unionArray = 0;
}
TVariable* TVariable::clone(TStructureMap& remapper)
{
TVariable *variable = new TVariable(*this, remapper);
return variable;
}
TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
{
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
TParameter param;
parameters.push_back(param);
parameters.back().copyParam(copyOf.parameters[i], remapper);
}
returnType.copyType(copyOf.returnType, remapper);
mangledName = copyOf.mangledName;
op = copyOf.op;
defined = copyOf.defined;
}
TFunction* TFunction::clone(TStructureMap& remapper)
{
TFunction *function = new TFunction(*this, remapper);
return function;
}
TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)
{
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
tLevel::iterator iter;
for (iter = level.begin(); iter != level.end(); ++iter) {
symTableLevel->insert(*iter->second->clone(remapper));
}
return symTableLevel;
}
void TSymbolTable::copyTable(const TSymbolTable& copyOf)
{
TStructureMap remapper;
uniqueId = copyOf.uniqueId;
for (unsigned int i = 0; i < copyOf.table.size(); ++i) {
table.push_back(copyOf.table[i]->clone(remapper));
}
}

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -77,6 +77,8 @@ public:
void setUniqueId(int id) { uniqueId = id; } void setUniqueId(int id) { uniqueId = id; }
int getUniqueId() const { return uniqueId; } int getUniqueId() const { return uniqueId; }
virtual void dump(TInfoSink &infoSink) const = 0; virtual void dump(TInfoSink &infoSink) const = 0;
TSymbol(const TSymbol&);
virtual TSymbol* clone(TStructureMap& remapper) = 0;
protected: protected:
const TString *name; const TString *name;
@ -95,11 +97,11 @@ protected:
// //
class TVariable : public TSymbol { class TVariable : public TSymbol {
public: public:
TVariable(const TString *name, TType t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { } TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
virtual ~TVariable() { } virtual ~TVariable() { }
virtual bool isVariable() const { return true; } virtual bool isVariable() const { return true; }
TType& getType() { return type; } TType& getType() { return type; }
const TType getType() const { return type; } const TType& getType() const { return type; }
bool isUserType() const { return userType; } bool isUserType() const { return userType; }
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); } void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
void updateArrayInformationType(TType *t) { arrayInformationType = t; } void updateArrayInformationType(TType *t) { arrayInformationType = t; }
@ -124,6 +126,8 @@ public:
delete unionArray; delete unionArray;
unionArray = constArray; unionArray = constArray;
} }
TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
virtual TVariable* clone(TStructureMap& remapper);
protected: protected:
TType type; TType type;
@ -141,6 +145,10 @@ protected:
struct TParameter { struct TParameter {
TString *name; TString *name;
TType* type; TType* type;
void copyParam(const TParameter& param, TStructureMap& remapper) {
name = NewPoolTString(param.name->c_str());
type = param.type->clone(remapper);
}
}; };
// //
@ -153,7 +161,7 @@ public:
returnType(TType(EbtVoid)), returnType(TType(EbtVoid)),
op(o), op(o),
defined(false) { } defined(false) { }
TFunction(const TString *name, TType retType, TOperator tOp = EOpNull) : TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
TSymbol(name), TSymbol(name),
returnType(retType), returnType(retType),
mangledName(*name + '('), mangledName(*name + '('),
@ -180,6 +188,8 @@ public:
const TParameter& operator [](int i) const { return parameters[i]; } const TParameter& operator [](int i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const; virtual void dump(TInfoSink &infoSink) const;
TFunction(const TFunction&, TStructureMap& remapper);
virtual TFunction* clone(TStructureMap& remapper);
protected: protected:
typedef TVector<TParameter> TParamList; typedef TVector<TParameter> TParamList;
@ -219,6 +229,7 @@ public:
void relateToOperator(const char* name, TOperator op); void relateToOperator(const char* name, TOperator op);
void dump(TInfoSink &infoSink) const; void dump(TInfoSink &infoSink) const;
TSymbolTableLevel* clone(TStructureMap& remapper);
protected: protected:
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel; typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
@ -258,8 +269,9 @@ public:
// globals are at level 1. // globals are at level 1.
// //
bool isEmpty() { return table.size() == 0; } bool isEmpty() { return table.size() == 0; }
bool atBuiltInLevel() { return table.size() == 1; } bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
bool atGlobalLevel() { return table.size() <= 2; } bool atSharedBuiltInLevel() { return table.size() == 1; }
bool atGlobalLevel() { return table.size() <= 3; }
void push() { void push() {
table.push_back(new TSymbolTableLevel); table.push_back(new TSymbolTableLevel);
} }
@ -291,12 +303,15 @@ public:
return symbol; return symbol;
} }
TSymbolTableLevel* getGlobalLevel() { assert (table.size() >= 3); return table[2]; }
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); } void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
int getMaxSymbolId() { return uniqueId; } int getMaxSymbolId() { return uniqueId; }
void dump(TInfoSink &infoSink) const; void dump(TInfoSink &infoSink) const;
void copyTable(const TSymbolTable& copyOf);
protected: protected:
int currentLevel() const { return static_cast<int>(table.size()) - 1; } int currentLevel() const { return static_cast<int>(table.size()) - 1; }
bool atDynamicBuiltInLevel() { return table.size() == 2; }
std::vector<TSymbolTableLevel*> table; std::vector<TSymbolTableLevel*> table;
int uniqueId; // for unique identification in code generation int uniqueId; // for unique identification in code generation

View File

@ -1,4 +1,223 @@
typedef union { /* A Bison parser, made by GNU Bison 1.875. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
ATTRIBUTE = 258,
CONST_QUAL = 259,
BOOL_TYPE = 260,
FLOAT_TYPE = 261,
INT_TYPE = 262,
BREAK = 263,
CONTINUE = 264,
DO = 265,
ELSE = 266,
FOR = 267,
IF = 268,
DISCARD = 269,
RETURN = 270,
BVEC2 = 271,
BVEC3 = 272,
BVEC4 = 273,
IVEC2 = 274,
IVEC3 = 275,
IVEC4 = 276,
VEC2 = 277,
VEC3 = 278,
VEC4 = 279,
MATRIX2 = 280,
MATRIX3 = 281,
MATRIX4 = 282,
IN_QUAL = 283,
OUT_QUAL = 284,
INOUT_QUAL = 285,
UNIFORM = 286,
VARYING = 287,
STRUCT = 288,
VOID_TYPE = 289,
WHILE = 290,
SAMPLER1D = 291,
SAMPLER2D = 292,
SAMPLER3D = 293,
SAMPLERCUBE = 294,
SAMPLER1DSHADOW = 295,
SAMPLER2DSHADOW = 296,
IDENTIFIER = 297,
TYPE_NAME = 298,
FLOATCONSTANT = 299,
INTCONSTANT = 300,
BOOLCONSTANT = 301,
FIELD_SELECTION = 302,
LEFT_OP = 303,
RIGHT_OP = 304,
INC_OP = 305,
DEC_OP = 306,
LE_OP = 307,
GE_OP = 308,
EQ_OP = 309,
NE_OP = 310,
AND_OP = 311,
OR_OP = 312,
XOR_OP = 313,
MUL_ASSIGN = 314,
DIV_ASSIGN = 315,
ADD_ASSIGN = 316,
MOD_ASSIGN = 317,
LEFT_ASSIGN = 318,
RIGHT_ASSIGN = 319,
AND_ASSIGN = 320,
XOR_ASSIGN = 321,
OR_ASSIGN = 322,
SUB_ASSIGN = 323,
LEFT_PAREN = 324,
RIGHT_PAREN = 325,
LEFT_BRACKET = 326,
RIGHT_BRACKET = 327,
LEFT_BRACE = 328,
RIGHT_BRACE = 329,
DOT = 330,
COMMA = 331,
COLON = 332,
EQUAL = 333,
SEMICOLON = 334,
BANG = 335,
DASH = 336,
TILDE = 337,
PLUS = 338,
STAR = 339,
SLASH = 340,
PERCENT = 341,
LEFT_ANGLE = 342,
RIGHT_ANGLE = 343,
VERTICAL_BAR = 344,
CARET = 345,
AMPERSAND = 346,
QUESTION = 347
};
#endif
#define ATTRIBUTE 258
#define CONST_QUAL 259
#define BOOL_TYPE 260
#define FLOAT_TYPE 261
#define INT_TYPE 262
#define BREAK 263
#define CONTINUE 264
#define DO 265
#define ELSE 266
#define FOR 267
#define IF 268
#define DISCARD 269
#define RETURN 270
#define BVEC2 271
#define BVEC3 272
#define BVEC4 273
#define IVEC2 274
#define IVEC3 275
#define IVEC4 276
#define VEC2 277
#define VEC3 278
#define VEC4 279
#define MATRIX2 280
#define MATRIX3 281
#define MATRIX4 282
#define IN_QUAL 283
#define OUT_QUAL 284
#define INOUT_QUAL 285
#define UNIFORM 286
#define VARYING 287
#define STRUCT 288
#define VOID_TYPE 289
#define WHILE 290
#define SAMPLER1D 291
#define SAMPLER2D 292
#define SAMPLER3D 293
#define SAMPLERCUBE 294
#define SAMPLER1DSHADOW 295
#define SAMPLER2DSHADOW 296
#define IDENTIFIER 297
#define TYPE_NAME 298
#define FLOATCONSTANT 299
#define INTCONSTANT 300
#define BOOLCONSTANT 301
#define FIELD_SELECTION 302
#define LEFT_OP 303
#define RIGHT_OP 304
#define INC_OP 305
#define DEC_OP 306
#define LE_OP 307
#define GE_OP 308
#define EQ_OP 309
#define NE_OP 310
#define AND_OP 311
#define OR_OP 312
#define XOR_OP 313
#define MUL_ASSIGN 314
#define DIV_ASSIGN 315
#define ADD_ASSIGN 316
#define MOD_ASSIGN 317
#define LEFT_ASSIGN 318
#define RIGHT_ASSIGN 319
#define AND_ASSIGN 320
#define XOR_ASSIGN 321
#define OR_ASSIGN 322
#define SUB_ASSIGN 323
#define LEFT_PAREN 324
#define RIGHT_PAREN 325
#define LEFT_BRACKET 326
#define RIGHT_BRACKET 327
#define LEFT_BRACE 328
#define RIGHT_BRACE 329
#define DOT 330
#define COMMA 331
#define COLON 332
#define EQUAL 333
#define SEMICOLON 334
#define BANG 335
#define DASH 336
#define TILDE 337
#define PLUS 338
#define STAR 339
#define SLASH 340
#define PERCENT 341
#define LEFT_ANGLE 342
#define RIGHT_ANGLE 343
#define VERTICAL_BAR 344
#define CARET 345
#define AMPERSAND 346
#define QUESTION 347
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 117 "glslang.y"
typedef union YYSTYPE {
struct { struct {
TSourceLoc line; TSourceLoc line;
union { union {
@ -28,94 +247,14 @@ typedef union {
}; };
} interm; } interm;
} YYSTYPE; } YYSTYPE;
#define ATTRIBUTE 258 /* Line 1240 of yacc.c. */
#define CONST_QUAL 259 #line 251 "glslang.tab.h"
#define BOOL_TYPE 260 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
#define FLOAT_TYPE 261 # define YYSTYPE_IS_DECLARED 1
#define INT_TYPE 262 # define YYSTYPE_IS_TRIVIAL 1
#define BREAK 263 #endif
#define CONTINUE 264
#define DO 265
#define ELSE 266
#define FOR 267
#define IF 268
#define DISCARD 269
#define RETURN 270
#define BVEC2 271
#define BVEC3 272
#define BVEC4 273
#define IVEC2 274
#define IVEC3 275
#define IVEC4 276
#define VEC2 277
#define VEC3 278
#define VEC4 279
#define MATRIX2 280
#define MATRIX3 281
#define MATRIX4 282
#define IN_QUAL 283
#define OUT_QUAL 284
#define INOUT_QUAL 285
#define UNIFORM 286
#define VARYING 287
#define STRUCT 288
#define VOID_TYPE 289
#define WHILE 290
#define SAMPLER1D 291
#define SAMPLER2D 292
#define SAMPLER3D 293
#define SAMPLERCUBE 294
#define SAMPLER1DSHADOW 295
#define SAMPLER2DSHADOW 296
#define IDENTIFIER 297
#define TYPE_NAME 298
#define FLOATCONSTANT 299
#define INTCONSTANT 300
#define BOOLCONSTANT 301
#define FIELD_SELECTION 302
#define LEFT_OP 303
#define RIGHT_OP 304
#define INC_OP 305
#define DEC_OP 306
#define LE_OP 307
#define GE_OP 308
#define EQ_OP 309
#define NE_OP 310
#define AND_OP 311
#define OR_OP 312
#define XOR_OP 313
#define MUL_ASSIGN 314
#define DIV_ASSIGN 315
#define ADD_ASSIGN 316
#define MOD_ASSIGN 317
#define LEFT_ASSIGN 318
#define RIGHT_ASSIGN 319
#define AND_ASSIGN 320
#define XOR_ASSIGN 321
#define OR_ASSIGN 322
#define SUB_ASSIGN 323
#define LEFT_PAREN 324
#define RIGHT_PAREN 325
#define LEFT_BRACKET 326
#define RIGHT_BRACKET 327
#define LEFT_BRACE 328
#define RIGHT_BRACE 329
#define DOT 330
#define COMMA 331
#define COLON 332
#define EQUAL 333
#define SEMICOLON 334
#define BANG 335
#define DASH 336
#define TILDE 337
#define PLUS 338
#define STAR 339
#define SLASH 340
#define PERCENT 341
#define LEFT_ANGLE 342
#define RIGHT_ANGLE 343
#define VERTICAL_BAR 344
#define CARET 345
#define AMPERSAND 346
#define QUESTION 347

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -64,6 +64,7 @@ public:
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc); TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc); TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc); TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc); TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ; TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
TIntermTyped* copyConstUnion(TIntermConstantUnion*) ; TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -40,7 +40,7 @@
// //
class TConstTraverser : public TIntermTraverser { class TConstTraverser : public TIntermTraverser {
public: public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType t) : unionArray(cUnion), type(t), TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;} constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;}
int index ; int index ;
constUnion *unionArray; constUnion *unionArray;
@ -174,7 +174,6 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it) bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
{ {
TConstTraverser* oit = static_cast<TConstTraverser*>(it); TConstTraverser* oit = static_cast<TConstTraverser*>(it);
TType tt = node->getType();
if (!node->isConstructor() && node->getOp() != EOpComma) { if (!node->isConstructor() && node->getOp() != EOpComma) {
char buf[200]; char buf[200];

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -75,9 +75,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// atom.c /* atom.c */
*/ /* */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@ -90,9 +90,9 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef realloc #undef realloc
#undef free #undef free
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
////////////////////////////////////////// String table: ////////////////////////////////////// /*//////////////////////////////////////// String table: ////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
static const struct { static const struct {
int val; int val;
@ -130,9 +130,9 @@ static const struct {
{ CPP_TYPEIDENTIFIER, "<type-ident>" }, { CPP_TYPEIDENTIFIER, "<type-ident>" },
}; };
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
////////////////////////////////////////// String table: ////////////////////////////////////// /*//////////////////////////////////////// String table: ////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
#define INIT_STRING_TABLE_SIZE 16384 #define INIT_STRING_TABLE_SIZE 16384
@ -228,9 +228,9 @@ static int AddString(StringTable *stable, const char *s)
return loc; return loc;
} /* AddString */ } /* AddString */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////////////// Hash table: /////////////////////////////////////// /*///////////////////////////////////////// Hash table: /////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
#define INIT_HASH_TABLE_SIZE 2047 #define INIT_HASH_TABLE_SIZE 2047
#define HASH_TABLE_MAX_COLLISIONS 3 #define HASH_TABLE_MAX_COLLISIONS 3
@ -316,24 +316,24 @@ static int Match(HashTable *htable, StringTable *stable, const char *s, int hash
} }
} /* Match */ } /* Match */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////////////// Atom table: /////////////////////////////////////// /*///////////////////////////////////////// Atom table: /////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
#define INIT_ATOM_TABLE_SIZE 1024 #define INIT_ATOM_TABLE_SIZE 1024
struct AtomTable_Rec { struct AtomTable_Rec {
StringTable stable; /* String table. */ StringTable stable; /* String table. */
HashTable htable; /* Hashes string to atom number and token value. Multiple strings can HashTable htable; /* Hashes string to atom number and token value. Multiple strings can */
// have the same token value but each unique string is a unique atom. */ /* have the same token value but each unique string is a unique atom. */
int *amap; /* Maps atom value to offset in string table. Atoms all map to unique int *amap; /* Maps atom value to offset in string table. Atoms all map to unique */
// strings except for some undefined values in the lower, fixed part /* strings except for some undefined values in the lower, fixed part */
// of the atom table that map to "<undefined>". The lowest 256 atoms /* of the atom table that map to "<undefined>". The lowest 256 atoms */
// correspond to single character ASCII values except for alphanumeric /* correspond to single character ASCII values except for alphanumeric */
// characters and '_', which can be other tokens. Next come the /* characters and '_', which can be other tokens. Next come the */
// language tokens with their atom values equal to the token value. /* language tokens with their atom values equal to the token value. */
// Then come predefined atoms, followed by user specified identifiers. */ /* Then come predefined atoms, followed by user specified identifiers. */
int *arev; /* Reversed atom for symbol table use. */ int *arev; /* Reversed atom for symbol table use. */
int nextFree; int nextFree;
int size; int size;
@ -396,8 +396,8 @@ static int lReverse(int fval)
cnt++; cnt++;
} }
/* Don't use all 31 bits. One million atoms is plenty and sometimes the /* Don't use all 31 bits. One million atoms is plenty and sometimes the */
// upper bits are used for other things. */ /* upper bits are used for other things. */
if (cnt < 20) if (cnt < 20)
result <<= 20 - cnt; result <<= 20 - cnt;
@ -636,8 +636,8 @@ static int AddAtomFixed(AtomTable *atable, const char *s, int atom)
} }
atable->amap[atom] = atable->htable.entry[hashindex].index; atable->amap[atom] = atable->htable.entry[hashindex].index;
atable->htable.entry[hashindex].value = atom; atable->htable.entry[hashindex].value = atom;
/*if (atom >= atable->nextFree) /*if (atom >= atable->nextFree) */
// atable->nextFree = atom + 1; */ /* atable->nextFree = atom + 1; */
while (atom >= atable->nextFree) { while (atom >= atable->nextFree) {
atable->arev[atable->nextFree] = lReverse(atable->nextFree); atable->arev[atable->nextFree] = lReverse(atable->nextFree);
atable->nextFree++; atable->nextFree++;
@ -702,9 +702,9 @@ int InitAtomTable(AtomTable *atable, int htsize)
return 1; return 1;
} /* InitAtomTable */ } /* InitAtomTable */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
////////////////////////////////// Debug Printing Functions: ////////////////////////////////// /*//////////////////////////////// Debug Printing Functions: ////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
/* /*
* PrintAtomTable() * PrintAtomTable()
@ -762,7 +762,7 @@ void FreeAtomTable(AtomTable *atable)
atable->size = 0; atable->size = 0;
} /* FreeAtomTable */ } /* FreeAtomTable */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
///////////////////////////////////////// End of atom.c /////////////////////////////////////// /*/////////////////////////////////////// End of atom.c /////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// atom.h /* atom.h */
*/ /* */
#if !defined(__ATOM_H) #if !defined(__ATOM_H)
#define __ATOM_H 1 #define __ATOM_H 1

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// compile.h /* compile.h */
*/ /* */
#if !defined(__COMPILE_H) #if !defined(__COMPILE_H)
#define __COMPILE_H 1 #define __COMPILE_H 1
@ -108,24 +108,25 @@ struct CPPStruct_Rec {
int previous_token; int previous_token;
int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */ int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
void *pC; /* storing the parseContext of the compile object in cpp. */ void *pC; /* storing the parseContext of the compile object in cpp. */
/* Private members: */ /* Private members: */
SourceLoc ltokenLoc; SourceLoc ltokenLoc;
int ifdepth; /* current #if-#else-#endif nesting in the cpp.c file (pre-processor) */ int ifdepth; /*current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
int elsedepth[64]; /* Keep a track of #if depth..Max allowed is 64. */ int elsedepth[64]; /*Keep a track of #if depth..Max allowed is 64. */
int elsetracker; /* #if-#else and #endif constructs...Counter. */ int elsetracker; /*#if-#else and #endif constructs...Counter. */
const char *ErrMsg; const char *ErrMsg;
int CompileError; /* Indicate compile error when #error, #else,#elif mismatch. */ int CompileError; /*Indicate compile error when #error, #else,#elif mismatch. */
/* /* */
// Globals used to communicate between PaParseStrings() and yy_input()and /* Globals used to communicate between PaParseStrings() and yy_input()and */
// also across the files.(gen_glslang.cpp and scanner.c) /* also across the files.(gen_glslang.cpp and scanner.c) */
*/ /* */
int PaWhichStr; /* which string we're parsing */ int PaWhichStr; /* which string we're parsing */
int* PaStrLen; /* array of lengths of the PaArgv strings */ int* PaStrLen; /* array of lengths of the PaArgv strings */
int PaArgc; /* count of strings in the array */ int PaArgc; /* count of strings in the array */
char** PaArgv; /* our array of strings to parse */ char** PaArgv; /* our array of strings to parse */
unsigned int tokensBeforeEOF : 1;
}; };
#endif /* !defined(__COMPILE_H) */ #endif /* !defined(__COMPILE_H) */

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// cpp.c /* cpp.c */
*/ /* */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
@ -86,8 +86,6 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "slglobals.h" #include "slglobals.h"
#include "slang_mesa.h"
static int CPPif(yystypepp * yylvalpp); static int CPPif(yystypepp * yylvalpp);
/* Don't use memory.c's replacements, as we clean up properly here */ /* Don't use memory.c's replacements, as we clean up properly here */
@ -154,7 +152,7 @@ int InitCPP(void)
strcpy(buffer, "PROFILE_"); strcpy(buffer, "PROFILE_");
t = buffer + strlen(buffer); t = buffer + strlen(buffer);
f = cpp->options.profileString; f = cpp->options.profileString;
while ((_mesa_isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1) while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)
*t++ = toupper(*f++); *t++ = toupper(*f++);
*t = 0; *t = 0;
return 1; return 1;
@ -299,10 +297,13 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
while (token > 0) { while (token > 0) {
if (token != '#') {
while (token != '\n') while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != '#')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
continue; continue;
}
if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER) if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)
continue; continue;
atom = yylvalpp->sc_ident; atom = yylvalpp->sc_ident;
@ -321,7 +322,13 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
--cpp->ifdepth; --cpp->ifdepth;
} }
else if (((int)(matchelse) != 0)&& depth==0) { else if (((int)(matchelse) != 0)&& depth==0) {
if (atom == elseAtom ){ if (atom == elseAtom ) {
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
break; break;
} }
else if (atom == elifAtom) { else if (atom == elifAtom) {
@ -472,7 +479,7 @@ static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)
} }
return token; return token;
error: error:
CPPErrorToInfoLog("#if");; CPPErrorToInfoLog("incorrect preprocessor directive");
*err = 1; *err = 1;
*res = 0; *res = 0;
return token; return token;
@ -490,10 +497,14 @@ static int CPPif(yystypepp * yylvalpp) {
} }
token = eval(token, MIN_PREC, &res, &err, yylvalpp); token = eval(token, MIN_PREC, &res, &err, yylvalpp);
if (token != '\n') { if (token != '\n') {
CPPErrorToInfoLog("#if"); CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");
} else if (!res && !err) { while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
if (!res && !err) {
token = CPPelse(1, yylvalpp); token = CPPelse(1, yylvalpp);
} }
return token; return token;
} /* CPPif */ } /* CPPif */
@ -510,6 +521,12 @@ static int CPPifdef(int defined, yystypepp * yylvalpp)
defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef"); defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
} else { } else {
Symbol *s = LookUpSymbol(macros, name); Symbol *s = LookUpSymbol(macros, name);
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
if (((s && !s->details.mac.undef) ? 1 : 0) != defined) if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
token = CPPelse(1, yylvalpp); token = CPPelse(1, yylvalpp);
} }
@ -566,46 +583,78 @@ static int CPPerror(yystypepp * yylvalpp) {
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} }
DecLineNumber(); DecLineNumber();
/* store this msg into the shader's information log..set the Compile Error flag!!!! */ /*store this msg into the shader's information log..set the Compile Error flag!!!! */
message=GetStrfromTStr(); message=GetStrfromTStr();
CPPShInfoLogMsg(message); CPPShInfoLogMsg(message);
ResetTString(); ResetTString();
cpp->CompileError=1; cpp->CompileError=1;
IncLineNumber(); IncLineNumber();
return '\n'; return '\n';
}/* CPPerror */ }/*CPPerror */
static int CPPpragma(yystypepp * yylvalpp) static int CPPpragma(yystypepp * yylvalpp)
{ {
const char *SrcStr; char SrcStrName[2];
const char *DestStr; char** allTokens;
int tokenCount = 0;
int maxTokenCount = 10;
const char* SrcStr;
int i;
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if(token=='\n'){ if (token=='\n') {
DecLineNumber(); DecLineNumber();
CPPErrorToInfoLog("#pragma"); CPPErrorToInfoLog("#pragma");
IncLineNumber(); IncLineNumber();
return token; return token;
} }
if (token != CPP_IDENTIFIER)goto error;
allTokens = (char**)malloc(sizeof(char*) * maxTokenCount);
while (token != '\n') {
if (tokenCount >= maxTokenCount) {
maxTokenCount *= 2;
allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount);
}
switch (token) {
case CPP_IDENTIFIER:
SrcStr = GetAtomString(atable, yylvalpp->sc_ident); SrcStr = GetAtomString(atable, yylvalpp->sc_ident);
allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
strcpy(allTokens[tokenCount++], SrcStr);
break;
case CPP_INTCONSTANT:
SrcStr = yylvalpp->symbol_name;
allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
strcpy(allTokens[tokenCount++], SrcStr);
break;
case CPP_FLOATCONSTANT:
SrcStr = yylvalpp->symbol_name;
allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
strcpy(allTokens[tokenCount++], SrcStr);
break;
case -1:
/* EOF */
CPPShInfoLogMsg("#pragma directive must end with a newline");
return token;
default:
SrcStrName[0] = token;
SrcStrName[1] = '\0';
allTokens[tokenCount] = (char*)malloc(2);
strcpy(allTokens[tokenCount++], SrcStrName);
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token == '(') {
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != CPP_IDENTIFIER) goto error;
DestStr = GetAtomString(atable, yylvalpp->sc_ident);
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != ')') goto error;
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if(token!='\n')goto error;
/* make a call to CPP function MapStrings with SrcStr and DestStr. */
MapStrings(SrcStr,DestStr);
}else{
error:
CPPErrorToInfoLog("#pragma");
return token;
} }
cpp->currentInput->ungetch(cpp->currentInput, token, yylvalpp);
HandlePragma(allTokens, tokenCount);
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
for (i = 0; i < tokenCount; ++i) {
free (allTokens[i]);
}
free (allTokens);
return token; return token;
} /* CPPpragma */ } /* CPPpragma */
@ -629,7 +678,7 @@ static int CPPversion(yystypepp * yylvalpp)
CPPErrorToInfoLog("#version"); CPPErrorToInfoLog("#version");
yylvalpp->sc_int=atoi(yylvalpp->symbol_name); yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
/* SetVersionNumber(yylvalpp->sc_int); */ /*SetVersionNumber(yylvalpp->sc_int); */
if (yylvalpp->sc_int != GL2_VERSION_NUMBER) if (yylvalpp->sc_int != GL2_VERSION_NUMBER)
CPPShInfoLogMsg("Version number not supported by GL2"); CPPShInfoLogMsg("Version number not supported by GL2");
@ -701,6 +750,12 @@ int readCPPline(yystypepp * yylvalpp)
if (!cpp->ifdepth ){ if (!cpp->ifdepth ){
CPPErrorToInfoLog("#else mismatch"); CPPErrorToInfoLog("#else mismatch");
cpp->CompileError=1; cpp->CompileError=1;
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} }
token = CPPelse(0, yylvalpp); token = CPPelse(0, yylvalpp);
}else{ }else{
@ -714,6 +769,10 @@ int readCPPline(yystypepp * yylvalpp)
CPPErrorToInfoLog("#elif mismatch"); CPPErrorToInfoLog("#elif mismatch");
cpp->CompileError=1; cpp->CompileError=1;
} }
/* this token is really a dont care, but we still need to eat the tokens */
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
token = CPPelse(0, yylvalpp); token = CPPelse(0, yylvalpp);
} else if (yylvalpp->sc_ident == endifAtom) { } else if (yylvalpp->sc_ident == endifAtom) {
cpp->elsedepth[cpp->elsetracker]=0; cpp->elsedepth[cpp->elsetracker]=0;

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// cpp.h /* cpp.h */
*/ /* */
#if !defined(__CPP_H) #if !defined(__CPP_H)
#define __CPP_H 1 #define __CPP_H 1
@ -103,15 +103,16 @@ int PredefineMacro(char *);
void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */ void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */ void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
void MapStrings(const char*,const char*); /* #pragma directive container. */ void CPPWarningToInfoLog(const char *msg); /* Prints warning messages into info log */
void HandlePragma(const char**, int numTokens); /* #pragma directive container. */
void ResetTString(void); /* #error Message as TString. */ void ResetTString(void); /* #error Message as TString. */
void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log */ void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log . */
void StoreStr(char*); /* Store the TString in Parse Context. */ void StoreStr(char*); /* Store the TString in Parse Context. */
void SetLineNumber(int); /* Set line number. */ void SetLineNumber(int); /* Set line number. */
void SetStringNumber(int); /* Set string number. */ void SetStringNumber(int); /* Set string number. */
int GetLineNumber(void); /* Get the current String Number. */ int GetLineNumber(void); /* Get the current String Number. */
int GetStringNumber(void); /* Get the current String Number. */ int GetStringNumber(void); /* Get the current String Number. */
const char* GetStrfromTStr(void); /* Convert TString to String. */ const char* GetStrfromTStr(void); /* Convert TString to String. */
void updateExtensionBehavior(const char* extName, const char* behavior); void updateExtensionBehavior(const char* extName, const char* behavior);
int FreeCPP(void); int FreeCPP(void);

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// cppstruct.c /* cppstruct.c */
*/ /* */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -131,6 +131,7 @@ int ResetPreprocessor(void)
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++) for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
cpp->elsedepth[cpp->elsetracker]=0; cpp->elsedepth[cpp->elsetracker]=0;
cpp->elsetracker=0; cpp->elsetracker=0;
cpp->tokensBeforeEOF = 0;
return 1; return 1;
} }
@ -152,7 +153,7 @@ int InitPreprocessor(void)
return 0; return 0;
} }
/* FreeCPPStruct() - Free the CPP structure. */ /*FreeCPPStruct() - Free the CPP structure. */
int FreeCPPStruct(void) int FreeCPPStruct(void)
{ {
@ -165,7 +166,7 @@ int FreeCPPStruct(void)
return 1; return 1;
} }
/* Finalizing the Preprocessor. */ /*Finalizing the Preprocessor. */
int FinalizePreprocessor(void) int FinalizePreprocessor(void)
{ {
@ -179,6 +180,6 @@ int FinalizePreprocessor(void)
} }
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
////////////////////////////////////// End of cppstruct.c ////////////////////////////////////// /*//////////////////////////////////// End of cppstruct.c ////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,7 +74,7 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* */
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -160,8 +160,8 @@ void *mem_Alloc(MemoryPool *pool, size_t size)
& ~pool->alignmask; & ~pool->alignmask;
pool->free = (uintptr_t)rv; pool->free = (uintptr_t)rv;
if (minreq >= pool->chunksize) { if (minreq >= pool->chunksize) {
/* request size is too big for the chunksize, so allocate it as /* request size is too big for the chunksize, so allocate it as */
// a single chunk of the right size */ /* a single chunk of the right size */
ch = malloc(minreq); ch = malloc(minreq);
if (!ch) return 0; if (!ch) return 0;
} else { } else {

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,7 +74,7 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* */
#ifndef __MEMORY_H #ifndef __MEMORY_H
#define __MEMORY_H #define __MEMORY_H

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// scanner.c /* scanner.c */
*/ /* */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
@ -194,7 +194,7 @@ static int str_getch(StringInputSrc *in)
static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) { static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {
if (in->p[-1] == ch)in->p--; if (in->p[-1] == ch)in->p--;
else { else {
*(in->p)='\0'; /* this would take care of shifting to the previous string. */ *(in->p)='\0'; /*this would take care of shifting to the previous string. */
cpp->PaWhichStr--; cpp->PaWhichStr--;
} }
if (ch == '\n') { if (ch == '\n') {
@ -220,9 +220,9 @@ int ScanFromString(char *s)
} /* ScanFromString; */ } /* ScanFromString; */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////// Floating point constants: ///////////////////////////////// /*///////////////////////////////// Floating point constants: ///////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
/* /*
* lBuildFloatValue() - Quick and dirty conversion to floating point. Since all * lBuildFloatValue() - Quick and dirty conversion to floating point. Since all
* we need is single precision this should be quite precise. * we need is single precision this should be quite precise.
@ -339,9 +339,9 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
return CPP_FLOATCONSTANT; return CPP_FLOATCONSTANT;
} /* lFloatConst */ } /* lFloatConst */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
///////////////////////////////////////// Normal Scanner ////////////////////////////////////// /*/////////////////////////////////////// Normal Scanner ////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
static int byte_scan(InputSrc *in, yystypepp * yylvalpp) static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
{ {
@ -755,9 +755,11 @@ int yylex_CPP(char* buf, int maxSize)
if (tokenString) { if (tokenString) {
if ((signed)strlen(tokenString) >= maxSize) { if ((signed)strlen(tokenString) >= maxSize) {
cpp->tokensBeforeEOF = 1;
return maxSize; return maxSize;
} else if (strlen(tokenString) > 0) { } else if (strlen(tokenString) > 0) {
strcpy(buf, tokenString); strcpy(buf, tokenString);
cpp->tokensBeforeEOF = 1;
return (int)strlen(tokenString); return (int)strlen(tokenString);
} }
@ -768,7 +770,7 @@ int yylex_CPP(char* buf, int maxSize)
return 0; return 0;
} /* yylex */ } /* yylex */
/* Checks if the token just read is EOF or not. */ /*Checks if the token just read is EOF or not. */
int check_EOF(int token) int check_EOF(int token)
{ {
if(token==-1){ if(token==-1){
@ -781,7 +783,7 @@ int check_EOF(int token)
return 0; return 0;
} }
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////////// End of scanner.c ////////////////////////////////////// /*///////////////////////////////////// End of scanner.c ////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// scanner.h /* scanner.h */
*/ /* */
#if !defined(__SCANNER_H) #if !defined(__SCANNER_H)
#define __SCANNER_H 1 #define __SCANNER_H 1
@ -105,9 +105,9 @@ typedef struct InputSrc {
int line; int line;
} InputSrc; } InputSrc;
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */ int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
int ScanFromString(char *); /* Start scanning the input from the string mentioned. */ int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
int check_EOF(int); /* check if we hit a EOF abruptly */ int check_EOF(int); /* check if we hit a EOF abruptly */
void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */ void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
void SetLineNumber(int); void SetLineNumber(int);
void SetStringNumber(int); void SetStringNumber(int);

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// slglobals.h /* slglobals.h */
*/ /* */
#if !defined(__SLGLOBALS_H) #if !defined(__SLGLOBALS_H)
#define __SLGLOBALS_H 1 #define __SLGLOBALS_H 1

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// symbols.c /* symbols.c */
*/ /* */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@ -85,9 +85,9 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "slglobals.h" #include "slglobals.h"
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////// Symbol Table Variables: /////////////////////////////////// /*///////////////////////////////// Symbol Table Variables: /////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */
Scope *ScopeList = NULL; Scope *ScopeList = NULL;
Scope *CurrentScope = NULL; Scope *CurrentScope = NULL;

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// symbols.h /* symbols.h */
*/ /* */
#if !defined(__SYMBOLS_H) #if !defined(__SYMBOLS_H)
#define __SYMBOLS_H 1 #define __SYMBOLS_H 1

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// tokens.c /* tokens.c */
*/ /* */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@ -86,11 +86,9 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "slglobals.h" #include "slglobals.h"
#include "slang_mesa.h" /*///////////////////////////////////////////////////////////////////////////////////////////// */
/*////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// */
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////*/
/* /*
* idstr() * idstr()
@ -108,7 +106,7 @@ static char *idstr(const char *fstr)
len = strlen(fstr); len = strlen(fstr);
str = (char *) malloc(len + 1); str = (char *) malloc(len + 1);
for (f=fstr, t=str; *f; f++) { for (f=fstr, t=str; *f; f++) {
if (_mesa_isalnum(*f)) *t++ = *f; if (isalnum(*f)) *t++ = *f;
else if (*f == '.' || *f == '/') *t++ = '_'; else if (*f == '.' || *f == '/') *t++ = '_';
} }
*t = 0; *t = 0;
@ -180,7 +178,7 @@ static int lReadByte(TokenStream *pTok)
return lval; return lval;
} /* lReadByte */ } /* lReadByte */
/*///////////////////////////////////// Global Functions:////////////////////////////////////*/ /*///////////////////////////////////// Global Functions:////////////////////////////////////// */
/* /*
* NewTokenStream() * NewTokenStream()
@ -443,10 +441,10 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident)); sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
break; break;
case CPP_FLOATCONSTANT: case CPP_FLOATCONSTANT:
/*printf("%g9.6 ", yylvalpp->sc_fval);*/ /*printf("%g9.6 ", yylvalpp->sc_fval); */
break; break;
case CPP_INTCONSTANT: case CPP_INTCONSTANT:
/*printf("%d ", yylvalpp->sc_int);*/ /*printf("%d ", yylvalpp->sc_int); */
break; break;
default: default:
if (token >= 127) if (token >= 127)
@ -459,6 +457,6 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
} }
} }
/*///////////////////////////////////////////////////////////////////////////////////////////// /*///////////////////////////////////////////////////////////////////////////////////////////// */
/////////////////////////////////////// End of tokens.c /////////////////////////////////////// /*///////////////////////////////////// End of tokens.c /////////////////////////////////////// */
/////////////////////////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////////////////////////// */

View File

@ -1,36 +1,36 @@
/* /* */
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. /*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
//All rights reserved. /*All rights reserved. */
// /* */
//Redistribution and use in source and binary forms, with or without /*Redistribution and use in source and binary forms, with or without */
//modification, are permitted provided that the following conditions /*modification, are permitted provided that the following conditions */
//are met: /*are met: */
// /* */
// Redistributions of source code must retain the above copyright /* Redistributions of source code must retain the above copyright */
// notice, this list of conditions and the following disclaimer. /* notice, this list of conditions and the following disclaimer. */
// /* */
// Redistributions in binary form must reproduce the above /* Redistributions in binary form must reproduce the above */
// copyright notice, this list of conditions and the following /* copyright notice, this list of conditions and the following */
// disclaimer in the documentation and/or other materials provided /* disclaimer in the documentation and/or other materials provided */
// with the distribution. /* with the distribution. */
// /* */
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its /* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
// contributors may be used to endorse or promote products derived /* contributors may be used to endorse or promote products derived */
// from this software without specific prior written permission. /* from this software without specific prior written permission. */
// /* */
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
//POSSIBILITY OF SUCH DAMAGE. /*POSSIBILITY OF SUCH DAMAGE. */
*/ /* */
/****************************************************************************\ /****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation. Copyright (c) 2002, NVIDIA Corporation.
@ -74,9 +74,9 @@ NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/ \****************************************************************************/
/* /* */
// tokens.h /* tokens.h */
*/ /* */
#if !defined(__TOKENS_H) #if !defined(__TOKENS_H)
#define __TOKENS_H 1 #define __TOKENS_H 1

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -39,6 +39,11 @@
// This file contains any Linux specific functions. // This file contains any Linux specific functions.
// //
/* WORKAROUND: linux builds seem not to define "linux" */
/*#if !(defined(linux))
#error Trying to include a Linux specific file in a non-Linux build.
#endif*/
#include <pthread.h> #include <pthread.h>
#include <semaphore.h> #include <semaphore.h>
#include <assert.h> #include <assert.h>

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -38,9 +38,9 @@
#include "osinclude.h" #include "osinclude.h"
#include "Initialisation.h" #include "Initialisation.h"
#if !(defined(linux)) /*#if !(defined(linux))
#error Trying to build a Linux specific file in a non-Linux build. #error Trying to build a Linux specific file in a non-Linux build.
#endif #endif*/
// //
// Thread cleanup // Thread cleanup

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -44,7 +44,7 @@
#error Trying to include a windows specific file in a non windows build. #error Trying to include a windows specific file in a non windows build.
#endif #endif
#define STRICT 1 #define STRICT
#define VC_EXTRALEAN 1 #define VC_EXTRALEAN 1
#include <windows.h> #include <windows.h>
#include <assert.h> #include <assert.h>

View File

@ -1,5 +1,5 @@
// //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -42,11 +42,7 @@
#error Trying to build a windows specific file in a non windows build. #error Trying to build a windows specific file in a non windows build.
#endif #endif
// BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
// disable DllMain on Mesa-3D builds, call appropriate Init* and Detach*
// routines manually in context initialization
//
/*BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
switch (fdwReason) switch (fdwReason)
{ {
@ -76,7 +72,7 @@
} }
return true; return true;
}*/ }
// //
// Thread Local Storage Operations // Thread Local Storage Operations

View File

@ -1,5 +1,5 @@
/* //
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd. //Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved. //All rights reserved.
// //
//Redistribution and use in source and binary forms, with or without //Redistribution and use in source and binary forms, with or without
@ -30,69 +30,47 @@
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE. //POSSIBILITY OF SUCH DAMAGE.
*/ //
#ifndef _COMPILER_INTERFACE_INCLUDED_ #ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_ #define _COMPILER_INTERFACE_INCLUDED_
#include "../Include/ResourceLimits.h"
#ifdef _WIN32 #ifdef _WIN32
#define C_DECL __cdecl #define C_DECL __cdecl
#define SH_IMPORT_EXPORT #ifdef SH_EXPORTING
#define SH_IMPORT_EXPORT __declspec(dllexport)
#else
#define SH_IMPORT_EXPORT __declspec(dllimport)
#endif
#else #else
#define SH_IMPORT_EXPORT #define SH_IMPORT_EXPORT
#define __fastcall #define __fastcall
#define C_DECL #define C_DECL
#endif #endif
/* //
// This is the platform independent interface between an OGL driver // This is the platform independent interface between an OGL driver
// and the shading language compiler/linker. // and the shading language compiler/linker.
*/ //
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* //
// Driver must call this first, once, before doing any other // Driver must call this first, once, before doing any other
// compiler/linker operations. // compiler/linker operations.
*/ //
SH_IMPORT_EXPORT int ShInitialize(); SH_IMPORT_EXPORT int ShInitialize();
/* //
// Driver should call this at shutdown. // Driver should call this at shutdown.
*/ //
SH_IMPORT_EXPORT int __fastcall ShFinalize(); SH_IMPORT_EXPORT int __fastcall ShFinalize();
/*
// to be used for hardwareDataType and userDataType by ICD
*/
typedef enum {
EFloat,
EInt,
EBool,
EFloat_Vec2,
EFloat_Vec3,
EFloat_Vec4,
EInt_Vec2,
EInt_Vec3,
EInt_Vec4,
EBool_Vec2,
EBool_Vec3,
EBool_Vec4,
EFloat_Mat2,
EFloat_Mat3,
EFloat_Mat4,
ESampler_1D,
ESampler_2D,
ESampler_3D,
ESampler_Cube,
ESampler_1D_Shadow,
ESampler_2D_Shadow,
EStruct
} ShBasicType;
/* //
// Types of languages the compiler can consume. // Types of languages the compiler can consume.
*/ //
typedef enum { typedef enum {
EShLangVertex, EShLangVertex,
EShLangFragment, EShLangFragment,
@ -101,9 +79,9 @@ typedef enum {
EShLangCount EShLangCount
} EShLanguage; } EShLanguage;
/* //
// Types of output the linker will create. // Types of output the linker will create.
*/ //
typedef enum { typedef enum {
EShExVertexFragment, EShExVertexFragment,
EShExPackFragment, EShExPackFragment,
@ -111,20 +89,20 @@ typedef enum {
EShExFragment EShExFragment
} EShExecutable; } EShExecutable;
/* //
// Optimization level for the compiler. // Optimization level for the compiler.
*/ //
typedef enum { typedef enum {
EShOptNoGeneration, EShOptNoGeneration,
EShOptNone, EShOptNone,
EShOptSimple, /* Optimizations that can be done quickly */ EShOptSimple, // Optimizations that can be done quickly
EShOptFull /* Optimizations that will take more time */ EShOptFull // Optimizations that will take more time
} EShOptimizationLevel; } EShOptimizationLevel;
/* //
// Build a table for bindings. This can be used for locating // Build a table for bindings. This can be used for locating
// attributes, uniforms, globals, etc., as needed. // attributes, uniforms, globals, etc., as needed.
*/ //
typedef struct { typedef struct {
char* name; char* name;
int binding; int binding;
@ -132,10 +110,10 @@ typedef struct {
typedef struct { typedef struct {
int numBindings; int numBindings;
ShBinding* bindings; /* array of bindings */ ShBinding* bindings; // array of bindings
} ShBindingTable; } ShBindingTable;
/* //
// ShHandle held by but opaque to the driver. It is allocated, // ShHandle held by but opaque to the driver. It is allocated,
// managed, and de-allocated by the compiler/linker. It's contents // managed, and de-allocated by the compiler/linker. It's contents
// are defined by and used by the compiler and linker. For example, // are defined by and used by the compiler and linker. For example,
@ -143,79 +121,79 @@ typedef struct {
// to the linker can be stored where ShHandle points. // to the linker can be stored where ShHandle points.
// //
// If handle creation fails, 0 will be returned. // If handle creation fails, 0 will be returned.
*/ //
typedef void* ShHandle; typedef void* ShHandle;
/* //
// Driver calls these to create and destroy compiler/linker // Driver calls these to create and destroy compiler/linker
// objects. // objects.
*/ //
SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); /* one per shader */ SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); // one per shader
SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); /* one per shader pair */ SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair
SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */ SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
SH_IMPORT_EXPORT void ShDestruct(ShHandle); SH_IMPORT_EXPORT void ShDestruct(ShHandle);
/* //
// The return value of ShCompile is boolean, indicating // The return value of ShCompile is boolean, indicating
// success or failure. // success or failure.
// //
// The info-log should be written by ShCompile into // The info-log should be written by ShCompile into
// ShHandle, so it can answer future queries. // ShHandle, so it can answer future queries.
*/ //
SH_IMPORT_EXPORT int ShCompile( SH_IMPORT_EXPORT int ShCompile(
const ShHandle, const ShHandle,
const char* const shaderStrings[], const char* const shaderStrings[],
const int numStrings, const int numStrings,
const EShOptimizationLevel, const EShOptimizationLevel,
const TBuiltInResource *resources,
int debugOptions int debugOptions
); );
/* //
// Similar to ShCompile, but accepts an opaque handle to an // Similar to ShCompile, but accepts an opaque handle to an
// intermediate language structure. // intermediate language structure.
*/ //
SH_IMPORT_EXPORT int ShCompileIntermediate( SH_IMPORT_EXPORT int ShCompileIntermediate(
ShHandle compiler, ShHandle compiler,
ShHandle intermediate, ShHandle intermediate,
const EShOptimizationLevel, const EShOptimizationLevel,
int debuggable /* boolean */ int debuggable // boolean
); );
SH_IMPORT_EXPORT int ShLink( SH_IMPORT_EXPORT int ShLink(
const ShHandle, /* linker object */ const ShHandle, // linker object
const ShHandle h[], /* compiler objects to link together */ const ShHandle h[], // compiler objects to link together
const int numHandles, const int numHandles,
ShHandle uniformMap, /* updated with new uniforms */ ShHandle uniformMap, // updated with new uniforms
short int** uniformsAccessed, /* returned with indexes of uniforms accessed */ short int** uniformsAccessed, // returned with indexes of uniforms accessed
int* numUniformsAccessed); int* numUniformsAccessed);
/* //
// ShSetEncrpytionMethod is a place-holder for specifying // ShSetEncrpytionMethod is a place-holder for specifying
// how source code is encrypted. // how source code is encrypted.
*/ //
SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle); SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);
/* //
// All the following return 0 if the information is not // All the following return 0 if the information is not
// available in the object passed down, or the object is bad. // available in the object passed down, or the object is bad.
*/ //
SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle); SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle);
SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle); SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle);
SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); /* to detect user aliasing */ SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); // to detect user aliasing
SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); /* to force any physical mappings */ SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); // to force any physical mappings
SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); /* for all attributes */ SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); // for all attributes
/* //
// Tell the linker to never assign a vertex attribute to this list of physical attributes // Tell the linker to never assign a vertex attribute to this list of physical attributes
*/ //
SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count); SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);
/* //
// Returns the location ID of the named uniform. // Returns the location ID of the named uniform.
// Returns -1 if error. // Returns -1 if error.
*/ //
SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name); SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
SH_IMPORT_EXPORT char* ShGetUniformName(const ShHandle linker, int virtualLocation);
enum TDebugOptions { enum TDebugOptions {
EDebugOpNone = 0x000, EDebugOpNone = 0x000,
@ -229,4 +207,4 @@ enum TDebugOptions {
} }
#endif #endif
#endif /* _COMPILER_INTERFACE_INCLUDED_ */ #endif // _COMPILER_INTERFACE_INCLUDED_

View File

@ -45,143 +45,11 @@
extern "C" { extern "C" {
#endif #endif
typedef enum {
EReserved = 0,
EFixed,
ERecommended,
EFloating
} ShPriority;
typedef enum {
ESymbol = 0,
EFloatConst,
EFloatConstPtr,
EIntConst,
EIntConstPtr,
EBoolConst,
EBoolConstPtr
} ShDataType;
// this definition will eventually go once we move to the new linker interface in the driver
typedef enum {
EVirtualBinding,
EPhysicalBinding
} ShVirtualPhysicalBinding;
typedef struct {
int size; // out - total physical size for the binding in floats - P10
int location; // in-out - virtualLocation for all cases
int functionPriority; // out - used for giving priorities to function bindings
int proEpilogue; // out - essentially a bool defining whether its a prologue/epilogue or not, 1 means it is
int builtInName; // out - basically a bool value, 0 means not a builtInName, 1 means its a builtInName
int arraySize; // out - size of the array in units of its type - if the binding is for an array
ShPriority bindingPriority; // in-out - EFixed, ERecommended, EFloating
ShDataType bindingDataType; // in-out - whether its a symbol name or a constant value
ShBasicType hardwareDataType; // out - bool are loaded as floats on the hardware
ShBasicType userDataType; // out - mat3 -> mat3, ivec2 -> ivec2, vec2 -> vec2
ShBasicType basicUserType; // out - mat3 -> float, ivec2 ->int, vec2 -> float
int sizeOfType; // out - for vec3 -> 3, for float -> 1, for mat3 -> 3, mat3[10] -> 3
int matrix; // out - essentially a boolean, 0 means vector, 1 means matrix
union { // in-out
char* name;
float floatVal;
float* floatValPtr;
int intVal;
int* intValPtr;
};
// A pointer to ShP10PhysicalBinding or ShP20PhysicalBinding
void* targetDependentData; // in-out
} ShBindingExt;
//
// to specify the type of binding
//
typedef enum {
EAttribute,
EUniform,
EVarying,
EFunction,
EConstant,
EFunctionRelocation,
EArbVertexLocal,
EArbVertexEnv,
EArbFragmentLocal,
EArbFragmentEnv,
EState,
ENoBindingType } ShBindingType;
typedef struct {
// a pointer to ShBindingExt
ShBindingExt* pBinding;
int numOfBindings;
ShBindingType type;
} ShBindingTableExt;
typedef struct {
ShBindingTableExt *bindingTable;
int numOfBindingTables;
} ShBindingList;
SH_IMPORT_EXPORT ShHandle ShConstructBindings();
SH_IMPORT_EXPORT ShHandle ShConstructLibrary();
SH_IMPORT_EXPORT ShHandle ShAddBinding(ShHandle bindingHandle,
ShBindingExt* binding,
ShBindingType type);
SH_IMPORT_EXPORT ShHandle ShAddBindingTable(ShHandle bindingHandle,
ShBindingTableExt *bindingTable,
ShBindingType type);
SH_IMPORT_EXPORT int ShLinkExt( SH_IMPORT_EXPORT int ShLinkExt(
const ShHandle, // linker object const ShHandle, // linker object
const ShHandle h[], // compiler objects to link together const ShHandle h[], // compiler objects to link together
const int numHandles); const int numHandles);
SH_IMPORT_EXPORT ShBindingList* ShGetBindingList(const ShHandle linkerHandle);
SH_IMPORT_EXPORT ShBindingTableExt* ShGetBindingTable(const ShHandle linkerHandle, ShBindingType type);
SH_IMPORT_EXPORT int ShGetUniformLocationExt(const ShHandle linkerHandle, const char* name);
SH_IMPORT_EXPORT int ShSetFixedAttributeBindingsExt(const ShHandle, const ShBindingTableExt*);
SH_IMPORT_EXPORT int ShGetUniformLocationExt2(const ShHandle handle, const char* name, int* location, int* offset);
SH_IMPORT_EXPORT int ShSetVirtualLocation(const ShHandle handle, ShBindingType type, int bindingIndex, int virtualLocation);
SH_IMPORT_EXPORT int ShGetVirtualLocation(const ShHandle handle, ShBindingType type, int bindingIndex, int *virtualLocation);
//
// To get the bindings object from the linker object (after the link is done so that
// bindings can be added to the list)
//
SH_IMPORT_EXPORT ShHandle ShGetBindings(const ShHandle linkerHandle);
SH_IMPORT_EXPORT int ShAddLibraryCode(ShHandle library, const char* name, const ShHandle objectCodes[], const int numHandles);
/*****************************************************************************
This code is used by the new shared linker
*****************************************************************************/
//
// Each programmable unit has a UnitExecutable. Targets may subclass
// and append to this as desired.
//
typedef struct {
int name; // name of unit to which executable is targeted
int entry; // a target specific entry point
int count; // size of executable
const void* code; // read-only code
} ShUnitExecutable;
//
// The "void*" returned from ShGetExecutable() will be an ShExecutable
//
typedef struct {
int count; // count of unit executables
ShUnitExecutable* executables;
} ShExecutable;
SH_IMPORT_EXPORT ShExecutable* ShGetExecutableExt(const ShHandle linkerHandle);
typedef struct {
int numThread;
int stackSpacePerThread;
int visBufferValidity; // essenatially a boolean
int shaderFragTerminationStatus; // essentially a boolean
} ShDeviceInfo;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif