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.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -45,8 +45,6 @@
|
||||||
#define UINT_PTR uintptr_t
|
#define UINT_PTR uintptr_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/* windows only pragma */
|
/* windows only pragma */
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4786) // Don't warn about too long identifiers
|
#pragma warning(disable : 4786) // Don't warn about too long identifiers
|
||||||
|
@ -73,6 +71,7 @@
|
||||||
|
|
||||||
typedef int TSourceLoc;
|
typedef int TSourceLoc;
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include "PoolAlloc.h"
|
#include "PoolAlloc.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -194,7 +193,7 @@ public :
|
||||||
//
|
//
|
||||||
typedef pool_allocator<char> TStringAllocator;
|
typedef pool_allocator<char> TStringAllocator;
|
||||||
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
|
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
|
||||||
inline TString* NewPoolTString(char* s)
|
inline TString* NewPoolTString(const char* s)
|
||||||
{
|
{
|
||||||
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
|
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
|
||||||
return new(memory) TString(s);
|
return new(memory) TString(s);
|
||||||
|
@ -253,13 +252,12 @@ inline const TString String(const int i, const int base = 10)
|
||||||
{
|
{
|
||||||
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
||||||
|
|
||||||
// we assume base 10 or 16 for all cases
|
#ifdef _WIN32
|
||||||
if (base == 10)
|
itoa(i, text, base);
|
||||||
sprintf(text, "%d", i);
|
#else
|
||||||
else if (base == 16)
|
// we assume base 10 for all cases
|
||||||
sprintf(text, "%x", i);
|
sprintf(text, "%d", i);
|
||||||
else
|
#endif
|
||||||
assert (!"String(int): unsupported base");
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -281,5 +279,7 @@ __inline TPersistString FormatSourceLoc(const TSourceLoc loc)
|
||||||
|
|
||||||
return TPersistString(locText);
|
return TPersistString(locText);
|
||||||
}
|
}
|
||||||
|
typedef TMap<TString, TString> TPragmaTable;
|
||||||
|
typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
||||||
|
|
||||||
#endif // _COMMON_INCLUDED_
|
#endif // _COMMON_INCLUDED_
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -84,8 +84,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void check() const {
|
void check() const {
|
||||||
checkGuardBlock(preGuard(), (unsigned char) (guardBlockBeginVal), "before");
|
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
|
||||||
checkGuardBlock(postGuard(), (unsigned char) (guardBlockEndVal), "after");
|
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkAllocList() const;
|
void checkAllocList() const;
|
||||||
|
@ -113,21 +113,16 @@ private:
|
||||||
unsigned char* mem; // beginning of our allocation (pts to header)
|
unsigned char* mem; // beginning of our allocation (pts to header)
|
||||||
TAllocation* prevAlloc; // prior allocation in the chain
|
TAllocation* prevAlloc; // prior allocation in the chain
|
||||||
|
|
||||||
enum {
|
// Support MSVC++ 6.0
|
||||||
guardBlockBeginVal = 0xfb,
|
const static unsigned char guardBlockBeginVal;
|
||||||
guardBlockEndVal = 0xfe,
|
const static unsigned char guardBlockEndVal;
|
||||||
userDataFill = 0xcd
|
const static unsigned char userDataFill;
|
||||||
};
|
|
||||||
|
|
||||||
# ifdef GUARD_BLOCKS
|
# ifdef GUARD_BLOCKS
|
||||||
enum {
|
const static size_t guardBlockSize;
|
||||||
guardBlockSize = 16
|
|
||||||
};
|
|
||||||
inline static size_t headerSize() { return sizeof(TAllocation); }
|
inline static size_t headerSize() { return sizeof(TAllocation); }
|
||||||
# else
|
# else
|
||||||
enum {
|
const static size_t guardBlockSize;
|
||||||
guardBlockSize = 0
|
|
||||||
};
|
|
||||||
inline static size_t headerSize() { return 0; }
|
inline static size_t headerSize() { return 0; }
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
@ -254,13 +249,10 @@ private:
|
||||||
//
|
//
|
||||||
typedef TPoolAllocator* PoolAllocatorPointer;
|
typedef TPoolAllocator* PoolAllocatorPointer;
|
||||||
extern TPoolAllocator& GetGlobalPoolAllocator();
|
extern TPoolAllocator& GetGlobalPoolAllocator();
|
||||||
extern PoolAllocatorPointer& GetCompilerPoolAllocator();
|
|
||||||
#define GlobalPoolAllocator GetGlobalPoolAllocator()
|
#define GlobalPoolAllocator GetGlobalPoolAllocator()
|
||||||
#define CompilerPoolAllocator GetCompilerPoolAllocator()
|
|
||||||
struct TThreadGlobalPools
|
struct TThreadGlobalPools
|
||||||
{
|
{
|
||||||
TPoolAllocator* globalPoolAllocator;
|
TPoolAllocator* globalPoolAllocator;
|
||||||
TPoolAllocator* compilerPoolAllocator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -35,6 +35,10 @@
|
||||||
#ifndef _RESOURCE_LIMITS_INCLUDED_
|
#ifndef _RESOURCE_LIMITS_INCLUDED_
|
||||||
#define _RESOURCE_LIMITS_INCLUDED_
|
#define _RESOURCE_LIMITS_INCLUDED_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct TBuiltInResource {
|
struct TBuiltInResource {
|
||||||
int maxLights;
|
int maxLights;
|
||||||
int maxClipPlanes;
|
int maxClipPlanes;
|
||||||
|
@ -49,4 +53,9 @@ struct TBuiltInResource {
|
||||||
int maxFragmentUniformComponents;
|
int maxFragmentUniformComponents;
|
||||||
int maxDrawBuffers;
|
int maxDrawBuffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // _RESOURCE_LIMITS_INCLUDED_
|
#endif // _RESOURCE_LIMITS_INCLUDED_
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -101,32 +101,10 @@ public:
|
||||||
virtual TCompiler* getAsCompiler() { return this; }
|
virtual TCompiler* getAsCompiler() { return this; }
|
||||||
virtual bool linkable() { return haveValidObjectCode; }
|
virtual bool linkable() { return haveValidObjectCode; }
|
||||||
|
|
||||||
// Initialize our private pool for a new compilation, and
|
|
||||||
// return it.
|
|
||||||
virtual TPoolAllocator& getNewCompilationAllocator()
|
|
||||||
{
|
|
||||||
// We do a pop and push on the compiler pool, because compile can
|
|
||||||
// be called repeatedly on the same compiler handle. Each time,
|
|
||||||
// we want to pop away the results of any previous compile. We
|
|
||||||
// could do that with popAll, but this is a somewhat smaller
|
|
||||||
// hammer.
|
|
||||||
compilerPool.pop();
|
|
||||||
compilerPool.push();
|
|
||||||
|
|
||||||
return compilerPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
TPoolAllocator& getCompilerPoolAllocator() { return compilerPool; }
|
|
||||||
|
|
||||||
TInfoSink& infoSink;
|
TInfoSink& infoSink;
|
||||||
protected:
|
protected:
|
||||||
EShLanguage language;
|
EShLanguage language;
|
||||||
bool haveValidObjectCode;
|
bool haveValidObjectCode;
|
||||||
|
|
||||||
// This is a per-compiler-object pool allocator. Allocations
|
|
||||||
// who's lifetime need not extend beyond the lifetime of the
|
|
||||||
// compiler itself can use this private pool.
|
|
||||||
TPoolAllocator compilerPool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -74,6 +74,8 @@ public:
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::map<TTypeList*, TTypeList*> TStructureMap;
|
||||||
|
typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
|
||||||
//
|
//
|
||||||
// Base class for things that have a type.
|
// Base class for things that have a type.
|
||||||
//
|
//
|
||||||
|
@ -82,33 +84,91 @@ public:
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||||
explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
|
explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
|
||||||
type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
|
type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
|
||||||
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0)
|
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), typeName(0), mangled(0), fieldName(0)
|
||||||
{ }
|
{ }
|
||||||
explicit TType(TPublicType p) :
|
explicit TType(TPublicType p) :
|
||||||
type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0),
|
type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0),
|
||||||
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0)
|
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
|
||||||
{
|
{
|
||||||
if (p.userDef) {
|
if (p.userDef) {
|
||||||
structure = p.userDef->getStruct();
|
structure = p.userDef->getStruct();
|
||||||
structureSize = setStructSize(p.userDef->getStruct());
|
structureSize = setStructSize(p.userDef->getStruct());
|
||||||
typeName = p.userDef->getTypeName();
|
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
explicit TType(TTypeList* userDef, TString n) :
|
explicit TType(TTypeList* userDef, TString n) :
|
||||||
type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
|
type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
|
||||||
structure(userDef), typeName(n), maxArraySize(0), arrayInformationType(0) {
|
structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {
|
||||||
structureSize = setStructSize(userDef);
|
structureSize = setStructSize(userDef);
|
||||||
|
typeName = NewPoolTString(n.c_str());
|
||||||
}
|
}
|
||||||
|
explicit TType() {}
|
||||||
virtual ~TType() {}
|
virtual ~TType() {}
|
||||||
|
|
||||||
TType (const TType& type) { *this = type; }
|
TType (const TType& type) { *this = type; }
|
||||||
|
|
||||||
|
void copyType(const TType& copyOf, TStructureMap& remapper)
|
||||||
|
{
|
||||||
|
type = copyOf.type;
|
||||||
|
qualifier = copyOf.qualifier;
|
||||||
|
size = copyOf.size;
|
||||||
|
matrix = copyOf.matrix;
|
||||||
|
array = copyOf.array;
|
||||||
|
arraySize = copyOf.arraySize;
|
||||||
|
|
||||||
|
TStructureMapIterator iter;
|
||||||
|
if (copyOf.structure) {
|
||||||
|
if ((iter = remapper.find(structure)) == remapper.end()) {
|
||||||
|
// create the new structure here
|
||||||
|
structure = NewPoolTTypeList();
|
||||||
|
for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
|
||||||
|
TTypeLine typeLine;
|
||||||
|
typeLine.line = (*copyOf.structure)[i].line;
|
||||||
|
typeLine.type = (*copyOf.structure)[i].type->clone(remapper);
|
||||||
|
structure->push_back(typeLine);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
structure = iter->second;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
structure = 0;
|
||||||
|
|
||||||
|
fieldName = 0;
|
||||||
|
if (copyOf.fieldName)
|
||||||
|
fieldName = NewPoolTString(copyOf.fieldName->c_str());
|
||||||
|
typeName = 0;
|
||||||
|
if (copyOf.typeName)
|
||||||
|
typeName = NewPoolTString(copyOf.typeName->c_str());
|
||||||
|
|
||||||
|
mangled = 0;
|
||||||
|
if (copyOf.mangled)
|
||||||
|
mangled = NewPoolTString(copyOf.mangled->c_str());
|
||||||
|
|
||||||
|
structureSize = copyOf.structureSize;
|
||||||
|
maxArraySize = copyOf.maxArraySize;
|
||||||
|
assert (copyOf.arrayInformationType == 0);
|
||||||
|
arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
|
||||||
|
}
|
||||||
|
|
||||||
|
TType* clone(TStructureMap& remapper)
|
||||||
|
{
|
||||||
|
TType *newType = new TType();
|
||||||
|
newType->copyType(*this, remapper);
|
||||||
|
|
||||||
|
return newType;
|
||||||
|
}
|
||||||
|
|
||||||
int setStructSize(TTypeList* userDef)
|
int setStructSize(TTypeList* userDef)
|
||||||
{
|
{
|
||||||
int stSize = 0;
|
int stSize = 0;
|
||||||
for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
|
for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
|
||||||
if (((*tl).type)->isArray()) {
|
if (((*tl).type)->isArray()) {
|
||||||
|
if (((*tl).type)->getStruct()) {
|
||||||
|
int structSize = setStructSize(((*tl).type)->getStruct());
|
||||||
|
stSize += structSize * ((*tl).type)->getArraySize();
|
||||||
|
} else {
|
||||||
stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();
|
stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();
|
||||||
|
}
|
||||||
} else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
|
} else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
|
||||||
stSize += ((*tl).type)->getInstanceSize();
|
stSize += ((*tl).type)->getInstanceSize();
|
||||||
} else if (((*tl).type)->getStruct()) {
|
} else if (((*tl).type)->getStruct()) {
|
||||||
|
@ -132,10 +192,20 @@ public:
|
||||||
structure = userDef->getStruct();
|
structure = userDef->getStruct();
|
||||||
// leave array information intact.
|
// leave array information intact.
|
||||||
}
|
}
|
||||||
virtual void setTypeName(const TString& n) { typeName = n; }
|
virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
|
||||||
virtual void setFieldName(const TString& n) { fieldName = n; }
|
virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
|
||||||
virtual const TString& getTypeName() const { return typeName; }
|
virtual const TString& getTypeName() const
|
||||||
virtual const TString& getFieldName() const { return fieldName; }
|
{
|
||||||
|
assert (typeName);
|
||||||
|
return *typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual const TString& getFieldName() const
|
||||||
|
{
|
||||||
|
assert (fieldName);
|
||||||
|
return *fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
virtual TBasicType getBasicType() const { return type; }
|
virtual TBasicType getBasicType() const { return type; }
|
||||||
virtual TQualifier getQualifier() const { return qualifier; }
|
virtual TQualifier getQualifier() const { return qualifier; }
|
||||||
virtual void changeQualifier(TQualifier q) { qualifier = q; }
|
virtual void changeQualifier(TQualifier q) { qualifier = q; }
|
||||||
|
@ -152,8 +222,8 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isMatrix() const { return matrix; }
|
virtual bool isMatrix() const { return matrix ? true : false; }
|
||||||
virtual bool isArray() const { return array; }
|
virtual bool isArray() const { return array ? true : false; }
|
||||||
int getArraySize() const { return arraySize; }
|
int getArraySize() const { return arraySize; }
|
||||||
void setArraySize(int s) { array = true; arraySize = s; }
|
void setArraySize(int s) { array = true; arraySize = s; }
|
||||||
void setMaxArraySize (int s) { maxArraySize = s; }
|
void setMaxArraySize (int s) { maxArraySize = s; }
|
||||||
|
@ -180,14 +250,16 @@ public:
|
||||||
const char* getBasicString() const { return TType::getBasicString(type); }
|
const char* getBasicString() const { return TType::getBasicString(type); }
|
||||||
const char* getQualifierString() const { return ::getQualifierString(qualifier); }
|
const char* getQualifierString() const { return ::getQualifierString(qualifier); }
|
||||||
TTypeList* getStruct() { return structure; }
|
TTypeList* getStruct() { return structure; }
|
||||||
int getStructSize() { return structureSize; }
|
int getStructSize() const { return structureSize; }
|
||||||
TTypeList* getStruct() const { return structure; }
|
TTypeList* getStruct() const { return structure; }
|
||||||
TString& getMangledName() {
|
TString& getMangledName() {
|
||||||
if (mangled.size() == 0) {
|
if (!mangled) {
|
||||||
buildMangledName(mangled);
|
mangled = NewPoolTString("");
|
||||||
mangled+=';';
|
buildMangledName(*mangled);
|
||||||
|
*mangled+=';';
|
||||||
}
|
}
|
||||||
return mangled;
|
|
||||||
|
return *mangled;
|
||||||
}
|
}
|
||||||
bool operator==(const TType& right) const {
|
bool operator==(const TType& right) const {
|
||||||
return type == right.type &&
|
return type == right.type &&
|
||||||
|
@ -203,21 +275,22 @@ public:
|
||||||
TString getCompleteString() const;
|
TString getCompleteString() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TBasicType type;
|
void buildMangledName(TString&);
|
||||||
TQualifier qualifier;
|
|
||||||
int size; // size of vector or matrix, not size of array
|
|
||||||
bool matrix;
|
|
||||||
bool array;
|
|
||||||
int arraySize;
|
int arraySize;
|
||||||
TTypeList* structure; // 0 unless this is a struct
|
TTypeList* structure; // 0 unless this is a struct
|
||||||
TString fieldName; // for structure field names
|
TString *fieldName; // for structure field names
|
||||||
TString typeName; // for structure field type name
|
TString *typeName; // for structure field type name
|
||||||
TString mangled;
|
TString *mangled;
|
||||||
int structureSize;
|
int structureSize;
|
||||||
int maxArraySize;
|
int maxArraySize;
|
||||||
TType* arrayInformationType;
|
TType* arrayInformationType;
|
||||||
|
|
||||||
void buildMangledName(TString&);
|
TQualifier qualifier : 7;
|
||||||
|
TBasicType type : 6;
|
||||||
|
int size : 8; // size of vector or matrix, not size of array
|
||||||
|
unsigned int matrix : 1;
|
||||||
|
unsigned int array : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _TYPES_INCLUDED_
|
#endif // _TYPES_INCLUDED_
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -51,7 +51,6 @@
|
||||||
//
|
//
|
||||||
// Operators used by the high-level (parse tree) representation.
|
// Operators used by the high-level (parse tree) representation.
|
||||||
//
|
//
|
||||||
|
|
||||||
enum TOperator {
|
enum TOperator {
|
||||||
EOpNull, // if in a node, should only mean a node is still being built
|
EOpNull, // if in a node, should only mean a node is still being built
|
||||||
EOpSequence, // denotes a list of statements, or parameters, etc.
|
EOpSequence, // denotes a list of statements, or parameters, etc.
|
||||||
|
@ -379,7 +378,7 @@ public:
|
||||||
virtual bool promote(TInfoSink&) { return true; }
|
virtual bool promote(TInfoSink&) { return true; }
|
||||||
protected:
|
protected:
|
||||||
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
|
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
|
||||||
TIntermOperator(TOperator o, TType t) : TIntermTyped(t), op(o) {}
|
TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
|
||||||
TOperator op;
|
TOperator op;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -406,7 +405,7 @@ protected:
|
||||||
//
|
//
|
||||||
class TIntermUnary : public TIntermOperator {
|
class TIntermUnary : public TIntermOperator {
|
||||||
public:
|
public:
|
||||||
TIntermUnary(TOperator o, TType t) : TIntermOperator(o, t), operand(0) {}
|
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
|
||||||
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
|
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
|
||||||
virtual void traverse(TIntermTraverser*);
|
virtual void traverse(TIntermTraverser*);
|
||||||
virtual void setOperand(TIntermTyped* o) { operand = o; }
|
virtual void setOperand(TIntermTyped* o) { operand = o; }
|
||||||
|
@ -423,8 +422,9 @@ typedef TVector<int> TQualifierList;
|
||||||
//
|
//
|
||||||
class TIntermAggregate : public TIntermOperator {
|
class TIntermAggregate : public TIntermOperator {
|
||||||
public:
|
public:
|
||||||
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false) { }
|
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
|
||||||
TIntermAggregate(TOperator o) : TIntermOperator(o) { }
|
TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
|
||||||
|
~TIntermAggregate() { delete pragmaTable; }
|
||||||
virtual TIntermAggregate* getAsAggregate() { return this; }
|
virtual TIntermAggregate* getAsAggregate() { return this; }
|
||||||
virtual void setOperator(TOperator o) { op = o; }
|
virtual void setOperator(TOperator o) { op = o; }
|
||||||
virtual TIntermSequence& getSequence() { return sequence; }
|
virtual TIntermSequence& getSequence() { return sequence; }
|
||||||
|
@ -434,11 +434,22 @@ public:
|
||||||
virtual void setUserDefined() { userDefined = true; }
|
virtual void setUserDefined() { userDefined = true; }
|
||||||
virtual bool isUserDefined() { return userDefined; }
|
virtual bool isUserDefined() { return userDefined; }
|
||||||
virtual TQualifierList& getQualifier() { return qualifier; }
|
virtual TQualifierList& getQualifier() { return qualifier; }
|
||||||
|
void setOptimize(bool o) { optimize = o; }
|
||||||
|
void setDebug(bool d) { debug = d; }
|
||||||
|
bool getOptimize() { return optimize; }
|
||||||
|
bool getDebug() { return debug; }
|
||||||
|
void addToPragmaTable(const TPragmaTable& pTable);
|
||||||
|
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
|
||||||
protected:
|
protected:
|
||||||
|
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
|
||||||
|
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
|
||||||
TIntermSequence sequence;
|
TIntermSequence sequence;
|
||||||
TQualifierList qualifier;
|
TQualifierList qualifier;
|
||||||
TString name;
|
TString name;
|
||||||
bool userDefined; // used for user defined function names
|
bool userDefined; // used for user defined function names
|
||||||
|
bool optimize;
|
||||||
|
bool debug;
|
||||||
|
TPragmaTable *pragmaTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -448,7 +459,7 @@ class TIntermSelection : public TIntermTyped {
|
||||||
public:
|
public:
|
||||||
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
|
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
|
||||||
TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
|
TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
|
||||||
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, TType type) :
|
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
|
||||||
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
|
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
|
||||||
virtual void traverse(TIntermTraverser*);
|
virtual void traverse(TIntermTraverser*);
|
||||||
virtual TIntermNode* getCondition() const { return condition; }
|
virtual TIntermNode* getCondition() const { return condition; }
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -57,7 +57,7 @@ void TInfoSinkBase::append(const char *s)
|
||||||
void TInfoSinkBase::append(int count, char c)
|
void TInfoSinkBase::append(int count, char c)
|
||||||
{
|
{
|
||||||
if (outputStream & EString) {
|
if (outputStream & EString) {
|
||||||
checkMem(1);
|
checkMem(count);
|
||||||
sink.append(count, c);
|
sink.append(count, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -40,9 +40,8 @@
|
||||||
|
|
||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
#include "Initialize.h"
|
#include "Initialize.h"
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
void TBuiltIns::initialize(TBuiltInResource &resources)
|
void TBuiltIns::initialize()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Initialize all the built-in strings for parsing.
|
// Initialize all the built-in strings for parsing.
|
||||||
|
@ -355,53 +354,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
// Texture Functions.
|
// Texture Functions.
|
||||||
//
|
//
|
||||||
s.append(TString("vec4 texture1D(sampler1D sampler, float coord);"));
|
s.append(TString("vec4 texture1D(sampler1D sampler, float coord);"));
|
||||||
s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);"));
|
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);"));
|
||||||
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);"));
|
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);"));
|
||||||
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));
|
|
||||||
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
|
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
|
||||||
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
|
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
|
||||||
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
|
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
|
||||||
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);"));
|
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);"));
|
||||||
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);"));
|
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);"));
|
||||||
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
|
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
|
||||||
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
|
|
||||||
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);"));
|
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);"));
|
||||||
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);"));
|
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);"));
|
||||||
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);"));
|
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);"));
|
||||||
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);"));
|
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);"));
|
||||||
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));
|
|
||||||
|
|
||||||
s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));
|
|
||||||
s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Noise functions.
|
// Noise functions.
|
||||||
|
@ -442,6 +414,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
//
|
//
|
||||||
s.append(TString("vec4 ftransform();"));
|
s.append(TString("vec4 ftransform();"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Texture Functions.
|
||||||
|
//
|
||||||
|
s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));
|
||||||
|
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));
|
||||||
|
s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));
|
||||||
|
|
||||||
s.append(TString("\n"));
|
s.append(TString("\n"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -453,6 +445,26 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
|
|
||||||
TString& s = BuiltInFunctionsFragment;
|
TString& s = BuiltInFunctionsFragment;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Texture Functions.
|
||||||
|
//
|
||||||
|
s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));
|
||||||
|
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
|
||||||
|
|
||||||
|
s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));
|
||||||
|
s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));
|
||||||
|
|
||||||
s.append(TString("float dFdx(float p);"));
|
s.append(TString("float dFdx(float p);"));
|
||||||
s.append(TString("vec2 dFdx(vec2 p);"));
|
s.append(TString("vec2 dFdx(vec2 p);"));
|
||||||
s.append(TString("vec3 dFdx(vec3 p);"));
|
s.append(TString("vec3 dFdx(vec3 p);"));
|
||||||
|
@ -479,46 +491,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
|
|
||||||
TString& s = StandardUniforms;
|
TString& s = StandardUniforms;
|
||||||
|
|
||||||
//
|
|
||||||
// Implementation dependent constants. The example values below
|
|
||||||
// are the minimum values allowed for these maximums.
|
|
||||||
//
|
|
||||||
char builtInConstant[80];
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
|
|
||||||
s.append(TString(builtInConstant));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// OpenGL'uniform' state. Page numbers are in reference to version
|
// OpenGL'uniform' state. Page numbers are in reference to version
|
||||||
|
@ -531,7 +503,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
s.append(TString("uniform mat4 gl_ModelViewMatrix;"));
|
s.append(TString("uniform mat4 gl_ModelViewMatrix;"));
|
||||||
s.append(TString("uniform mat4 gl_ProjectionMatrix;"));
|
s.append(TString("uniform mat4 gl_ProjectionMatrix;"));
|
||||||
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;"));
|
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;"));
|
||||||
s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Derived matrix state that provides inverse and transposed versions
|
// Derived matrix state that provides inverse and transposed versions
|
||||||
|
@ -542,17 +513,14 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));
|
s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));
|
||||||
s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));
|
s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));
|
||||||
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;"));
|
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;"));
|
||||||
s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));
|
|
||||||
|
|
||||||
s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;"));
|
s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;"));
|
s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;"));
|
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));
|
|
||||||
|
|
||||||
s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;"));
|
s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;"));
|
s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));
|
s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));
|
||||||
s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Normal scaling p. 39.
|
// Normal scaling p. 39.
|
||||||
|
@ -569,10 +537,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
s.append(TString("};"));
|
s.append(TString("};"));
|
||||||
s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
|
s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
|
||||||
|
|
||||||
//
|
|
||||||
// Clip planes p. 42.
|
|
||||||
//
|
|
||||||
s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Point Size, p. 66, 67.
|
// Point Size, p. 66, 67.
|
||||||
|
@ -623,7 +587,6 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
s.append(TString(" float quadraticAttenuation;"));// K2
|
s.append(TString(" float quadraticAttenuation;"));// K2
|
||||||
s.append(TString("};"));
|
s.append(TString("};"));
|
||||||
|
|
||||||
s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
|
|
||||||
|
|
||||||
s.append(TString("struct gl_LightModelParameters {"));
|
s.append(TString("struct gl_LightModelParameters {"));
|
||||||
s.append(TString(" vec4 ambient;")); // Acs
|
s.append(TString(" vec4 ambient;")); // Acs
|
||||||
|
@ -648,21 +611,8 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
s.append(TString(" vec4 specular;")); // Scm * Scli
|
s.append(TString(" vec4 specular;")); // Scm * Scli
|
||||||
s.append(TString("};"));
|
s.append(TString("};"));
|
||||||
|
|
||||||
s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));
|
|
||||||
s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Textureg Environment and Generation, p. 152, p. 40-42.
|
|
||||||
//
|
|
||||||
s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));
|
|
||||||
s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));
|
|
||||||
s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fog p. 161
|
// Fog p. 161
|
||||||
|
@ -751,7 +701,121 @@ void TBuiltIns::initialize(TBuiltInResource &resources)
|
||||||
builtInStrings[EShLangVertex].push_back(StandardUniforms);
|
builtInStrings[EShLangVertex].push_back(StandardUniforms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInResource &resources)
|
|
||||||
|
void TBuiltIns::initialize(const TBuiltInResource &resources)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Initialize all the built-in strings for parsing.
|
||||||
|
//
|
||||||
|
TString StandardUniforms;
|
||||||
|
|
||||||
|
{
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// Standard Uniforms
|
||||||
|
//
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
TString& s = StandardUniforms;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implementation dependent constants. The example values below
|
||||||
|
// are the minimum values allowed for these maximums.
|
||||||
|
//
|
||||||
|
char builtInConstant[80];
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
|
||||||
|
s.append(TString(builtInConstant));
|
||||||
|
|
||||||
|
//
|
||||||
|
// OpenGL'uniform' state. Page numbers are in reference to version
|
||||||
|
// 1.4 of the OpenGL specification.
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Matrix state. p. 31, 32, 37, 39, 40.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Derived matrix state that provides inverse and transposed versions
|
||||||
|
// of the matrices above.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));
|
||||||
|
|
||||||
|
s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));
|
||||||
|
|
||||||
|
s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clip planes p. 42.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Light State p 50, 53, 55.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Derived state from products of light.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));
|
||||||
|
s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Textureg Environment and Generation, p. 152, p. 40-42.
|
||||||
|
//
|
||||||
|
s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));
|
||||||
|
s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));
|
||||||
|
s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));
|
||||||
|
|
||||||
|
s.append(TString("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
builtInStrings[EShLangFragment].push_back(StandardUniforms);
|
||||||
|
builtInStrings[EShLangVertex].push_back(StandardUniforms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// First, insert some special built-in variables that are not in
|
// First, insert some special built-in variables that are not in
|
||||||
|
@ -765,10 +829,6 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInR
|
||||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4)));
|
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4)));
|
||||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1)));
|
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1)));
|
||||||
|
|
||||||
// Set up gl_FragData. The array size.
|
|
||||||
TType fragData(EbtFloat, EvqFragColor, 4, false, true);
|
|
||||||
fragData.setArraySize(resources.maxDrawBuffers);
|
|
||||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -863,6 +923,26 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, TBuiltInR
|
||||||
symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
|
symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
|
||||||
symbolTable.relateToOperator("readPixel", EOpReadPixel);
|
symbolTable.relateToOperator("readPixel", EOpReadPixel);
|
||||||
break;
|
break;
|
||||||
default: assert (true && "Language not supported");
|
default: assert (false && "Language not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// First, insert some special built-in variables that are not in
|
||||||
|
// the built-in header files.
|
||||||
|
//
|
||||||
|
switch(language) {
|
||||||
|
|
||||||
|
case EShLangFragment: {
|
||||||
|
// Set up gl_FragData. The array size.
|
||||||
|
TType fragData(EbtFloat, EvqFragColor, 4, false, true);
|
||||||
|
fragData.setArraySize(resources.maxDrawBuffers);
|
||||||
|
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -45,12 +45,14 @@ typedef TVector<TString> TBuiltInStrings;
|
||||||
class TBuiltIns {
|
class TBuiltIns {
|
||||||
public:
|
public:
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||||
void initialize(TBuiltInResource &resources);
|
void initialize();
|
||||||
|
void initialize(const TBuiltInResource& resources);
|
||||||
TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
|
TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
|
||||||
protected:
|
protected:
|
||||||
TBuiltInStrings builtInStrings[EShLangCount];
|
TBuiltInStrings builtInStrings[EShLangCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, TBuiltInResource &resources);
|
void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
|
||||||
|
void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
|
||||||
|
|
||||||
#endif // _INITIALIZE_INCLUDED_
|
#endif // _INITIALIZE_INCLUDED_
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -40,7 +40,6 @@
|
||||||
#include "localintermediate.h"
|
#include "localintermediate.h"
|
||||||
#include "QualifierAlive.h"
|
#include "QualifierAlive.h"
|
||||||
#include "RemoveTree.h"
|
#include "RemoveTree.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -230,7 +229,7 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
|
||||||
node->setLeft(base);
|
node->setLeft(base);
|
||||||
node->setRight(index);
|
node->setRight(index);
|
||||||
|
|
||||||
// caller should set the type
|
// caller should set the type
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -446,12 +445,17 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
bool allConstant = true;
|
bool allConstant = true;
|
||||||
// check to see if there is an aggregate node
|
// check to see if there is an aggregate node
|
||||||
if (node->getAsAggregate()) {
|
if (node->getAsAggregate()) {
|
||||||
|
if (node->getAsAggregate()->getOp() != EOpFunctionCall) {
|
||||||
|
// if the aggregate node is a constructor or a comma operator, look at its children, if they are constant
|
||||||
|
// convert them into the right type
|
||||||
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
|
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
|
||||||
for (TIntermSequence::iterator p = sequenceVector.begin();
|
for (TIntermSequence::iterator p = sequenceVector.begin();
|
||||||
p != sequenceVector.end(); p++) {
|
p != sequenceVector.end(); p++) {
|
||||||
if (!(*p)->getAsTyped()->getAsConstantUnion())
|
if (!(*p)->getAsTyped()->getAsConstantUnion())
|
||||||
allConstant = false;
|
allConstant = false;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
allConstant = false;
|
||||||
}
|
}
|
||||||
if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const
|
if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const
|
||||||
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
|
TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
|
||||||
|
@ -559,10 +563,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
newNode = new TIntermUnary(newOp, TType(promoteTo, EvqTemporary,
|
TType type(promoteTo, EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());
|
||||||
node->getNominalSize(),
|
newNode = new TIntermUnary(newOp, type);
|
||||||
node->isMatrix(),
|
|
||||||
node->isArray()));
|
|
||||||
newNode->setLine(node->getLine());
|
newNode->setLine(node->getLine());
|
||||||
newNode->setOperand(node);
|
newNode->setOperand(node);
|
||||||
|
|
||||||
|
@ -648,6 +650,20 @@ TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nod
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
|
||||||
|
{
|
||||||
|
if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) {
|
||||||
|
return right;
|
||||||
|
} else {
|
||||||
|
TIntermTyped *commaAggregate = growAggregate(left, right, line);
|
||||||
|
commaAggregate->getAsAggregate()->setOperator(EOpComma);
|
||||||
|
commaAggregate->setType(right->getType());
|
||||||
|
commaAggregate->getTypePointer()->changeQualifier(EvqTemporary);
|
||||||
|
return commaAggregate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// For "?:" test nodes. There are three children; a condition,
|
// For "?:" test nodes. There are three children; a condition,
|
||||||
// a true path, and a false path. The two paths are specified
|
// a true path, and a false path. The two paths are specified
|
||||||
|
@ -768,15 +784,6 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
|
||||||
if (aggRoot && aggRoot->getOp() == EOpNull)
|
if (aggRoot && aggRoot->getOp() == EOpNull)
|
||||||
aggRoot->setOperator(EOpSequence);
|
aggRoot->setOperator(EOpSequence);
|
||||||
|
|
||||||
//
|
|
||||||
// Other things...
|
|
||||||
//
|
|
||||||
|
|
||||||
if (language == EShLangVertex && !QualifierWritten(root, EvqPosition)) {
|
|
||||||
infoSink.info.message(EPrefixError, "gl_Position must be written by all paths through a vertex shader.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,8 +792,8 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
|
||||||
//
|
//
|
||||||
void TIntermediate::remove(TIntermNode* root)
|
void TIntermediate::remove(TIntermNode* root)
|
||||||
{
|
{
|
||||||
if (root)
|
if (root)
|
||||||
RemoveAllTreeNodes(root);
|
RemoveAllTreeNodes(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
@ -1062,7 +1069,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
|
||||||
case EOpAdd:
|
case EOpAdd:
|
||||||
case EOpSub:
|
case EOpSub:
|
||||||
case EOpDiv:
|
case EOpDiv:
|
||||||
case EOpMod:
|
case EOpMod:
|
||||||
case EOpAddAssign:
|
case EOpAddAssign:
|
||||||
case EOpSubAssign:
|
case EOpSubAssign:
|
||||||
case EOpDivAssign:
|
case EOpDivAssign:
|
||||||
|
@ -1073,8 +1080,8 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
|
||||||
return false;
|
return false;
|
||||||
setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));
|
setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpEqual:
|
case EOpEqual:
|
||||||
case EOpNotEqual:
|
case EOpNotEqual:
|
||||||
case EOpLessThan:
|
case EOpLessThan:
|
||||||
case EOpGreaterThan:
|
case EOpGreaterThan:
|
||||||
|
@ -1116,7 +1123,7 @@ default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareStructure(TType leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index)
|
bool compareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index)
|
||||||
{
|
{
|
||||||
TTypeList* fields = leftNodeType.getStruct();
|
TTypeList* fields = leftNodeType.getStruct();
|
||||||
|
|
||||||
|
@ -1172,131 +1179,144 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
||||||
TIntermConstantUnion *newNode;
|
TIntermConstantUnion *newNode;
|
||||||
constUnion* tempConstArray;
|
constUnion* tempConstArray;
|
||||||
int i;
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case EOpAdd:
|
case EOpAdd:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
|
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
|
||||||
default:
|
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOpMatrixTimesScalar:
|
case EOpMatrixTimesScalar:
|
||||||
case EOpVectorTimesScalar:
|
case EOpVectorTimesScalar:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
|
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
|
||||||
default:
|
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOpSub:
|
case EOpSub:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat:
|
switch (this->getType().getBasicType()) {
|
||||||
if (leftOperand)
|
case EbtFloat:
|
||||||
tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
|
if (leftOperand)
|
||||||
else
|
tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
|
||||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
|
else
|
||||||
break;
|
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
|
||||||
|
|
||||||
case EbtInt:
|
|
||||||
if (leftOperand)
|
|
||||||
tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
|
|
||||||
else
|
|
||||||
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
|
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
case EbtInt:
|
||||||
return 0;
|
if (leftOperand)
|
||||||
|
tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
|
||||||
|
else
|
||||||
|
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpDiv:
|
case EOpDiv:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat:
|
switch (this->getType().getBasicType()) {
|
||||||
if (leftOperand) {
|
case EbtFloat:
|
||||||
if (node->getUnionArrayPointer()->fConst == 0.0) {
|
if (leftOperand) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
if (node->getUnionArrayPointer()->fConst == 0.0) {
|
||||||
tempConstArray[i].fConst = FLT_MAX;
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
} else
|
tempConstArray[i].fConst = FLT_MAX;
|
||||||
tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
|
} else
|
||||||
} else {
|
tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
|
||||||
if (unionArray[i].fConst == 0.0) {
|
} else {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
if (unionArray[i].fConst == 0.0) {
|
||||||
tempConstArray[i].fConst = FLT_MAX;
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
} else
|
tempConstArray[i].fConst = FLT_MAX;
|
||||||
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
|
} else
|
||||||
}
|
tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
if (leftOperand) {
|
if (leftOperand) {
|
||||||
if (node->getUnionArrayPointer()->iConst == 0) {
|
if (node->getUnionArrayPointer()->iConst == 0) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
tempConstArray[i].iConst = INT_MAX;
|
tempConstArray[i].iConst = INT_MAX;
|
||||||
} else
|
} else
|
||||||
tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
|
tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
|
||||||
} else {
|
} else {
|
||||||
if (unionArray[i].iConst == 0) {
|
if (unionArray[i].iConst == 0) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
tempConstArray[i].iConst = INT_MAX;
|
tempConstArray[i].iConst = INT_MAX;
|
||||||
} else
|
} else
|
||||||
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst;
|
tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1316,68 +1336,69 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
TIntermConstantUnion *tempNode;
|
TIntermConstantUnion *tempNode;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
bool boolNodeFlag = false;
|
bool boolNodeFlag = false;
|
||||||
int i;
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case EOpAdd:
|
case EOpAdd:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
|
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
|
||||||
default:
|
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOpSub:
|
case EOpSub:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat:
|
switch (this->getType().getBasicType()) {
|
||||||
if (leftOperand)
|
case EbtFloat:
|
||||||
tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
|
if (leftOperand)
|
||||||
else
|
tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
|
||||||
tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
|
else
|
||||||
break;
|
tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
|
||||||
|
|
||||||
case EbtInt:
|
|
||||||
if (leftOperand)
|
|
||||||
tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;
|
|
||||||
else
|
|
||||||
tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
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:
|
default:
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOpMul:
|
case EOpMul:
|
||||||
{
|
if (this->isVector()) { // two vectors multiplied together
|
||||||
if (this->isVector()) { // two vectors multiplied together
|
int size = this->getSize();
|
||||||
int size = this->getSize();
|
tempConstArray = new constUnion[size];
|
||||||
tempConstArray = new constUnion[size];
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
for (int i = 0; i < size; i++) {
|
switch (this->getType().getBasicType()) {
|
||||||
switch (this->getType().getBasicType()) {
|
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
|
||||||
case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
|
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
|
||||||
case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
|
default:
|
||||||
default:
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOpMatrixTimesMatrix:
|
case EOpMatrixTimesMatrix:
|
||||||
{
|
if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
|
||||||
if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
|
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
{// support MSVC++6.0
|
||||||
int size = this->getNominalSize();
|
int size = this->getNominalSize();
|
||||||
tempConstArray = new constUnion[size*size];
|
tempConstArray = new constUnion[size*size];
|
||||||
for (int row = 0; row < size; row++) {
|
for (int row = 0; row < size; row++) {
|
||||||
|
@ -1392,42 +1413,44 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
break;
|
break;
|
||||||
case EOpDiv:
|
case EOpDiv:
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtFloat:
|
switch (this->getType().getBasicType()) {
|
||||||
if (leftOperand) {
|
case EbtFloat:
|
||||||
if (rightUnionArray[i].fConst == 0.0) {
|
if (leftOperand) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
if (rightUnionArray[i].fConst == 0.0) {
|
||||||
tempConstArray[i].fConst = FLT_MAX;
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
} else
|
tempConstArray[i].fConst = FLT_MAX;
|
||||||
tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
|
} else
|
||||||
} else {
|
tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
|
||||||
if (unionArray[i].fConst == 0.0) {
|
} else {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
if (unionArray[i].fConst == 0.0) {
|
||||||
tempConstArray[i].fConst = FLT_MAX;
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
} else
|
tempConstArray[i].fConst = FLT_MAX;
|
||||||
tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
|
} else
|
||||||
}
|
tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
if (leftOperand) {
|
if (leftOperand) {
|
||||||
if (rightUnionArray[i].iConst == 0) {
|
if (rightUnionArray[i].iConst == 0) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
tempConstArray[i].iConst = INT_MAX;
|
tempConstArray[i].iConst = INT_MAX;
|
||||||
} else
|
} else
|
||||||
tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
|
tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
|
||||||
} else {
|
} else {
|
||||||
if (unionArray[i].iConst == 0) {
|
if (unionArray[i].iConst == 0) {
|
||||||
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
|
||||||
tempConstArray[i].iConst = INT_MAX;
|
tempConstArray[i].iConst = INT_MAX;
|
||||||
} else
|
} else
|
||||||
tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst;
|
tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1436,22 +1459,23 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
if (node->getBasicType() != EbtFloat) {
|
if (node->getBasicType() != EbtFloat) {
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", this->getLine());
|
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", this->getLine());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tempConstArray = new constUnion[this->getNominalSize()];
|
tempConstArray = new constUnion[this->getNominalSize()];
|
||||||
{
|
|
||||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
{// support MSVC++6.0
|
||||||
tempConstArray[i].fConst = 0.0;
|
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||||
for (int j = 0; j < size; j++) {
|
tempConstArray[i].fConst = 0.0;
|
||||||
tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst);
|
for (int j = 0; j < size; j++) {
|
||||||
}
|
tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tempNode = new TIntermConstantUnion(tempConstArray, node->getType());
|
tempNode = new TIntermConstantUnion(tempConstArray, node->getType());
|
||||||
tempNode->setLine(this->getLine());
|
tempNode->setLine(this->getLine());
|
||||||
|
|
||||||
return tempNode;
|
return tempNode;
|
||||||
|
|
||||||
case EOpVectorTimesMatrix:
|
case EOpVectorTimesMatrix:
|
||||||
if (this->getType().getBasicType() != EbtFloat) {
|
if (this->getType().getBasicType() != EbtFloat) {
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for vector times matrix", this->getLine());
|
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()];
|
tempConstArray = new constUnion[this->getNominalSize()];
|
||||||
{
|
{// support MSVC++6.0
|
||||||
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
for (int size = this->getNominalSize(), i = 0; i < size; i++) {
|
||||||
tempConstArray[i].fConst = 0.0;
|
tempConstArray[i].fConst = 0.0;
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
|
tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
||||||
tempConstArray = new constUnion[this->getSize()];
|
tempConstArray = new constUnion[this->getSize()];
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
switch (this->getType().getBasicType()) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
|
switch (this->getType().getBasicType()) {
|
||||||
default:
|
case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
|
||||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
default:
|
||||||
return 0;
|
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1509,27 +1539,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
|
|
||||||
switch (this->getType().getBasicType()) {
|
switch (this->getType().getBasicType()) {
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].fConst != rightUnionArray[i].fConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].fConst != rightUnionArray[i].fConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].iConst != rightUnionArray[i].iConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].iConst != rightUnionArray[i].iConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EbtBool:
|
case EbtBool:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].bConst != rightUnionArray[i].bConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].bConst != rightUnionArray[i].bConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1559,27 +1595,33 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
||||||
case EOpNotEqual:
|
case EOpNotEqual:
|
||||||
switch (this->getType().getBasicType()) {
|
switch (this->getType().getBasicType()) {
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].fConst == rightUnionArray[i].fConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].fConst == rightUnionArray[i].fConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].iConst == rightUnionArray[i].iConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].iConst == rightUnionArray[i].iConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EbtBool:
|
case EbtBool:
|
||||||
for (i = 0; i < this->getSize(); i++) {
|
{// support MSVC++6.0
|
||||||
if (unionArray[i].bConst == rightUnionArray[i].bConst) {
|
for (int i = 0; i < this->getSize(); i++) {
|
||||||
boolNodeFlag = true;
|
if (unionArray[i].bConst == rightUnionArray[i].bConst) {
|
||||||
break; // break out of for loop
|
boolNodeFlag = true;
|
||||||
|
break; // break out of for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1945,7 +1987,8 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
TType t = node->getType();
|
|
||||||
|
const TType& t = node->getType();
|
||||||
|
|
||||||
return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
|
return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
|
||||||
}
|
}
|
||||||
|
@ -2027,31 +2070,40 @@ bool TIntermediate::removeMatrixConstNode(TIntermSequence &parentSequence, TType
|
||||||
|
|
||||||
TIntermSequence::iterator parentNodeIter;
|
TIntermSequence::iterator parentNodeIter;
|
||||||
TIntermSequence &childSequence = child->getSequence();
|
TIntermSequence &childSequence = child->getSequence();
|
||||||
int i;
|
|
||||||
|
|
||||||
switch (child->getOp()) {
|
switch (child->getOp()) {
|
||||||
case EOpConstructMat2:
|
case EOpConstructMat2:
|
||||||
case EOpConstructMat3:
|
case EOpConstructMat3:
|
||||||
case EOpConstructMat4:
|
case EOpConstructMat4:
|
||||||
for (i = 0; i < child->getType().getInstanceSize(); i++) {
|
{// support MSVC++6.0
|
||||||
constUnion* constantUnion = new constUnion[1];
|
for (int i = 0; i < child->getType().getInstanceSize(); i++) {
|
||||||
if (i % (child->getType().getNominalSize() + 1) == 0) {
|
constUnion* constantUnion = new constUnion[1];
|
||||||
*constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
|
if (i % (child->getType().getNominalSize() + 1) == 0) {
|
||||||
} else {
|
*constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
|
||||||
switch (parentType.getBasicType()) {
|
} else {
|
||||||
case EbtInt: constantUnion->iConst = 0; break;
|
switch (parentType.getBasicType()) {
|
||||||
case EbtFloat: constantUnion->fConst = 0.0; break;
|
case EbtInt: constantUnion->iConst = 0; break;
|
||||||
case EbtBool: constantUnion->bConst = false; break;
|
case EbtFloat: constantUnion->fConst = 0.0; break;
|
||||||
|
case EbtBool: constantUnion->bConst = false; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
|
||||||
|
childSequence[0]->getAsConstantUnion()->getType());
|
||||||
|
constant->setLine(child->getLine());
|
||||||
|
parentNodeIter = parentSequence.begin() + offset + i;
|
||||||
|
parentSequence.insert(parentNodeIter, constant);
|
||||||
}
|
}
|
||||||
TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
|
|
||||||
childSequence[0]->getAsConstantUnion()->getType());
|
|
||||||
constant->setLine(child->getLine());
|
|
||||||
parentNodeIter = parentSequence.begin() + offset + i;
|
|
||||||
parentSequence.insert(parentNodeIter, constant);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
|
||||||
|
{
|
||||||
|
assert (!pragmaTable);
|
||||||
|
pragmaTable = new TPragmaTable();
|
||||||
|
*pragmaTable = pTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -54,25 +54,62 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tooBig = false;
|
enum {
|
||||||
|
exyzw,
|
||||||
|
ergba,
|
||||||
|
estpq
|
||||||
|
} fieldSet[4];
|
||||||
|
|
||||||
for (int i = 0; i < fields.num; ++i) {
|
for (int i = 0; i < fields.num; ++i) {
|
||||||
switch (compString[i]) {
|
switch (compString[i]) {
|
||||||
case 'x': case 'r': case 's': case '0':
|
case 'x':
|
||||||
fields.offsets[i] = 0;
|
fields.offsets[i] = 0;
|
||||||
|
fieldSet[i] = exyzw;
|
||||||
break;
|
break;
|
||||||
case 'y': case 'g': case 't': case '1':
|
case 'r':
|
||||||
|
fields.offsets[i] = 0;
|
||||||
|
fieldSet[i] = ergba;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
fields.offsets[i] = 0;
|
||||||
|
fieldSet[i] = estpq;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
fields.offsets[i] = 1;
|
fields.offsets[i] = 1;
|
||||||
|
fieldSet[i] = exyzw;
|
||||||
break;
|
break;
|
||||||
case 'z': case 'b': case 'p': case '2':
|
case 'g':
|
||||||
if (vecSize < 3)
|
fields.offsets[i] = 1;
|
||||||
tooBig = true;
|
fieldSet[i] = ergba;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
fields.offsets[i] = 1;
|
||||||
|
fieldSet[i] = estpq;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
fields.offsets[i] = 2;
|
fields.offsets[i] = 2;
|
||||||
|
fieldSet[i] = exyzw;
|
||||||
break;
|
break;
|
||||||
case 'w': case 'a': case 'q': case '3':
|
case 'b':
|
||||||
if (vecSize < 4)
|
fields.offsets[i] = 2;
|
||||||
tooBig = true;
|
fieldSet[i] = ergba;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
fields.offsets[i] = 2;
|
||||||
|
fieldSet[i] = estpq;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
fields.offsets[i] = 3;
|
fields.offsets[i] = 3;
|
||||||
|
fieldSet[i] = exyzw;
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
fields.offsets[i] = 3;
|
||||||
|
fieldSet[i] = ergba;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
fields.offsets[i] = 3;
|
||||||
|
fieldSet[i] = estpq;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error(line, "illegal vector field selection", compString.c_str(), "");
|
error(line, "illegal vector field selection", compString.c_str(), "");
|
||||||
|
@ -80,11 +117,20 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tooBig) {
|
for (int i = 0; i < fields.num; ++i) {
|
||||||
|
if (fields.offsets[i] >= vecSize) {
|
||||||
error(line, "vector field selection out of range", compString.c_str(), "");
|
error(line, "vector field selection out of range", compString.c_str(), "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
if (fieldSet[i] != fieldSet[i-1]) {
|
||||||
|
error(line, "illegal - vector component fields not from the same set", compString.c_str(), "");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +1016,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOpe
|
||||||
TTypeList::iterator list;
|
TTypeList::iterator list;
|
||||||
TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
|
TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
|
||||||
if (op == EOpConstructStruct) {
|
if (op == EOpConstructStruct) {
|
||||||
TType ttype = fnCall->getReturnType();
|
const TType& ttype = fnCall->getReturnType();
|
||||||
structure = ttype.getStruct();
|
structure = ttype.getStruct();
|
||||||
list = (*structure).begin();
|
list = (*structure).begin();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -52,6 +52,13 @@ typedef enum {
|
||||||
EBhDisable
|
EBhDisable
|
||||||
} TBehavior;
|
} TBehavior;
|
||||||
|
|
||||||
|
struct TPragma {
|
||||||
|
TPragma(bool o, bool d) : optimize(o), debug(d) { }
|
||||||
|
bool optimize;
|
||||||
|
bool debug;
|
||||||
|
TPragmaTable pragmaTable;
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// The following are extra variables needed during parsing, grouped together so
|
// The following are extra variables needed during parsing, grouped together so
|
||||||
// they can be passed to the parser without needing a global.
|
// they can be passed to the parser without needing a global.
|
||||||
|
@ -60,7 +67,7 @@ struct TParseContext {
|
||||||
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
|
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
|
||||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
|
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
|
||||||
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
|
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
|
||||||
inTypeParen(false) { }
|
inTypeParen(false), contextPragma(true, false) { }
|
||||||
TIntermediate& intermediate; // to hold and build a parse tree
|
TIntermediate& intermediate; // to hold and build a parse tree
|
||||||
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
||||||
TInfoSink& infoSink;
|
TInfoSink& infoSink;
|
||||||
|
@ -113,8 +120,7 @@ struct TParseContext {
|
||||||
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
|
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
|
||||||
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
|
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
|
||||||
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
|
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
|
||||||
typedef std::map<TString, TString> PragmaStringMap;
|
struct TPragma contextPragma;
|
||||||
PragmaStringMap PragmaTable;
|
|
||||||
TString HashErrMsg;
|
TString HashErrMsg;
|
||||||
bool AfterEOF;
|
bool AfterEOF;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
#include "../Include/PoolAlloc.h"
|
#include "../Include/PoolAlloc.h"
|
||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "Include/InitializeGlobals.h"
|
#include "Include/InitializeGlobals.h"
|
||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
|
@ -52,7 +51,6 @@ void InitializeGlobalPools()
|
||||||
TThreadGlobalPools* threadData = new TThreadGlobalPools();
|
TThreadGlobalPools* threadData = new TThreadGlobalPools();
|
||||||
|
|
||||||
threadData->globalPoolAllocator = globalPoolAllocator;
|
threadData->globalPoolAllocator = globalPoolAllocator;
|
||||||
threadData->compilerPoolAllocator = 0;
|
|
||||||
|
|
||||||
OS_SetTLSValue(PoolIndex, threadData);
|
OS_SetTLSValue(PoolIndex, threadData);
|
||||||
globalPoolAllocator->push();
|
globalPoolAllocator->push();
|
||||||
|
@ -99,13 +97,6 @@ void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
|
||||||
threadData->globalPoolAllocator = poolAllocator;
|
threadData->globalPoolAllocator = poolAllocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolAllocatorPointer& GetCompilerPoolAllocator()
|
|
||||||
{
|
|
||||||
TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
|
|
||||||
|
|
||||||
return threadData->compilerPoolAllocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implement the functionality of the TPoolAllocator class, which
|
// Implement the functionality of the TPoolAllocator class, which
|
||||||
// is documented in PoolAlloc.h.
|
// is documented in PoolAlloc.h.
|
||||||
|
@ -191,6 +182,16 @@ TPoolAllocator::~TPoolAllocator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support MSVC++ 6.0
|
||||||
|
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
|
||||||
|
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
|
||||||
|
const unsigned char TAllocation::userDataFill = 0xcd;
|
||||||
|
|
||||||
|
# ifdef GUARD_BLOCKS
|
||||||
|
const size_t TAllocation::guardBlockSize = 16;
|
||||||
|
# else
|
||||||
|
const size_t TAllocation::guardBlockSize = 0;
|
||||||
|
# endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check a single guard block for damage
|
// Check a single guard block for damage
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -51,9 +51,15 @@ extern "C" int InitPreprocessor(void);
|
||||||
extern "C" int FinalizePreprocessor(void);
|
extern "C" int FinalizePreprocessor(void);
|
||||||
extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
|
extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
|
||||||
|
|
||||||
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink&);
|
bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);
|
||||||
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, TBuiltInResource &resources);
|
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);
|
||||||
void GenerateResources(TBuiltInResource& resources);
|
|
||||||
|
//
|
||||||
|
// A symbol table for each language. Each has a different
|
||||||
|
// set of built-ins, and we want to preserve that from
|
||||||
|
// compile to compile.
|
||||||
|
//
|
||||||
|
TSymbolTable SymbolTables[EShLangCount];
|
||||||
|
|
||||||
TPoolAllocator* PerProcessGPA = 0;
|
TPoolAllocator* PerProcessGPA = 0;
|
||||||
//
|
//
|
||||||
|
@ -68,8 +74,6 @@ TPoolAllocator* PerProcessGPA = 0;
|
||||||
int ShInitialize()
|
int ShInitialize()
|
||||||
{
|
{
|
||||||
TInfoSink infoSink;
|
TInfoSink infoSink;
|
||||||
TBuiltInResource resources;
|
|
||||||
GenerateResources(resources);
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
if (!InitProcess())
|
if (!InitProcess())
|
||||||
|
@ -79,13 +83,29 @@ int ShInitialize()
|
||||||
// we need to have thread synchronization code around the initialization of per process
|
// we need to have thread synchronization code around the initialization of per process
|
||||||
// global pool allocator
|
// global pool allocator
|
||||||
if (!PerProcessGPA) {
|
if (!PerProcessGPA) {
|
||||||
|
TPoolAllocator *builtInPoolAllocator = new TPoolAllocator(true);
|
||||||
|
builtInPoolAllocator->push();
|
||||||
|
TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
|
||||||
|
SetGlobalPoolAllocatorPtr(builtInPoolAllocator);
|
||||||
|
|
||||||
|
TSymbolTable symTables[EShLangCount];
|
||||||
|
generateBuiltInSymbolTable(0, infoSink, symTables);
|
||||||
|
|
||||||
PerProcessGPA = new TPoolAllocator(true);
|
PerProcessGPA = new TPoolAllocator(true);
|
||||||
PerProcessGPA->push();
|
PerProcessGPA->push();
|
||||||
|
SetGlobalPoolAllocatorPtr(PerProcessGPA);
|
||||||
TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
|
|
||||||
SetGlobalPoolAllocatorPtr(PerProcessGPA);
|
SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);
|
||||||
ret = generateBuiltInSymbolTable(resources, infoSink);
|
SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);
|
||||||
|
|
||||||
SetGlobalPoolAllocatorPtr(gPoolAllocator);
|
SetGlobalPoolAllocatorPtr(gPoolAllocator);
|
||||||
|
|
||||||
|
symTables[EShLangVertex].pop();
|
||||||
|
symTables[EShLangFragment].pop();
|
||||||
|
|
||||||
|
builtInPoolAllocator->popAll();
|
||||||
|
delete builtInPoolAllocator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret ? 1 : 0;
|
return ret ? 1 : 0;
|
||||||
|
@ -141,13 +161,6 @@ void ShDestruct(ShHandle handle)
|
||||||
DeleteUniformMap(base->getAsUniformMap());
|
DeleteUniformMap(base->getAsUniformMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// A symbol table for each language. Each has a different
|
|
||||||
// set of built-ins, and we want to preserve that from
|
|
||||||
// compile to compile.
|
|
||||||
//
|
|
||||||
TSymbolTable SymbolTables[EShLangCount];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup symbol tables
|
// Cleanup symbol tables
|
||||||
//
|
//
|
||||||
|
@ -160,88 +173,86 @@ int __fastcall ShFinalize()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// This method is required only for Sh interface, not for OGLC interface
|
|
||||||
//
|
|
||||||
void GenerateResources(TBuiltInResource& resources)
|
|
||||||
{
|
|
||||||
resources.maxLights = 32;
|
|
||||||
resources.maxClipPlanes = 6;
|
|
||||||
resources.maxTextureUnits = 32;
|
|
||||||
resources.maxTextureCoords = 32;
|
|
||||||
resources.maxVertexAttribs = 64;
|
|
||||||
resources.maxVertexUniformComponents = 4096;
|
|
||||||
resources.maxVaryingFloats = 64;
|
|
||||||
resources.maxVertexTextureImageUnits = 32;
|
|
||||||
resources.maxCombinedTextureImageUnits = 32;
|
|
||||||
resources.maxTextureImageUnits = 32;
|
|
||||||
resources.maxFragmentUniformComponents = 4096;
|
|
||||||
resources.maxDrawBuffers = 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This function should be called only once by the Master Dll. Currently, this is being called for each thread
|
// This function should be called only once by the Master Dll. Currently, this is being called for each thread
|
||||||
// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called
|
// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called
|
||||||
// from master dll once.
|
// from master dll once.
|
||||||
//
|
//
|
||||||
bool generateBuiltInSymbolTable(TBuiltInResource& resources, TInfoSink& infoSink)
|
bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable* symbolTables, EShLanguage language)
|
||||||
{
|
{
|
||||||
TBuiltIns builtIns;
|
TBuiltIns builtIns;
|
||||||
builtIns.initialize(resources);
|
|
||||||
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources);
|
if (resources) {
|
||||||
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources);
|
builtIns.initialize(*resources);
|
||||||
|
initializeSymbolTable(builtIns.getBuiltInStrings(), language, infoSink, resources, symbolTables);
|
||||||
|
} else {
|
||||||
|
builtIns.initialize();
|
||||||
|
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources, symbolTables);
|
||||||
|
initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources, symbolTables);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, TBuiltInResource &resources)
|
bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource* resources, TSymbolTable* symbolTables)
|
||||||
{
|
{
|
||||||
TIntermediate intermediate(infoSink);
|
TIntermediate intermediate(infoSink);
|
||||||
TSymbolTable& symbolTable = SymbolTables[language];
|
TSymbolTable* symbolTable;
|
||||||
TParseContext parseContext(symbolTable, intermediate, language, infoSink);
|
|
||||||
|
if (resources)
|
||||||
|
symbolTable = symbolTables;
|
||||||
|
else
|
||||||
|
symbolTable = &symbolTables[language];
|
||||||
|
|
||||||
|
TParseContext parseContext(*symbolTable, intermediate, language, infoSink);
|
||||||
|
|
||||||
GlobalParseContext = &parseContext;
|
GlobalParseContext = &parseContext;
|
||||||
|
|
||||||
setInitialState();
|
setInitialState();
|
||||||
|
|
||||||
if (symbolTable.isEmpty()) {
|
assert (symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse the built-ins. This should only happen once per
|
// Parse the built-ins. This should only happen once per
|
||||||
// language symbol table.
|
// language symbol table.
|
||||||
//
|
//
|
||||||
// Push the symbol table to give it an initial scope. This
|
// Push the symbol table to give it an initial scope. This
|
||||||
// push should not have a corresponding pop, so that built-ins
|
// push should not have a corresponding pop, so that built-ins
|
||||||
// are preserved, and the test for an empty table fails.
|
// are preserved, and the test for an empty table fails.
|
||||||
//
|
//
|
||||||
|
|
||||||
symbolTable.push();
|
symbolTable->push();
|
||||||
|
|
||||||
//Initialize the Preprocessor
|
//Initialize the Preprocessor
|
||||||
int ret = InitPreprocessor();
|
int ret = InitPreprocessor();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
|
infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
|
||||||
|
i != BuiltInStrings[parseContext.language].end();
|
||||||
|
++i) {
|
||||||
|
const char* builtInShaders[1];
|
||||||
|
int builtInLengths[1];
|
||||||
|
|
||||||
|
builtInShaders[0] = (*i).c_str();
|
||||||
|
builtInLengths[0] = (int) (*i).size();
|
||||||
|
|
||||||
|
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {
|
||||||
|
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
|
|
||||||
i != BuiltInStrings[parseContext.language].end();
|
|
||||||
++i) {
|
|
||||||
const char* builtInShaders[1];
|
|
||||||
int builtInLengths[1];
|
|
||||||
|
|
||||||
builtInShaders[0] = (*i).c_str();
|
|
||||||
builtInLengths[0] = (int) (*i).size();
|
|
||||||
|
|
||||||
if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {
|
|
||||||
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentifyBuiltIns(parseContext.language, symbolTable, resources);
|
|
||||||
FinalizePreprocessor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resources) {
|
||||||
|
IdentifyBuiltIns(parseContext.language, *symbolTable, *resources);
|
||||||
|
} else {
|
||||||
|
IdentifyBuiltIns(parseContext.language, *symbolTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
FinalizePreprocessor();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +269,7 @@ int ShCompile(
|
||||||
const char* const shaderStrings[],
|
const char* const shaderStrings[],
|
||||||
const int numStrings,
|
const int numStrings,
|
||||||
const EShOptimizationLevel optLevel,
|
const EShOptimizationLevel optLevel,
|
||||||
|
const TBuiltInResource* resources,
|
||||||
int debugOptions
|
int debugOptions
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -271,7 +283,8 @@ int ShCompile(
|
||||||
TCompiler* compiler = base->getAsCompiler();
|
TCompiler* compiler = base->getAsCompiler();
|
||||||
if (compiler == 0)
|
if (compiler == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
GlobalPoolAllocator.push();
|
||||||
compiler->infoSink.info.erase();
|
compiler->infoSink.info.erase();
|
||||||
compiler->infoSink.debug.erase();
|
compiler->infoSink.debug.erase();
|
||||||
|
|
||||||
|
@ -280,6 +293,9 @@ int ShCompile(
|
||||||
|
|
||||||
TIntermediate intermediate(compiler->infoSink);
|
TIntermediate intermediate(compiler->infoSink);
|
||||||
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
|
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
|
||||||
|
|
||||||
|
generateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());
|
||||||
|
|
||||||
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
|
TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
|
||||||
parseContext.initializeExtensionBehavior();
|
parseContext.initializeExtensionBehavior();
|
||||||
|
|
||||||
|
@ -294,7 +310,7 @@ int ShCompile(
|
||||||
// be thrown away, then push a scope for the current shader's globals.
|
// be thrown away, then push a scope for the current shader's globals.
|
||||||
//
|
//
|
||||||
bool success = true;
|
bool success = true;
|
||||||
GlobalPoolAllocator.push();
|
|
||||||
symbolTable.push();
|
symbolTable.push();
|
||||||
if (!symbolTable.atGlobalLevel())
|
if (!symbolTable.atGlobalLevel())
|
||||||
parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
|
parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
|
||||||
|
@ -306,41 +322,39 @@ int ShCompile(
|
||||||
if (ret)
|
if (ret)
|
||||||
success = false;
|
success = false;
|
||||||
|
|
||||||
if (! ret && parseContext.treeRoot) {
|
if (success && parseContext.treeRoot) {
|
||||||
if (parseContext.recoveredFromError) {
|
if (optLevel == EShOptNoGeneration)
|
||||||
parseContext.infoSink.info.prefix(EPrefixError);
|
parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
|
||||||
parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n";
|
else {
|
||||||
success = false;
|
success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
|
||||||
if (debugOptions & EDebugOpIntermediate)
|
|
||||||
intermediate.outputTree(parseContext.treeRoot);
|
|
||||||
} else {
|
|
||||||
if (optLevel == EShOptNoGeneration)
|
|
||||||
parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
|
|
||||||
else {
|
|
||||||
success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
|
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
||||||
if (debugOptions & EDebugOpIntermediate)
|
if (debugOptions & EDebugOpIntermediate)
|
||||||
intermediate.outputTree(parseContext.treeRoot);
|
intermediate.outputTree(parseContext.treeRoot);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call the machine dependent compiler
|
// Call the machine dependent compiler
|
||||||
//
|
//
|
||||||
if (! compiler->compile(parseContext.treeRoot))
|
if (! compiler->compile(parseContext.treeRoot))
|
||||||
success = false;
|
success = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (!success) {
|
||||||
|
parseContext.infoSink.info.prefix(EPrefixError);
|
||||||
|
parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n";
|
||||||
|
success = false;
|
||||||
|
if (debugOptions & EDebugOpIntermediate)
|
||||||
|
intermediate.outputTree(parseContext.treeRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
intermediate.remove(parseContext.treeRoot);
|
intermediate.remove(parseContext.treeRoot);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ensure symbol table is returned to the built-in level,
|
// Ensure symbol table is returned to the built-in level,
|
||||||
// throwing away all but the built-ins.
|
// throwing away all but the built-ins.
|
||||||
//
|
//
|
||||||
while (! symbolTable.atBuiltInLevel())
|
while (! symbolTable.atSharedBuiltInLevel())
|
||||||
symbolTable.pop();
|
symbolTable.pop();
|
||||||
|
|
||||||
FinalizePreprocessor();
|
FinalizePreprocessor();
|
||||||
|
@ -397,21 +411,22 @@ int ShLinkExt(
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
THandleList cObjects;
|
THandleList cObjects;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < numHandles; ++i) {
|
{// support MSVC++6.0
|
||||||
if (compHandles[i] == 0)
|
for (int i = 0; i < numHandles; ++i) {
|
||||||
return 0;
|
if (compHandles[i] == 0)
|
||||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
|
return 0;
|
||||||
if (base->getAsLinker()) {
|
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
|
||||||
cObjects.push_back(base->getAsLinker());
|
if (base->getAsLinker()) {
|
||||||
|
cObjects.push_back(base->getAsLinker());
|
||||||
|
}
|
||||||
|
if (base->getAsCompiler())
|
||||||
|
cObjects.push_back(base->getAsCompiler());
|
||||||
|
|
||||||
|
|
||||||
|
if (cObjects[i] == 0)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
if (base->getAsCompiler())
|
|
||||||
cObjects.push_back(base->getAsCompiler());
|
|
||||||
|
|
||||||
|
|
||||||
if (cObjects[i] == 0)
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
|
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
|
||||||
|
@ -422,11 +437,13 @@ int ShLinkExt(
|
||||||
|
|
||||||
linker->infoSink.info.erase();
|
linker->infoSink.info.erase();
|
||||||
|
|
||||||
for (i = 0; i < numHandles; ++i) {
|
{// support MSVC++6.0
|
||||||
if (cObjects[i]->getAsCompiler()) {
|
for (int i = 0; i < numHandles; ++i) {
|
||||||
if (! cObjects[i]->getAsCompiler()->linkable()) {
|
if (cObjects[i]->getAsCompiler()) {
|
||||||
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
|
if (! cObjects[i]->getAsCompiler()->linkable()) {
|
||||||
return 0;
|
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +571,7 @@ int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
|
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
|
||||||
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
|
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
|
||||||
if (linker == 0)
|
if (linker == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -53,8 +53,6 @@ void TType::buildMangledName(TString& mangledName)
|
||||||
else if (isVector())
|
else if (isVector())
|
||||||
mangledName += 'v';
|
mangledName += 'v';
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtFloat: mangledName += 'f'; break;
|
case EbtFloat: mangledName += 'f'; break;
|
||||||
case EbtInt: mangledName += 'i'; break;
|
case EbtInt: mangledName += 'i'; break;
|
||||||
|
@ -65,12 +63,15 @@ void TType::buildMangledName(TString& mangledName)
|
||||||
case EbtSamplerCube: mangledName += "sC"; break;
|
case EbtSamplerCube: mangledName += "sC"; break;
|
||||||
case EbtSampler1DShadow: mangledName += "sS1"; break;
|
case EbtSampler1DShadow: mangledName += "sS1"; break;
|
||||||
case EbtSampler2DShadow: mangledName += "sS2"; break;
|
case EbtSampler2DShadow: mangledName += "sS2"; break;
|
||||||
case EbtStruct:
|
case EbtStruct:
|
||||||
mangledName += "struct-";
|
mangledName += "struct-";
|
||||||
mangledName += typeName;
|
if (typeName)
|
||||||
for (i = 0; i < structure->size(); ++i) {
|
mangledName += *typeName;
|
||||||
mangledName += '-';
|
{// support MSVC++6.0
|
||||||
(*structure)[i].type->buildMangledName(mangledName);
|
for (unsigned int i = 0; i < structure->size(); ++i) {
|
||||||
|
mangledName += '-';
|
||||||
|
(*structure)[i].type->buildMangledName(mangledName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -124,8 +125,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const
|
||||||
//
|
//
|
||||||
TFunction::~TFunction()
|
TFunction::~TFunction()
|
||||||
{
|
{
|
||||||
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
|
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
|
||||||
delete (*i).type;
|
delete (*i).type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -133,8 +134,8 @@ TFunction::~TFunction()
|
||||||
//
|
//
|
||||||
TSymbolTableLevel::~TSymbolTableLevel()
|
TSymbolTableLevel::~TSymbolTableLevel()
|
||||||
{
|
{
|
||||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||||
delete (*it).second;
|
delete (*it).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -154,3 +155,81 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TSymbol::TSymbol(const TSymbol& copyOf)
|
||||||
|
{
|
||||||
|
name = NewPoolTString(copyOf.name->c_str());
|
||||||
|
uniqueId = copyOf.uniqueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
|
||||||
|
{
|
||||||
|
type.copyType(copyOf.type, remapper);
|
||||||
|
userType = copyOf.userType;
|
||||||
|
// for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL
|
||||||
|
assert(copyOf.arrayInformationType == 0);
|
||||||
|
arrayInformationType = 0;
|
||||||
|
|
||||||
|
if (copyOf.unionArray) {
|
||||||
|
assert(!copyOf.type.getStruct());
|
||||||
|
assert(copyOf.type.getInstanceSize() == 1);
|
||||||
|
unionArray = new constUnion[1];
|
||||||
|
switch (type.getBasicType()) {
|
||||||
|
case EbtFloat: unionArray[0].fConst = copyOf.unionArray[0].fConst; break;
|
||||||
|
case EbtInt: unionArray[0].iConst = copyOf.unionArray[0].iConst; break;
|
||||||
|
case EbtBool: unionArray[0].bConst = copyOf.unionArray[0].bConst; break;
|
||||||
|
default:
|
||||||
|
assert (false && "Unknown type");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
unionArray = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TVariable* TVariable::clone(TStructureMap& remapper)
|
||||||
|
{
|
||||||
|
TVariable *variable = new TVariable(*this, remapper);
|
||||||
|
|
||||||
|
return variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
|
||||||
|
TParameter param;
|
||||||
|
parameters.push_back(param);
|
||||||
|
parameters.back().copyParam(copyOf.parameters[i], remapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
returnType.copyType(copyOf.returnType, remapper);
|
||||||
|
mangledName = copyOf.mangledName;
|
||||||
|
op = copyOf.op;
|
||||||
|
defined = copyOf.defined;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFunction* TFunction::clone(TStructureMap& remapper)
|
||||||
|
{
|
||||||
|
TFunction *function = new TFunction(*this, remapper);
|
||||||
|
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)
|
||||||
|
{
|
||||||
|
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
|
||||||
|
tLevel::iterator iter;
|
||||||
|
for (iter = level.begin(); iter != level.end(); ++iter) {
|
||||||
|
symTableLevel->insert(*iter->second->clone(remapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
return symTableLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSymbolTable::copyTable(const TSymbolTable& copyOf)
|
||||||
|
{
|
||||||
|
TStructureMap remapper;
|
||||||
|
uniqueId = copyOf.uniqueId;
|
||||||
|
for (unsigned int i = 0; i < copyOf.table.size(); ++i) {
|
||||||
|
table.push_back(copyOf.table[i]->clone(remapper));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -77,6 +77,8 @@ public:
|
||||||
void setUniqueId(int id) { uniqueId = id; }
|
void setUniqueId(int id) { uniqueId = id; }
|
||||||
int getUniqueId() const { return uniqueId; }
|
int getUniqueId() const { return uniqueId; }
|
||||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
virtual void dump(TInfoSink &infoSink) const = 0;
|
||||||
|
TSymbol(const TSymbol&);
|
||||||
|
virtual TSymbol* clone(TStructureMap& remapper) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TString *name;
|
const TString *name;
|
||||||
|
@ -95,11 +97,11 @@ protected:
|
||||||
//
|
//
|
||||||
class TVariable : public TSymbol {
|
class TVariable : public TSymbol {
|
||||||
public:
|
public:
|
||||||
TVariable(const TString *name, TType t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
|
||||||
virtual ~TVariable() { }
|
virtual ~TVariable() { }
|
||||||
virtual bool isVariable() const { return true; }
|
virtual bool isVariable() const { return true; }
|
||||||
TType& getType() { return type; }
|
TType& getType() { return type; }
|
||||||
const TType getType() const { return type; }
|
const TType& getType() const { return type; }
|
||||||
bool isUserType() const { return userType; }
|
bool isUserType() const { return userType; }
|
||||||
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
|
void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
|
||||||
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
|
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
|
||||||
|
@ -124,6 +126,8 @@ public:
|
||||||
delete unionArray;
|
delete unionArray;
|
||||||
unionArray = constArray;
|
unionArray = constArray;
|
||||||
}
|
}
|
||||||
|
TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
|
||||||
|
virtual TVariable* clone(TStructureMap& remapper);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TType type;
|
TType type;
|
||||||
|
@ -141,6 +145,10 @@ protected:
|
||||||
struct TParameter {
|
struct TParameter {
|
||||||
TString *name;
|
TString *name;
|
||||||
TType* type;
|
TType* type;
|
||||||
|
void copyParam(const TParameter& param, TStructureMap& remapper) {
|
||||||
|
name = NewPoolTString(param.name->c_str());
|
||||||
|
type = param.type->clone(remapper);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -153,7 +161,7 @@ public:
|
||||||
returnType(TType(EbtVoid)),
|
returnType(TType(EbtVoid)),
|
||||||
op(o),
|
op(o),
|
||||||
defined(false) { }
|
defined(false) { }
|
||||||
TFunction(const TString *name, TType retType, TOperator tOp = EOpNull) :
|
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
|
||||||
TSymbol(name),
|
TSymbol(name),
|
||||||
returnType(retType),
|
returnType(retType),
|
||||||
mangledName(*name + '('),
|
mangledName(*name + '('),
|
||||||
|
@ -180,6 +188,8 @@ public:
|
||||||
const TParameter& operator [](int i) const { return parameters[i]; }
|
const TParameter& operator [](int i) const { return parameters[i]; }
|
||||||
|
|
||||||
virtual void dump(TInfoSink &infoSink) const;
|
virtual void dump(TInfoSink &infoSink) const;
|
||||||
|
TFunction(const TFunction&, TStructureMap& remapper);
|
||||||
|
virtual TFunction* clone(TStructureMap& remapper);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef TVector<TParameter> TParamList;
|
typedef TVector<TParameter> TParamList;
|
||||||
|
@ -219,6 +229,7 @@ public:
|
||||||
|
|
||||||
void relateToOperator(const char* name, TOperator op);
|
void relateToOperator(const char* name, TOperator op);
|
||||||
void dump(TInfoSink &infoSink) const;
|
void dump(TInfoSink &infoSink) const;
|
||||||
|
TSymbolTableLevel* clone(TStructureMap& remapper);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
|
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
|
||||||
|
@ -258,8 +269,9 @@ public:
|
||||||
// globals are at level 1.
|
// globals are at level 1.
|
||||||
//
|
//
|
||||||
bool isEmpty() { return table.size() == 0; }
|
bool isEmpty() { return table.size() == 0; }
|
||||||
bool atBuiltInLevel() { return table.size() == 1; }
|
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
|
||||||
bool atGlobalLevel() { return table.size() <= 2; }
|
bool atSharedBuiltInLevel() { return table.size() == 1; }
|
||||||
|
bool atGlobalLevel() { return table.size() <= 3; }
|
||||||
void push() {
|
void push() {
|
||||||
table.push_back(new TSymbolTableLevel);
|
table.push_back(new TSymbolTableLevel);
|
||||||
}
|
}
|
||||||
|
@ -291,12 +303,15 @@ public:
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSymbolTableLevel* getGlobalLevel() { assert (table.size() >= 3); return table[2]; }
|
||||||
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
|
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
|
||||||
int getMaxSymbolId() { return uniqueId; }
|
int getMaxSymbolId() { return uniqueId; }
|
||||||
void dump(TInfoSink &infoSink) const;
|
void dump(TInfoSink &infoSink) const;
|
||||||
|
void copyTable(const TSymbolTable& copyOf);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||||
|
bool atDynamicBuiltInLevel() { return table.size() == 2; }
|
||||||
|
|
||||||
std::vector<TSymbolTableLevel*> table;
|
std::vector<TSymbolTableLevel*> table;
|
||||||
int uniqueId; // for unique identification in code generation
|
int uniqueId; // for unique identification in code generation
|
||||||
|
|
|
@ -1,121 +1,260 @@
|
||||||
typedef union {
|
/* A Bison parser, made by GNU Bison 1.875. */
|
||||||
struct {
|
|
||||||
TSourceLoc line;
|
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||||
union {
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||||
TString *string;
|
|
||||||
float f;
|
This program is free software; you can redistribute it and/or modify
|
||||||
int i;
|
it under the terms of the GNU General Public License as published by
|
||||||
bool b;
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
};
|
any later version.
|
||||||
TSymbol* symbol;
|
|
||||||
} lex;
|
This program is distributed in the hope that it will be useful,
|
||||||
struct {
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
TSourceLoc line;
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
TOperator op;
|
GNU General Public License for more details.
|
||||||
union {
|
|
||||||
TIntermNode* intermNode;
|
You should have received a copy of the GNU General Public License
|
||||||
TIntermNodePair nodePair;
|
along with this program; if not, write to the Free Software
|
||||||
TIntermTyped* intermTypedNode;
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
TIntermAggregate* intermAggregate;
|
Boston, MA 02111-1307, USA. */
|
||||||
};
|
|
||||||
union {
|
/* As a special exception, when this file is copied by Bison into a
|
||||||
TPublicType type;
|
Bison output file, you may use that output file without restriction.
|
||||||
TQualifier qualifier;
|
This special exception was added by the Free Software Foundation
|
||||||
TFunction* function;
|
in version 1.24 of Bison. */
|
||||||
TParameter param;
|
|
||||||
TTypeLine typeLine;
|
/* Tokens. */
|
||||||
TTypeList* typeList;
|
#ifndef YYTOKENTYPE
|
||||||
};
|
# define YYTOKENTYPE
|
||||||
} interm;
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
} YYSTYPE;
|
know about them. */
|
||||||
#define ATTRIBUTE 258
|
enum yytokentype {
|
||||||
#define CONST_QUAL 259
|
ATTRIBUTE = 258,
|
||||||
#define BOOL_TYPE 260
|
CONST_QUAL = 259,
|
||||||
#define FLOAT_TYPE 261
|
BOOL_TYPE = 260,
|
||||||
#define INT_TYPE 262
|
FLOAT_TYPE = 261,
|
||||||
#define BREAK 263
|
INT_TYPE = 262,
|
||||||
#define CONTINUE 264
|
BREAK = 263,
|
||||||
#define DO 265
|
CONTINUE = 264,
|
||||||
#define ELSE 266
|
DO = 265,
|
||||||
#define FOR 267
|
ELSE = 266,
|
||||||
#define IF 268
|
FOR = 267,
|
||||||
#define DISCARD 269
|
IF = 268,
|
||||||
#define RETURN 270
|
DISCARD = 269,
|
||||||
#define BVEC2 271
|
RETURN = 270,
|
||||||
#define BVEC3 272
|
BVEC2 = 271,
|
||||||
#define BVEC4 273
|
BVEC3 = 272,
|
||||||
#define IVEC2 274
|
BVEC4 = 273,
|
||||||
#define IVEC3 275
|
IVEC2 = 274,
|
||||||
#define IVEC4 276
|
IVEC3 = 275,
|
||||||
#define VEC2 277
|
IVEC4 = 276,
|
||||||
#define VEC3 278
|
VEC2 = 277,
|
||||||
#define VEC4 279
|
VEC3 = 278,
|
||||||
#define MATRIX2 280
|
VEC4 = 279,
|
||||||
#define MATRIX3 281
|
MATRIX2 = 280,
|
||||||
#define MATRIX4 282
|
MATRIX3 = 281,
|
||||||
#define IN_QUAL 283
|
MATRIX4 = 282,
|
||||||
#define OUT_QUAL 284
|
IN_QUAL = 283,
|
||||||
#define INOUT_QUAL 285
|
OUT_QUAL = 284,
|
||||||
#define UNIFORM 286
|
INOUT_QUAL = 285,
|
||||||
#define VARYING 287
|
UNIFORM = 286,
|
||||||
#define STRUCT 288
|
VARYING = 287,
|
||||||
#define VOID_TYPE 289
|
STRUCT = 288,
|
||||||
#define WHILE 290
|
VOID_TYPE = 289,
|
||||||
#define SAMPLER1D 291
|
WHILE = 290,
|
||||||
#define SAMPLER2D 292
|
SAMPLER1D = 291,
|
||||||
#define SAMPLER3D 293
|
SAMPLER2D = 292,
|
||||||
#define SAMPLERCUBE 294
|
SAMPLER3D = 293,
|
||||||
#define SAMPLER1DSHADOW 295
|
SAMPLERCUBE = 294,
|
||||||
#define SAMPLER2DSHADOW 296
|
SAMPLER1DSHADOW = 295,
|
||||||
#define IDENTIFIER 297
|
SAMPLER2DSHADOW = 296,
|
||||||
#define TYPE_NAME 298
|
IDENTIFIER = 297,
|
||||||
#define FLOATCONSTANT 299
|
TYPE_NAME = 298,
|
||||||
#define INTCONSTANT 300
|
FLOATCONSTANT = 299,
|
||||||
#define BOOLCONSTANT 301
|
INTCONSTANT = 300,
|
||||||
#define FIELD_SELECTION 302
|
BOOLCONSTANT = 301,
|
||||||
#define LEFT_OP 303
|
FIELD_SELECTION = 302,
|
||||||
#define RIGHT_OP 304
|
LEFT_OP = 303,
|
||||||
#define INC_OP 305
|
RIGHT_OP = 304,
|
||||||
#define DEC_OP 306
|
INC_OP = 305,
|
||||||
#define LE_OP 307
|
DEC_OP = 306,
|
||||||
#define GE_OP 308
|
LE_OP = 307,
|
||||||
#define EQ_OP 309
|
GE_OP = 308,
|
||||||
#define NE_OP 310
|
EQ_OP = 309,
|
||||||
#define AND_OP 311
|
NE_OP = 310,
|
||||||
#define OR_OP 312
|
AND_OP = 311,
|
||||||
#define XOR_OP 313
|
OR_OP = 312,
|
||||||
#define MUL_ASSIGN 314
|
XOR_OP = 313,
|
||||||
#define DIV_ASSIGN 315
|
MUL_ASSIGN = 314,
|
||||||
#define ADD_ASSIGN 316
|
DIV_ASSIGN = 315,
|
||||||
#define MOD_ASSIGN 317
|
ADD_ASSIGN = 316,
|
||||||
#define LEFT_ASSIGN 318
|
MOD_ASSIGN = 317,
|
||||||
#define RIGHT_ASSIGN 319
|
LEFT_ASSIGN = 318,
|
||||||
#define AND_ASSIGN 320
|
RIGHT_ASSIGN = 319,
|
||||||
#define XOR_ASSIGN 321
|
AND_ASSIGN = 320,
|
||||||
#define OR_ASSIGN 322
|
XOR_ASSIGN = 321,
|
||||||
#define SUB_ASSIGN 323
|
OR_ASSIGN = 322,
|
||||||
#define LEFT_PAREN 324
|
SUB_ASSIGN = 323,
|
||||||
#define RIGHT_PAREN 325
|
LEFT_PAREN = 324,
|
||||||
#define LEFT_BRACKET 326
|
RIGHT_PAREN = 325,
|
||||||
#define RIGHT_BRACKET 327
|
LEFT_BRACKET = 326,
|
||||||
#define LEFT_BRACE 328
|
RIGHT_BRACKET = 327,
|
||||||
#define RIGHT_BRACE 329
|
LEFT_BRACE = 328,
|
||||||
#define DOT 330
|
RIGHT_BRACE = 329,
|
||||||
#define COMMA 331
|
DOT = 330,
|
||||||
#define COLON 332
|
COMMA = 331,
|
||||||
#define EQUAL 333
|
COLON = 332,
|
||||||
#define SEMICOLON 334
|
EQUAL = 333,
|
||||||
#define BANG 335
|
SEMICOLON = 334,
|
||||||
#define DASH 336
|
BANG = 335,
|
||||||
#define TILDE 337
|
DASH = 336,
|
||||||
#define PLUS 338
|
TILDE = 337,
|
||||||
#define STAR 339
|
PLUS = 338,
|
||||||
#define SLASH 340
|
STAR = 339,
|
||||||
#define PERCENT 341
|
SLASH = 340,
|
||||||
#define LEFT_ANGLE 342
|
PERCENT = 341,
|
||||||
#define RIGHT_ANGLE 343
|
LEFT_ANGLE = 342,
|
||||||
#define VERTICAL_BAR 344
|
RIGHT_ANGLE = 343,
|
||||||
#define CARET 345
|
VERTICAL_BAR = 344,
|
||||||
#define AMPERSAND 346
|
CARET = 345,
|
||||||
#define QUESTION 347
|
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.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -64,6 +64,7 @@ public:
|
||||||
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
|
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
|
||||||
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
|
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
|
||||||
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
||||||
|
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||||
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
||||||
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
||||||
TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;
|
TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
//
|
//
|
||||||
class TConstTraverser : public TIntermTraverser {
|
class TConstTraverser : public TIntermTraverser {
|
||||||
public:
|
public:
|
||||||
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType t) : unionArray(cUnion), type(t),
|
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
|
||||||
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;}
|
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;}
|
||||||
int index ;
|
int index ;
|
||||||
constUnion *unionArray;
|
constUnion *unionArray;
|
||||||
|
@ -174,7 +174,6 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
|
||||||
bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
|
bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
|
||||||
{
|
{
|
||||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||||
TType tt = node->getType();
|
|
||||||
|
|
||||||
if (!node->isConstructor() && node->getOp() != EOpComma) {
|
if (!node->isConstructor() && node->getOp() != EOpComma) {
|
||||||
char buf[200];
|
char buf[200];
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,96 +1,96 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// atom.h
|
/* atom.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__ATOM_H)
|
#if !defined(__ATOM_H)
|
||||||
#define __ATOM_H 1
|
#define __ATOM_H 1
|
||||||
|
|
||||||
typedef struct AtomTable_Rec AtomTable;
|
typedef struct AtomTable_Rec AtomTable;
|
||||||
|
|
||||||
extern AtomTable *atable;
|
extern AtomTable *atable;
|
||||||
|
|
||||||
int InitAtomTable(AtomTable *atable, int htsize);
|
int InitAtomTable(AtomTable *atable, int htsize);
|
||||||
void FreeAtomTable(AtomTable *atable);
|
void FreeAtomTable(AtomTable *atable);
|
||||||
int AddAtom(AtomTable *atable, const char *s);
|
int AddAtom(AtomTable *atable, const char *s);
|
||||||
void PrintAtomTable(AtomTable *atable);
|
void PrintAtomTable(AtomTable *atable);
|
||||||
int LookUpAddString(AtomTable *atable, const char *s);
|
int LookUpAddString(AtomTable *atable, const char *s);
|
||||||
const char *GetAtomString(AtomTable *atable, int atom);
|
const char *GetAtomString(AtomTable *atable, int atom);
|
||||||
int GetReversedAtom(AtomTable *atable, int atom);
|
int GetReversedAtom(AtomTable *atable, int atom);
|
||||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||||
#endif /* !defined(__ATOM_H) */
|
#endif /* !defined(__ATOM_H) */
|
||||||
|
|
|
@ -1,131 +1,132 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// compile.h
|
/* compile.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__COMPILE_H)
|
#if !defined(__COMPILE_H)
|
||||||
#define __COMPILE_H 1
|
#define __COMPILE_H 1
|
||||||
|
|
||||||
int InitCPPStruct(void);
|
int InitCPPStruct(void);
|
||||||
|
|
||||||
typedef struct Options_Rec{
|
typedef struct Options_Rec{
|
||||||
const char *profileString;
|
const char *profileString;
|
||||||
int ErrorMode;
|
int ErrorMode;
|
||||||
int Quiet;
|
int Quiet;
|
||||||
|
|
||||||
/* Debug The Compiler options: */
|
/* Debug The Compiler options: */
|
||||||
int DumpAtomTable;
|
int DumpAtomTable;
|
||||||
} Options;
|
} Options;
|
||||||
|
|
||||||
struct CPPStruct_Rec {
|
struct CPPStruct_Rec {
|
||||||
/* Public members */
|
/* Public members */
|
||||||
SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
|
SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
|
||||||
Options options; /* Compile options and parameters */
|
Options options; /* Compile options and parameters */
|
||||||
|
|
||||||
/* Private members */
|
/* Private members */
|
||||||
SourceLoc lastSourceLoc;
|
SourceLoc lastSourceLoc;
|
||||||
|
|
||||||
/* Scanner data: */
|
/* Scanner data: */
|
||||||
|
|
||||||
SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
|
SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
|
||||||
int mostRecentToken; /* Most recent token seen by the scanner */
|
int mostRecentToken; /* Most recent token seen by the scanner */
|
||||||
InputSrc *currentInput;
|
InputSrc *currentInput;
|
||||||
int previous_token;
|
int previous_token;
|
||||||
int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
|
int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
|
||||||
|
|
||||||
void *pC; /* storing the parseContext of the compile object in cpp. */
|
void *pC; /* storing the parseContext of the compile object in cpp. */
|
||||||
|
|
||||||
/* Private members: */
|
/* Private members: */
|
||||||
SourceLoc ltokenLoc;
|
SourceLoc ltokenLoc;
|
||||||
int ifdepth; /* current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
|
int ifdepth; /*current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
|
||||||
int elsedepth[64]; /* Keep a track of #if depth..Max allowed is 64. */
|
int elsedepth[64]; /*Keep a track of #if depth..Max allowed is 64. */
|
||||||
int elsetracker; /* #if-#else and #endif constructs...Counter. */
|
int elsetracker; /*#if-#else and #endif constructs...Counter. */
|
||||||
const char *ErrMsg;
|
const char *ErrMsg;
|
||||||
int CompileError; /* Indicate compile error when #error, #else,#elif mismatch. */
|
int CompileError; /*Indicate compile error when #error, #else,#elif mismatch. */
|
||||||
|
|
||||||
/*
|
/* */
|
||||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
/* Globals used to communicate between PaParseStrings() and yy_input()and */
|
||||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
/* also across the files.(gen_glslang.cpp and scanner.c) */
|
||||||
*/
|
/* */
|
||||||
int PaWhichStr; /* which string we're parsing */
|
int PaWhichStr; /* which string we're parsing */
|
||||||
int* PaStrLen; /* array of lengths of the PaArgv strings */
|
int* PaStrLen; /* array of lengths of the PaArgv strings */
|
||||||
int PaArgc; /* count of strings in the array */
|
int PaArgc; /* count of strings in the array */
|
||||||
char** PaArgv; /* our array of strings to parse */
|
char** PaArgv; /* our array of strings to parse */
|
||||||
};
|
unsigned int tokensBeforeEOF : 1;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* !defined(__COMPILE_H) */
|
#endif /* !defined(__COMPILE_H) */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,118 +1,119 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// cpp.h
|
/* cpp.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__CPP_H)
|
#if !defined(__CPP_H)
|
||||||
#define __CPP_H 1
|
#define __CPP_H 1
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
|
|
||||||
int InitCPP(void);
|
int InitCPP(void);
|
||||||
int FinalCPP(void);
|
int FinalCPP(void);
|
||||||
int readCPPline(yystypepp * yylvalpp);
|
int readCPPline(yystypepp * yylvalpp);
|
||||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||||
int ChkCorrectElseNesting(void);
|
int ChkCorrectElseNesting(void);
|
||||||
|
|
||||||
typedef struct MacroSymbol {
|
typedef struct MacroSymbol {
|
||||||
int argc;
|
int argc;
|
||||||
int *args;
|
int *args;
|
||||||
TokenStream *body;
|
TokenStream *body;
|
||||||
unsigned busy:1;
|
unsigned busy:1;
|
||||||
unsigned undef:1;
|
unsigned undef:1;
|
||||||
} MacroSymbol;
|
} MacroSymbol;
|
||||||
|
|
||||||
void FreeMacro(MacroSymbol *);
|
void FreeMacro(MacroSymbol *);
|
||||||
int PredefineMacro(char *);
|
int PredefineMacro(char *);
|
||||||
|
|
||||||
void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
|
void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
|
||||||
void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
|
void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
|
||||||
void MapStrings(const char*,const char*); /* #pragma directive container. */
|
void CPPWarningToInfoLog(const char *msg); /* Prints warning messages into info log */
|
||||||
|
void HandlePragma(const char**, int numTokens); /* #pragma directive container. */
|
||||||
void ResetTString(void); /* #error Message as TString. */
|
void ResetTString(void); /* #error Message as TString. */
|
||||||
void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log */
|
void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log . */
|
||||||
void StoreStr(char*); /* Store the TString in Parse Context. */
|
void StoreStr(char*); /* Store the TString in Parse Context. */
|
||||||
void SetLineNumber(int); /* Set line number. */
|
void SetLineNumber(int); /* Set line number. */
|
||||||
void SetStringNumber(int); /* Set string number. */
|
void SetStringNumber(int); /* Set string number. */
|
||||||
int GetLineNumber(void); /* Get the current String Number. */
|
int GetLineNumber(void); /* Get the current String Number. */
|
||||||
int GetStringNumber(void); /* Get the current String Number. */
|
int GetStringNumber(void); /* Get the current String Number. */
|
||||||
const char* GetStrfromTStr(void); /* Convert TString to String. */
|
const char* GetStrfromTStr(void); /* Convert TString to String. */
|
||||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||||
int FreeCPP(void);
|
int FreeCPP(void);
|
||||||
|
|
||||||
#endif /* !(defined(__CPP_H) */
|
#endif /* !(defined(__CPP_H) */
|
||||||
|
|
|
@ -1,184 +1,185 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// cppstruct.c
|
/* cppstruct.c */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "slglobals.h"
|
#include "slglobals.h"
|
||||||
|
|
||||||
CPPStruct *cpp = NULL;
|
CPPStruct *cpp = NULL;
|
||||||
static int refCount = 0;
|
static int refCount = 0;
|
||||||
|
|
||||||
int InitPreprocessor(void);
|
int InitPreprocessor(void);
|
||||||
int ResetPreprocessor(void);
|
int ResetPreprocessor(void);
|
||||||
int FreeCPPStruct(void);
|
int FreeCPPStruct(void);
|
||||||
int FinalizePreprocessor(void);
|
int FinalizePreprocessor(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InitCPPStruct() - Initilaize the CPP structure.
|
* InitCPPStruct() - Initilaize the CPP structure.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int InitCPPStruct(void)
|
int InitCPPStruct(void)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||||
if (cpp == NULL)
|
if (cpp == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
refCount++;
|
refCount++;
|
||||||
|
|
||||||
/* Initialize public members: */
|
/* Initialize public members: */
|
||||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||||
|
|
||||||
p = (char *) &cpp->options;
|
p = (char *) &cpp->options;
|
||||||
len = sizeof(cpp->options);
|
len = sizeof(cpp->options);
|
||||||
while (--len >= 0)
|
while (--len >= 0)
|
||||||
p[len] = 0;
|
p[len] = 0;
|
||||||
|
|
||||||
ResetPreprocessor();
|
ResetPreprocessor();
|
||||||
return 1;
|
return 1;
|
||||||
} /* InitCPPStruct */
|
} /* InitCPPStruct */
|
||||||
|
|
||||||
int ResetPreprocessor(void)
|
int ResetPreprocessor(void)
|
||||||
{
|
{
|
||||||
/* Initialize private members: */
|
/* Initialize private members: */
|
||||||
|
|
||||||
cpp->lastSourceLoc.file = 0;
|
cpp->lastSourceLoc.file = 0;
|
||||||
cpp->lastSourceLoc.line = 0;
|
cpp->lastSourceLoc.line = 0;
|
||||||
cpp->pC=0;
|
cpp->pC=0;
|
||||||
cpp->CompileError=0;
|
cpp->CompileError=0;
|
||||||
cpp->ifdepth=0;
|
cpp->ifdepth=0;
|
||||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||||
cpp->elsedepth[cpp->elsetracker]=0;
|
cpp->elsedepth[cpp->elsetracker]=0;
|
||||||
cpp->elsetracker=0;
|
cpp->elsetracker=0;
|
||||||
return 1;
|
cpp->tokensBeforeEOF = 0;
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*Intializing the Preprocessor. */
|
/*Intializing the Preprocessor. */
|
||||||
|
|
||||||
int InitPreprocessor(void)
|
int InitPreprocessor(void)
|
||||||
{
|
{
|
||||||
# define CPP_STUFF true
|
# define CPP_STUFF true
|
||||||
# ifdef CPP_STUFF
|
# ifdef CPP_STUFF
|
||||||
FreeCPPStruct();
|
FreeCPPStruct();
|
||||||
InitCPPStruct();
|
InitCPPStruct();
|
||||||
cpp->options.Quiet = 1;
|
cpp->options.Quiet = 1;
|
||||||
cpp->options.profileString = "generic";
|
cpp->options.profileString = "generic";
|
||||||
if (!InitAtomTable(atable, 0))
|
if (!InitAtomTable(atable, 0))
|
||||||
return 1;
|
return 1;
|
||||||
if (!InitScanner(cpp))
|
if (!InitScanner(cpp))
|
||||||
return 1;
|
return 1;
|
||||||
# endif
|
# endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FreeCPPStruct() - Free the CPP structure. */
|
/*FreeCPPStruct() - Free the CPP structure. */
|
||||||
|
|
||||||
int FreeCPPStruct(void)
|
int FreeCPPStruct(void)
|
||||||
{
|
{
|
||||||
if (refCount)
|
if (refCount)
|
||||||
{
|
{
|
||||||
free(cpp);
|
free(cpp);
|
||||||
refCount--;
|
refCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finalizing the Preprocessor. */
|
/*Finalizing the Preprocessor. */
|
||||||
|
|
||||||
int FinalizePreprocessor(void)
|
int FinalizePreprocessor(void)
|
||||||
{
|
{
|
||||||
# define CPP_STUFF true
|
# define CPP_STUFF true
|
||||||
# ifdef CPP_STUFF
|
# ifdef CPP_STUFF
|
||||||
FreeAtomTable(atable);
|
FreeAtomTable(atable);
|
||||||
FreeCPPStruct();
|
FreeCPPStruct();
|
||||||
FreeScanner();
|
FreeScanner();
|
||||||
# endif
|
# endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
/*//////////////////////////////////// End of cppstruct.c ////////////////////////////////////// */
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
|
|
|
@ -1,191 +1,191 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
/* */
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __STDC99__
|
#ifdef __STDC99__
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#elif defined (_WIN64)
|
#elif defined (_WIN64)
|
||||||
typedef unsigned __int64 uintptr_t;
|
typedef unsigned __int64 uintptr_t;
|
||||||
#else
|
#else
|
||||||
typedef unsigned int uintptr_t;
|
typedef unsigned int uintptr_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
/* default alignment and chunksize, if called with 0 arguments */
|
/* default alignment and chunksize, if called with 0 arguments */
|
||||||
#define CHUNKSIZE (64*1024)
|
#define CHUNKSIZE (64*1024)
|
||||||
#define ALIGN 8
|
#define ALIGN 8
|
||||||
|
|
||||||
/* we need to call the `real' malloc and free, not our replacements */
|
/* we need to call the `real' malloc and free, not our replacements */
|
||||||
#undef malloc
|
#undef malloc
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
struct chunk {
|
struct chunk {
|
||||||
struct chunk *next;
|
struct chunk *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cleanup {
|
struct cleanup {
|
||||||
struct cleanup *next;
|
struct cleanup *next;
|
||||||
void (*fn)(void *);
|
void (*fn)(void *);
|
||||||
void *arg;
|
void *arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MemoryPool_rec {
|
struct MemoryPool_rec {
|
||||||
struct chunk *next;
|
struct chunk *next;
|
||||||
uintptr_t free, end;
|
uintptr_t free, end;
|
||||||
size_t chunksize;
|
size_t chunksize;
|
||||||
uintptr_t alignmask;
|
uintptr_t alignmask;
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
};
|
};
|
||||||
|
|
||||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||||
{
|
{
|
||||||
MemoryPool *pool;
|
MemoryPool *pool;
|
||||||
|
|
||||||
if (align == 0) align = ALIGN;
|
if (align == 0) align = ALIGN;
|
||||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||||
if (align & (align-1)) return 0;
|
if (align & (align-1)) return 0;
|
||||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||||
if (chunksize & (align-1)) return 0;
|
if (chunksize & (align-1)) return 0;
|
||||||
if (!(pool = malloc(chunksize))) return 0;
|
if (!(pool = malloc(chunksize))) return 0;
|
||||||
pool->next = 0;
|
pool->next = 0;
|
||||||
pool->chunksize = chunksize;
|
pool->chunksize = chunksize;
|
||||||
pool->alignmask = (uintptr_t)(align)-1;
|
pool->alignmask = (uintptr_t)(align)-1;
|
||||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||||
pool->end = (uintptr_t)pool + chunksize;
|
pool->end = (uintptr_t)pool + chunksize;
|
||||||
pool->cleanup = 0;
|
pool->cleanup = 0;
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mem_FreePool(MemoryPool *pool)
|
void mem_FreePool(MemoryPool *pool)
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
struct chunk *p, *next;
|
struct chunk *p, *next;
|
||||||
|
|
||||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||||
cleanup->fn(cleanup->arg);
|
cleanup->fn(cleanup->arg);
|
||||||
}
|
}
|
||||||
for (p = (struct chunk *)pool; p; p = next) {
|
for (p = (struct chunk *)pool; p; p = next) {
|
||||||
next = p->next;
|
next = p->next;
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||||
{
|
{
|
||||||
struct chunk *ch;
|
struct chunk *ch;
|
||||||
void *rv = (void *)pool->free;
|
void *rv = (void *)pool->free;
|
||||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||||
if (size <= 0) size = pool->alignmask;
|
if (size <= 0) size = pool->alignmask;
|
||||||
pool->free += size;
|
pool->free += size;
|
||||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||||
& ~pool->alignmask;
|
& ~pool->alignmask;
|
||||||
pool->free = (uintptr_t)rv;
|
pool->free = (uintptr_t)rv;
|
||||||
if (minreq >= pool->chunksize) {
|
if (minreq >= pool->chunksize) {
|
||||||
/* request size is too big for the chunksize, so allocate it as
|
/* request size is too big for the chunksize, so allocate it as */
|
||||||
// a single chunk of the right size */
|
/* a single chunk of the right size */
|
||||||
ch = malloc(minreq);
|
ch = malloc(minreq);
|
||||||
if (!ch) return 0;
|
if (!ch) return 0;
|
||||||
} else {
|
} else {
|
||||||
ch = malloc(pool->chunksize);
|
ch = malloc(pool->chunksize);
|
||||||
if (!ch) return 0;
|
if (!ch) return 0;
|
||||||
pool->free = (uintptr_t)ch + minreq;
|
pool->free = (uintptr_t)ch + minreq;
|
||||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||||
}
|
}
|
||||||
ch->next = pool->next;
|
ch->next = pool->next;
|
||||||
pool->next = ch;
|
pool->next = ch;
|
||||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
|
|
||||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||||
if (!cleanup) return -1;
|
if (!cleanup) return -1;
|
||||||
cleanup->next = pool->cleanup;
|
cleanup->next = pool->cleanup;
|
||||||
cleanup->fn = fn;
|
cleanup->fn = fn;
|
||||||
cleanup->arg = arg;
|
cleanup->arg = arg;
|
||||||
pool->cleanup = cleanup;
|
pool->cleanup = cleanup;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,89 +1,89 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
/* */
|
||||||
#ifndef __MEMORY_H
|
#ifndef __MEMORY_H
|
||||||
#define __MEMORY_H
|
#define __MEMORY_H
|
||||||
|
|
||||||
typedef struct MemoryPool_rec MemoryPool;
|
typedef struct MemoryPool_rec MemoryPool;
|
||||||
|
|
||||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||||
extern void mem_FreePool(MemoryPool *);
|
extern void mem_FreePool(MemoryPool *);
|
||||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
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);
|
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||||
|
|
||||||
#endif /* __MEMORY_H */
|
#endif /* __MEMORY_H */
|
||||||
|
|
|
@ -1,126 +1,126 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
#ifndef BISON_PARSER_H
|
#ifndef BISON_PARSER_H
|
||||||
# define BISON_PARSER_H
|
# define BISON_PARSER_H
|
||||||
|
|
||||||
#ifndef yystypepp
|
#ifndef yystypepp
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int sc_int;
|
int sc_int;
|
||||||
float sc_fval;
|
float sc_fval;
|
||||||
int sc_ident;
|
int sc_ident;
|
||||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||||
} yystypepp;
|
} yystypepp;
|
||||||
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
# define CPP_AND_OP 257
|
# define CPP_AND_OP 257
|
||||||
# define CPP_SUB_ASSIGN 259
|
# define CPP_SUB_ASSIGN 259
|
||||||
# define CPP_MOD_ASSIGN 260
|
# define CPP_MOD_ASSIGN 260
|
||||||
# define CPP_ADD_ASSIGN 261
|
# define CPP_ADD_ASSIGN 261
|
||||||
# define CPP_DIV_ASSIGN 262
|
# define CPP_DIV_ASSIGN 262
|
||||||
# define CPP_MUL_ASSIGN 263
|
# define CPP_MUL_ASSIGN 263
|
||||||
# define CPP_EQ_OP 264
|
# define CPP_EQ_OP 264
|
||||||
# define CPP_XOR_OP 265
|
# define CPP_XOR_OP 265
|
||||||
# define ERROR_SY 266
|
# define ERROR_SY 266
|
||||||
# define CPP_FLOATCONSTANT 267
|
# define CPP_FLOATCONSTANT 267
|
||||||
# define CPP_GE_OP 268
|
# define CPP_GE_OP 268
|
||||||
# define CPP_RIGHT_OP 269
|
# define CPP_RIGHT_OP 269
|
||||||
# define CPP_IDENTIFIER 270
|
# define CPP_IDENTIFIER 270
|
||||||
# define CPP_INTCONSTANT 271
|
# define CPP_INTCONSTANT 271
|
||||||
# define CPP_LE_OP 272
|
# define CPP_LE_OP 272
|
||||||
# define CPP_LEFT_OP 273
|
# define CPP_LEFT_OP 273
|
||||||
# define CPP_DEC_OP 274
|
# define CPP_DEC_OP 274
|
||||||
# define CPP_NE_OP 275
|
# define CPP_NE_OP 275
|
||||||
# define CPP_OR_OP 276
|
# define CPP_OR_OP 276
|
||||||
# define CPP_INC_OP 277
|
# define CPP_INC_OP 277
|
||||||
# define CPP_STRCONSTANT 278
|
# define CPP_STRCONSTANT 278
|
||||||
# define CPP_TYPEIDENTIFIER 279
|
# define CPP_TYPEIDENTIFIER 279
|
||||||
|
|
||||||
# define FIRST_USER_TOKEN_SY 289
|
# define FIRST_USER_TOKEN_SY 289
|
||||||
|
|
||||||
# define CPP_RIGHT_ASSIGN 280
|
# define CPP_RIGHT_ASSIGN 280
|
||||||
# define CPP_LEFT_ASSIGN 281
|
# define CPP_LEFT_ASSIGN 281
|
||||||
# define CPP_AND_ASSIGN 282
|
# define CPP_AND_ASSIGN 282
|
||||||
# define CPP_OR_ASSIGN 283
|
# define CPP_OR_ASSIGN 283
|
||||||
# define CPP_XOR_ASSIGN 284
|
# define CPP_XOR_ASSIGN 284
|
||||||
# define CPP_LEFT_BRACKET 285
|
# define CPP_LEFT_BRACKET 285
|
||||||
# define CPP_RIGHT_BRACKET 286
|
# define CPP_RIGHT_BRACKET 286
|
||||||
# define CPP_LEFT_BRACE 287
|
# define CPP_LEFT_BRACE 287
|
||||||
# define CPP_RIGHT_BRACE 288
|
# define CPP_RIGHT_BRACE 288
|
||||||
|
|
||||||
#endif /* not BISON_PARSER_H */
|
#endif /* not BISON_PARSER_H */
|
||||||
|
|
|
@ -1,84 +1,84 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
# include "slglobals.h"
|
# include "slglobals.h"
|
||||||
extern CPPStruct *cpp;
|
extern CPPStruct *cpp;
|
||||||
int InitCPPStruct(void);
|
int InitCPPStruct(void);
|
||||||
int InitScanner(CPPStruct *cpp);
|
int InitScanner(CPPStruct *cpp);
|
||||||
int InitAtomTable(AtomTable *atable, int htsize);
|
int InitAtomTable(AtomTable *atable, int htsize);
|
||||||
int ScanFromString(char *s);
|
int ScanFromString(char *s);
|
||||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
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.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// scanner.h
|
/* scanner.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__SCANNER_H)
|
#if !defined(__SCANNER_H)
|
||||||
#define __SCANNER_H 1
|
#define __SCANNER_H 1
|
||||||
|
|
||||||
#define MAX_SYMBOL_NAME_LEN 128
|
#define MAX_SYMBOL_NAME_LEN 128
|
||||||
#define MAX_STRING_LEN 512
|
#define MAX_STRING_LEN 512
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
/* Not really atom table stuff but needed first... */
|
/* Not really atom table stuff but needed first... */
|
||||||
|
|
||||||
typedef struct SourceLoc_Rec {
|
typedef struct SourceLoc_Rec {
|
||||||
unsigned short file, line;
|
unsigned short file, line;
|
||||||
} SourceLoc;
|
} SourceLoc;
|
||||||
|
|
||||||
int yyparse (void);
|
int yyparse (void);
|
||||||
|
|
||||||
int yylex_CPP(char* buf, int maxSize);
|
int yylex_CPP(char* buf, int maxSize);
|
||||||
|
|
||||||
typedef struct InputSrc {
|
typedef struct InputSrc {
|
||||||
struct InputSrc *prev;
|
struct InputSrc *prev;
|
||||||
int (*scan)(struct InputSrc *, yystypepp *);
|
int (*scan)(struct InputSrc *, yystypepp *);
|
||||||
int (*getch)(struct InputSrc *, yystypepp *);
|
int (*getch)(struct InputSrc *, yystypepp *);
|
||||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||||
int name; /* atom */
|
int name; /* atom */
|
||||||
int line;
|
int line;
|
||||||
} InputSrc;
|
} InputSrc;
|
||||||
|
|
||||||
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
|
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
|
||||||
int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
|
int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
|
||||||
int check_EOF(int); /* check if we hit a EOF abruptly */
|
int check_EOF(int); /* check if we hit a EOF abruptly */
|
||||||
void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
|
void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
|
||||||
void SetLineNumber(int);
|
void SetLineNumber(int);
|
||||||
void SetStringNumber(int);
|
void SetStringNumber(int);
|
||||||
void IncLineNumber(void);
|
void IncLineNumber(void);
|
||||||
void DecLineNumber(void);
|
void DecLineNumber(void);
|
||||||
int FreeScanner(void); /* Free the cpp scanner */
|
int FreeScanner(void); /* Free the cpp scanner */
|
||||||
#endif /* !(defined(__SCANNER_H) */
|
#endif /* !(defined(__SCANNER_H) */
|
||||||
|
|
||||||
|
|
|
@ -1,115 +1,115 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// slglobals.h
|
/* slglobals.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__SLGLOBALS_H)
|
#if !defined(__SLGLOBALS_H)
|
||||||
#define __SLGLOBALS_H 1
|
#define __SLGLOBALS_H 1
|
||||||
|
|
||||||
typedef struct CPPStruct_Rec CPPStruct;
|
typedef struct CPPStruct_Rec CPPStruct;
|
||||||
|
|
||||||
extern CPPStruct *cpp;
|
extern CPPStruct *cpp;
|
||||||
|
|
||||||
#undef CPPC_DEBUG_THE_COMPILER
|
#undef CPPC_DEBUG_THE_COMPILER
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#define CPPC_DEBUG_THE_COMPILER 1
|
#define CPPC_DEBUG_THE_COMPILER 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef CPPC_ENABLE_TOOLS
|
#undef CPPC_ENABLE_TOOLS
|
||||||
#define CPPC_ENABLE_TOOLS 1
|
#define CPPC_ENABLE_TOOLS 1
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
#include "cpp.h"
|
#include "cpp.h"
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
#include "compile.h"
|
#include "compile.h"
|
||||||
#if !defined(NO_PARSER)
|
#if !defined(NO_PARSER)
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(NULL)
|
#if !defined(NULL)
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !(defined(__SLGLOBALS_H) */
|
#endif /* !(defined(__SLGLOBALS_H) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,318 +1,318 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// symbols.c
|
/* symbols.c */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "slglobals.h"
|
#include "slglobals.h"
|
||||||
|
|
||||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
/*///////////////////////////////// Symbol Table Variables: /////////////////////////////////// */
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
Scope *ScopeList = NULL;
|
Scope *ScopeList = NULL;
|
||||||
Scope *CurrentScope = NULL;
|
Scope *CurrentScope = NULL;
|
||||||
Scope *GlobalScope = NULL;
|
Scope *GlobalScope = NULL;
|
||||||
|
|
||||||
static void unlinkScope(void *_scope) {
|
static void unlinkScope(void *_scope) {
|
||||||
Scope *scope = _scope;
|
Scope *scope = _scope;
|
||||||
|
|
||||||
if (scope->next)
|
if (scope->next)
|
||||||
scope->next->prev = scope->prev;
|
scope->next->prev = scope->prev;
|
||||||
if (scope->prev)
|
if (scope->prev)
|
||||||
scope->prev->next = scope->next;
|
scope->prev->next = scope->next;
|
||||||
else
|
else
|
||||||
ScopeList = scope->next;
|
ScopeList = scope->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NewScope()
|
* NewScope()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Scope *NewScopeInPool(MemoryPool *pool)
|
Scope *NewScopeInPool(MemoryPool *pool)
|
||||||
{
|
{
|
||||||
Scope *lScope;
|
Scope *lScope;
|
||||||
|
|
||||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||||
lScope->pool = pool;
|
lScope->pool = pool;
|
||||||
lScope->parent = NULL;
|
lScope->parent = NULL;
|
||||||
lScope->funScope = NULL;
|
lScope->funScope = NULL;
|
||||||
lScope->symbols = NULL;
|
lScope->symbols = NULL;
|
||||||
|
|
||||||
lScope->level = 0;
|
lScope->level = 0;
|
||||||
|
|
||||||
lScope->programs = NULL;
|
lScope->programs = NULL;
|
||||||
if ((lScope->next = ScopeList))
|
if ((lScope->next = ScopeList))
|
||||||
ScopeList->prev = lScope;
|
ScopeList->prev = lScope;
|
||||||
lScope->prev = 0;
|
lScope->prev = 0;
|
||||||
ScopeList = lScope;
|
ScopeList = lScope;
|
||||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||||
return lScope;
|
return lScope;
|
||||||
} /* NewScope */
|
} /* NewScope */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PushScope()
|
* PushScope()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PushScope(Scope *fScope)
|
void PushScope(Scope *fScope)
|
||||||
{
|
{
|
||||||
Scope *lScope;
|
Scope *lScope;
|
||||||
|
|
||||||
if (CurrentScope) {
|
if (CurrentScope) {
|
||||||
fScope->level = CurrentScope->level + 1;
|
fScope->level = CurrentScope->level + 1;
|
||||||
if (fScope->level == 1) {
|
if (fScope->level == 1) {
|
||||||
if (!GlobalScope) {
|
if (!GlobalScope) {
|
||||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||||
* defining a function in the superglobal scope. Things
|
* defining a function in the superglobal scope. Things
|
||||||
* will break if we leave the level as 1, so we arbitrarily
|
* will break if we leave the level as 1, so we arbitrarily
|
||||||
* set it to 2 */
|
* set it to 2 */
|
||||||
fScope->level = 2;
|
fScope->level = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fScope->level >= 2) {
|
if (fScope->level >= 2) {
|
||||||
lScope = fScope;
|
lScope = fScope;
|
||||||
while (lScope->level > 2)
|
while (lScope->level > 2)
|
||||||
lScope = lScope->next;
|
lScope = lScope->next;
|
||||||
fScope->funScope = lScope;
|
fScope->funScope = lScope;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fScope->level = 0;
|
fScope->level = 0;
|
||||||
}
|
}
|
||||||
fScope->parent = CurrentScope;
|
fScope->parent = CurrentScope;
|
||||||
CurrentScope = fScope;
|
CurrentScope = fScope;
|
||||||
} /* PushScope */
|
} /* PushScope */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PopScope()
|
* PopScope()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Scope *PopScope(void)
|
Scope *PopScope(void)
|
||||||
{
|
{
|
||||||
Scope *lScope;
|
Scope *lScope;
|
||||||
|
|
||||||
lScope = CurrentScope;
|
lScope = CurrentScope;
|
||||||
if (CurrentScope)
|
if (CurrentScope)
|
||||||
CurrentScope = CurrentScope->parent;
|
CurrentScope = CurrentScope->parent;
|
||||||
return lScope;
|
return lScope;
|
||||||
} /* PopScope */
|
} /* PopScope */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NewSymbol() - Allocate a new symbol node;
|
* NewSymbol() - Allocate a new symbol node;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||||
{
|
{
|
||||||
Symbol *lSymb;
|
Symbol *lSymb;
|
||||||
char *pch;
|
char *pch;
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||||
lSymb->left = NULL;
|
lSymb->left = NULL;
|
||||||
lSymb->right = NULL;
|
lSymb->right = NULL;
|
||||||
lSymb->next = NULL;
|
lSymb->next = NULL;
|
||||||
lSymb->name = name;
|
lSymb->name = name;
|
||||||
lSymb->loc = *loc;
|
lSymb->loc = *loc;
|
||||||
lSymb->kind = kind;
|
lSymb->kind = kind;
|
||||||
|
|
||||||
/* Clear union area: */
|
/* Clear union area: */
|
||||||
|
|
||||||
pch = (char *) &lSymb->details;
|
pch = (char *) &lSymb->details;
|
||||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||||
*pch++ = 0;
|
*pch++ = 0;
|
||||||
return lSymb;
|
return lSymb;
|
||||||
} /* NewSymbol */
|
} /* NewSymbol */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
* 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).
|
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||||
{
|
{
|
||||||
Symbol *lSymb;
|
Symbol *lSymb;
|
||||||
int lrev, frev;
|
int lrev, frev;
|
||||||
|
|
||||||
lSymb = *fSymbols;
|
lSymb = *fSymbols;
|
||||||
if (lSymb) {
|
if (lSymb) {
|
||||||
frev = GetReversedAtom(atable, fSymb->name);
|
frev = GetReversedAtom(atable, fSymb->name);
|
||||||
while (lSymb) {
|
while (lSymb) {
|
||||||
lrev = GetReversedAtom(atable, lSymb->name);
|
lrev = GetReversedAtom(atable, lSymb->name);
|
||||||
if (lrev == frev) {
|
if (lrev == frev) {
|
||||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (lrev > frev) {
|
if (lrev > frev) {
|
||||||
if (lSymb->left) {
|
if (lSymb->left) {
|
||||||
lSymb = lSymb->left;
|
lSymb = lSymb->left;
|
||||||
} else {
|
} else {
|
||||||
lSymb->left = fSymb;
|
lSymb->left = fSymb;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lSymb->right) {
|
if (lSymb->right) {
|
||||||
lSymb = lSymb->right;
|
lSymb = lSymb->right;
|
||||||
} else {
|
} else {
|
||||||
lSymb->right = fSymb;
|
lSymb->right = fSymb;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*fSymbols = fSymb;
|
*fSymbols = fSymb;
|
||||||
}
|
}
|
||||||
} /* lAddToTree */
|
} /* lAddToTree */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||||
{
|
{
|
||||||
Symbol *lSymb;
|
Symbol *lSymb;
|
||||||
|
|
||||||
if (!fScope)
|
if (!fScope)
|
||||||
fScope = CurrentScope;
|
fScope = CurrentScope;
|
||||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||||
lAddToTree(&fScope->symbols, lSymb);
|
lAddToTree(&fScope->symbols, lSymb);
|
||||||
return lSymb;
|
return lSymb;
|
||||||
} /* AddSymbol */
|
} /* AddSymbol */
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
/************************************ Symbol Semantic Functions ******************************/
|
/************************************ Symbol Semantic Functions ******************************/
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LookUpLocalSymbol()
|
* LookUpLocalSymbol()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||||
{
|
{
|
||||||
Symbol *lSymb;
|
Symbol *lSymb;
|
||||||
int rname, ratom;
|
int rname, ratom;
|
||||||
|
|
||||||
ratom = GetReversedAtom(atable, atom);
|
ratom = GetReversedAtom(atable, atom);
|
||||||
if (!fScope)
|
if (!fScope)
|
||||||
fScope = CurrentScope;
|
fScope = CurrentScope;
|
||||||
lSymb = fScope->symbols;
|
lSymb = fScope->symbols;
|
||||||
while (lSymb) {
|
while (lSymb) {
|
||||||
rname = GetReversedAtom(atable, lSymb->name);
|
rname = GetReversedAtom(atable, lSymb->name);
|
||||||
if (rname == ratom) {
|
if (rname == ratom) {
|
||||||
return lSymb;
|
return lSymb;
|
||||||
} else {
|
} else {
|
||||||
if (rname > ratom) {
|
if (rname > ratom) {
|
||||||
lSymb = lSymb->left;
|
lSymb = lSymb->left;
|
||||||
} else {
|
} else {
|
||||||
lSymb = lSymb->right;
|
lSymb = lSymb->right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* LookUpLocalSymbol */
|
} /* LookUpLocalSymbol */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LookUpSymbol()
|
* LookUpSymbol()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||||
{
|
{
|
||||||
Symbol *lSymb;
|
Symbol *lSymb;
|
||||||
|
|
||||||
if (!fScope)
|
if (!fScope)
|
||||||
fScope = CurrentScope;
|
fScope = CurrentScope;
|
||||||
while (fScope) {
|
while (fScope) {
|
||||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||||
if (lSymb)
|
if (lSymb)
|
||||||
return lSymb;
|
return lSymb;
|
||||||
fScope = fScope->parent;
|
fScope = fScope->parent;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* LookUpSymbol */
|
} /* LookUpSymbol */
|
||||||
|
|
||||||
|
|
|
@ -1,145 +1,145 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// symbols.h
|
/* symbols.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__SYMBOLS_H)
|
#if !defined(__SYMBOLS_H)
|
||||||
#define __SYMBOLS_H 1
|
#define __SYMBOLS_H 1
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
typedef enum symbolkind {
|
typedef enum symbolkind {
|
||||||
MACRO_S
|
MACRO_S
|
||||||
} symbolkind;
|
} symbolkind;
|
||||||
|
|
||||||
/* Typedefs for things defined here in "symbols.h": */
|
/* Typedefs for things defined here in "symbols.h": */
|
||||||
|
|
||||||
typedef struct Scope_Rec Scope;
|
typedef struct Scope_Rec Scope;
|
||||||
typedef struct Symbol_Rec Symbol;
|
typedef struct Symbol_Rec Symbol;
|
||||||
|
|
||||||
typedef struct SymbolList_Rec {
|
typedef struct SymbolList_Rec {
|
||||||
struct SymbolList_Rec *next;
|
struct SymbolList_Rec *next;
|
||||||
Symbol *symb;
|
Symbol *symb;
|
||||||
} SymbolList;
|
} SymbolList;
|
||||||
|
|
||||||
struct Scope_Rec {
|
struct Scope_Rec {
|
||||||
Scope *next, *prev; /* doubly-linked list of all scopes */
|
Scope *next, *prev; /* doubly-linked list of all scopes */
|
||||||
Scope *parent;
|
Scope *parent;
|
||||||
Scope *funScope; /* Points to base scope of enclosing function */
|
Scope *funScope; /* Points to base scope of enclosing function */
|
||||||
MemoryPool *pool; /* pool used for allocation in this scope */
|
MemoryPool *pool; /* pool used for allocation in this scope */
|
||||||
Symbol *symbols;
|
Symbol *symbols;
|
||||||
|
|
||||||
int level; /* 0 = super globals, 1 = globals, etc. */
|
int level; /* 0 = super globals, 1 = globals, etc. */
|
||||||
|
|
||||||
/* Only used at global scope (level 1): */
|
/* Only used at global scope (level 1): */
|
||||||
SymbolList *programs; /* List of programs for this compilation. */
|
SymbolList *programs; /* List of programs for this compilation. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Symbol table is a simple binary tree. */
|
/* Symbol table is a simple binary tree. */
|
||||||
|
|
||||||
#include "cpp.h" /* to get MacroSymbol def */
|
#include "cpp.h" /* to get MacroSymbol def */
|
||||||
|
|
||||||
struct Symbol_Rec {
|
struct Symbol_Rec {
|
||||||
Symbol *left, *right;
|
Symbol *left, *right;
|
||||||
Symbol *next;
|
Symbol *next;
|
||||||
int name; /* Name atom */
|
int name; /* Name atom */
|
||||||
SourceLoc loc;
|
SourceLoc loc;
|
||||||
symbolkind kind;
|
symbolkind kind;
|
||||||
union {
|
union {
|
||||||
MacroSymbol mac;
|
MacroSymbol mac;
|
||||||
} details;
|
} details;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Scope *CurrentScope;
|
extern Scope *CurrentScope;
|
||||||
extern Scope *GlobalScope;
|
extern Scope *GlobalScope;
|
||||||
extern Scope *ScopeList;
|
extern Scope *ScopeList;
|
||||||
|
|
||||||
Scope *NewScopeInPool(MemoryPool *);
|
Scope *NewScopeInPool(MemoryPool *);
|
||||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||||
void PushScope(Scope *fScope);
|
void PushScope(Scope *fScope);
|
||||||
Scope *PopScope(void);
|
Scope *PopScope(void);
|
||||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||||
void CPPErrorToInfoLog(char *);
|
void CPPErrorToInfoLog(char *);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(__SYMBOLS_H) */
|
#endif /* !defined(__SYMBOLS_H) */
|
||||||
|
|
||||||
|
|
|
@ -1,464 +1,462 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// tokens.c
|
/* tokens.c */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "slglobals.h"
|
#include "slglobals.h"
|
||||||
|
|
||||||
#include "slang_mesa.h"
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
|
/*////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// */
|
||||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
/*
|
||||||
|
* idstr()
|
||||||
/*
|
* Copy a string to a malloc'ed block and convert it into something suitable
|
||||||
* idstr()
|
* for an ID
|
||||||
* Copy a string to a malloc'ed block and convert it into something suitable
|
*
|
||||||
* for an ID
|
*/
|
||||||
*
|
|
||||||
*/
|
static char *idstr(const char *fstr)
|
||||||
|
{
|
||||||
static char *idstr(const char *fstr)
|
size_t len;
|
||||||
{
|
char *str, *t;
|
||||||
size_t len;
|
const char *f;
|
||||||
char *str, *t;
|
|
||||||
const char *f;
|
len = strlen(fstr);
|
||||||
|
str = (char *) malloc(len + 1);
|
||||||
len = strlen(fstr);
|
for (f=fstr, t=str; *f; f++) {
|
||||||
str = (char *) malloc(len + 1);
|
if (isalnum(*f)) *t++ = *f;
|
||||||
for (f=fstr, t=str; *f; f++) {
|
else if (*f == '.' || *f == '/') *t++ = '_';
|
||||||
if (_mesa_isalnum(*f)) *t++ = *f;
|
}
|
||||||
else if (*f == '.' || *f == '/') *t++ = '_';
|
*t = 0;
|
||||||
}
|
return str;
|
||||||
*t = 0;
|
|
||||||
return str;
|
|
||||||
} /* idstr */
|
} /* idstr */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lNewBlock()
|
* lNewBlock()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static TokenBlock *lNewBlock(TokenStream *fTok)
|
static TokenBlock *lNewBlock(TokenStream *fTok)
|
||||||
{
|
{
|
||||||
TokenBlock *lBlock;
|
TokenBlock *lBlock;
|
||||||
|
|
||||||
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
||||||
lBlock->count = 0;
|
lBlock->count = 0;
|
||||||
lBlock->current = 0;
|
lBlock->current = 0;
|
||||||
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
||||||
lBlock->max = 256;
|
lBlock->max = 256;
|
||||||
lBlock->next = NULL;
|
lBlock->next = NULL;
|
||||||
if (fTok->head) {
|
if (fTok->head) {
|
||||||
fTok->current->next = lBlock;
|
fTok->current->next = lBlock;
|
||||||
} else {
|
} else {
|
||||||
fTok->head = lBlock;
|
fTok->head = lBlock;
|
||||||
}
|
}
|
||||||
fTok->current = lBlock;
|
fTok->current = lBlock;
|
||||||
return lBlock;
|
return lBlock;
|
||||||
} /* lNewBlock */
|
} /* lNewBlock */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lAddByte()
|
* lAddByte()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
||||||
{
|
{
|
||||||
TokenBlock *lBlock;
|
TokenBlock *lBlock;
|
||||||
lBlock = fTok->current;
|
lBlock = fTok->current;
|
||||||
if (lBlock->count >= lBlock->max)
|
if (lBlock->count >= lBlock->max)
|
||||||
lBlock = lNewBlock(fTok);
|
lBlock = lNewBlock(fTok);
|
||||||
lBlock->data[lBlock->count++] = fVal;
|
lBlock->data[lBlock->count++] = fVal;
|
||||||
} /* lAddByte */
|
} /* lAddByte */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lReadByte() - Get the next byte from a stream.
|
* lReadByte() - Get the next byte from a stream.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int lReadByte(TokenStream *pTok)
|
static int lReadByte(TokenStream *pTok)
|
||||||
{
|
{
|
||||||
TokenBlock *lBlock;
|
TokenBlock *lBlock;
|
||||||
int lval = -1;
|
int lval = -1;
|
||||||
|
|
||||||
lBlock = pTok->current;
|
lBlock = pTok->current;
|
||||||
if (lBlock) {
|
if (lBlock) {
|
||||||
if (lBlock->current >= lBlock->count) {
|
if (lBlock->current >= lBlock->count) {
|
||||||
lBlock = lBlock->next;
|
lBlock = lBlock->next;
|
||||||
if (lBlock)
|
if (lBlock)
|
||||||
lBlock->current = 0;
|
lBlock->current = 0;
|
||||||
pTok->current = lBlock;
|
pTok->current = lBlock;
|
||||||
}
|
}
|
||||||
if (lBlock)
|
if (lBlock)
|
||||||
lval = lBlock->data[lBlock->current++];
|
lval = lBlock->data[lBlock->current++];
|
||||||
}
|
}
|
||||||
return lval;
|
return lval;
|
||||||
} /* lReadByte */
|
} /* lReadByte */
|
||||||
|
|
||||||
/*///////////////////////////////////// Global Functions:////////////////////////////////////*/
|
/*///////////////////////////////////// Global Functions:////////////////////////////////////// */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NewTokenStream()
|
* NewTokenStream()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TokenStream *NewTokenStream(const char *name)
|
TokenStream *NewTokenStream(const char *name)
|
||||||
{
|
{
|
||||||
TokenStream *pTok;
|
TokenStream *pTok;
|
||||||
|
|
||||||
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
||||||
pTok->next = NULL;
|
pTok->next = NULL;
|
||||||
pTok->name = idstr(name);
|
pTok->name = idstr(name);
|
||||||
pTok->head = NULL;
|
pTok->head = NULL;
|
||||||
pTok->current = NULL;
|
pTok->current = NULL;
|
||||||
lNewBlock(pTok);
|
lNewBlock(pTok);
|
||||||
return pTok;
|
return pTok;
|
||||||
} /* NewTokenStream */
|
} /* NewTokenStream */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DeleteTokenStream()
|
* DeleteTokenStream()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void DeleteTokenStream(TokenStream *pTok)
|
void DeleteTokenStream(TokenStream *pTok)
|
||||||
{
|
{
|
||||||
TokenBlock *pBlock, *nBlock;
|
TokenBlock *pBlock, *nBlock;
|
||||||
|
|
||||||
if (pTok) {
|
if (pTok) {
|
||||||
pBlock = pTok->head;
|
pBlock = pTok->head;
|
||||||
while (pBlock) {
|
while (pBlock) {
|
||||||
nBlock = pBlock->next;
|
nBlock = pBlock->next;
|
||||||
free(pBlock);
|
free(pBlock);
|
||||||
pBlock = nBlock;
|
pBlock = nBlock;
|
||||||
}
|
}
|
||||||
if (pTok->name)
|
if (pTok->name)
|
||||||
free(pTok->name);
|
free(pTok->name);
|
||||||
free(pTok);
|
free(pTok);
|
||||||
}
|
}
|
||||||
} /* DeleteTokenStream */
|
} /* DeleteTokenStream */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
unsigned char *str=NULL;
|
unsigned char *str=NULL;
|
||||||
|
|
||||||
if (token > 256)
|
if (token > 256)
|
||||||
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
||||||
else
|
else
|
||||||
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case CPP_IDENTIFIER:
|
case CPP_IDENTIFIER:
|
||||||
case CPP_TYPEIDENTIFIER:
|
case CPP_TYPEIDENTIFIER:
|
||||||
case CPP_STRCONSTANT:
|
case CPP_STRCONSTANT:
|
||||||
s = GetAtomString(atable, yylvalpp->sc_ident);
|
s = GetAtomString(atable, yylvalpp->sc_ident);
|
||||||
while (*s)
|
while (*s)
|
||||||
lAddByte(pTok, (unsigned char) *s++);
|
lAddByte(pTok, (unsigned char) *s++);
|
||||||
lAddByte(pTok, 0);
|
lAddByte(pTok, 0);
|
||||||
break;
|
break;
|
||||||
case CPP_FLOATCONSTANT:
|
case CPP_FLOATCONSTANT:
|
||||||
case CPP_INTCONSTANT:
|
case CPP_INTCONSTANT:
|
||||||
str=yylvalpp->symbol_name;
|
str=yylvalpp->symbol_name;
|
||||||
while (*str){
|
while (*str){
|
||||||
lAddByte(pTok,(unsigned char) *str);
|
lAddByte(pTok,(unsigned char) *str);
|
||||||
*str++;
|
*str++;
|
||||||
}
|
}
|
||||||
lAddByte(pTok, 0);
|
lAddByte(pTok, 0);
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* RecordToken */
|
} /* RecordToken */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RewindTokenStream(TokenStream *pTok)
|
void RewindTokenStream(TokenStream *pTok)
|
||||||
{
|
{
|
||||||
if (pTok->head) {
|
if (pTok->head) {
|
||||||
pTok->current = pTok->head;
|
pTok->current = pTok->head;
|
||||||
pTok->current->current = 0;
|
pTok->current->current = 0;
|
||||||
}
|
}
|
||||||
} /* RewindTokenStream */
|
} /* RewindTokenStream */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ReadToken() - Read the next token from a stream.
|
* ReadToken() - Read the next token from a stream.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
||||||
{
|
{
|
||||||
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
||||||
char string_val[MAX_STRING_LEN + 1];
|
char string_val[MAX_STRING_LEN + 1];
|
||||||
int ltoken, len;
|
int ltoken, len;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
ltoken = lReadByte(pTok);
|
ltoken = lReadByte(pTok);
|
||||||
if (ltoken >= 0) {
|
if (ltoken >= 0) {
|
||||||
if (ltoken > 127)
|
if (ltoken > 127)
|
||||||
ltoken += 128;
|
ltoken += 128;
|
||||||
switch (ltoken) {
|
switch (ltoken) {
|
||||||
case CPP_IDENTIFIER:
|
case CPP_IDENTIFIER:
|
||||||
case CPP_TYPEIDENTIFIER:
|
case CPP_TYPEIDENTIFIER:
|
||||||
len = 0;
|
len = 0;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
while ((ch >= 'a' && ch <= 'z') ||
|
while ((ch >= 'a' && ch <= 'z') ||
|
||||||
(ch >= 'A' && ch <= 'Z') ||
|
(ch >= 'A' && ch <= 'Z') ||
|
||||||
(ch >= '0' && ch <= '9') ||
|
(ch >= '0' && ch <= '9') ||
|
||||||
ch == '_')
|
ch == '_')
|
||||||
{
|
{
|
||||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||||
symbol_name[len] = ch;
|
symbol_name[len] = ch;
|
||||||
len++;
|
len++;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
symbol_name[len] = '\0';
|
symbol_name[len] = '\0';
|
||||||
assert(ch == '\0');
|
assert(ch == '\0');
|
||||||
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
||||||
return CPP_IDENTIFIER;
|
return CPP_IDENTIFIER;
|
||||||
break;
|
break;
|
||||||
case CPP_STRCONSTANT:
|
case CPP_STRCONSTANT:
|
||||||
len = 0;
|
len = 0;
|
||||||
while ((ch = lReadByte(pTok)) != 0)
|
while ((ch = lReadByte(pTok)) != 0)
|
||||||
if (len < MAX_STRING_LEN)
|
if (len < MAX_STRING_LEN)
|
||||||
string_val[len++] = ch;
|
string_val[len++] = ch;
|
||||||
string_val[len] = 0;
|
string_val[len] = 0;
|
||||||
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
||||||
break;
|
break;
|
||||||
case CPP_FLOATCONSTANT:
|
case CPP_FLOATCONSTANT:
|
||||||
len = 0;
|
len = 0;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
||||||
{
|
{
|
||||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||||
symbol_name[len] = ch;
|
symbol_name[len] = ch;
|
||||||
len++;
|
len++;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
symbol_name[len] = '\0';
|
symbol_name[len] = '\0';
|
||||||
assert(ch == '\0');
|
assert(ch == '\0');
|
||||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||||
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
||||||
break;
|
break;
|
||||||
case CPP_INTCONSTANT:
|
case CPP_INTCONSTANT:
|
||||||
len = 0;
|
len = 0;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
while ((ch >= '0' && ch <= '9'))
|
while ((ch >= '0' && ch <= '9'))
|
||||||
{
|
{
|
||||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||||
symbol_name[len] = ch;
|
symbol_name[len] = ch;
|
||||||
len++;
|
len++;
|
||||||
ch = lReadByte(pTok);
|
ch = lReadByte(pTok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
symbol_name[len] = '\0';
|
symbol_name[len] = '\0';
|
||||||
assert(ch == '\0');
|
assert(ch == '\0');
|
||||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||||
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
yylvalpp->sc_int = lReadByte(pTok);
|
yylvalpp->sc_int = lReadByte(pTok);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ltoken;
|
return ltoken;
|
||||||
}
|
}
|
||||||
return EOF_SY;
|
return EOF_SY;
|
||||||
} /* ReadToken */
|
} /* ReadToken */
|
||||||
|
|
||||||
typedef struct TokenInputSrc {
|
typedef struct TokenInputSrc {
|
||||||
InputSrc base;
|
InputSrc base;
|
||||||
TokenStream *tokens;
|
TokenStream *tokens;
|
||||||
int (*final)(CPPStruct *);
|
int (*final)(CPPStruct *);
|
||||||
} TokenInputSrc;
|
} TokenInputSrc;
|
||||||
|
|
||||||
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
||||||
{
|
{
|
||||||
int token = ReadToken(in->tokens, yylvalpp);
|
int token = ReadToken(in->tokens, yylvalpp);
|
||||||
int (*final)(CPPStruct *);
|
int (*final)(CPPStruct *);
|
||||||
cpp->tokenLoc->file = cpp->currentInput->name;
|
cpp->tokenLoc->file = cpp->currentInput->name;
|
||||||
cpp->tokenLoc->line = cpp->currentInput->line;
|
cpp->tokenLoc->line = cpp->currentInput->line;
|
||||||
if (token == '\n') {
|
if (token == '\n') {
|
||||||
in->base.line++;
|
in->base.line++;
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
if (token > 0) return token;
|
if (token > 0) return token;
|
||||||
cpp->currentInput = in->base.prev;
|
cpp->currentInput = in->base.prev;
|
||||||
final = in->final;
|
final = in->final;
|
||||||
free(in);
|
free(in);
|
||||||
if (final && !final(cpp)) return -1;
|
if (final && !final(cpp)) return -1;
|
||||||
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
||||||
{
|
{
|
||||||
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
||||||
memset(in, 0, sizeof(TokenInputSrc));
|
memset(in, 0, sizeof(TokenInputSrc));
|
||||||
in->base.name = name;
|
in->base.name = name;
|
||||||
in->base.prev = cpp->currentInput;
|
in->base.prev = cpp->currentInput;
|
||||||
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
||||||
in->base.line = 1;
|
in->base.line = 1;
|
||||||
in->tokens = ts;
|
in->tokens = ts;
|
||||||
in->final = final;
|
in->final = final;
|
||||||
RewindTokenStream(ts);
|
RewindTokenStream(ts);
|
||||||
cpp->currentInput = &in->base;
|
cpp->currentInput = &in->base;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct UngotToken {
|
typedef struct UngotToken {
|
||||||
InputSrc base;
|
InputSrc base;
|
||||||
int token;
|
int token;
|
||||||
yystypepp lval;
|
yystypepp lval;
|
||||||
} UngotToken;
|
} UngotToken;
|
||||||
|
|
||||||
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
||||||
{
|
{
|
||||||
int token = t->token;
|
int token = t->token;
|
||||||
*yylvalpp = t->lval;
|
*yylvalpp = t->lval;
|
||||||
cpp->currentInput = t->base.prev;
|
cpp->currentInput = t->base.prev;
|
||||||
free(t);
|
free(t);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UngetToken(int token, yystypepp * yylvalpp) {
|
void UngetToken(int token, yystypepp * yylvalpp) {
|
||||||
UngotToken *t = malloc(sizeof(UngotToken));
|
UngotToken *t = malloc(sizeof(UngotToken));
|
||||||
memset(t, 0, sizeof(UngotToken));
|
memset(t, 0, sizeof(UngotToken));
|
||||||
t->token = token;
|
t->token = token;
|
||||||
t->lval = *yylvalpp;
|
t->lval = *yylvalpp;
|
||||||
t->base.scan = (void *)reget_token;
|
t->base.scan = (void *)reget_token;
|
||||||
t->base.prev = cpp->currentInput;
|
t->base.prev = cpp->currentInput;
|
||||||
t->base.name = cpp->currentInput->name;
|
t->base.name = cpp->currentInput->name;
|
||||||
t->base.line = cpp->currentInput->line;
|
t->base.line = cpp->currentInput->line;
|
||||||
cpp->currentInput = &t->base;
|
cpp->currentInput = &t->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
||||||
int token;
|
int token;
|
||||||
char str[100];
|
char str[100];
|
||||||
|
|
||||||
if (fp == 0) fp = stdout;
|
if (fp == 0) fp = stdout;
|
||||||
RewindTokenStream(s);
|
RewindTokenStream(s);
|
||||||
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case CPP_IDENTIFIER:
|
case CPP_IDENTIFIER:
|
||||||
case CPP_TYPEIDENTIFIER:
|
case CPP_TYPEIDENTIFIER:
|
||||||
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
||||||
break;
|
break;
|
||||||
case CPP_STRCONSTANT:
|
case CPP_STRCONSTANT:
|
||||||
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
||||||
break;
|
break;
|
||||||
case CPP_FLOATCONSTANT:
|
case CPP_FLOATCONSTANT:
|
||||||
/*printf("%g9.6 ", yylvalpp->sc_fval);*/
|
/*printf("%g9.6 ", yylvalpp->sc_fval); */
|
||||||
break;
|
break;
|
||||||
case CPP_INTCONSTANT:
|
case CPP_INTCONSTANT:
|
||||||
/*printf("%d ", yylvalpp->sc_int);*/
|
/*printf("%d ", yylvalpp->sc_int); */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (token >= 127)
|
if (token >= 127)
|
||||||
sprintf(str, "%s ", GetAtomString(atable, token));
|
sprintf(str, "%s ", GetAtomString(atable, token));
|
||||||
else
|
else
|
||||||
sprintf(str, "%c", token);
|
sprintf(str, "%c", token);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CPPDebugLogMsg(str);
|
CPPDebugLogMsg(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
|
/*///////////////////////////////////// End of tokens.c /////////////////////////////////////// */
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
/*///////////////////////////////////////////////////////////////////////////////////////////// */
|
||||||
|
|
|
@ -1,122 +1,122 @@
|
||||||
/*
|
/* */
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
|
||||||
//All rights reserved.
|
/*All rights reserved. */
|
||||||
//
|
/* */
|
||||||
//Redistribution and use in source and binary forms, with or without
|
/*Redistribution and use in source and binary forms, with or without */
|
||||||
//modification, are permitted provided that the following conditions
|
/*modification, are permitted provided that the following conditions */
|
||||||
//are met:
|
/*are met: */
|
||||||
//
|
/* */
|
||||||
// Redistributions of source code must retain the above copyright
|
/* Redistributions of source code must retain the above copyright */
|
||||||
// notice, this list of conditions and the following disclaimer.
|
/* notice, this list of conditions and the following disclaimer. */
|
||||||
//
|
/* */
|
||||||
// Redistributions in binary form must reproduce the above
|
/* Redistributions in binary form must reproduce the above */
|
||||||
// copyright notice, this list of conditions and the following
|
/* copyright notice, this list of conditions and the following */
|
||||||
// disclaimer in the documentation and/or other materials provided
|
/* disclaimer in the documentation and/or other materials provided */
|
||||||
// with the distribution.
|
/* with the distribution. */
|
||||||
//
|
/* */
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
|
||||||
// contributors may be used to endorse or promote products derived
|
/* contributors may be used to endorse or promote products derived */
|
||||||
// from this software without specific prior written permission.
|
/* from this software without specific prior written permission. */
|
||||||
//
|
/* */
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
/*POSSIBILITY OF SUCH DAMAGE. */
|
||||||
*/
|
/* */
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
Copyright (c) 2002, NVIDIA Corporation.
|
Copyright (c) 2002, NVIDIA Corporation.
|
||||||
|
|
||||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||||
consideration of your agreement to the following terms, and your use,
|
consideration of your agreement to the following terms, and your use,
|
||||||
installation, modification or redistribution of this NVIDIA software
|
installation, modification or redistribution of this NVIDIA software
|
||||||
constitutes acceptance of these terms. If you do not agree with these
|
constitutes acceptance of these terms. If you do not agree with these
|
||||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||||
software.
|
software.
|
||||||
|
|
||||||
In consideration of your agreement to abide by the following terms, and
|
In consideration of your agreement to abide by the following terms, and
|
||||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||||
NVIDIA Software, with or without modifications, in source and/or binary
|
NVIDIA Software, with or without modifications, in source and/or binary
|
||||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||||
retain the copyright notice of NVIDIA, this notice and the following
|
retain the copyright notice of NVIDIA, this notice and the following
|
||||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||||
Corporation may be used to endorse or promote products derived from the
|
Corporation may be used to endorse or promote products derived from the
|
||||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||||
Except as expressly stated in this notice, no other rights or licenses
|
Except as expressly stated in this notice, no other rights or licenses
|
||||||
express or implied, are granted by NVIDIA herein, including but not
|
express or implied, are granted by NVIDIA herein, including but not
|
||||||
limited to any patent rights that may be infringed by your derivative
|
limited to any patent rights that may be infringed by your derivative
|
||||||
works or by other works in which the NVIDIA Software may be
|
works or by other works in which the NVIDIA Software may be
|
||||||
incorporated. No hardware is licensed hereunder.
|
incorporated. No hardware is licensed hereunder.
|
||||||
|
|
||||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||||
PRODUCTS.
|
PRODUCTS.
|
||||||
|
|
||||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
/*
|
/* */
|
||||||
// tokens.h
|
/* tokens.h */
|
||||||
*/
|
/* */
|
||||||
|
|
||||||
#if !defined(__TOKENS_H)
|
#if !defined(__TOKENS_H)
|
||||||
#define __TOKENS_H 1
|
#define __TOKENS_H 1
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
#define EOF_SY (-1)
|
#define EOF_SY (-1)
|
||||||
|
|
||||||
typedef struct TokenBlock_Rec TokenBlock;
|
typedef struct TokenBlock_Rec TokenBlock;
|
||||||
|
|
||||||
typedef struct TokenStream_Rec {
|
typedef struct TokenStream_Rec {
|
||||||
struct TokenStream_Rec *next;
|
struct TokenStream_Rec *next;
|
||||||
char *name;
|
char *name;
|
||||||
TokenBlock *head;
|
TokenBlock *head;
|
||||||
TokenBlock *current;
|
TokenBlock *current;
|
||||||
} TokenStream;
|
} TokenStream;
|
||||||
|
|
||||||
struct TokenBlock_Rec {
|
struct TokenBlock_Rec {
|
||||||
TokenBlock *next;
|
TokenBlock *next;
|
||||||
int current;
|
int current;
|
||||||
int count;
|
int count;
|
||||||
int max;
|
int max;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TokenStream stdlib_cpp_stream;
|
extern TokenStream stdlib_cpp_stream;
|
||||||
|
|
||||||
|
|
||||||
TokenStream *NewTokenStream(const char *name);
|
TokenStream *NewTokenStream(const char *name);
|
||||||
void DeleteTokenStream(TokenStream *pTok);
|
void DeleteTokenStream(TokenStream *pTok);
|
||||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||||
void RewindTokenStream(TokenStream *pTok);
|
void RewindTokenStream(TokenStream *pTok);
|
||||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||||
void UngetToken(int, yystypepp * yylvalpp);
|
void UngetToken(int, yystypepp * yylvalpp);
|
||||||
|
|
||||||
#if defined(CPPC_ENABLE_TOOLS)
|
#if defined(CPPC_ENABLE_TOOLS)
|
||||||
|
|
||||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||||
|
|
||||||
#endif /* defined(CPPC_ENABLE_TOOLS) */
|
#endif /* defined(CPPC_ENABLE_TOOLS) */
|
||||||
|
|
||||||
#endif /* !defined(__TOKENS_H) */
|
#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.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,73 +1,78 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
//modification, are permitted provided that the following conditions
|
//modification, are permitted provided that the following conditions
|
||||||
//are met:
|
//are met:
|
||||||
//
|
//
|
||||||
// Redistributions of source code must retain the above copyright
|
// Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// Redistributions in binary form must reproduce the above
|
// Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following
|
// copyright notice, this list of conditions and the following
|
||||||
// disclaimer in the documentation and/or other materials provided
|
// disclaimer in the documentation and/or other materials provided
|
||||||
// with the distribution.
|
// with the distribution.
|
||||||
//
|
//
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||||
// contributors may be used to endorse or promote products derived
|
// contributors may be used to endorse or promote products derived
|
||||||
// from this software without specific prior written permission.
|
// from this software without specific prior written permission.
|
||||||
//
|
//
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __OSINCLUDE_H
|
#ifndef __OSINCLUDE_H
|
||||||
#define __OSINCLUDE_H
|
#define __OSINCLUDE_H
|
||||||
|
|
||||||
//
|
//
|
||||||
// This file contains any Linux specific functions.
|
// This file contains any Linux specific functions.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <pthread.h>
|
/* WORKAROUND: linux builds seem not to define "linux" */
|
||||||
#include <semaphore.h>
|
/*#if !(defined(linux))
|
||||||
#include <assert.h>
|
#error Trying to include a Linux specific file in a non-Linux build.
|
||||||
#include <errno.h>
|
#endif*/
|
||||||
#include "Include/InitializeGlobals.h"
|
|
||||||
#include "Include/PoolAlloc.h"
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
#define _vsnprintf vsnprintf
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
void DetachThreadLinux(void *);
|
#include "Include/InitializeGlobals.h"
|
||||||
|
#include "Include/PoolAlloc.h"
|
||||||
//
|
|
||||||
// Thread Local Storage Operations
|
#define _vsnprintf vsnprintf
|
||||||
//
|
|
||||||
typedef unsigned int OS_TLSIndex;
|
void DetachThreadLinux(void *);
|
||||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
|
||||||
|
//
|
||||||
OS_TLSIndex OS_AllocTLSIndex();
|
// Thread Local Storage Operations
|
||||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
//
|
||||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
typedef unsigned int OS_TLSIndex;
|
||||||
|
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||||
|
|
||||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
OS_TLSIndex OS_AllocTLSIndex();
|
||||||
{
|
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||||
//
|
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||||
// This function should return 0 if nIndex is invalid.
|
|
||||||
//
|
|
||||||
assert(nIndex != OS_INVALID_TLS_INDEX);
|
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||||
return (pthread_getspecific(nIndex));
|
{
|
||||||
}
|
//
|
||||||
|
// This function should return 0 if nIndex is invalid.
|
||||||
#endif // __OSINCLUDE_H
|
//
|
||||||
|
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.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -38,9 +38,9 @@
|
||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
#include "Initialisation.h"
|
#include "Initialisation.h"
|
||||||
|
|
||||||
#if !(defined(linux))
|
/*#if !(defined(linux))
|
||||||
#error Trying to build a Linux specific file in a non-Linux build.
|
#error Trying to build a Linux specific file in a non-Linux build.
|
||||||
#endif
|
#endif*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Thread cleanup
|
// Thread cleanup
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
#error Trying to include a windows specific file in a non windows build.
|
#error Trying to include a windows specific file in a non windows build.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STRICT 1
|
#define STRICT
|
||||||
#define VC_EXTRALEAN 1
|
#define VC_EXTRALEAN 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -42,11 +42,7 @@
|
||||||
#error Trying to build a windows specific file in a non windows build.
|
#error Trying to build a windows specific file in a non windows build.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
// disable DllMain on Mesa-3D builds, call appropriate Init* and Detach*
|
|
||||||
// routines manually in context initialization
|
|
||||||
//
|
|
||||||
/*BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
||||||
{
|
{
|
||||||
switch (fdwReason)
|
switch (fdwReason)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +72,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Thread Local Storage Operations
|
// Thread Local Storage Operations
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
//
|
||||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
//
|
//
|
||||||
//Redistribution and use in source and binary forms, with or without
|
//Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -30,69 +30,47 @@
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
//
|
||||||
#ifndef _COMPILER_INTERFACE_INCLUDED_
|
#ifndef _COMPILER_INTERFACE_INCLUDED_
|
||||||
#define _COMPILER_INTERFACE_INCLUDED_
|
#define _COMPILER_INTERFACE_INCLUDED_
|
||||||
|
|
||||||
|
#include "../Include/ResourceLimits.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define C_DECL __cdecl
|
#define C_DECL __cdecl
|
||||||
#define SH_IMPORT_EXPORT
|
#ifdef SH_EXPORTING
|
||||||
|
#define SH_IMPORT_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define SH_IMPORT_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SH_IMPORT_EXPORT
|
#define SH_IMPORT_EXPORT
|
||||||
#define __fastcall
|
#define __fastcall
|
||||||
#define C_DECL
|
#define C_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
//
|
||||||
// This is the platform independent interface between an OGL driver
|
// This is the platform independent interface between an OGL driver
|
||||||
// and the shading language compiler/linker.
|
// and the shading language compiler/linker.
|
||||||
*/
|
//
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Driver must call this first, once, before doing any other
|
// Driver must call this first, once, before doing any other
|
||||||
// compiler/linker operations.
|
// compiler/linker operations.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int ShInitialize();
|
SH_IMPORT_EXPORT int ShInitialize();
|
||||||
/*
|
//
|
||||||
// Driver should call this at shutdown.
|
// Driver should call this at shutdown.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int __fastcall ShFinalize();
|
SH_IMPORT_EXPORT int __fastcall ShFinalize();
|
||||||
/*
|
|
||||||
// to be used for hardwareDataType and userDataType by ICD
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
EFloat,
|
|
||||||
EInt,
|
|
||||||
EBool,
|
|
||||||
EFloat_Vec2,
|
|
||||||
EFloat_Vec3,
|
|
||||||
EFloat_Vec4,
|
|
||||||
EInt_Vec2,
|
|
||||||
EInt_Vec3,
|
|
||||||
EInt_Vec4,
|
|
||||||
EBool_Vec2,
|
|
||||||
EBool_Vec3,
|
|
||||||
EBool_Vec4,
|
|
||||||
EFloat_Mat2,
|
|
||||||
EFloat_Mat3,
|
|
||||||
EFloat_Mat4,
|
|
||||||
ESampler_1D,
|
|
||||||
ESampler_2D,
|
|
||||||
ESampler_3D,
|
|
||||||
ESampler_Cube,
|
|
||||||
ESampler_1D_Shadow,
|
|
||||||
ESampler_2D_Shadow,
|
|
||||||
EStruct
|
|
||||||
} ShBasicType;
|
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Types of languages the compiler can consume.
|
// Types of languages the compiler can consume.
|
||||||
*/
|
//
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EShLangVertex,
|
EShLangVertex,
|
||||||
EShLangFragment,
|
EShLangFragment,
|
||||||
|
@ -101,9 +79,9 @@ typedef enum {
|
||||||
EShLangCount
|
EShLangCount
|
||||||
} EShLanguage;
|
} EShLanguage;
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Types of output the linker will create.
|
// Types of output the linker will create.
|
||||||
*/
|
//
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EShExVertexFragment,
|
EShExVertexFragment,
|
||||||
EShExPackFragment,
|
EShExPackFragment,
|
||||||
|
@ -111,20 +89,20 @@ typedef enum {
|
||||||
EShExFragment
|
EShExFragment
|
||||||
} EShExecutable;
|
} EShExecutable;
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Optimization level for the compiler.
|
// Optimization level for the compiler.
|
||||||
*/
|
//
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EShOptNoGeneration,
|
EShOptNoGeneration,
|
||||||
EShOptNone,
|
EShOptNone,
|
||||||
EShOptSimple, /* Optimizations that can be done quickly */
|
EShOptSimple, // Optimizations that can be done quickly
|
||||||
EShOptFull /* Optimizations that will take more time */
|
EShOptFull // Optimizations that will take more time
|
||||||
} EShOptimizationLevel;
|
} EShOptimizationLevel;
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Build a table for bindings. This can be used for locating
|
// Build a table for bindings. This can be used for locating
|
||||||
// attributes, uniforms, globals, etc., as needed.
|
// attributes, uniforms, globals, etc., as needed.
|
||||||
*/
|
//
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
char* name;
|
||||||
int binding;
|
int binding;
|
||||||
|
@ -132,10 +110,10 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int numBindings;
|
int numBindings;
|
||||||
ShBinding* bindings; /* array of bindings */
|
ShBinding* bindings; // array of bindings
|
||||||
} ShBindingTable;
|
} ShBindingTable;
|
||||||
|
|
||||||
/*
|
//
|
||||||
// ShHandle held by but opaque to the driver. It is allocated,
|
// ShHandle held by but opaque to the driver. It is allocated,
|
||||||
// managed, and de-allocated by the compiler/linker. It's contents
|
// managed, and de-allocated by the compiler/linker. It's contents
|
||||||
// are defined by and used by the compiler and linker. For example,
|
// are defined by and used by the compiler and linker. For example,
|
||||||
|
@ -143,79 +121,79 @@ typedef struct {
|
||||||
// to the linker can be stored where ShHandle points.
|
// to the linker can be stored where ShHandle points.
|
||||||
//
|
//
|
||||||
// If handle creation fails, 0 will be returned.
|
// If handle creation fails, 0 will be returned.
|
||||||
*/
|
//
|
||||||
typedef void* ShHandle;
|
typedef void* ShHandle;
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Driver calls these to create and destroy compiler/linker
|
// Driver calls these to create and destroy compiler/linker
|
||||||
// objects.
|
// objects.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); /* one per shader */
|
SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); // one per shader
|
||||||
SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); /* one per shader pair */
|
SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair
|
||||||
SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */
|
SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
|
||||||
SH_IMPORT_EXPORT void ShDestruct(ShHandle);
|
SH_IMPORT_EXPORT void ShDestruct(ShHandle);
|
||||||
|
|
||||||
/*
|
//
|
||||||
// The return value of ShCompile is boolean, indicating
|
// The return value of ShCompile is boolean, indicating
|
||||||
// success or failure.
|
// success or failure.
|
||||||
//
|
//
|
||||||
// The info-log should be written by ShCompile into
|
// The info-log should be written by ShCompile into
|
||||||
// ShHandle, so it can answer future queries.
|
// ShHandle, so it can answer future queries.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int ShCompile(
|
SH_IMPORT_EXPORT int ShCompile(
|
||||||
const ShHandle,
|
const ShHandle,
|
||||||
const char* const shaderStrings[],
|
const char* const shaderStrings[],
|
||||||
const int numStrings,
|
const int numStrings,
|
||||||
const EShOptimizationLevel,
|
const EShOptimizationLevel,
|
||||||
|
const TBuiltInResource *resources,
|
||||||
int debugOptions
|
int debugOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Similar to ShCompile, but accepts an opaque handle to an
|
// Similar to ShCompile, but accepts an opaque handle to an
|
||||||
// intermediate language structure.
|
// intermediate language structure.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int ShCompileIntermediate(
|
SH_IMPORT_EXPORT int ShCompileIntermediate(
|
||||||
ShHandle compiler,
|
ShHandle compiler,
|
||||||
ShHandle intermediate,
|
ShHandle intermediate,
|
||||||
const EShOptimizationLevel,
|
const EShOptimizationLevel,
|
||||||
int debuggable /* boolean */
|
int debuggable // boolean
|
||||||
);
|
);
|
||||||
|
|
||||||
SH_IMPORT_EXPORT int ShLink(
|
SH_IMPORT_EXPORT int ShLink(
|
||||||
const ShHandle, /* linker object */
|
const ShHandle, // linker object
|
||||||
const ShHandle h[], /* compiler objects to link together */
|
const ShHandle h[], // compiler objects to link together
|
||||||
const int numHandles,
|
const int numHandles,
|
||||||
ShHandle uniformMap, /* updated with new uniforms */
|
ShHandle uniformMap, // updated with new uniforms
|
||||||
short int** uniformsAccessed, /* returned with indexes of uniforms accessed */
|
short int** uniformsAccessed, // returned with indexes of uniforms accessed
|
||||||
int* numUniformsAccessed);
|
int* numUniformsAccessed);
|
||||||
|
|
||||||
/*
|
//
|
||||||
// ShSetEncrpytionMethod is a place-holder for specifying
|
// ShSetEncrpytionMethod is a place-holder for specifying
|
||||||
// how source code is encrypted.
|
// how source code is encrypted.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);
|
SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);
|
||||||
|
|
||||||
/*
|
//
|
||||||
// All the following return 0 if the information is not
|
// All the following return 0 if the information is not
|
||||||
// available in the object passed down, or the object is bad.
|
// available in the object passed down, or the object is bad.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle);
|
SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle);
|
||||||
SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle);
|
SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle);
|
||||||
SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); /* to detect user aliasing */
|
SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); // to detect user aliasing
|
||||||
SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); /* to force any physical mappings */
|
SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); // to force any physical mappings
|
||||||
SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); /* for all attributes */
|
SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); // for all attributes
|
||||||
/*
|
//
|
||||||
// Tell the linker to never assign a vertex attribute to this list of physical attributes
|
// Tell the linker to never assign a vertex attribute to this list of physical attributes
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);
|
SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);
|
||||||
|
|
||||||
/*
|
//
|
||||||
// Returns the location ID of the named uniform.
|
// Returns the location ID of the named uniform.
|
||||||
// Returns -1 if error.
|
// Returns -1 if error.
|
||||||
*/
|
//
|
||||||
SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
|
SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
|
||||||
SH_IMPORT_EXPORT char* ShGetUniformName(const ShHandle linker, int virtualLocation);
|
|
||||||
|
|
||||||
enum TDebugOptions {
|
enum TDebugOptions {
|
||||||
EDebugOpNone = 0x000,
|
EDebugOpNone = 0x000,
|
||||||
|
@ -229,4 +207,4 @@ enum TDebugOptions {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _COMPILER_INTERFACE_INCLUDED_ */
|
#endif // _COMPILER_INTERFACE_INCLUDED_
|
||||||
|
|
|
@ -45,143 +45,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
EReserved = 0,
|
|
||||||
EFixed,
|
|
||||||
ERecommended,
|
|
||||||
EFloating
|
|
||||||
} ShPriority;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ESymbol = 0,
|
|
||||||
EFloatConst,
|
|
||||||
EFloatConstPtr,
|
|
||||||
EIntConst,
|
|
||||||
EIntConstPtr,
|
|
||||||
EBoolConst,
|
|
||||||
EBoolConstPtr
|
|
||||||
} ShDataType;
|
|
||||||
|
|
||||||
// this definition will eventually go once we move to the new linker interface in the driver
|
|
||||||
typedef enum {
|
|
||||||
EVirtualBinding,
|
|
||||||
EPhysicalBinding
|
|
||||||
} ShVirtualPhysicalBinding;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int size; // out - total physical size for the binding in floats - P10
|
|
||||||
int location; // in-out - virtualLocation for all cases
|
|
||||||
int functionPriority; // out - used for giving priorities to function bindings
|
|
||||||
int proEpilogue; // out - essentially a bool defining whether its a prologue/epilogue or not, 1 means it is
|
|
||||||
int builtInName; // out - basically a bool value, 0 means not a builtInName, 1 means its a builtInName
|
|
||||||
int arraySize; // out - size of the array in units of its type - if the binding is for an array
|
|
||||||
ShPriority bindingPriority; // in-out - EFixed, ERecommended, EFloating
|
|
||||||
ShDataType bindingDataType; // in-out - whether its a symbol name or a constant value
|
|
||||||
ShBasicType hardwareDataType; // out - bool are loaded as floats on the hardware
|
|
||||||
ShBasicType userDataType; // out - mat3 -> mat3, ivec2 -> ivec2, vec2 -> vec2
|
|
||||||
ShBasicType basicUserType; // out - mat3 -> float, ivec2 ->int, vec2 -> float
|
|
||||||
int sizeOfType; // out - for vec3 -> 3, for float -> 1, for mat3 -> 3, mat3[10] -> 3
|
|
||||||
int matrix; // out - essentially a boolean, 0 means vector, 1 means matrix
|
|
||||||
union { // in-out
|
|
||||||
char* name;
|
|
||||||
float floatVal;
|
|
||||||
float* floatValPtr;
|
|
||||||
int intVal;
|
|
||||||
int* intValPtr;
|
|
||||||
};
|
|
||||||
// A pointer to ShP10PhysicalBinding or ShP20PhysicalBinding
|
|
||||||
void* targetDependentData; // in-out
|
|
||||||
} ShBindingExt;
|
|
||||||
|
|
||||||
//
|
|
||||||
// to specify the type of binding
|
|
||||||
//
|
|
||||||
typedef enum {
|
|
||||||
EAttribute,
|
|
||||||
EUniform,
|
|
||||||
EVarying,
|
|
||||||
EFunction,
|
|
||||||
EConstant,
|
|
||||||
EFunctionRelocation,
|
|
||||||
EArbVertexLocal,
|
|
||||||
EArbVertexEnv,
|
|
||||||
EArbFragmentLocal,
|
|
||||||
EArbFragmentEnv,
|
|
||||||
EState,
|
|
||||||
ENoBindingType } ShBindingType;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
// a pointer to ShBindingExt
|
|
||||||
ShBindingExt* pBinding;
|
|
||||||
int numOfBindings;
|
|
||||||
ShBindingType type;
|
|
||||||
} ShBindingTableExt;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ShBindingTableExt *bindingTable;
|
|
||||||
int numOfBindingTables;
|
|
||||||
} ShBindingList;
|
|
||||||
|
|
||||||
SH_IMPORT_EXPORT ShHandle ShConstructBindings();
|
|
||||||
SH_IMPORT_EXPORT ShHandle ShConstructLibrary();
|
|
||||||
|
|
||||||
SH_IMPORT_EXPORT ShHandle ShAddBinding(ShHandle bindingHandle,
|
|
||||||
ShBindingExt* binding,
|
|
||||||
ShBindingType type);
|
|
||||||
SH_IMPORT_EXPORT ShHandle ShAddBindingTable(ShHandle bindingHandle,
|
|
||||||
ShBindingTableExt *bindingTable,
|
|
||||||
ShBindingType type);
|
|
||||||
|
|
||||||
SH_IMPORT_EXPORT int ShLinkExt(
|
SH_IMPORT_EXPORT int ShLinkExt(
|
||||||
const ShHandle, // linker object
|
const ShHandle, // linker object
|
||||||
const ShHandle h[], // compiler objects to link together
|
const ShHandle h[], // compiler objects to link together
|
||||||
const int numHandles);
|
const int numHandles);
|
||||||
|
|
||||||
SH_IMPORT_EXPORT ShBindingList* ShGetBindingList(const ShHandle linkerHandle);
|
|
||||||
SH_IMPORT_EXPORT ShBindingTableExt* ShGetBindingTable(const ShHandle linkerHandle, ShBindingType type);
|
|
||||||
SH_IMPORT_EXPORT int ShGetUniformLocationExt(const ShHandle linkerHandle, const char* name);
|
|
||||||
SH_IMPORT_EXPORT int ShSetFixedAttributeBindingsExt(const ShHandle, const ShBindingTableExt*);
|
|
||||||
SH_IMPORT_EXPORT int ShGetUniformLocationExt2(const ShHandle handle, const char* name, int* location, int* offset);
|
|
||||||
SH_IMPORT_EXPORT int ShSetVirtualLocation(const ShHandle handle, ShBindingType type, int bindingIndex, int virtualLocation);
|
|
||||||
SH_IMPORT_EXPORT int ShGetVirtualLocation(const ShHandle handle, ShBindingType type, int bindingIndex, int *virtualLocation);
|
|
||||||
//
|
|
||||||
// To get the bindings object from the linker object (after the link is done so that
|
|
||||||
// bindings can be added to the list)
|
|
||||||
//
|
|
||||||
SH_IMPORT_EXPORT ShHandle ShGetBindings(const ShHandle linkerHandle);
|
|
||||||
SH_IMPORT_EXPORT int ShAddLibraryCode(ShHandle library, const char* name, const ShHandle objectCodes[], const int numHandles);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
This code is used by the new shared linker
|
|
||||||
*****************************************************************************/
|
|
||||||
//
|
|
||||||
// Each programmable unit has a UnitExecutable. Targets may subclass
|
|
||||||
// and append to this as desired.
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
int name; // name of unit to which executable is targeted
|
|
||||||
int entry; // a target specific entry point
|
|
||||||
int count; // size of executable
|
|
||||||
const void* code; // read-only code
|
|
||||||
} ShUnitExecutable;
|
|
||||||
|
|
||||||
//
|
|
||||||
// The "void*" returned from ShGetExecutable() will be an ShExecutable
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
int count; // count of unit executables
|
|
||||||
ShUnitExecutable* executables;
|
|
||||||
} ShExecutable;
|
|
||||||
|
|
||||||
SH_IMPORT_EXPORT ShExecutable* ShGetExecutableExt(const ShHandle linkerHandle);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int numThread;
|
|
||||||
int stackSpacePerThread;
|
|
||||||
int visBufferValidity; // essenatially a boolean
|
|
||||||
int shaderFragTerminationStatus; // essentially a boolean
|
|
||||||
} ShDeviceInfo;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue