update against 03-Feb-2005 release
This commit is contained in:
parent
5b641a516e
commit
2fb2e27e28
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -45,8 +45,6 @@
|
|||
#define UINT_PTR uintptr_t
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* windows only pragma */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4786) // Don't warn about too long identifiers
|
||||
|
@ -73,6 +71,7 @@
|
|||
|
||||
typedef int TSourceLoc;
|
||||
|
||||
#include <assert.h>
|
||||
#include "PoolAlloc.h"
|
||||
|
||||
//
|
||||
|
@ -194,7 +193,7 @@ public :
|
|||
//
|
||||
typedef pool_allocator<char> TStringAllocator;
|
||||
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));
|
||||
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
|
||||
|
||||
// we assume base 10 or 16 for all cases
|
||||
if (base == 10)
|
||||
sprintf(text, "%d", i);
|
||||
else if (base == 16)
|
||||
sprintf(text, "%x", i);
|
||||
else
|
||||
assert (!"String(int): unsupported base");
|
||||
#ifdef _WIN32
|
||||
itoa(i, text, base);
|
||||
#else
|
||||
// we assume base 10 for all cases
|
||||
sprintf(text, "%d", i);
|
||||
#endif
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -281,5 +279,7 @@ __inline TPersistString FormatSourceLoc(const TSourceLoc loc)
|
|||
|
||||
return TPersistString(locText);
|
||||
}
|
||||
typedef TMap<TString, TString> TPragmaTable;
|
||||
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
||||
|
||||
#endif // _COMMON_INCLUDED_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -84,8 +84,8 @@ public:
|
|||
}
|
||||
|
||||
void check() const {
|
||||
checkGuardBlock(preGuard(), (unsigned char) (guardBlockBeginVal), "before");
|
||||
checkGuardBlock(postGuard(), (unsigned char) (guardBlockEndVal), "after");
|
||||
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
|
||||
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
|
||||
}
|
||||
|
||||
void checkAllocList() const;
|
||||
|
@ -113,21 +113,16 @@ private:
|
|||
unsigned char* mem; // beginning of our allocation (pts to header)
|
||||
TAllocation* prevAlloc; // prior allocation in the chain
|
||||
|
||||
enum {
|
||||
guardBlockBeginVal = 0xfb,
|
||||
guardBlockEndVal = 0xfe,
|
||||
userDataFill = 0xcd
|
||||
};
|
||||
// Support MSVC++ 6.0
|
||||
const static unsigned char guardBlockBeginVal;
|
||||
const static unsigned char guardBlockEndVal;
|
||||
const static unsigned char userDataFill;
|
||||
|
||||
# ifdef GUARD_BLOCKS
|
||||
enum {
|
||||
guardBlockSize = 16
|
||||
};
|
||||
const static size_t guardBlockSize;
|
||||
inline static size_t headerSize() { return sizeof(TAllocation); }
|
||||
# else
|
||||
enum {
|
||||
guardBlockSize = 0
|
||||
};
|
||||
const static size_t guardBlockSize;
|
||||
inline static size_t headerSize() { return 0; }
|
||||
# endif
|
||||
};
|
||||
|
@ -254,13 +249,10 @@ private:
|
|||
//
|
||||
typedef TPoolAllocator* PoolAllocatorPointer;
|
||||
extern TPoolAllocator& GetGlobalPoolAllocator();
|
||||
extern PoolAllocatorPointer& GetCompilerPoolAllocator();
|
||||
#define GlobalPoolAllocator GetGlobalPoolAllocator()
|
||||
#define CompilerPoolAllocator GetCompilerPoolAllocator()
|
||||
struct TThreadGlobalPools
|
||||
{
|
||||
TPoolAllocator* globalPoolAllocator;
|
||||
TPoolAllocator* compilerPoolAllocator;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -35,6 +35,10 @@
|
|||
#ifndef _RESOURCE_LIMITS_INCLUDED_
|
||||
#define _RESOURCE_LIMITS_INCLUDED_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct TBuiltInResource {
|
||||
int maxLights;
|
||||
int maxClipPlanes;
|
||||
|
@ -49,4 +53,9 @@ struct TBuiltInResource {
|
|||
int maxFragmentUniformComponents;
|
||||
int maxDrawBuffers;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _RESOURCE_LIMITS_INCLUDED_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -101,32 +101,10 @@ public:
|
|||
virtual TCompiler* getAsCompiler() { return this; }
|
||||
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;
|
||||
protected:
|
||||
EShLanguage language;
|
||||
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;
|
||||
bool haveValidObjectCode;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -74,6 +74,8 @@ public:
|
|||
int line;
|
||||
};
|
||||
|
||||
typedef std::map<TTypeList*, TTypeList*> TStructureMap;
|
||||
typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
|
||||
//
|
||||
// Base class for things that have a type.
|
||||
//
|
||||
|
@ -82,33 +84,91 @@ public:
|
|||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
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),
|
||||
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) :
|
||||
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) {
|
||||
structure = 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) :
|
||||
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);
|
||||
typeName = NewPoolTString(n.c_str());
|
||||
}
|
||||
|
||||
explicit TType() {}
|
||||
virtual ~TType() {}
|
||||
|
||||
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 stSize = 0;
|
||||
for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
|
||||
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();
|
||||
}
|
||||
} else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
|
||||
stSize += ((*tl).type)->getInstanceSize();
|
||||
} else if (((*tl).type)->getStruct()) {
|
||||
|
@ -132,10 +192,20 @@ public:
|
|||
structure = userDef->getStruct();
|
||||
// leave array information intact.
|
||||
}
|
||||
virtual void setTypeName(const TString& n) { typeName = n; }
|
||||
virtual void setFieldName(const TString& n) { fieldName = n; }
|
||||
virtual const TString& getTypeName() const { return typeName; }
|
||||
virtual const TString& getFieldName() const { return fieldName; }
|
||||
virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
|
||||
virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
|
||||
virtual const TString& getTypeName() const
|
||||
{
|
||||
assert (typeName);
|
||||
return *typeName;
|
||||
}
|
||||
|
||||
virtual const TString& getFieldName() const
|
||||
{
|
||||
assert (fieldName);
|
||||
return *fieldName;
|
||||
}
|
||||
|
||||
virtual TBasicType getBasicType() const { return type; }
|
||||
virtual TQualifier getQualifier() const { return qualifier; }
|
||||
virtual void changeQualifier(TQualifier q) { qualifier = q; }
|
||||
|
@ -152,8 +222,8 @@ public:
|
|||
return size;
|
||||
}
|
||||
|
||||
virtual bool isMatrix() const { return matrix; }
|
||||
virtual bool isArray() const { return array; }
|
||||
virtual bool isMatrix() const { return matrix ? true : false; }
|
||||
virtual bool isArray() const { return array ? true : false; }
|
||||
int getArraySize() const { return arraySize; }
|
||||
void setArraySize(int s) { array = true; arraySize = s; }
|
||||
void setMaxArraySize (int s) { maxArraySize = s; }
|
||||
|
@ -180,14 +250,16 @@ public:
|
|||
const char* getBasicString() const { return TType::getBasicString(type); }
|
||||
const char* getQualifierString() const { return ::getQualifierString(qualifier); }
|
||||
TTypeList* getStruct() { return structure; }
|
||||
int getStructSize() { return structureSize; }
|
||||
int getStructSize() const { return structureSize; }
|
||||
TTypeList* getStruct() const { return structure; }
|
||||
TString& getMangledName() {
|
||||
if (mangled.size() == 0) {
|
||||
buildMangledName(mangled);
|
||||
mangled+=';';
|
||||
if (!mangled) {
|
||||
mangled = NewPoolTString("");
|
||||
buildMangledName(*mangled);
|
||||
*mangled+=';';
|
||||
}
|
||||
return mangled;
|
||||
|
||||
return *mangled;
|
||||
}
|
||||
bool operator==(const TType& right) const {
|
||||
return type == right.type &&
|
||||
|
@ -203,21 +275,22 @@ public:
|
|||
TString getCompleteString() const;
|
||||
|
||||
protected:
|
||||
TBasicType type;
|
||||
TQualifier qualifier;
|
||||
int size; // size of vector or matrix, not size of array
|
||||
bool matrix;
|
||||
bool array;
|
||||
void buildMangledName(TString&);
|
||||
|
||||
int arraySize;
|
||||
TTypeList* structure; // 0 unless this is a struct
|
||||
TString fieldName; // for structure field names
|
||||
TString typeName; // for structure field type name
|
||||
TString mangled;
|
||||
TString *fieldName; // for structure field names
|
||||
TString *typeName; // for structure field type name
|
||||
TString *mangled;
|
||||
int structureSize;
|
||||
int maxArraySize;
|
||||
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_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -51,7 +51,6 @@
|
|||
//
|
||||
// Operators used by the high-level (parse tree) representation.
|
||||
//
|
||||
|
||||
enum TOperator {
|
||||
EOpNull, // if in a node, should only mean a node is still being built
|
||||
EOpSequence, // denotes a list of statements, or parameters, etc.
|
||||
|
@ -379,7 +378,7 @@ public:
|
|||
virtual bool promote(TInfoSink&) { return true; }
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -406,7 +405,7 @@ protected:
|
|||
//
|
||||
class TIntermUnary : public TIntermOperator {
|
||||
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) {}
|
||||
virtual void traverse(TIntermTraverser*);
|
||||
virtual void setOperand(TIntermTyped* o) { operand = o; }
|
||||
|
@ -423,8 +422,9 @@ typedef TVector<int> TQualifierList;
|
|||
//
|
||||
class TIntermAggregate : public TIntermOperator {
|
||||
public:
|
||||
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false) { }
|
||||
TIntermAggregate(TOperator o) : TIntermOperator(o) { }
|
||||
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
|
||||
TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
|
||||
~TIntermAggregate() { delete pragmaTable; }
|
||||
virtual TIntermAggregate* getAsAggregate() { return this; }
|
||||
virtual void setOperator(TOperator o) { op = o; }
|
||||
virtual TIntermSequence& getSequence() { return sequence; }
|
||||
|
@ -434,11 +434,22 @@ public:
|
|||
virtual void setUserDefined() { userDefined = true; }
|
||||
virtual bool isUserDefined() { return userDefined; }
|
||||
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:
|
||||
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
|
||||
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
|
||||
TIntermSequence sequence;
|
||||
TQualifierList qualifier;
|
||||
TString name;
|
||||
bool userDefined; // used for user defined function names
|
||||
bool optimize;
|
||||
bool debug;
|
||||
TPragmaTable *pragmaTable;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -448,7 +459,7 @@ class TIntermSelection : public TIntermTyped {
|
|||
public:
|
||||
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* 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) {}
|
||||
virtual void traverse(TIntermTraverser*);
|
||||
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
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//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)
|
||||
{
|
||||
if (outputStream & EString) {
|
||||
checkMem(1);
|
||||
checkMem(count);
|
||||
sink.append(count, c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,9 +40,8 @@
|
|||
|
||||
#include "../Include/intermediate.h"
|
||||
#include "Initialize.h"
|
||||
#include <assert.h>
|
||||
|
||||
void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||
void TBuiltIns::initialize()
|
||||
{
|
||||
//
|
||||
// Initialize all the built-in strings for parsing.
|
||||
|
@ -355,53 +354,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
// Texture Functions.
|
||||
//
|
||||
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, float bias);"));
|
||||
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, float bias);"));
|
||||
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, 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, float bias);"));
|
||||
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, 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, float bias);"));
|
||||
|
||||
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, float bias);"));
|
||||
|
||||
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.
|
||||
|
@ -442,6 +414,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
//
|
||||
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"));
|
||||
}
|
||||
{
|
||||
|
@ -453,6 +445,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
|
||||
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("vec2 dFdx(vec2 p);"));
|
||||
s.append(TString("vec3 dFdx(vec3 p);"));
|
||||
|
@ -479,46 +491,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
|
||||
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
|
||||
|
@ -531,7 +503,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
s.append(TString("uniform mat4 gl_ModelViewMatrix;"));
|
||||
s.append(TString("uniform mat4 gl_ProjectionMatrix;"));
|
||||
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
|
||||
|
@ -542,17 +513,14 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));
|
||||
s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));
|
||||
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_ProjectionMatrixTranspose;"));
|
||||
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_ProjectionMatrixInverseTranspose;"));
|
||||
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));
|
||||
s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
|
||||
|
||||
//
|
||||
// Normal scaling p. 39.
|
||||
|
@ -569,10 +537,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
s.append(TString("};"));
|
||||
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.
|
||||
|
@ -623,7 +587,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
s.append(TString(" float quadraticAttenuation;"));// K2
|
||||
s.append(TString("};"));
|
||||
|
||||
s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
|
||||
|
||||
s.append(TString("struct gl_LightModelParameters {"));
|
||||
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("};"));
|
||||
|
||||
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
|
||||
|
@ -751,7 +701,121 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
|||
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
|
||||
|
@ -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_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;
|
||||
|
||||
|
@ -863,6 +923,26 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInR
|
|||
symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
|
||||
symbolTable.relateToOperator("readPixel", EOpReadPixel);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -45,12 +45,14 @@ typedef TVector<TString> TBuiltInStrings;
|
|||
class TBuiltIns {
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
void initialize(TBuiltInResource &resources);
|
||||
void initialize();
|
||||
void initialize(const TBuiltInResource& resources);
|
||||
TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
|
||||
protected:
|
||||
TBuiltInStrings builtInStrings[EShLangCount];
|
||||
};
|
||||
|
||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, TBuiltInResource &resources);
|
||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
|
||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
|
||||
|
||||
#endif // _INITIALIZE_INCLUDED_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,7 +40,6 @@
|
|||
#include "localintermediate.h"
|
||||
#include "QualifierAlive.h"
|
||||
#include "RemoveTree.h"
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -230,7 +229,7 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
|
|||
node->setLeft(base);
|
||||
node->setRight(index);
|
||||
|
||||
// caller should set the type
|
||||
// caller should set the type
|
||||
|
||||
return node;
|
||||
}
|
||||
|
@ -446,12 +445,17 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
bool allConstant = true;
|
||||
// check to see if there is an aggregate node
|
||||
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() ;
|
||||
for (TIntermSequence::iterator p = sequenceVector.begin();
|
||||
p != sequenceVector.end(); p++) {
|
||||
if (!(*p)->getAsTyped()->getAsConstantUnion())
|
||||
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
|
||||
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
|
||||
|
@ -559,10 +563,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
return 0;
|
||||
}
|
||||
|
||||
newNode = new TIntermUnary(newOp, TType(promoteTo, EvqTemporary,
|
||||
node->getNominalSize(),
|
||||
node->isMatrix(),
|
||||
node->isArray()));
|
||||
TType type(promoteTo, EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());
|
||||
newNode = new TIntermUnary(newOp, type);
|
||||
newNode->setLine(node->getLine());
|
||||
newNode->setOperand(node);
|
||||
|
||||
|
@ -648,6 +650,20 @@ TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nod
|
|||
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,
|
||||
// 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)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -785,8 +792,8 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
|
|||
//
|
||||
void TIntermediate::remove(TIntermNode* root)
|
||||
{
|
||||
if (root)
|
||||
RemoveAllTreeNodes(root);
|
||||
if (root)
|
||||
RemoveAllTreeNodes(root);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -1062,7 +1069,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
|
|||
case EOpAdd:
|
||||
case EOpSub:
|
||||
case EOpDiv:
|
||||
case EOpMod:
|
||||
case EOpMod:
|
||||
case EOpAddAssign:
|
||||
case EOpSubAssign:
|
||||
case EOpDivAssign:
|
||||
|
@ -1073,8 +1080,8 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
|
|||
return false;
|
||||
setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));
|
||||
break;
|
||||
|
||||
case EOpEqual:
|
||||
|
||||
case EOpEqual:
|
||||
case EOpNotEqual:
|
||||
case EOpLessThan:
|
||||
case EOpGreaterThan:
|
||||
|
@ -1116,7 +1123,7 @@ default:
|
|||
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();
|
||||
|
||||
|
@ -1172,131 +1179,144 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
||||
TIntermConstantUnion *newNode;
|
||||
constUnion* tempConstArray;
|
||||
int i;
|
||||
switch(op) {
|
||||
case EOpAdd:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EOpMatrixTimesScalar:
|
||||
case EOpVectorTimesScalar:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EOpSub:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
|
||||
else
|
||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
|
||||
else
|
||||
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
|
||||
else
|
||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
|
||||
break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
||||
return 0;
|
||||
|
||||
case EbtInt:
|
||||
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;
|
||||
|
||||
case EOpDiv:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand) {
|
||||
if (node->getUnionArrayPointer()->fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
|
||||
} else {
|
||||
if (unionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
|
||||
}
|
||||
break;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand) {
|
||||
if (node->getUnionArrayPointer()->fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
|
||||
} else {
|
||||
if (unionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
|
||||
}
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
if (leftOperand) {
|
||||
if (node->getUnionArrayPointer()->iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
|
||||
} else {
|
||||
if (unionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst;
|
||||
case EbtInt:
|
||||
if (leftOperand) {
|
||||
if (node->getUnionArrayPointer()->iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
|
||||
} else {
|
||||
if (unionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} 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;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
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()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1316,68 +1336,69 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
TIntermConstantUnion *tempNode;
|
||||
int index = 0;
|
||||
bool boolNodeFlag = false;
|
||||
int i;
|
||||
switch(op) {
|
||||
case EOpAdd:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EOpSub:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
|
||||
else
|
||||
tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;
|
||||
else
|
||||
tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand)
|
||||
tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
|
||||
else
|
||||
tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
if (leftOperand)
|
||||
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;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EOpMul:
|
||||
{
|
||||
if (this->isVector()) { // two vectors multiplied together
|
||||
int size = this->getSize();
|
||||
tempConstArray = new constUnion[size];
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
if (this->isVector()) { // two vectors multiplied together
|
||||
int size = this->getSize();
|
||||
tempConstArray = new constUnion[size];
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
|
||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EOpMatrixTimesMatrix:
|
||||
{
|
||||
if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
|
||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
|
||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
{// support MSVC++6.0
|
||||
int size = this->getNominalSize();
|
||||
tempConstArray = new constUnion[size*size];
|
||||
for (int row = 0; row < size; row++) {
|
||||
|
@ -1392,42 +1413,44 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
break;
|
||||
case EOpDiv:
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand) {
|
||||
if (rightUnionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
|
||||
} else {
|
||||
if (unionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
|
||||
}
|
||||
break;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
if (leftOperand) {
|
||||
if (rightUnionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
|
||||
} else {
|
||||
if (unionArray[i].fConst == 0.0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].fConst = FLT_MAX;
|
||||
} else
|
||||
tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
|
||||
}
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
if (leftOperand) {
|
||||
if (rightUnionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
|
||||
} else {
|
||||
if (unionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst;
|
||||
case EbtInt:
|
||||
if (leftOperand) {
|
||||
if (rightUnionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} else
|
||||
tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
|
||||
} else {
|
||||
if (unionArray[i].iConst == 0) {
|
||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||
tempConstArray[i].iConst = INT_MAX;
|
||||
} 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;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1436,22 +1459,23 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
if (node->getBasicType() != EbtFloat) {
|
||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
tempConstArray = new constUnion[this->getNominalSize()];
|
||||
{
|
||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||
tempConstArray[i].fConst = 0.0;
|
||||
for (int j = 0; j < size; j++) {
|
||||
tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{// support MSVC++6.0
|
||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||
tempConstArray[i].fConst = 0.0;
|
||||
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->setLine(this->getLine());
|
||||
|
||||
return tempNode;
|
||||
|
||||
|
||||
case EOpVectorTimesMatrix:
|
||||
if (this->getType().getBasicType() != EbtFloat) {
|
||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for vector times matrix", this->getLine());
|
||||
|
@ -1459,48 +1483,54 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
}
|
||||
|
||||
tempConstArray = new constUnion[this->getNominalSize()];
|
||||
{
|
||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||
tempConstArray[i].fConst = 0.0;
|
||||
for (int j = 0; j < size; j++) {
|
||||
tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
|
||||
}
|
||||
}
|
||||
{// support MSVC++6.0
|
||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||
tempConstArray[i].fConst = 0.0;
|
||||
for (int j = 0; j < size; j++) {
|
||||
tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
||||
tempConstArray = new constUnion[this->getSize()];
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1509,27 +1539,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].fConst != rightUnionArray[i].fConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].fConst != rightUnionArray[i].fConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].iConst != rightUnionArray[i].iConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].iConst != rightUnionArray[i].iConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EbtBool:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].bConst != rightUnionArray[i].bConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].bConst != rightUnionArray[i].bConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1559,27 +1595,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
case EOpNotEqual:
|
||||
switch (this->getType().getBasicType()) {
|
||||
case EbtFloat:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].fConst == rightUnionArray[i].fConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].fConst == rightUnionArray[i].fConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EbtInt:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].iConst == rightUnionArray[i].iConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].iConst == rightUnionArray[i].iConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EbtBool:
|
||||
for (i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].bConst == rightUnionArray[i].bConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
if (unionArray[i].bConst == rightUnionArray[i].bConst) {
|
||||
boolNodeFlag = true;
|
||||
break; // break out of for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
@ -2027,31 +2070,40 @@ bool TIntermediate::removeMatrixConstNode(TIntermSequence &parentSequence, TType
|
|||
|
||||
TIntermSequence::iterator parentNodeIter;
|
||||
TIntermSequence &childSequence = child->getSequence();
|
||||
int i;
|
||||
|
||||
switch (child->getOp()) {
|
||||
case EOpConstructMat2:
|
||||
case EOpConstructMat3:
|
||||
case EOpConstructMat4:
|
||||
for (i = 0; i < child->getType().getInstanceSize(); i++) {
|
||||
constUnion* constantUnion = new constUnion[1];
|
||||
if (i % (child->getType().getNominalSize() + 1) == 0) {
|
||||
*constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
|
||||
} else {
|
||||
switch (parentType.getBasicType()) {
|
||||
case EbtInt: constantUnion->iConst = 0; break;
|
||||
case EbtFloat: constantUnion->fConst = 0.0; break;
|
||||
case EbtBool: constantUnion->bConst = false; break;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < child->getType().getInstanceSize(); i++) {
|
||||
constUnion* constantUnion = new constUnion[1];
|
||||
if (i % (child->getType().getNominalSize() + 1) == 0) {
|
||||
*constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
|
||||
} else {
|
||||
switch (parentType.getBasicType()) {
|
||||
case EbtInt: constantUnion->iConst = 0; 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;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
|
||||
{
|
||||
assert (!pragmaTable);
|
||||
pragmaTable = new TPragmaTable();
|
||||
*pragmaTable = pTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//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;
|
||||
}
|
||||
|
||||
bool tooBig = false;
|
||||
enum {
|
||||
exyzw,
|
||||
ergba,
|
||||
estpq
|
||||
} fieldSet[4];
|
||||
|
||||
for (int i = 0; i < fields.num; ++i) {
|
||||
switch (compString[i]) {
|
||||
case 'x': case 'r': case 's': case '0':
|
||||
case 'x':
|
||||
fields.offsets[i] = 0;
|
||||
fieldSet[i] = exyzw;
|
||||
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;
|
||||
fieldSet[i] = exyzw;
|
||||
break;
|
||||
case 'z': case 'b': case 'p': case '2':
|
||||
if (vecSize < 3)
|
||||
tooBig = true;
|
||||
case 'g':
|
||||
fields.offsets[i] = 1;
|
||||
fieldSet[i] = ergba;
|
||||
break;
|
||||
case 't':
|
||||
fields.offsets[i] = 1;
|
||||
fieldSet[i] = estpq;
|
||||
break;
|
||||
case 'z':
|
||||
fields.offsets[i] = 2;
|
||||
fieldSet[i] = exyzw;
|
||||
break;
|
||||
case 'w': case 'a': case 'q': case '3':
|
||||
if (vecSize < 4)
|
||||
tooBig = true;
|
||||
case 'b':
|
||||
fields.offsets[i] = 2;
|
||||
fieldSet[i] = ergba;
|
||||
break;
|
||||
case 'p':
|
||||
fields.offsets[i] = 2;
|
||||
fieldSet[i] = estpq;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
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;
|
||||
default:
|
||||
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(), "");
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -970,7 +1016,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOpe
|
|||
TTypeList::iterator list;
|
||||
TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
|
||||
if (op == EOpConstructStruct) {
|
||||
TType ttype = fnCall->getReturnType();
|
||||
const TType& ttype = fnCall->getReturnType();
|
||||
structure = ttype.getStruct();
|
||||
list = (*structure).begin();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -52,6 +52,13 @@ typedef enum {
|
|||
EBhDisable
|
||||
} 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
|
||||
// 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) :
|
||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(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
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
||||
TInfoSink& infoSink;
|
||||
|
@ -113,8 +120,7 @@ struct TParseContext {
|
|||
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
|
||||
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
|
||||
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
|
||||
typedef std::map<TString, TString> PragmaStringMap;
|
||||
PragmaStringMap PragmaTable;
|
||||
struct TPragma contextPragma;
|
||||
TString HashErrMsg;
|
||||
bool AfterEOF;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -34,7 +34,6 @@
|
|||
|
||||
#include "../Include/PoolAlloc.h"
|
||||
#include "../Include/Common.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include "Include/InitializeGlobals.h"
|
||||
#include "osinclude.h"
|
||||
|
@ -52,7 +51,6 @@ void InitializeGlobalPools()
|
|||
TThreadGlobalPools* threadData = new TThreadGlobalPools();
|
||||
|
||||
threadData->globalPoolAllocator = globalPoolAllocator;
|
||||
threadData->compilerPoolAllocator = 0;
|
||||
|
||||
OS_SetTLSValue(PoolIndex, threadData);
|
||||
globalPoolAllocator->push();
|
||||
|
@ -99,13 +97,6 @@ void SetGlobalPoolAllocatorPtr(TPoolAllocator* 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
|
||||
// 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//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 void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
|
||||
|
||||
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink&);
|
||||
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, TBuiltInResource &resources);
|
||||
void GenerateResources(TBuiltInResource& resources);
|
||||
bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);
|
||||
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);
|
||||
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
|
@ -68,8 +74,6 @@ TPoolAllocator* PerProcessGPA = 0;
|
|||
int ShInitialize()
|
||||
{
|
||||
TInfoSink infoSink;
|
||||
TBuiltInResource resources;
|
||||
GenerateResources(resources);
|
||||
bool ret = true;
|
||||
|
||||
if (!InitProcess())
|
||||
|
@ -79,13 +83,29 @@ int ShInitialize()
|
|||
// we need to have thread synchronization code around the initialization of per process
|
||||
// global pool allocator
|
||||
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->push();
|
||||
|
||||
TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
|
||||
SetGlobalPoolAllocatorPtr(PerProcessGPA);
|
||||
ret = generateBuiltInSymbolTable(resources, infoSink);
|
||||
SetGlobalPoolAllocatorPtr(PerProcessGPA);
|
||||
|
||||
SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);
|
||||
SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);
|
||||
|
||||
SetGlobalPoolAllocatorPtr(gPoolAllocator);
|
||||
|
||||
symTables[EShLangVertex].pop();
|
||||
symTables[EShLangFragment].pop();
|
||||
|
||||
builtInPoolAllocator->popAll();
|
||||
delete builtInPoolAllocator;
|
||||
|
||||
}
|
||||
|
||||
return ret ? 1 : 0;
|
||||
|
@ -141,13 +161,6 @@ void ShDestruct(ShHandle handle)
|
|||
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
|
||||
//
|
||||
|
@ -160,88 +173,86 @@ int __fastcall ShFinalize()
|
|||
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
|
||||
// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called
|
||||
// from master dll once.
|
||||
//
|
||||
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink& infoSink)
|
||||
bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable* symbolTables, EShLanguage language)
|
||||
{
|
||||
TBuiltIns builtIns;
|
||||
builtIns.initialize(resources);
|
||||
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources);
|
||||
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources);
|
||||
|
||||
if (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;
|
||||
}
|
||||
|
||||
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);
|
||||
TSymbolTable& symbolTable = SymbolTables[language];
|
||||
TParseContext parseContext(symbolTable, intermediate, language, infoSink);
|
||||
TSymbolTable* symbolTable;
|
||||
|
||||
if (resources)
|
||||
symbolTable = symbolTables;
|
||||
else
|
||||
symbolTable = &symbolTables[language];
|
||||
|
||||
TParseContext parseContext(*symbolTable, intermediate, language, infoSink);
|
||||
|
||||
GlobalParseContext = &parseContext;
|
||||
|
||||
setInitialState();
|
||||
|
||||
if (symbolTable.isEmpty()) {
|
||||
assert (symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
|
||||
|
||||
//
|
||||
// Parse the built-ins. This should only happen once per
|
||||
// language symbol table.
|
||||
//
|
||||
// Push the symbol table to give it an initial scope. This
|
||||
// push should not have a corresponding pop, so that built-ins
|
||||
// are preserved, and the test for an empty table fails.
|
||||
//
|
||||
//
|
||||
// Parse the built-ins. This should only happen once per
|
||||
// language symbol table.
|
||||
//
|
||||
// Push the symbol table to give it an initial scope. This
|
||||
// push should not have a corresponding pop, so that built-ins
|
||||
// are preserved, and the test for an empty table fails.
|
||||
//
|
||||
|
||||
symbolTable.push();
|
||||
|
||||
//Initialize the Preprocessor
|
||||
int ret = InitPreprocessor();
|
||||
if (ret) {
|
||||
infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
|
||||
symbolTable->push();
|
||||
|
||||
//Initialize the Preprocessor
|
||||
int ret = InitPreprocessor();
|
||||
if (ret) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -258,6 +269,7 @@ int ShCompile(
|
|||
const char* const shaderStrings[],
|
||||
const int numStrings,
|
||||
const EShOptimizationLevel optLevel,
|
||||
const TBuiltInResource* resources,
|
||||
int debugOptions
|
||||
)
|
||||
{
|
||||
|
@ -271,7 +283,8 @@ int ShCompile(
|
|||
TCompiler* compiler = base->getAsCompiler();
|
||||
if (compiler == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
GlobalPoolAllocator.push();
|
||||
compiler->infoSink.info.erase();
|
||||
compiler->infoSink.debug.erase();
|
||||
|
||||
|
@ -280,6 +293,9 @@ int ShCompile(
|
|||
|
||||
TIntermediate intermediate(compiler->infoSink);
|
||||
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
|
||||
|
||||
generateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());
|
||||
|
||||
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
|
||||
parseContext.initializeExtensionBehavior();
|
||||
|
||||
|
@ -294,7 +310,7 @@ int ShCompile(
|
|||
// be thrown away, then push a scope for the current shader's globals.
|
||||
//
|
||||
bool success = true;
|
||||
GlobalPoolAllocator.push();
|
||||
|
||||
symbolTable.push();
|
||||
if (!symbolTable.atGlobalLevel())
|
||||
parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
|
||||
|
@ -306,41 +322,39 @@ int ShCompile(
|
|||
if (ret)
|
||||
success = false;
|
||||
|
||||
if (! ret && parseContext.treeRoot) {
|
||||
if (parseContext.recoveredFromError) {
|
||||
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);
|
||||
} 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 && parseContext.treeRoot) {
|
||||
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)
|
||||
intermediate.outputTree(parseContext.treeRoot);
|
||||
if (debugOptions & EDebugOpIntermediate)
|
||||
intermediate.outputTree(parseContext.treeRoot);
|
||||
|
||||
//
|
||||
// Call the machine dependent compiler
|
||||
//
|
||||
if (! compiler->compile(parseContext.treeRoot))
|
||||
success = false;
|
||||
}
|
||||
//
|
||||
// Call the machine dependent compiler
|
||||
//
|
||||
if (! compiler->compile(parseContext.treeRoot))
|
||||
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,
|
||||
// throwing away all but the built-ins.
|
||||
//
|
||||
while (! symbolTable.atBuiltInLevel())
|
||||
while (! symbolTable.atSharedBuiltInLevel())
|
||||
symbolTable.pop();
|
||||
|
||||
FinalizePreprocessor();
|
||||
|
@ -397,21 +411,22 @@ int ShLinkExt(
|
|||
return 0;
|
||||
|
||||
THandleList cObjects;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numHandles; ++i) {
|
||||
if (compHandles[i] == 0)
|
||||
return 0;
|
||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
|
||||
if (base->getAsLinker()) {
|
||||
cObjects.push_back(base->getAsLinker());
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < numHandles; ++i) {
|
||||
if (compHandles[i] == 0)
|
||||
return 0;
|
||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
|
||||
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);
|
||||
|
@ -422,11 +437,13 @@ int ShLinkExt(
|
|||
|
||||
linker->infoSink.info.erase();
|
||||
|
||||
for (i = 0; i < numHandles; ++i) {
|
||||
if (cObjects[i]->getAsCompiler()) {
|
||||
if (! cObjects[i]->getAsCompiler()->linkable()) {
|
||||
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
|
||||
return 0;
|
||||
{// support MSVC++6.0
|
||||
for (int i = 0; i < numHandles; ++i) {
|
||||
if (cObjects[i]->getAsCompiler()) {
|
||||
if (! cObjects[i]->getAsCompiler()->linkable()) {
|
||||
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)
|
||||
return 0;
|
||||
|
||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
|
||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
|
||||
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
|
||||
if (linker == 0)
|
||||
return 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -53,8 +53,6 @@ void TType::buildMangledName(TString& mangledName)
|
|||
else if (isVector())
|
||||
mangledName += 'v';
|
||||
|
||||
unsigned int i;
|
||||
|
||||
switch (type) {
|
||||
case EbtFloat: mangledName += 'f'; break;
|
||||
case EbtInt: mangledName += 'i'; break;
|
||||
|
@ -65,12 +63,15 @@ void TType::buildMangledName(TString& mangledName)
|
|||
case EbtSamplerCube: mangledName += "sC"; break;
|
||||
case EbtSampler1DShadow: mangledName += "sS1"; break;
|
||||
case EbtSampler2DShadow: mangledName += "sS2"; break;
|
||||
case EbtStruct:
|
||||
case EbtStruct:
|
||||
mangledName += "struct-";
|
||||
mangledName += typeName;
|
||||
for (i = 0; i < structure->size(); ++i) {
|
||||
mangledName += '-';
|
||||
(*structure)[i].type->buildMangledName(mangledName);
|
||||
if (typeName)
|
||||
mangledName += *typeName;
|
||||
{// support MSVC++6.0
|
||||
for (unsigned int i = 0; i < structure->size(); ++i) {
|
||||
mangledName += '-';
|
||||
(*structure)[i].type->buildMangledName(mangledName);
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -124,8 +125,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const
|
|||
//
|
||||
TFunction::~TFunction()
|
||||
{
|
||||
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
|
||||
delete (*i).type;
|
||||
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
|
||||
delete (*i).type;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -133,8 +134,8 @@ TFunction::~TFunction()
|
|||
//
|
||||
TSymbolTableLevel::~TSymbolTableLevel()
|
||||
{
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||
delete (*it).second;
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -77,6 +77,8 @@ public:
|
|||
void setUniqueId(int id) { uniqueId = id; }
|
||||
int getUniqueId() const { return uniqueId; }
|
||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
||||
TSymbol(const TSymbol&);
|
||||
virtual TSymbol* clone(TStructureMap& remapper) = 0;
|
||||
|
||||
protected:
|
||||
const TString *name;
|
||||
|
@ -95,11 +97,11 @@ protected:
|
|||
//
|
||||
class TVariable : public TSymbol {
|
||||
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 bool isVariable() const { return true; }
|
||||
TType& getType() { return type; }
|
||||
const TType getType() const { return type; }
|
||||
const TType& getType() const { return type; }
|
||||
bool isUserType() const { return userType; }
|
||||
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
|
||||
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
|
||||
|
@ -124,6 +126,8 @@ public:
|
|||
delete unionArray;
|
||||
unionArray = constArray;
|
||||
}
|
||||
TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
|
||||
virtual TVariable* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
TType type;
|
||||
|
@ -141,6 +145,10 @@ protected:
|
|||
struct TParameter {
|
||||
TString *name;
|
||||
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)),
|
||||
op(o),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, TType retType, TOperator tOp = EOpNull) :
|
||||
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name),
|
||||
returnType(retType),
|
||||
mangledName(*name + '('),
|
||||
|
@ -180,6 +188,8 @@ public:
|
|||
const TParameter& operator [](int i) const { return parameters[i]; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
TFunction(const TFunction&, TStructureMap& remapper);
|
||||
virtual TFunction* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
typedef TVector<TParameter> TParamList;
|
||||
|
@ -219,6 +229,7 @@ public:
|
|||
|
||||
void relateToOperator(const char* name, TOperator op);
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
TSymbolTableLevel* clone(TStructureMap& remapper);
|
||||
|
||||
protected:
|
||||
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.
|
||||
//
|
||||
bool isEmpty() { return table.size() == 0; }
|
||||
bool atBuiltInLevel() { return table.size() == 1; }
|
||||
bool atGlobalLevel() { return table.size() <= 2; }
|
||||
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
|
||||
bool atSharedBuiltInLevel() { return table.size() == 1; }
|
||||
bool atGlobalLevel() { return table.size() <= 3; }
|
||||
void push() {
|
||||
table.push_back(new TSymbolTableLevel);
|
||||
}
|
||||
|
@ -291,12 +303,15 @@ public:
|
|||
return symbol;
|
||||
}
|
||||
|
||||
TSymbolTableLevel* getGlobalLevel() { assert (table.size() >= 3); return table[2]; }
|
||||
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
|
||||
int getMaxSymbolId() { return uniqueId; }
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
void copyTable(const TSymbolTable& copyOf);
|
||||
|
||||
protected:
|
||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||
bool atDynamicBuiltInLevel() { return table.size() == 2; }
|
||||
|
||||
std::vector<TSymbolTableLevel*> table;
|
||||
int uniqueId; // for unique identification in code generation
|
||||
|
|
|
@ -1,121 +1,260 @@
|
|||
typedef union {
|
||||
struct {
|
||||
TSourceLoc line;
|
||||
union {
|
||||
TString *string;
|
||||
float f;
|
||||
int i;
|
||||
bool b;
|
||||
};
|
||||
TSymbol* symbol;
|
||||
} lex;
|
||||
struct {
|
||||
TSourceLoc line;
|
||||
TOperator op;
|
||||
union {
|
||||
TIntermNode* intermNode;
|
||||
TIntermNodePair nodePair;
|
||||
TIntermTyped* intermTypedNode;
|
||||
TIntermAggregate* intermAggregate;
|
||||
};
|
||||
union {
|
||||
TPublicType type;
|
||||
TQualifier qualifier;
|
||||
TFunction* function;
|
||||
TParameter param;
|
||||
TTypeLine typeLine;
|
||||
TTypeList* typeList;
|
||||
};
|
||||
} interm;
|
||||
} YYSTYPE;
|
||||
#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
|
||||
|
||||
/* 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 {
|
||||
TSourceLoc line;
|
||||
union {
|
||||
TString *string;
|
||||
float f;
|
||||
int i;
|
||||
bool b;
|
||||
};
|
||||
TSymbol* symbol;
|
||||
} lex;
|
||||
struct {
|
||||
TSourceLoc line;
|
||||
TOperator op;
|
||||
union {
|
||||
TIntermNode* intermNode;
|
||||
TIntermNodePair nodePair;
|
||||
TIntermTyped* intermTypedNode;
|
||||
TIntermAggregate* intermAggregate;
|
||||
};
|
||||
union {
|
||||
TPublicType type;
|
||||
TQualifier qualifier;
|
||||
TFunction* function;
|
||||
TParameter param;
|
||||
TTypeLine typeLine;
|
||||
TTypeList* typeList;
|
||||
};
|
||||
} interm;
|
||||
} YYSTYPE;
|
||||
/* Line 1240 of yacc.c. */
|
||||
#line 251 "glslang.tab.h"
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -64,6 +64,7 @@ public:
|
|||
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
|
||||
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
|
||||
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
||||
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
||||
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
||||
TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,7 +40,7 @@
|
|||
//
|
||||
class TConstTraverser : public TIntermTraverser {
|
||||
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;}
|
||||
int index ;
|
||||
constUnion *unionArray;
|
||||
|
@ -174,7 +174,6 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
|
|||
bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
|
||||
{
|
||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||
TType tt = node->getType();
|
||||
|
||||
if (!node->isConstructor() && node->getOp() != EOpComma) {
|
||||
char buf[200];
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,96 +1,96 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// atom.h
|
||||
*/
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* atom.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
#endif /* !defined(__ATOM_H) */
|
||||
|
|
|
@ -1,131 +1,132 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// compile.h
|
||||
*/
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* compile.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
/* Debug The Compiler options: */
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
/* Public members */
|
||||
SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
|
||||
Options options; /* Compile options and parameters */
|
||||
|
||||
|
||||
/* Private members */
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
/* Scanner data: */
|
||||
|
||||
|
||||
SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
|
||||
int mostRecentToken; /* Most recent token seen by the scanner */
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
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: */
|
||||
SourceLoc ltokenLoc;
|
||||
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 elsetracker; /* #if-#else and #endif constructs...Counter. */
|
||||
const char *ErrMsg;
|
||||
int CompileError; /* Indicate compile error when #error, #else,#elif mismatch. */
|
||||
|
||||
/*
|
||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
||||
*/
|
||||
SourceLoc ltokenLoc;
|
||||
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 elsetracker; /*#if-#else and #endif constructs...Counter. */
|
||||
const char *ErrMsg;
|
||||
int CompileError; /*Indicate compile error when #error, #else,#elif mismatch. */
|
||||
|
||||
/* */
|
||||
/* Globals used to communicate between PaParseStrings() and yy_input()and */
|
||||
/* also across the files.(gen_glslang.cpp and scanner.c) */
|
||||
/* */
|
||||
int PaWhichStr; /* which string we're parsing */
|
||||
int* PaStrLen; /* array of lengths of the PaArgv strings */
|
||||
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) */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,118 +1,119 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// cpp.h
|
||||
*/
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* cpp.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
void CPPDebugLogMsg(const char *msg); /* Prints information into debug 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 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 SetLineNumber(int); /* Set line number. */
|
||||
void SetStringNumber(int); /* Set string number. */
|
||||
int GetLineNumber(void); /* Get the current String Number. */
|
||||
int GetStringNumber(void); /* Get the current String Number. */
|
||||
const char* GetStrfromTStr(void); /* Convert TString to String. */
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
void SetLineNumber(int); /* Set line number. */
|
||||
void SetStringNumber(int); /* Set string number. */
|
||||
int GetLineNumber(void); /* Get the current String Number. */
|
||||
int GetStringNumber(void); /* Get the current String Number. */
|
||||
const char* GetStrfromTStr(void); /* Convert TString to String. */
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
#endif /* !(defined(__CPP_H) */
|
||||
|
|
|
@ -1,184 +1,185 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// cppstruct.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* cppstruct.c */
|
||||
/* */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
/* Initialize public members: */
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
} /* InitCPPStruct */
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
/* Initialize private members: */
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
cpp->tokensBeforeEOF = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*Intializing the Preprocessor. */
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FreeCPPStruct() - Free the CPP structure. */
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Finalizing the Preprocessor. */
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*FreeCPPStruct() - Free the CPP structure. */
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*Finalizing the Preprocessor. */
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
/*//////////////////////////////////// End of cppstruct.c ////////////////////////////////////// */
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
|
|
|
@ -1,191 +1,191 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
/* default alignment and chunksize, if called with 0 arguments */
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
/* we need to call the `real' malloc and free, not our replacements */
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
/* request size is too big for the chunksize, so allocate it as
|
||||
// a single chunk of the right size */
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
/* request size is too big for the chunksize, so allocate it as */
|
||||
/* a single chunk of the right size */
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,89 +1,89 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
|
|
|
@ -1,126 +1,126 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
|
|
|
@ -1,84 +1,84 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,118 +1,118 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// scanner.h
|
||||
*/
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* scanner.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
/* Not really atom table stuff but needed first... */
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
|
||||
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 SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
void SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
int FreeScanner(void); /* Free the cpp scanner */
|
||||
#endif /* !(defined(__SCANNER_H) */
|
||||
|
||||
|
||||
|
|
|
@ -1,115 +1,115 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// slglobals.h
|
||||
*/
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* slglobals.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* !(defined(__SLGLOBALS_H) */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,318 +1,318 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// symbols.c
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* symbols.c */
|
||||
/* */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
/*///////////////////////////////// Symbol Table Variables: /////////////////////////////////// */
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
} /* NewScope */
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
} /* PushScope */
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
} /* PopScope */
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
/* Clear union area: */
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
} /* NewSymbol */
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
} /* lAddToTree */
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
} /* AddSymbol */
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* LookUpLocalSymbol */
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
} /* LookUpSymbol */
|
||||
|
||||
|
||||
|
|
|
@ -1,145 +1,145 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// symbols.h
|
||||
*/
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* symbols.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
/* Typedefs for things defined here in "symbols.h": */
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
Scope *next, *prev; /* doubly-linked list of all scopes */
|
||||
Scope *parent;
|
||||
Scope *parent;
|
||||
Scope *funScope; /* Points to base scope of enclosing function */
|
||||
MemoryPool *pool; /* pool used for allocation in this scope */
|
||||
Symbol *symbols;
|
||||
|
||||
Symbol *symbols;
|
||||
|
||||
int level; /* 0 = super globals, 1 = globals, etc. */
|
||||
|
||||
|
||||
/* Only used at global scope (level 1): */
|
||||
SymbolList *programs; /* List of programs for this compilation. */
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Symbol table is a simple binary tree. */
|
||||
|
||||
|
||||
#include "cpp.h" /* to get MacroSymbol def */
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
int name; /* Name atom */
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
#endif /* !defined(__SYMBOLS_H) */
|
||||
|
||||
|
||||
|
|
|
@ -1,464 +1,462 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// tokens.c
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
#include "slang_mesa.h"
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
/*
|
||||
* idstr()
|
||||
* Copy a string to a malloc'ed block and convert it into something suitable
|
||||
* for an ID
|
||||
*
|
||||
*/
|
||||
|
||||
static char *idstr(const char *fstr)
|
||||
{
|
||||
size_t len;
|
||||
char *str, *t;
|
||||
const char *f;
|
||||
|
||||
len = strlen(fstr);
|
||||
str = (char *) malloc(len + 1);
|
||||
for (f=fstr, t=str; *f; f++) {
|
||||
if (_mesa_isalnum(*f)) *t++ = *f;
|
||||
else if (*f == '.' || *f == '/') *t++ = '_';
|
||||
}
|
||||
*t = 0;
|
||||
return str;
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* tokens.c */
|
||||
/* */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
/*////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// */
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
/*
|
||||
* idstr()
|
||||
* Copy a string to a malloc'ed block and convert it into something suitable
|
||||
* for an ID
|
||||
*
|
||||
*/
|
||||
|
||||
static char *idstr(const char *fstr)
|
||||
{
|
||||
size_t len;
|
||||
char *str, *t;
|
||||
const char *f;
|
||||
|
||||
len = strlen(fstr);
|
||||
str = (char *) malloc(len + 1);
|
||||
for (f=fstr, t=str; *f; f++) {
|
||||
if (isalnum(*f)) *t++ = *f;
|
||||
else if (*f == '.' || *f == '/') *t++ = '_';
|
||||
}
|
||||
*t = 0;
|
||||
return str;
|
||||
} /* idstr */
|
||||
|
||||
|
||||
/*
|
||||
* lNewBlock()
|
||||
*
|
||||
*/
|
||||
|
||||
static TokenBlock *lNewBlock(TokenStream *fTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
|
||||
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
||||
lBlock->count = 0;
|
||||
lBlock->current = 0;
|
||||
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
||||
lBlock->max = 256;
|
||||
lBlock->next = NULL;
|
||||
if (fTok->head) {
|
||||
fTok->current->next = lBlock;
|
||||
} else {
|
||||
fTok->head = lBlock;
|
||||
}
|
||||
fTok->current = lBlock;
|
||||
return lBlock;
|
||||
|
||||
|
||||
/*
|
||||
* lNewBlock()
|
||||
*
|
||||
*/
|
||||
|
||||
static TokenBlock *lNewBlock(TokenStream *fTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
|
||||
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
||||
lBlock->count = 0;
|
||||
lBlock->current = 0;
|
||||
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
||||
lBlock->max = 256;
|
||||
lBlock->next = NULL;
|
||||
if (fTok->head) {
|
||||
fTok->current->next = lBlock;
|
||||
} else {
|
||||
fTok->head = lBlock;
|
||||
}
|
||||
fTok->current = lBlock;
|
||||
return lBlock;
|
||||
} /* lNewBlock */
|
||||
|
||||
/*
|
||||
* lAddByte()
|
||||
*
|
||||
*/
|
||||
|
||||
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
lBlock = fTok->current;
|
||||
if (lBlock->count >= lBlock->max)
|
||||
lBlock = lNewBlock(fTok);
|
||||
lBlock->data[lBlock->count++] = fVal;
|
||||
|
||||
/*
|
||||
* lAddByte()
|
||||
*
|
||||
*/
|
||||
|
||||
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
lBlock = fTok->current;
|
||||
if (lBlock->count >= lBlock->max)
|
||||
lBlock = lNewBlock(fTok);
|
||||
lBlock->data[lBlock->count++] = fVal;
|
||||
} /* lAddByte */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* lReadByte() - Get the next byte from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
static int lReadByte(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
int lval = -1;
|
||||
|
||||
lBlock = pTok->current;
|
||||
if (lBlock) {
|
||||
if (lBlock->current >= lBlock->count) {
|
||||
lBlock = lBlock->next;
|
||||
if (lBlock)
|
||||
lBlock->current = 0;
|
||||
pTok->current = lBlock;
|
||||
}
|
||||
if (lBlock)
|
||||
lval = lBlock->data[lBlock->current++];
|
||||
}
|
||||
return lval;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* lReadByte() - Get the next byte from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
static int lReadByte(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
int lval = -1;
|
||||
|
||||
lBlock = pTok->current;
|
||||
if (lBlock) {
|
||||
if (lBlock->current >= lBlock->count) {
|
||||
lBlock = lBlock->next;
|
||||
if (lBlock)
|
||||
lBlock->current = 0;
|
||||
pTok->current = lBlock;
|
||||
}
|
||||
if (lBlock)
|
||||
lval = lBlock->data[lBlock->current++];
|
||||
}
|
||||
return lval;
|
||||
} /* lReadByte */
|
||||
|
||||
/*///////////////////////////////////// Global Functions:////////////////////////////////////*/
|
||||
|
||||
/*
|
||||
* NewTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
TokenStream *NewTokenStream(const char *name)
|
||||
{
|
||||
TokenStream *pTok;
|
||||
|
||||
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
||||
pTok->next = NULL;
|
||||
pTok->name = idstr(name);
|
||||
pTok->head = NULL;
|
||||
pTok->current = NULL;
|
||||
lNewBlock(pTok);
|
||||
return pTok;
|
||||
|
||||
/*///////////////////////////////////// Global Functions:////////////////////////////////////// */
|
||||
|
||||
/*
|
||||
* NewTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
TokenStream *NewTokenStream(const char *name)
|
||||
{
|
||||
TokenStream *pTok;
|
||||
|
||||
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
||||
pTok->next = NULL;
|
||||
pTok->name = idstr(name);
|
||||
pTok->head = NULL;
|
||||
pTok->current = NULL;
|
||||
lNewBlock(pTok);
|
||||
return pTok;
|
||||
} /* NewTokenStream */
|
||||
|
||||
/*
|
||||
* DeleteTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
void DeleteTokenStream(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *pBlock, *nBlock;
|
||||
|
||||
if (pTok) {
|
||||
pBlock = pTok->head;
|
||||
while (pBlock) {
|
||||
nBlock = pBlock->next;
|
||||
free(pBlock);
|
||||
pBlock = nBlock;
|
||||
}
|
||||
if (pTok->name)
|
||||
free(pTok->name);
|
||||
free(pTok);
|
||||
}
|
||||
|
||||
/*
|
||||
* DeleteTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
void DeleteTokenStream(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *pBlock, *nBlock;
|
||||
|
||||
if (pTok) {
|
||||
pBlock = pTok->head;
|
||||
while (pBlock) {
|
||||
nBlock = pBlock->next;
|
||||
free(pBlock);
|
||||
pBlock = nBlock;
|
||||
}
|
||||
if (pTok->name)
|
||||
free(pTok->name);
|
||||
free(pTok);
|
||||
}
|
||||
} /* DeleteTokenStream */
|
||||
|
||||
/*
|
||||
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
||||
*
|
||||
*/
|
||||
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
||||
{
|
||||
const char *s;
|
||||
unsigned char *str=NULL;
|
||||
|
||||
if (token > 256)
|
||||
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
||||
else
|
||||
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
case CPP_STRCONSTANT:
|
||||
s = GetAtomString(atable, yylvalpp->sc_ident);
|
||||
while (*s)
|
||||
lAddByte(pTok, (unsigned char) *s++);
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
case CPP_INTCONSTANT:
|
||||
str=yylvalpp->symbol_name;
|
||||
while (*str){
|
||||
lAddByte(pTok,(unsigned char) *str);
|
||||
*str++;
|
||||
}
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case '(':
|
||||
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
||||
*
|
||||
*/
|
||||
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
||||
{
|
||||
const char *s;
|
||||
unsigned char *str=NULL;
|
||||
|
||||
if (token > 256)
|
||||
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
||||
else
|
||||
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
case CPP_STRCONSTANT:
|
||||
s = GetAtomString(atable, yylvalpp->sc_ident);
|
||||
while (*s)
|
||||
lAddByte(pTok, (unsigned char) *s++);
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
case CPP_INTCONSTANT:
|
||||
str=yylvalpp->symbol_name;
|
||||
while (*str){
|
||||
lAddByte(pTok,(unsigned char) *str);
|
||||
*str++;
|
||||
}
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case '(':
|
||||
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} /* RecordToken */
|
||||
|
||||
/*
|
||||
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
||||
*
|
||||
*/
|
||||
|
||||
void RewindTokenStream(TokenStream *pTok)
|
||||
{
|
||||
if (pTok->head) {
|
||||
pTok->current = pTok->head;
|
||||
pTok->current->current = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
||||
*
|
||||
*/
|
||||
|
||||
void RewindTokenStream(TokenStream *pTok)
|
||||
{
|
||||
if (pTok->head) {
|
||||
pTok->current = pTok->head;
|
||||
pTok->current->current = 0;
|
||||
}
|
||||
} /* RewindTokenStream */
|
||||
|
||||
/*
|
||||
* ReadToken() - Read the next token from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
||||
{
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
||||
char string_val[MAX_STRING_LEN + 1];
|
||||
int ltoken, len;
|
||||
char ch;
|
||||
|
||||
ltoken = lReadByte(pTok);
|
||||
if (ltoken >= 0) {
|
||||
if (ltoken > 127)
|
||||
ltoken += 128;
|
||||
switch (ltoken) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '_')
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
||||
return CPP_IDENTIFIER;
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
len = 0;
|
||||
while ((ch = lReadByte(pTok)) != 0)
|
||||
if (len < MAX_STRING_LEN)
|
||||
string_val[len++] = ch;
|
||||
string_val[len] = 0;
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
||||
break;
|
||||
case '(':
|
||||
yylvalpp->sc_int = lReadByte(pTok);
|
||||
break;
|
||||
}
|
||||
return ltoken;
|
||||
}
|
||||
return EOF_SY;
|
||||
|
||||
/*
|
||||
* ReadToken() - Read the next token from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
||||
{
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
||||
char string_val[MAX_STRING_LEN + 1];
|
||||
int ltoken, len;
|
||||
char ch;
|
||||
|
||||
ltoken = lReadByte(pTok);
|
||||
if (ltoken >= 0) {
|
||||
if (ltoken > 127)
|
||||
ltoken += 128;
|
||||
switch (ltoken) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '_')
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
||||
return CPP_IDENTIFIER;
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
len = 0;
|
||||
while ((ch = lReadByte(pTok)) != 0)
|
||||
if (len < MAX_STRING_LEN)
|
||||
string_val[len++] = ch;
|
||||
string_val[len] = 0;
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
||||
break;
|
||||
case '(':
|
||||
yylvalpp->sc_int = lReadByte(pTok);
|
||||
break;
|
||||
}
|
||||
return ltoken;
|
||||
}
|
||||
return EOF_SY;
|
||||
} /* ReadToken */
|
||||
|
||||
typedef struct TokenInputSrc {
|
||||
InputSrc base;
|
||||
TokenStream *tokens;
|
||||
int (*final)(CPPStruct *);
|
||||
} TokenInputSrc;
|
||||
|
||||
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = ReadToken(in->tokens, yylvalpp);
|
||||
int (*final)(CPPStruct *);
|
||||
cpp->tokenLoc->file = cpp->currentInput->name;
|
||||
cpp->tokenLoc->line = cpp->currentInput->line;
|
||||
if (token == '\n') {
|
||||
in->base.line++;
|
||||
return token;
|
||||
}
|
||||
if (token > 0) return token;
|
||||
cpp->currentInput = in->base.prev;
|
||||
final = in->final;
|
||||
free(in);
|
||||
if (final && !final(cpp)) return -1;
|
||||
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
}
|
||||
|
||||
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
||||
{
|
||||
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
||||
memset(in, 0, sizeof(TokenInputSrc));
|
||||
in->base.name = name;
|
||||
in->base.prev = cpp->currentInput;
|
||||
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
||||
in->base.line = 1;
|
||||
in->tokens = ts;
|
||||
in->final = final;
|
||||
RewindTokenStream(ts);
|
||||
cpp->currentInput = &in->base;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct UngotToken {
|
||||
InputSrc base;
|
||||
int token;
|
||||
yystypepp lval;
|
||||
} UngotToken;
|
||||
|
||||
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = t->token;
|
||||
*yylvalpp = t->lval;
|
||||
cpp->currentInput = t->base.prev;
|
||||
free(t);
|
||||
return token;
|
||||
}
|
||||
|
||||
void UngetToken(int token, yystypepp * yylvalpp) {
|
||||
UngotToken *t = malloc(sizeof(UngotToken));
|
||||
memset(t, 0, sizeof(UngotToken));
|
||||
t->token = token;
|
||||
t->lval = *yylvalpp;
|
||||
t->base.scan = (void *)reget_token;
|
||||
t->base.prev = cpp->currentInput;
|
||||
t->base.name = cpp->currentInput->name;
|
||||
t->base.line = cpp->currentInput->line;
|
||||
cpp->currentInput = &t->base;
|
||||
}
|
||||
|
||||
|
||||
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
||||
int token;
|
||||
char str[100];
|
||||
|
||||
if (fp == 0) fp = stdout;
|
||||
RewindTokenStream(s);
|
||||
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
/*printf("%g9.6 ", yylvalpp->sc_fval);*/
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
/*printf("%d ", yylvalpp->sc_int);*/
|
||||
break;
|
||||
default:
|
||||
if (token >= 127)
|
||||
sprintf(str, "%s ", GetAtomString(atable, token));
|
||||
else
|
||||
sprintf(str, "%c", token);
|
||||
break;
|
||||
}
|
||||
CPPDebugLogMsg(str);
|
||||
}
|
||||
}
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
typedef struct TokenInputSrc {
|
||||
InputSrc base;
|
||||
TokenStream *tokens;
|
||||
int (*final)(CPPStruct *);
|
||||
} TokenInputSrc;
|
||||
|
||||
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = ReadToken(in->tokens, yylvalpp);
|
||||
int (*final)(CPPStruct *);
|
||||
cpp->tokenLoc->file = cpp->currentInput->name;
|
||||
cpp->tokenLoc->line = cpp->currentInput->line;
|
||||
if (token == '\n') {
|
||||
in->base.line++;
|
||||
return token;
|
||||
}
|
||||
if (token > 0) return token;
|
||||
cpp->currentInput = in->base.prev;
|
||||
final = in->final;
|
||||
free(in);
|
||||
if (final && !final(cpp)) return -1;
|
||||
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
}
|
||||
|
||||
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
||||
{
|
||||
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
||||
memset(in, 0, sizeof(TokenInputSrc));
|
||||
in->base.name = name;
|
||||
in->base.prev = cpp->currentInput;
|
||||
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
||||
in->base.line = 1;
|
||||
in->tokens = ts;
|
||||
in->final = final;
|
||||
RewindTokenStream(ts);
|
||||
cpp->currentInput = &in->base;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct UngotToken {
|
||||
InputSrc base;
|
||||
int token;
|
||||
yystypepp lval;
|
||||
} UngotToken;
|
||||
|
||||
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = t->token;
|
||||
*yylvalpp = t->lval;
|
||||
cpp->currentInput = t->base.prev;
|
||||
free(t);
|
||||
return token;
|
||||
}
|
||||
|
||||
void UngetToken(int token, yystypepp * yylvalpp) {
|
||||
UngotToken *t = malloc(sizeof(UngotToken));
|
||||
memset(t, 0, sizeof(UngotToken));
|
||||
t->token = token;
|
||||
t->lval = *yylvalpp;
|
||||
t->base.scan = (void *)reget_token;
|
||||
t->base.prev = cpp->currentInput;
|
||||
t->base.name = cpp->currentInput->name;
|
||||
t->base.line = cpp->currentInput->line;
|
||||
cpp->currentInput = &t->base;
|
||||
}
|
||||
|
||||
|
||||
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
||||
int token;
|
||||
char str[100];
|
||||
|
||||
if (fp == 0) fp = stdout;
|
||||
RewindTokenStream(s);
|
||||
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
/*printf("%g9.6 ", yylvalpp->sc_fval); */
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
/*printf("%d ", yylvalpp->sc_int); */
|
||||
break;
|
||||
default:
|
||||
if (token >= 127)
|
||||
sprintf(str, "%s ", GetAtomString(atable, token));
|
||||
else
|
||||
sprintf(str, "%c", token);
|
||||
break;
|
||||
}
|
||||
CPPDebugLogMsg(str);
|
||||
}
|
||||
}
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
/*///////////////////////////////////// End of tokens.c /////////////////////////////////////// */
|
||||
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
|
|
|
@ -1,122 +1,122 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// tokens.h
|
||||
*/
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlock;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlock *head;
|
||||
TokenBlock *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlock *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
/* */
|
||||
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||
/*All rights reserved. */
|
||||
/* */
|
||||
/*Redistribution and use in source and binary forms, with or without */
|
||||
/*modification, are permitted provided that the following conditions */
|
||||
/*are met: */
|
||||
/* */
|
||||
/* Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* */
|
||||
/* Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* */
|
||||
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* */
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/* */
|
||||
/* tokens.h */
|
||||
/* */
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlock;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlock *head;
|
||||
TokenBlock *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlock *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
#endif /* defined(CPPC_ENABLE_TOOLS) */
|
||||
|
||||
|
||||
#endif /* !defined(__TOKENS_H) */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,73 +1,78 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// This file contains any Linux specific functions.
|
||||
//
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "Include/InitializeGlobals.h"
|
||||
#include "Include/PoolAlloc.h"
|
||||
|
||||
#define _vsnprintf vsnprintf
|
||||
|
||||
void DetachThreadLinux(void *);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef unsigned int OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
|
||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
//
|
||||
// This function should return 0 if nIndex is invalid.
|
||||
//
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return (pthread_getspecific(nIndex));
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef __OSINCLUDE_H
|
||||
#define __OSINCLUDE_H
|
||||
|
||||
//
|
||||
// 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 <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "Include/InitializeGlobals.h"
|
||||
#include "Include/PoolAlloc.h"
|
||||
|
||||
#define _vsnprintf vsnprintf
|
||||
|
||||
void DetachThreadLinux(void *);
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
typedef unsigned int OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||
|
||||
|
||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
//
|
||||
// This function should return 0 if nIndex is invalid.
|
||||
//
|
||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
||||
return (pthread_getspecific(nIndex));
|
||||
}
|
||||
|
||||
#endif // __OSINCLUDE_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -38,9 +38,9 @@
|
|||
#include "osinclude.h"
|
||||
#include "Initialisation.h"
|
||||
|
||||
#if !(defined(linux))
|
||||
/*#if !(defined(linux))
|
||||
#error Trying to build a Linux specific file in a non-Linux build.
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
//
|
||||
// Thread cleanup
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//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.
|
||||
#endif
|
||||
|
||||
#define STRICT 1
|
||||
#define STRICT
|
||||
#define VC_EXTRALEAN 1
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//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.
|
||||
#endif
|
||||
|
||||
//
|
||||
// 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)
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
switch (fdwReason)
|
||||
{
|
||||
|
@ -76,7 +72,7 @@
|
|||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//
|
||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
|
@ -30,69 +30,47 @@
|
|||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
//
|
||||
#ifndef _COMPILER_INTERFACE_INCLUDED_
|
||||
#define _COMPILER_INTERFACE_INCLUDED_
|
||||
|
||||
#include "../Include/ResourceLimits.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#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
|
||||
#define SH_IMPORT_EXPORT
|
||||
#define __fastcall
|
||||
#define C_DECL
|
||||
#endif
|
||||
|
||||
/*
|
||||
//
|
||||
// This is the platform independent interface between an OGL driver
|
||||
// and the shading language compiler/linker.
|
||||
*/
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
//
|
||||
// Driver must call this first, once, before doing any other
|
||||
// compiler/linker operations.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT int ShInitialize();
|
||||
/*
|
||||
//
|
||||
// Driver should call this at shutdown.
|
||||
*/
|
||||
//
|
||||
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.
|
||||
*/
|
||||
//
|
||||
typedef enum {
|
||||
EShLangVertex,
|
||||
EShLangFragment,
|
||||
|
@ -101,9 +79,9 @@ typedef enum {
|
|||
EShLangCount
|
||||
} EShLanguage;
|
||||
|
||||
/*
|
||||
//
|
||||
// Types of output the linker will create.
|
||||
*/
|
||||
//
|
||||
typedef enum {
|
||||
EShExVertexFragment,
|
||||
EShExPackFragment,
|
||||
|
@ -111,20 +89,20 @@ typedef enum {
|
|||
EShExFragment
|
||||
} EShExecutable;
|
||||
|
||||
/*
|
||||
//
|
||||
// Optimization level for the compiler.
|
||||
*/
|
||||
//
|
||||
typedef enum {
|
||||
EShOptNoGeneration,
|
||||
EShOptNone,
|
||||
EShOptSimple, /* Optimizations that can be done quickly */
|
||||
EShOptFull /* Optimizations that will take more time */
|
||||
EShOptSimple, // Optimizations that can be done quickly
|
||||
EShOptFull // Optimizations that will take more time
|
||||
} EShOptimizationLevel;
|
||||
|
||||
/*
|
||||
//
|
||||
// Build a table for bindings. This can be used for locating
|
||||
// attributes, uniforms, globals, etc., as needed.
|
||||
*/
|
||||
//
|
||||
typedef struct {
|
||||
char* name;
|
||||
int binding;
|
||||
|
@ -132,10 +110,10 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int numBindings;
|
||||
ShBinding* bindings; /* array of bindings */
|
||||
ShBinding* bindings; // array of bindings
|
||||
} ShBindingTable;
|
||||
|
||||
/*
|
||||
//
|
||||
// ShHandle held by but opaque to the driver. It is allocated,
|
||||
// managed, and de-allocated by the compiler/linker. It's contents
|
||||
// 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.
|
||||
//
|
||||
// If handle creation fails, 0 will be returned.
|
||||
*/
|
||||
//
|
||||
typedef void* ShHandle;
|
||||
|
||||
/*
|
||||
//
|
||||
// Driver calls these to create and destroy compiler/linker
|
||||
// objects.
|
||||
*/
|
||||
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 ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */
|
||||
//
|
||||
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 ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
|
||||
SH_IMPORT_EXPORT void ShDestruct(ShHandle);
|
||||
|
||||
/*
|
||||
//
|
||||
// The return value of ShCompile is boolean, indicating
|
||||
// success or failure.
|
||||
//
|
||||
// The info-log should be written by ShCompile into
|
||||
// ShHandle, so it can answer future queries.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT int ShCompile(
|
||||
const ShHandle,
|
||||
const char* const shaderStrings[],
|
||||
const int numStrings,
|
||||
const EShOptimizationLevel,
|
||||
const TBuiltInResource *resources,
|
||||
int debugOptions
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
//
|
||||
// Similar to ShCompile, but accepts an opaque handle to an
|
||||
// intermediate language structure.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT int ShCompileIntermediate(
|
||||
ShHandle compiler,
|
||||
ShHandle intermediate,
|
||||
const EShOptimizationLevel,
|
||||
int debuggable /* boolean */
|
||||
int debuggable // boolean
|
||||
);
|
||||
|
||||
SH_IMPORT_EXPORT int ShLink(
|
||||
const ShHandle, /* linker object */
|
||||
const ShHandle h[], /* compiler objects to link together */
|
||||
const ShHandle, // linker object
|
||||
const ShHandle h[], // compiler objects to link together
|
||||
const int numHandles,
|
||||
ShHandle uniformMap, /* updated with new uniforms */
|
||||
short int** uniformsAccessed, /* returned with indexes of uniforms accessed */
|
||||
ShHandle uniformMap, // updated with new uniforms
|
||||
short int** uniformsAccessed, // returned with indexes of uniforms accessed
|
||||
int* numUniformsAccessed);
|
||||
|
||||
/*
|
||||
//
|
||||
// ShSetEncrpytionMethod is a place-holder for specifying
|
||||
// how source code is encrypted.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);
|
||||
|
||||
/*
|
||||
//
|
||||
// All the following return 0 if the information is not
|
||||
// available in the object passed down, or the object is bad.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT const char* ShGetInfoLog(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 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 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 ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); // for all 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);
|
||||
|
||||
/*
|
||||
//
|
||||
// Returns the location ID of the named uniform.
|
||||
// Returns -1 if error.
|
||||
*/
|
||||
//
|
||||
SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
|
||||
SH_IMPORT_EXPORT char* ShGetUniformName(const ShHandle linker, int virtualLocation);
|
||||
|
||||
enum TDebugOptions {
|
||||
EDebugOpNone = 0x000,
|
||||
|
@ -229,4 +207,4 @@ enum TDebugOptions {
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* _COMPILER_INTERFACE_INCLUDED_ */
|
||||
#endif // _COMPILER_INTERFACE_INCLUDED_
|
||||
|
|
|
@ -45,143 +45,11 @@
|
|||
extern "C" {
|
||||
#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(
|
||||
const ShHandle, // linker object
|
||||
const ShHandle h[], // compiler objects to link together
|
||||
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
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue