Put all glslang internals (but not the external interface) into the glslang namespace.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22882 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-08-29 00:39:25 +00:00
parent 23bdb29eac
commit b603f918a4
55 changed files with 511 additions and 463 deletions

View file

@ -37,6 +37,8 @@
#ifndef _BASICTYPES_INCLUDED_
#define _BASICTYPES_INCLUDED_
namespace glslang {
//
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
//
@ -97,7 +99,7 @@ enum TStorageQualifier {
};
// These will show up in error messages
__inline const char* getStorageQualifierString(TStorageQualifier q)
__inline const char* GetStorageQualifierString(TStorageQualifier q)
{
switch (q) {
case EvqTemporary: return "temporary"; break;
@ -133,7 +135,7 @@ enum TPrecisionQualifier {
EpqHigh
};
__inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
{
switch(p) {
case EpqNone: return ""; break;
@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
}
}
} // end namespace glslang
#endif // _BASICTYPES_INCLUDED_

View file

@ -85,6 +85,8 @@
#define TBaseList std::list
#define TBaseSet std::set
namespace glslang {
//
// Pool version of string.
//
@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
const int GlslangMaxTokenLength = 1024;
} // end namespace glslang
#endif // _COMMON_INCLUDED_

View file

@ -37,8 +37,9 @@
#ifndef _CONSTANT_UNION_INCLUDED_
#define _CONSTANT_UNION_INCLUDED_
namespace glslang {
class constUnion {
class TConstUnion {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@ -103,7 +104,7 @@ public:
return false;
}
bool operator==(const constUnion& constant) const
bool operator==(const TConstUnion& constant) const
{
if (constant.type != type)
return false;
@ -156,12 +157,12 @@ public:
return !operator==(b);
}
bool operator!=(const constUnion& constant) const
bool operator!=(const TConstUnion& constant) const
{
return !operator==(constant);
}
bool operator>(const constUnion& constant) const
bool operator>(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
@ -188,7 +189,7 @@ public:
return false;
}
bool operator<(const constUnion& constant) const
bool operator<(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
@ -215,9 +216,9 @@ public:
return false;
}
constUnion operator+(const constUnion& constant) const
TConstUnion operator+(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
@ -229,9 +230,9 @@ public:
return returnValue;
}
constUnion operator-(const constUnion& constant) const
TConstUnion operator-(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
@ -243,9 +244,9 @@ public:
return returnValue;
}
constUnion operator*(const constUnion& constant) const
TConstUnion operator*(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
@ -257,9 +258,9 @@ public:
return returnValue;
}
constUnion operator%(const constUnion& constant) const
TConstUnion operator%(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
@ -270,9 +271,9 @@ public:
return returnValue;
}
constUnion operator>>(const constUnion& constant) const
TConstUnion operator>>(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt:
switch (constant.type) {
@ -294,9 +295,9 @@ public:
return returnValue;
}
constUnion operator<<(const constUnion& constant) const
TConstUnion operator<<(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt:
switch (constant.type) {
@ -318,9 +319,9 @@ public:
return returnValue;
}
constUnion operator&(const constUnion& constant) const
TConstUnion operator&(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
@ -331,9 +332,9 @@ public:
return returnValue;
}
constUnion operator|(const constUnion& constant) const
TConstUnion operator|(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
@ -344,9 +345,9 @@ public:
return returnValue;
}
constUnion operator^(const constUnion& constant) const
TConstUnion operator^(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
@ -357,9 +358,9 @@ public:
return returnValue;
}
constUnion operator~() const
TConstUnion operator~() const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break;
case EbtUint: returnValue.setUConst(~uConst); break;
@ -369,9 +370,9 @@ public:
return returnValue;
}
constUnion operator&&(const constUnion& constant) const
TConstUnion operator&&(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
@ -381,9 +382,9 @@ public:
return returnValue;
}
constUnion operator||(const constUnion& constant) const
TConstUnion operator||(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
@ -406,4 +407,6 @@ private:
TBasicType type;
};
} // end namespace glslang
#endif // _CONSTANT_UNION_INCLUDED_

View file

@ -38,6 +38,8 @@
#include "../Include/Common.h"
#include <math.h>
namespace glslang {
//
// TPrefixType is used to centralize how info log messages start.
// See below.
@ -131,10 +133,12 @@ protected:
int outputStream;
};
} // end namespace glslang
class TInfoSink {
public:
TInfoSinkBase info;
TInfoSinkBase debug;
glslang::TInfoSinkBase info;
glslang::TInfoSinkBase debug;
};
#endif // _INFOSINK_INCLUDED_

View file

@ -35,9 +35,13 @@
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
#define __INITIALIZE_GLOBALS_INCLUDED_
namespace glslang {
void InitializeGlobalPools();
void FreeGlobalPools();
bool InitializePoolIndex();
void FreePoolIndex();
} // end namespace glslang
#endif // __INITIALIZE_GLOBALS_INCLUDED_

View file

@ -65,6 +65,8 @@
#include <string.h>
#include <vector>
namespace glslang {
// If we are using guard blocks, we must track each indivual
// allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact.
@ -316,4 +318,6 @@ protected:
TPoolAllocator& allocator;
};
} // end namespace glslang
#endif // _POOLALLOC_INCLUDED_

View file

@ -58,4 +58,5 @@ struct TBuiltInResource {
int minProgramTexelOffset;
int maxProgramTexelOffset;
};
#endif // _RESOURCE_LIMITS_INCLUDED_

View file

@ -52,7 +52,6 @@ class TCompiler;
class TLinker;
class TUniformMap;
//
// The base class used to back handles returned to the driver.
//
@ -78,6 +77,7 @@ public:
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink infoSink;
};
class TIntermNode;
//
@ -105,8 +105,8 @@ protected:
//
// Link operations are base on a list of compile results...
//
typedef TVector<TCompiler*> TCompilerList;
typedef TVector<TShHandleBase*> THandleList;
typedef glslang::TVector<TCompiler*> TCompilerList;
typedef glslang::TVector<TShHandleBase*> THandleList;
//
// The base class for the machine dependent linker to derive from

View file

@ -40,6 +40,8 @@
#include "../Include/Common.h"
#include "../Include/BaseTypes.h"
namespace glslang {
const int GlslangMaxTypeLength = 200;
//
@ -680,8 +682,8 @@ public:
return getBasicString();
}
const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); }
const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); }
const char* getStorageQualifierString() const { return GetStorageQualifierString(qualifier.storage); }
const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
TTypeList* getStruct() { return structure; }
TTypeList* getStruct() const { return structure; }
@ -753,4 +755,6 @@ protected:
TString *typeName; // for structure field type name
};
} // end namespace glslang
#endif // _TYPES_INCLUDED_

View file

@ -50,6 +50,8 @@
#include "../Include/Types.h"
#include "../Include/ConstantUnion.h"
namespace glslang {
//
// Operators used by the high-level (parse tree) representation.
//
@ -324,34 +326,41 @@ class TIntermBranch;
class TIntermTyped;
class TIntermMethod;
class TIntermSymbol;
class TInfoSink;
} // end namespace glslang
//
// Base class for the tree nodes
//
// (Put outside the glslang namespace, as it's used as part of the external interface.)
//
class TIntermNode {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
TIntermNode() { loc.line = 0; loc.string = 0; }
virtual TSourceLoc getLoc() const { return loc; }
virtual void setLoc(TSourceLoc l) { loc = l; }
virtual void traverse(TIntermTraverser*) = 0;
virtual TIntermTyped* getAsTyped() { return 0; }
virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual TIntermAggregate* getAsAggregate() { return 0; }
virtual TIntermUnary* getAsUnaryNode() { return 0; }
virtual TIntermBinary* getAsBinaryNode() { return 0; }
virtual TIntermSelection* getAsSelectionNode() { return 0; }
virtual TIntermSwitch* getAsSwitchNode() { return 0; }
virtual TIntermMethod* getAsMethodNode() { return 0; }
virtual TIntermSymbol* getAsSymbolNode() { return 0; }
virtual TIntermBranch* getAsBranchNode() { return 0; }
virtual glslang::TSourceLoc getLoc() const { return loc; }
virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
virtual void traverse(glslang::TIntermTraverser*) = 0;
virtual glslang::TIntermTyped* getAsTyped() { return 0; }
virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual glslang::TIntermAggregate* getAsAggregate() { return 0; }
virtual glslang::TIntermUnary* getAsUnaryNode() { return 0; }
virtual glslang::TIntermBinary* getAsBinaryNode() { return 0; }
virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
virtual glslang::TIntermSwitch* getAsSwitchNode() { return 0; }
virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
virtual ~TIntermNode() { }
protected:
TSourceLoc loc;
glslang::TSourceLoc loc;
};
class TInfoSink;
namespace glslang {
//
// This is just to help yacc.
//
@ -465,15 +474,15 @@ protected:
class TIntermConstantUnion : public TIntermTyped {
public:
TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
TIntermConstantUnion(TConstUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
TConstUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(TConstUnion *c) { unionArrayPointer = c; }
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser* );
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
protected:
constUnion *unionArrayPointer;
TConstUnion *unionArrayPointer;
};
//
@ -646,4 +655,6 @@ public:
bool rightToLeft;
};
} // end namespace glslang
#endif // __INTERMEDIATE_H

View file

@ -39,7 +39,11 @@
#include <cfloat>
#include <cstdlib>
namespace glslang {
namespace {
using namespace glslang;
// Some helper functions
bool isNan(double x)
{
@ -59,17 +63,12 @@ bool isInf(double x)
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
}
};
namespace {
// Some helper functions
const double pi = 3.1415926535897932384626433832795;
bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray);
// forward reference for mutual recursion
bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray);
bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
bool CompareStructure(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
{
if (leftNodeType.isArray()) {
TType typeWithoutArrayness(leftNodeType);
@ -88,7 +87,7 @@ bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, co
return true;
}
bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
{
TTypeList* fields = leftNodeType.getStruct();
@ -112,7 +111,10 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
return true;
}
}; // end anonymous namespace
} // end anonymous namespace
namespace glslang {
//
// The fold functions see if an operation on a constant can be done in place,
@ -129,9 +131,9 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
//
TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
{
constUnion *unionArray = getUnionArrayPointer();
TConstUnion *unionArray = getUnionArrayPointer();
int objectSize = getType().getObjectSize();
constUnion* newConstArray = 0;
TConstUnion* newConstArray = 0;
// For most cases, the return type matches the argument type, so set that
// up and just code to exceptions below.
@ -142,17 +144,17 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
//
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
// for a case like float f = vec4(2,3,4,5) + 1.2;
rightUnionArray = new constUnion[objectSize];
rightUnionArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; ++i)
rightUnionArray[i] = *node->getUnionArrayPointer();
} else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
// for a case like float f = 1.2 + vec4(2,3,4,5);
rightUnionArray = node->getUnionArrayPointer();
unionArray = new constUnion[constantNode->getType().getObjectSize()];
unionArray = new TConstUnion[constantNode->getType().getObjectSize()];
for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
unionArray[i] = *getUnionArrayPointer();
returnType = node->getType();
@ -163,12 +165,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
bool boolNodeFlag = false;
switch(op) {
case EOpAdd:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] + rightUnionArray[i];
break;
case EOpSub:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] - rightUnionArray[i];
break;
@ -176,12 +178,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
case EOpMul:
case EOpVectorTimesScalar:
case EOpMatrixTimesScalar:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] * rightUnionArray[i];
break;
case EOpMatrixTimesMatrix:
newConstArray = new constUnion[getMatrixRows() * node->getMatrixCols()];
newConstArray = new TConstUnion[getMatrixRows() * node->getMatrixCols()];
for (int row = 0; row < getMatrixRows(); row++) {
for (int column = 0; column < node->getMatrixCols(); column++) {
double sum = 0.0f;
@ -193,7 +195,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
break;
case EOpDiv:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++) {
switch (getType().getBasicType()) {
case EbtFloat:
@ -221,7 +223,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
break;
case EOpMatrixTimesVector:
newConstArray = new constUnion[getMatrixRows()];
newConstArray = new TConstUnion[getMatrixRows()];
for (int i = 0; i < getMatrixRows(); i++) {
double sum = 0.0f;
for (int j = 0; j < node->getVectorSize(); j++) {
@ -234,7 +236,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
break;
case EOpVectorTimesMatrix:
newConstArray = new constUnion[node->getMatrixCols()];
newConstArray = new TConstUnion[node->getMatrixCols()];
for (int i = 0; i < node->getMatrixCols(); i++) {
double sum = 0.0f;
for (int j = 0; j < getVectorSize(); j++)
@ -246,53 +248,53 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
break;
case EOpMod:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] % rightUnionArray[i];
break;
case EOpRightShift:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] >> rightUnionArray[i];
break;
case EOpLeftShift:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] << rightUnionArray[i];
break;
case EOpAnd:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] & rightUnionArray[i];
break;
case EOpInclusiveOr:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] | rightUnionArray[i];
break;
case EOpExclusiveOr:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] ^ rightUnionArray[i];
break;
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] && rightUnionArray[i];
break;
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++)
newConstArray[i] = unionArray[i] || rightUnionArray[i];
break;
case EOpLogicalXor:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
for (int i = 0; i < objectSize; i++) {
switch (getType().getBasicType()) {
case EbtBool: newConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
@ -303,22 +305,22 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
case EOpLessThan:
assert(objectSize == 1);
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(*unionArray < *rightUnionArray);
returnType = TType(EbtBool, EvqConst);
break;
case EOpGreaterThan:
assert(objectSize == 1);
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(*unionArray > *rightUnionArray);
returnType = TType(EbtBool, EvqConst);
break;
case EOpLessThanEqual:
{
assert(objectSize == 1);
constUnion constant;
TConstUnion constant;
constant.setBConst(*unionArray > *rightUnionArray);
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(!constant.getBConst());
returnType = TType(EbtBool, EvqConst);
break;
@ -326,9 +328,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
case EOpGreaterThanEqual:
{
assert(objectSize == 1);
constUnion constant;
TConstUnion constant;
constant.setBConst(*unionArray < *rightUnionArray);
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(!constant.getBConst());
returnType = TType(EbtBool, EvqConst);
break;
@ -347,7 +349,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
}
}
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(! boolNodeFlag);
returnType = TType(EbtBool, EvqConst);
break;
@ -365,7 +367,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
}
}
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
newConstArray->setBConst(! boolNodeFlag);
returnType = TType(EbtBool, EvqConst);
break;
@ -387,19 +389,19 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
//
TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, TInfoSink& infoSink)
{
constUnion *unionArray = getUnionArrayPointer();
TConstUnion *unionArray = getUnionArrayPointer();
int objectSize = getType().getObjectSize();
// First, size the result, which is mostly the same as the argument's size,
// but not always.
constUnion* newConstArray;
TConstUnion* newConstArray;
switch (op) {
// TODO: functionality: constant folding: finish listing exceptions to size here
case EOpDeterminant:
case EOpAny:
case EOpAll:
case EOpLength:
newConstArray = new constUnion[1];
newConstArray = new TConstUnion[1];
break;
case EOpEmitStreamVertex:
@ -408,7 +410,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
return 0;
default:
newConstArray = new constUnion[objectSize];
newConstArray = new TConstUnion[objectSize];
}
// Process non-component-wise operations
@ -565,12 +567,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
case EOpIsNan:
{
newConstArray[i].setBConst(glslang::isNan(unionArray[i].getDConst()));
newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
break;
}
case EOpIsInf:
{
newConstArray[i].setBConst(glslang::isInf(unionArray[i].getDConst()));
newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
break;
}
@ -664,9 +666,9 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
default:
return aggrNode;
}
constUnion* newConstArray = new constUnion[objectSize];
TConstUnion* newConstArray = new TConstUnion[objectSize];
TVector<constUnion*> childConstUnions;
TVector<TConstUnion*> childConstUnions;
for (unsigned int i = 0; i < children.size(); ++i)
childConstUnions.push_back(children[i]->getAsConstantUnion()->getUnionArrayPointer());
@ -736,7 +738,7 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
{
bool returnVal = false;
constUnion* unionArray = new constUnion[aggrNode->getType().getObjectSize()];
TConstUnion* unionArray = new TConstUnion[aggrNode->getType().getObjectSize()];
if (aggrNode->getSequence().size() == 1)
returnVal = parseConstTree(aggrNode->getLoc(), aggrNode, unionArray, aggrNode->getOp(), aggrNode->getType(), true);
else
@ -747,3 +749,5 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
return addConstantUnion(unionArray, aggrNode->getType(), aggrNode->getLoc());
}
} // end namespace glslang

View file

@ -36,6 +36,8 @@
#include <string.h>
namespace glslang {
void TInfoSinkBase::append(const char *s)
{
if (outputStream & EString) {
@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t)
if (outputStream & EStdOut)
fprintf(stdout, "%s", t.c_str());
}
} // end namespace glslang

View file

@ -43,6 +43,8 @@
#include "../Include/intermediate.h"
#include "Initialize.h"
namespace glslang {
const int FirstProfileVersion = 150;
const bool ForwardCompatibility = false;
@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
break;
}
}
} // end namespace glslang

View file

@ -43,6 +43,8 @@
#include "SymbolTable.h"
#include "Versions.h"
namespace glslang {
class TBuiltIns {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@ -71,4 +73,6 @@ protected:
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_

View file

@ -36,6 +36,8 @@
#include "../Include/intermediate.h"
namespace glslang {
//
// Traverse the intermediate representation tree, and
// call a node type specific function for each node.
@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it)
if (visit && it->postVisit && it->visitSwitch)
it->visitSwitch(false, this, it);
}
} // end namespace glslang

View file

@ -43,6 +43,8 @@
#include "RemoveTree.h"
#include <float.h>
namespace glslang {
////////////////////////////////////////////////////////////////////////////
//
// First set of functions are to help build the intermediate representation.
@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
// Returns the constant union node created.
//
TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
TIntermConstantUnion* TIntermediate::addConstantUnion(TConstUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
{
TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
node->setLoc(loc);
@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc)
node->setLoc(loc);
TIntermConstantUnion* constIntNode;
TIntermSequence &sequenceVector = node->getSequence();
constUnion* unionArray;
TConstUnion* unionArray;
for (int i = 0; i < fields.num; i++) {
unionArray = new constUnion[1];
unionArray = new TConstUnion[1];
unionArray->setIConst(fields.offsets[i]);
constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
sequenceVector.push_back(constIntNode);
@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
if (node->getType().isArray())
infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
int size = node->getType().getObjectSize();
constUnion *leftUnionArray = new constUnion[size];
TConstUnion *leftUnionArray = new TConstUnion[size];
for (int i=0; i < size; i++) {
switch (promoteTo) {
@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
*pragmaTable = pTable;
}
} // end namespace glslang

View file

@ -1,84 +0,0 @@
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _MMAP_INCLUDED_
#define _MMAP_INCLUDED_
//
// Encapsulate memory mapped files
//
class TMMap {
public:
TMMap(const char* fileName) :
fSize(-1), // -1 is the error value returned by GetFileSize()
fp(NULL),
fBuff(0) // 0 is the error value returned by MapViewOfFile()
{
if ((fp = fopen(fileName, "r")) == NULL)
return;
char c = getc(fp);
fSize = 0;
while (c != EOF) {
fSize++;
c = getc(fp);
}
if (c == EOF)
fSize++;
rewind(fp);
fBuff = (char*)malloc(sizeof(char) * fSize);
int count = 0;
c = getc(fp);
while (c != EOF) {
fBuff[count++] = c;
c = getc(fp);
}
fBuff[count++] = c;
}
char* getData() { return fBuff; }
int getSize() { return fSize; }
~TMMap() {
if (fp != NULL)
fclose(fp);
}
private:
int fSize; // size of file to map in
FILE *fp;
char* fBuff; // the actual data;
};
#endif // _MMAP_INCLUDED_

View file

@ -41,6 +41,10 @@
#include "preprocessor/PpContext.h"
extern int yyparse(void*);
namespace glslang {
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,
bool fc, EShMessages m) :
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), linkage(0),
@ -104,8 +108,6 @@ const char* TParseContext::getPreamble()
return 0;
}
extern int yyparse(void*);
//
// Parse an array of strings using yyparse, going through the
// preprocessor to tokenize the shader strings, then through
@ -458,7 +460,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
// it was a member of an anonymous container, have to insert its dereference
TVariable* variable = anon->getAnonContainer().getAsVariable();
TIntermTyped* container = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), loc);
constUnion* unionArray = new constUnion[1];
TConstUnion* unionArray = new TConstUnion[1];
unionArray->setUConst(anon->getMemberNumber());
TIntermTyped* constNode = intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), loc);
@ -478,7 +480,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
// pop will reclaim the memory
if (variable->getType().getQualifier().storage == EvqConst ) {
constUnion* constArray = variable->getConstUnionPointer();
TConstUnion* constArray = variable->getConstUnionPointer();
TType t(variable->getType());
node = intermediate.addConstantUnion(constArray, t, loc);
} else
@ -547,7 +549,7 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
}
if (result == 0) {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst(0.0);
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
} else {
@ -595,7 +597,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
result->setType(TType(base->getBasicType(), EvqConst, (int) (field).size()));
} else {
if (fields.num == 1) {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst(fields.offsets[0]);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
@ -634,7 +636,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
result->getTypePointer()->getQualifier().storage = EvqConst;
}
} else {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst(i);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
@ -756,7 +758,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
} else
length = intermNode->getAsTyped()->getType().getArraySize();
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst(length);
result = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
} else if (op != EOpNull) {
@ -831,7 +833,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
} else {
// error message was put out by PaFindFunction()
// Put on a dummy node for error recovery
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst(0.0);
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
}
@ -1408,14 +1410,14 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
// now, knowing it is a shader in/out, do all the in/out semantic checks
if (publicType.basicType == EbtBool) {
error(loc, "cannot be bool", getStorageQualifierString(qualifier.storage), "");
error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), "");
return;
}
if (language == EShLangVertex && qualifier.storage == EvqVaryingIn) {
if (publicType.basicType == EbtStruct) {
error(loc, "cannot be a structure or array", getStorageQualifierString(qualifier.storage), "");
error(loc, "cannot be a structure or array", GetStorageQualifierString(qualifier.storage), "");
return;
}
@ -1428,7 +1430,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
if (language == EShLangFragment && qualifier.storage == EvqVaryingOut) {
profileRequires(loc, EEsProfile, 300, 0, "fragment shader output");
if (publicType.basicType == EbtStruct) {
error(loc, "cannot be a structure", getStorageQualifierString(qualifier.storage), "");
error(loc, "cannot be a structure", GetStorageQualifierString(qualifier.storage), "");
return;
}
@ -1438,7 +1440,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
error(loc, "must be qualified as 'flat'", getStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
return;
}
@ -1498,11 +1500,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
dst.storage == EvqConst && src.storage == EvqIn)
dst.storage = EvqConstReadOnly;
else if (src.storage != EvqTemporary)
error(loc, "too many storage qualifiers", getStorageQualifierString(src.storage), "");
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
// Precision qualifiers
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
error(loc, "only one precision qualifier allowed", getPrecisionQualifierString(src.precision), "");
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
if (dst.precision == EpqNone || force && src.precision != EpqNone)
dst.precision = src.precision;
@ -1882,7 +1884,7 @@ void TParseContext::paramCheck(TSourceLoc loc, TStorageQualifier qualifier, TTyp
break;
default:
type->getQualifier().storage = EvqIn;
error(loc, "qualifier not allowed on function parameter", getStorageQualifierString(qualifier), "");
error(loc, "qualifier not allowed on function parameter", GetStorageQualifierString(qualifier), "");
break;
}
}
@ -2050,7 +2052,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
return true;
}
if (initializer->getAsConstantUnion()) {
constUnion* unionArray = variable->getConstUnionPointer();
TConstUnion* unionArray = variable->getConstUnionPointer();
if (type.getObjectSize() == 1 && type.getBasicType() != EbtStruct) {
*unionArray = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0];
@ -2060,7 +2062,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
} else if (initializer->getAsSymbolNode()) {
TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getName());
if (TVariable* tVar = symbol->getAsVariable()) {
constUnion* constArray = tVar->getConstUnionPointer();
TConstUnion* constArray = tVar->getConstUnionPointer();
variable->shareConstPointer(constArray);
} else {
error(loc, "expected variable", initializer->getAsSymbolNode()->getName().c_str(), "");
@ -2563,12 +2565,12 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
constUnion *unionArray;
TConstUnion *unionArray;
if (tempConstantNode) {
unionArray = tempConstantNode->getUnionArrayPointer();
if (!unionArray) { // this error message should never be raised
infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", loc);
infoSink.info.message(EPrefixInternalError, "TConstUnion not initialized in addConstVectorNode function", loc);
return node;
}
@ -2578,7 +2580,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
return 0;
}
constUnion* constArray = new constUnion[fields.num];
TConstUnion* constArray = new TConstUnion[fields.num];
for (int i = 0; i < fields.num; i++) {
if (fields.offsets[i] >= node->getType().getObjectSize()) {
@ -2610,7 +2612,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
}
if (tempConstantNode) {
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
int size = tempConstantNode->getType().getMatrixRows();
// Note: the type is corrected (dereferenced) by the caller
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), loc);
@ -2646,7 +2648,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
int arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) {
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), loc);
} else {
error(loc, "Cannot offset into the array", "Error", "");
@ -2680,7 +2682,7 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
}
if (tempConstantNode) {
constUnion* constArray = tempConstantNode->getUnionArrayPointer();
TConstUnion* constArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), loc); // type will be changed in the calling function
} else {
@ -2704,3 +2706,5 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior["GL_ARB_texture_rectangle"] = EBhDisable;
extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
}
} // end namespace glslang

View file

@ -41,6 +41,8 @@
#include "SymbolTable.h"
#include "localintermediate.h"
namespace glslang {
typedef enum {
EBhRequire,
EBhEnable,
@ -55,12 +57,9 @@ struct TPragma {
TPragmaTable pragmaTable;
};
class TScanContext;
class TPpContext;
namespace glslang {
class TScanContext;
};
//
// The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global.
@ -70,7 +69,7 @@ public:
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
glslang::TScanContext* scanContext;
TScanContext* scanContext;
TPpContext* ppContext;
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
@ -200,4 +199,6 @@ public:
void doubleCheck(TSourceLoc, const char* op);
};
} // end namespace glslang
#endif // _PARSER_HELPER_INCLUDED_

View file

@ -38,6 +38,8 @@
#include "Include/InitializeGlobals.h"
#include "osinclude.h"
namespace glslang {
OS_TLSIndex PoolIndex;
void InitializeGlobalPools()
@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
alloc->check();
}
} // end namespace glslang

View file

@ -36,6 +36,8 @@
#include "../Include/intermediate.h"
namespace glslang {
class TAliveTraverser : public TIntermTraverser {
public:
TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
return true;
}
} // end namespace glslang
#endif

View file

@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE.
//
namespace glslang {
bool QualifierWritten(TIntermNode* root, TStorageQualifier);
} // end namespace glslang

View file

@ -36,6 +36,9 @@
#include "../Include/intermediate.h"
#include "RemoveTree.h"
namespace glslang {
//
// Code to recursively delete the intermediate tree.
//
@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root)
root->traverse(&it);
}
} // end namespace glslang

View file

@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE.
//
namespace glslang {
void RemoveAllTreeNodes(TIntermNode*);
} // end namespace glslang

View file

@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile)
return foundNonSpaceTab;
}
}; // end glslang namespace
namespace glslang {
// Fill this in when doing glslang-level scanning, to hand back to the parser.
class TParserToken {
public:
@ -242,10 +238,10 @@ public:
YYSTYPE& sType;
};
}; // end namespace glslang
} // end namespace glslang
// This is the function the glslang parser (i.e., bison) calls to get its next token
int yylex(YYSTYPE* glslangTokenDesc, TParseContext& parseContext)
int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
{
glslang::TParserToken token(*glslangTokenDesc);
@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage()
return identifierOrType();
}
};
} // end namespace glslang

View file

@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input);
void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
}; // end glslang namespace
} // end namespace glslang

View file

@ -40,11 +40,10 @@
#include "ParseHelper.h"
class TPpContext;
class TPpToken;
namespace glslang {
class TPpContext;
class TPpToken;
class TParserToken;
class TScanContext {
@ -79,4 +78,4 @@ protected:
int keyword;
};
};
} // end namespace glslang

View file

@ -57,6 +57,8 @@
namespace { // anonymous namespace for file-local functions and symbols
using namespace glslang;
int MapVersionToIndex(int version)
{
switch(version) {
@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
TPpContext ppContext(parseContext);
glslang::TScanContext scanContext(parseContext);
TScanContext scanContext(parseContext);
parseContext.scanContext = &scanContext;
parseContext.ppContext = &ppContext;
@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
return true;
}
}; // end anonymous namespace for local functions
} // end anonymous namespace for local functions
//
// ShInitialize() should be called exactly once per process, not per thread.

View file

@ -41,6 +41,8 @@
#include "SymbolTable.h"
namespace glslang {
//
// TType helper function needs a place to live.
//
@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
if (copyOf.unionArray) {
assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1);
unionArray = new constUnion[1];
unionArray = new TConstUnion[1];
unionArray[0] = copyOf.unionArray[0];
} else
unionArray = 0;
@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
for (unsigned int i = 0; i < copyOf.table.size(); ++i)
table.push_back(copyOf.table[i]->clone(remapper));
}
} // end namespace glslang

View file

@ -69,6 +69,8 @@
#include "../Include/intermediate.h"
#include "../Include/InfoSink.h"
namespace glslang {
//
// Symbol base class. (Can build functions or variables out of these...)
//
@ -126,16 +128,16 @@ public:
virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstUnionPointer() {
TConstUnion* getConstUnionPointer() {
if (!unionArray)
unionArray = new constUnion[type.getObjectSize()];
unionArray = new TConstUnion[type.getObjectSize()];
return unionArray;
}
constUnion* getConstUnionPointer() const { return unionArray; }
TConstUnion* getConstUnionPointer() const { return unionArray; }
void shareConstPointer( constUnion *constArray)
void shareConstPointer( TConstUnion *constArray)
{
delete unionArray;
unionArray = constArray;
@ -150,7 +152,7 @@ protected:
bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed
constUnion *unionArray;
TConstUnion *unionArray;
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
};
@ -479,4 +481,6 @@ protected:
unsigned int adoptedLevels;
};
} // end namespace glslang
#endif // _SYMBOL_TABLE_INCLUDED_

View file

@ -44,6 +44,8 @@
#include "ParseHelper.h"
namespace glslang {
const char* StageName[EShLangCount] = {
"vertex",
"tessellation control",
@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
profileRequires(loc, ECoreProfile, 400, 0, op);
profileRequires(loc, ECompatibilityProfile, 400, 0, op);
}
} // end namespace glslang

View file

@ -35,8 +35,8 @@
//
/**
* This is bison grammar and production code for parsing the OpenGL 2.0 shading
* languages.
* This is bison grammar and productions for parsing all versions of the
* GLSL shading languages.
*/
%{
@ -59,37 +59,39 @@ Jutta Degener, 1995
#include "ParseHelper.h"
#include "../Public/ShaderLang.h"
using namespace glslang;
%}
%union {
struct {
TSourceLoc loc;
glslang::TSourceLoc loc;
union {
TString *string;
glslang::TString *string;
int i;
unsigned int u;
bool b;
double d;
};
TSymbol* symbol;
glslang::TSymbol* symbol;
} lex;
struct {
TSourceLoc loc;
TOperator op;
glslang::TSourceLoc loc;
glslang::TOperator op;
union {
TIntermNode* intermNode;
TIntermNodePair nodePair;
TIntermTyped* intermTypedNode;
TIntermAggregate* intermAggregate;
glslang::TIntermNodePair nodePair;
glslang::TIntermTyped* intermTypedNode;
glslang::TIntermAggregate* intermAggregate;
};
union {
TPublicType type;
TFunction* function;
TParameter param;
TTypeLoc typeLine;
TTypeList* typeList;
TArraySizes arraySizes;
TIdentifierList* identifierList;
glslang::TPublicType type;
glslang::TFunction* function;
glslang::TParameter param;
glslang::TTypeLoc typeLine;
glslang::TTypeList* typeList;
glslang::TArraySizes arraySizes;
glslang::TIdentifierList* identifierList;
};
} interm;
}
@ -224,29 +226,29 @@ primary_expression
$$ = $1;
}
| INTCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst($1.i);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
}
| UINTCONSTANT {
parseContext.fullIntegerCheck($1.loc, "unsigned literal");
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setUConst($1.u);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
}
| FLOATCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
}
| DOUBLECONSTANT {
parseContext.doubleCheck($1.loc, "double literal");
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
}
| BOOLCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst($1.b);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
}
@ -511,7 +513,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -520,7 +522,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -529,7 +531,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -538,7 +540,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -551,7 +553,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray()))
@ -561,7 +563,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray()))
@ -611,7 +613,7 @@ logical_and_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -624,7 +626,7 @@ logical_xor_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -637,7 +639,7 @@ logical_or_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
@ -871,7 +873,7 @@ function_header
: fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
parseContext.error($2.loc, "no qualifiers allowed for function return",
getStorageQualifierString($1.qualifier.storage), "");
GetStorageQualifierString($1.qualifier.storage), "");
}
// Add the function as a prototype after parsing it (we do not support recursion)

View file

@ -36,6 +36,8 @@
#include "localintermediate.h"
namespace glslang {
//
// Two purposes:
// 1. Show an example of how to iterate tree. Functions can
@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root)
root->traverse(&it);
}
} // end namespace glslang

View file

@ -40,6 +40,8 @@
#include "SymbolTable.h"
#include "Versions.h"
namespace glslang {
struct TVectorFields {
int offsets[4];
int num;
@ -48,7 +50,6 @@ struct TVectorFields {
//
// Set of helper functions to help parse and build the tree.
//
class TInfoSink;
class TIntermediate {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@ -74,9 +75,9 @@ public:
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermConstantUnion* addConstantUnion(TConstUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, const TType&, bool singleConstantParam = false);
bool parseConstTree(TSourceLoc, TIntermNode*, TConstUnion*, TOperator, const TType&, bool singleConstantParam = false);
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
TIntermBranch* addBranch(TOperator, TSourceLoc);
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
@ -97,4 +98,6 @@ private:
void operator=(TIntermediate&); // prevent assignments
};
} // end namespace glslang
#endif // _LOCAL_INTERMEDIATE_INCLUDED_

View file

@ -34,17 +34,19 @@
#include "ParseHelper.h"
namespace glslang {
//
// Use this class to carry along data from node to node in
// the traversal
//
class TConstTraverser : public TIntermTraverser {
public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
TConstTraverser(TConstUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
int index ;
constUnion *unionArray;
TConstUnion *unionArray;
TOperator tOp;
const TType& type;
TOperator constructorType;
@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
constUnion* leftUnionArray = oit->unionArray;
TConstUnion* leftUnionArray = oit->unionArray;
int instanceSize = oit->type.getObjectSize();
if (oit->index >= instanceSize)
@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
if (!oit->singleConstantParam) {
int size = node->getType().getObjectSize();
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) {
if (oit->index >= instanceSize)
return;
@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
matrixRows = oit->matrixRows;
isMatrix = oit->isMatrix;
totalSize = oit->index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) {
int count = 0;
for (int i = oit->index; i < totalSize; i++) {
@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
// Individual functions can be initialized to 0 to skip processing of that
// type of node. It's children will still be processed.
//
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, TConstUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
{
if (root == 0)
return false;
@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio
else
return false;
}
} // end namespace glslang

View file

@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc
#undef free
namespace glslang {
int TPpContext::InitCPP()
{
TPpContext::AtomTable* atable = &atomTable;
@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) {
DeleteTokenStream(s->body);
}
static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
void TPpContext::PushEofSrc()
{
@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting()
return 0;
}
} // end namespace glslang

View file

@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef realloc
#undef free
namespace {
using namespace glslang;
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// String table: //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static const struct {
const struct {
int val;
const char *str;
} tokens[] = {
@ -135,7 +139,6 @@ static const struct {
* InitStringTable() - Initialize the string table.
*
*/
int InitStringTable(TPpContext::StringTable *stable)
{
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable)
* FreeStringTable() - Free the string table.
*
*/
void FreeStringTable(TPpContext::StringTable *stable)
{
if (stable->strings)
@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable)
* HashString() - Hash a string with the base hash function.
*
*/
static int HashString(const char *s)
int HashString(const char *s)
{
int hval = 0;
@ -181,8 +182,7 @@ static int HashString(const char *s)
* HashString2() - Hash a string with the incrimenting hash function.
*
*/
static int HashString2(const char *s)
int HashString2(const char *s)
{
int hval = 0;
@ -197,8 +197,7 @@ static int HashString2(const char *s)
* AddString() - Add a string to a string table. Return it's offset.
*
*/
static int AddString(TPpContext::StringTable *stable, const char *s)
int AddString(TPpContext::StringTable *stable, const char *s)
{
int len, loc;
char *str;
@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s)
* InitHashTable() - Initialize the hash table.
*
*/
static int InitHashTable(TPpContext::HashTable *htable, int fsize)
int InitHashTable(TPpContext::HashTable *htable, int fsize)
{
int ii;
@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize)
* FreeHashTable() - Free the hash table.
*
*/
static void FreeHashTable(TPpContext::HashTable *htable)
void FreeHashTable(TPpContext::HashTable *htable)
{
if (htable->entry)
free(htable->entry);
@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable)
* Empty() - See if a hash table entry is empty.
*
*/
static int Empty(TPpContext::HashTable *htable, int hashloc)
int Empty(TPpContext::HashTable *htable, int hashloc)
{
assert(hashloc >= 0 && hashloc < htable->size);
if (htable->entry[hashloc].index == 0) {
@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc)
* Match() - See if a hash table entry is matches a string.
*
*/
static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
{
int strloc;
@ -302,7 +297,6 @@ static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable,
* GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
*
*/
int GrowAtomTable(TPpContext::AtomTable *atable, int size)
{
int *newmap, *newrev;
@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size)
* lReverse() - Reverse the bottom 20 bits of a 32 bit int.
*
*/
static int lReverse(int fval)
int lReverse(int fval)
{
unsigned int in = fval;
int result = 0, cnt = 0;
@ -362,7 +355,6 @@ static int lReverse(int fval)
* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
*
*/
int AllocateAtom(TPpContext::AtomTable *atable)
{
if (atable->nextFree >= atable->size)
@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable)
* SetAtomValue() - Allocate a new atom associated with "hashindex".
*
*/
void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
{
atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
@ -388,7 +379,6 @@ void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
* FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
*
*/
int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
{
int hashloc, hashdelta, count;
@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
return hashloc;
} // FindHashLoc
} // end anonymous namespace
namespace glslang {
/*
* IncreaseHashTableSize()
*
*/
int TPpContext::IncreaseHashTableSize(AtomTable *atable)
{
int ii, strloc, oldhashloc, value, size;
@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable)
atable->size = 0;
} // FreeAtomTable
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// End of atom.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang

View file

@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
namespace glslang {
TPpContext::TPpContext(TParseContext& pc) :
parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
ScopeList(0), CurrentScope(0), GlobalScope(0)
@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n)
currentString = 0;
}
}
} // end namespace glslang

View file

@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../ParseHelper.h"
namespace glslang {
class TPpToken {
public:
static const int maxTokenLength = 1024;
@ -386,5 +388,6 @@ protected:
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
};
#endif // PPCONTEXT_H
} // end namespace glslang
#endif // PPCONTEXT_H

View file

@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc
#undef free
namespace glslang {
struct chunk {
struct chunk *next;
};
@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void
pool->cleanup = cleanup;
return 0;
}
} // end namespace glslang

View file

@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
#include "PpTokens.h"
static int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
namespace {
using namespace glslang;
int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
{
return EOF;
} // eof_scan
}
static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
{
}
TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
} // end anonymous namespace
namespace glslang {
int TPpContext::InitScanner(TPpContext *cpp)
{
@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token)
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// End of scanner.c //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang

View file

@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static void unlinkScope(void *_scope, void* scopeList)
namespace {
using namespace glslang;
void unlinkScope(void *_scope, void* scopeList)
{
TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList)
*(TPpContext::Scope**)scopeList = scope->next;
}
} // end anonymous namespace
namespace glslang {
/*
* NewScope()
*
@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
return NULL;
} // LookUpSymbol
} // end namespace glslang

View file

@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
#include "PpTokens.h"
namespace glslang {
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang

View file

@ -46,6 +46,7 @@
#define _vsnprintf vsnprintf
namespace glslang {
void DetachThreadLinux(void *);
@ -60,7 +61,7 @@ bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
//
// This function should return 0 if nIndex is invalid.
@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
return pthread_getspecific(nIndex);
}
namespace glslang {
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
typedef unsigned int (*TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
typedef unsigned int (*TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds);
void OS_Sleep(int milliseconds);
void OS_DumpMemoryCounters();
};
void OS_DumpMemoryCounters();
} // end namespace glslang
#endif // __OSINCLUDE_H

View file

@ -38,6 +38,8 @@
#include "osinclude.h"
#include "InitializeDll.h"
namespace glslang {
//
// Thread cleanup
//
@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false;
}
namespace glslang {
// TODO: if we need these on linux, flesh them out
void InitGlobalLock() { }
void GetGlobalLock() { }
void ReleaseGlobalLock() { }
// TODO: if we need these on linux, flesh them out
void InitGlobalLock() { }
void GetGlobalLock() { }
void ReleaseGlobalLock() { }
void* OS_CreateThread(TThreadEntrypoint entry)
{
}
void* OS_CreateThread(TThreadEntrypoint entry)
{
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
}
void OS_Sleep(int milliseconds)
{
}
void OS_Sleep(int milliseconds)
{
}
void OS_DumpMemoryCounters()
{
}
};
void OS_DumpMemoryCounters()
{
}
} // end namespace glslang

View file

@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
case DLL_PROCESS_ATTACH:
if (!InitProcess())
if (! glslang::InitProcess())
return FALSE;
break;
case DLL_THREAD_ATTACH:
if (!InitThread())
if (! glslang::InitThread())
return FALSE;
break;
case DLL_THREAD_DETACH:
if (!DetachThread())
if (! glslang::DetachThread())
return FALSE;
break;
case DLL_PROCESS_DETACH:
DetachProcess();
glslang::DetachProcess();
break;
default:

View file

@ -44,6 +44,8 @@
#error Trying to include a windows specific file in a non windows build.
#endif
namespace glslang {
//
// Thread Local Storage Operations
//
@ -56,18 +58,18 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
void* OS_GetTLSValue(OS_TLSIndex nIndex);
namespace glslang {
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds);
void OS_Sleep(int milliseconds);
void OS_DumpMemoryCounters();
};
void OS_DumpMemoryCounters();
} // end namespace glslang
#endif // __OSINCLUDE_H

View file

@ -50,6 +50,8 @@
#error Trying to build a windows specific file in a non windows build.
#endif
namespace glslang {
//
// Thread Local Storage Operations
//
@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false;
}
namespace glslang {
HANDLE GlobalLock;
HANDLE GlobalLock;
void InitGlobalLock()
{
GlobalLock = CreateMutex(0, false, 0);
}
void InitGlobalLock()
{
GlobalLock = CreateMutex(0, false, 0);
}
void GetGlobalLock()
{
WaitForSingleObject(GlobalLock, INFINITE);
}
void GetGlobalLock()
{
WaitForSingleObject(GlobalLock, INFINITE);
}
void ReleaseGlobalLock()
{
ReleaseMutex(GlobalLock);
}
void ReleaseGlobalLock()
{
ReleaseMutex(GlobalLock);
}
void* OS_CreateThread(TThreadEntrypoint entry)
{
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
//return CreateThread(0, 0, entry, 0, 0, 0);
}
void* OS_CreateThread(TThreadEntrypoint entry)
{
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
//return CreateThread(0, 0, entry, 0, 0, 0);
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
}
void OS_Sleep(int milliseconds)
{
Sleep(milliseconds);
}
void OS_Sleep(int milliseconds)
{
Sleep(milliseconds);
}
void OS_DumpMemoryCounters()
{
PROCESS_MEMORY_COUNTERS counters;
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
printf("Working set size: %d\n", counters.WorkingSetSize);
}
};
void OS_DumpMemoryCounters()
{
PROCESS_MEMORY_COUNTERS counters;
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
printf("Working set size: %d\n", counters.WorkingSetSize);
}
} // namespace glslang