Commit b603f918 by John Kessenich

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

parent 23bdb29e
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "Public/ShaderLang.h" #include "Public/ShaderLang.h"
namespace glslang {
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX; OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
bool InitProcess() bool InitProcess()
...@@ -144,3 +146,5 @@ bool DetachProcess() ...@@ -144,3 +146,5 @@ bool DetachProcess()
return success; return success;
} }
} // end namespace glslang
...@@ -37,11 +37,14 @@ ...@@ -37,11 +37,14 @@
#include "osinclude.h" #include "osinclude.h"
namespace glslang {
bool InitProcess(); bool InitProcess();
bool InitThread(); bool InitThread();
bool DetachThread(); bool DetachThread();
bool DetachProcess(); bool DetachProcess();
} // end namespace glslang
#endif // __INITIALIZEDLL_H #endif // __INITIALIZEDLL_H
...@@ -72,7 +72,7 @@ ShBinding FixedAttributeBindings[] = { ...@@ -72,7 +72,7 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings }; ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
static EShLanguage FindLanguage(const std::string& name); EShLanguage FindLanguage(const std::string& name);
bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*); bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
void usage(); void usage();
void FreeFileData(char **data); void FreeFileData(char **data);
...@@ -232,7 +232,7 @@ int C_DECL main(int argc, char* argv[]) ...@@ -232,7 +232,7 @@ int C_DECL main(int argc, char* argv[])
// .geom = geometry // .geom = geometry
// .frag = fragment // .frag = fragment
// //
static EShLanguage FindLanguage(const std::string& name) EShLanguage FindLanguage(const std::string& name)
{ {
size_t ext = name.rfind('.'); size_t ext = name.rfind('.');
if (ext == std::string::npos) { if (ext == std::string::npos) {
......
...@@ -78,6 +78,6 @@ namespace glslang { ...@@ -78,6 +78,6 @@ namespace glslang {
std::list<std::string> worklist; std::list<std::string> worklist;
}; };
}; } // end namespace glslang
#endif // WORKLIST_H_INCLUDED #endif // WORKLIST_H_INCLUDED
...@@ -9,10 +9,7 @@ Performance ...@@ -9,10 +9,7 @@ Performance
Testing Testing
- thread safety - thread safety
Interfacing Link Validation
- finish putting into a glslang namespace
Shader Linking Validation
- ensure no static references thrown away - ensure no static references thrown away
Cross-stage linking Cross-stage linking
- type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching - type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
...@@ -22,6 +19,9 @@ Shader Linking Validation ...@@ -22,6 +19,9 @@ Shader Linking Validation
- statically consumed input not produced by previous stage - statically consumed input not produced by previous stage
- matching between gl_PerVertex blocks and gl_PerFragment blocks - matching between gl_PerVertex blocks and gl_PerFragment blocks
- compute shader not with other stages - compute shader not with other stages
- 1.3: deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
- 4.3: remove cross-version linking restrictions.
- 4.3: Allow mismatches in interpolation and auxiliary qualification across stages.
Intra-stage linking Intra-stage linking
- exactly one main - exactly one main
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks - type consistency check of uniforms, globals, ins, and outs, both variables and blocks
...@@ -32,17 +32,20 @@ Shader Linking Validation ...@@ -32,17 +32,20 @@ Shader Linking Validation
- mixed es/non-es profiles - mixed es/non-es profiles
- matching initializers for globals - matching initializers for globals
- recursion for both functions and subroutines - recursion for both functions and subroutines
- Even the potential for recursion through subroutine uniforms is an error.
- matching redeclarations of interface blocks - matching redeclarations of interface blocks
- read or write to both gl_ClipVertex and gl_ClipDistance - read or write to both gl_ClipVertex and gl_ClipDistance
- write to only one of gl_FragColor, gl_FragData, or user-declared - write to only one of gl_FragColor, gl_FragData, or user-declared
- 4.3: Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
- 4.3: Be clear that implicit array sizing is only within a stage, not cross stage.
- 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching - 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
Functionality to Implement/Finish Shader Functionality to Implement/Finish
ESSL 3.0 ESSL 3.0
- "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions - "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions
GLSL 1.2 GLSL 1.2
- Handle multiple compilation units per stage - Handle multiple compilation units per stage
- Allow initializers on uniform declarations. The value is set at link time. - Allow initializers on uniform declarations
- signature matching takes type conversions into account, ambiguity is an error - signature matching takes type conversions into account, ambiguity is an error
GLSL 1.3 GLSL 1.3
. flat is for both user and predeclared built-in in/out variables . flat is for both user and predeclared built-in in/out variables
...@@ -51,7 +54,6 @@ Functionality to Implement/Finish ...@@ -51,7 +54,6 @@ Functionality to Implement/Finish
- non-perspective (linear) interpolation (noperspective) - non-perspective (linear) interpolation (noperspective)
- add gl_ClipDistance[] to both vertex and fragment shaders - add gl_ClipDistance[] to both vertex and fragment shaders
- only statically used built-ins have to be redeclared as flat - only statically used built-ins have to be redeclared as flat
- Link: Deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
- Deprecated gl_ClipVertex - Deprecated gl_ClipVertex
- deprecate almost all built-in state - deprecate almost all built-in state
- ftransform() is deprecated - ftransform() is deprecated
...@@ -78,7 +80,6 @@ Functionality to Implement/Finish ...@@ -78,7 +80,6 @@ Functionality to Implement/Finish
- Added geometry shaders. This includes targeting layers in FBO rendering. - Added geometry shaders. This includes targeting layers in FBO rendering.
- geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices. - geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices.
- Added geometry shader constants. - Added geometry shader constants.
- gl_FragCoord qualifiers use the layout(): origin_upper_left and pixel_center_integer.
- Broaden structure usage to include geometry inputs and geometry outputs. - Broaden structure usage to include geometry inputs and geometry outputs.
GLSL 4.0 GLSL 4.0
- tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization. - tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization.
...@@ -93,7 +94,7 @@ Functionality to Implement/Finish ...@@ -93,7 +94,7 @@ Functionality to Implement/Finish
- Sampler arrays can take a variable index now, as long as it's value is uniform for all uses. - Sampler arrays can take a variable index now, as long as it's value is uniform for all uses.
- Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset(). - Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset().
- New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision. - New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision.
- Add a fused multiply andadd built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.) - Add a fused multiply and add built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.)
- Added new built-in floating-point functions - Added new built-in floating-point functions
- frexp() and ldexp() - frexp() and ldexp()
- packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32() - packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32()
...@@ -121,7 +122,7 @@ Functionality to Implement/Finish ...@@ -121,7 +122,7 @@ Functionality to Implement/Finish
- Add 64-bit floating-point attributes for vertex shader inputs. - Add 64-bit floating-point attributes for vertex shader inputs.
- Support viewport arrays so where the geometry shader selects which viewport array will transform its output. - Support viewport arrays so where the geometry shader selects which viewport array will transform its output.
GLSL 4.2 GLSL 4.2
- Add 420-style function signature matching rules - Add 420-style function signature matching rules (or did this start in 4.0?)
+ Move these previously deprecated features to be only in the compatibility profile: + Move these previously deprecated features to be only in the compatibility profile:
+ The keyword attribute for vertex shader inputs. (Use in instead.) + The keyword attribute for vertex shader inputs. (Use in instead.)
+ The keyword varying for inputs and outputs. (Use in and out instead.) + The keyword varying for inputs and outputs. (Use in and out instead.)
...@@ -156,7 +157,6 @@ Functionality to Implement/Finish ...@@ -156,7 +157,6 @@ Functionality to Implement/Finish
- Allow .length() to be applied to vectors and matrices, returning the number of components or columns. - Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
+ Clarify that .length() returns an int type and can be used as a constant integer expression. + Clarify that .length() returns an int type and can be used as a constant integer expression.
- Allow swizzle operations on scalars. - Allow swizzle operations on scalars.
- Even the potential for recursion through subroutine uniforms is an error.
- Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value. - Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.
- Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined. - Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined.
- Minor consistency fixes, corrections - Minor consistency fixes, corrections
...@@ -188,33 +188,24 @@ Functionality to Implement/Finish ...@@ -188,33 +188,24 @@ Functionality to Implement/Finish
GL_ARB_explicit_uniform_location extension. GL_ARB_explicit_uniform_location extension.
- Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL - Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL
versions 100 and 300, as per the GL_ARB_ES3_compatibility extension. versions 100 and 300, as per the GL_ARB_ES3_compatibility extension.
- Clarified about 90 errors as being either compile time, link time, or either.
- Clarify and correct scoping rules to what would normally be expected and what was intended. - Clarify and correct scoping rules to what would normally be expected and what was intended.
(Function parameters and body nest inside global space. Loop variables and body nest inside (Function parameters and body nest inside global space. Loop variables and body nest inside
loop scope.) loop scope.)
- There are no digraphs (trigraphs were already disallowed). - There are no digraphs (trigraphs were already disallowed).
- Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions - Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions
containing undefined macro names. This reverts back to following expected CPP behavior. containing undefined macro names. This reverts back to following expected CPP behavior.
- Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniformsto 8. - Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniforms to 8.
- Clarify textureSize() for cube map arrays. - Clarify textureSize() for cube map arrays.
- For layout qualifiers, - For layout qualifiers,
- make negative output locations a compile-time error, and - make negative output locations a compile-time error, and
- make indexes outside the range [0,1] a compile-time error. - make indexes outside the range [0,1] a compile-time error.
- Allow mismatches in interpolation and auxiliary qualification across stages.
- Remove cross-version linking restrictions.
- Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the - Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the
GL_ARB_texture_query_levels extension. GL_ARB_texture_query_levels extension.
- Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the - Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the
GL_ARB_fragment_layer_viewport extension. GL_ARB_fragment_layer_viewport extension.
- Be explicit that compile-time constant expressions evaluating on the host may get a different
value than the same expression on the target. Also reinforce that compile-time constant
expressions are evaluated as if precise and invariantwere used.
- Add more examples and rules to be more specific about the required behavior of the precise - Add more examples and rules to be more specific about the required behavior of the precise
qualifier. qualifier.
- Clarify fragment output variables cannot be double precision. - Clarify fragment output variables cannot be double precision.
- Clarify that “floating-point” generally means both single- and double-precision and be more
consistent with that.
- Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
- Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility - Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility
with the shared identifier that was previously used. with the shared identifier that was previously used.
+ Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ). + Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ).
......
...@@ -188,7 +188,6 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command> ...@@ -188,7 +188,6 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command>
<ItemGroup> <ItemGroup>
<ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" /> <ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" />
<ClInclude Include="glslang\MachineIndependent\Initialize.h" /> <ClInclude Include="glslang\MachineIndependent\Initialize.h" />
<ClInclude Include="glslang\MachineIndependent\MMap.h" />
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h" /> <ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" /> <ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" /> <ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />
......
...@@ -114,9 +114,6 @@ ...@@ -114,9 +114,6 @@
<ClInclude Include="glslang\MachineIndependent\Initialize.h"> <ClInclude Include="glslang\MachineIndependent\Initialize.h">
<Filter>Machine Independent</Filter> <Filter>Machine Independent</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="glslang\MachineIndependent\MMap.h">
<Filter>Machine Independent</Filter>
</ClInclude>
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h"> <ClInclude Include="glslang\MachineIndependent\ParseHelper.h">
<Filter>Machine Independent</Filter> <Filter>Machine Independent</Filter>
</ClInclude> </ClInclude>
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#ifndef _BASICTYPES_INCLUDED_ #ifndef _BASICTYPES_INCLUDED_
#define _BASICTYPES_INCLUDED_ #define _BASICTYPES_INCLUDED_
namespace glslang {
// //
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this. // Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
// //
...@@ -97,7 +99,7 @@ enum TStorageQualifier { ...@@ -97,7 +99,7 @@ enum TStorageQualifier {
}; };
// These will show up in error messages // These will show up in error messages
__inline const char* getStorageQualifierString(TStorageQualifier q) __inline const char* GetStorageQualifierString(TStorageQualifier q)
{ {
switch (q) { switch (q) {
case EvqTemporary: return "temporary"; break; case EvqTemporary: return "temporary"; break;
...@@ -133,7 +135,7 @@ enum TPrecisionQualifier { ...@@ -133,7 +135,7 @@ enum TPrecisionQualifier {
EpqHigh EpqHigh
}; };
__inline const char* getPrecisionQualifierString(TPrecisionQualifier p) __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
{ {
switch(p) { switch(p) {
case EpqNone: return ""; break; case EpqNone: return ""; break;
...@@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p) ...@@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
} }
} }
} // end namespace glslang
#endif // _BASICTYPES_INCLUDED_ #endif // _BASICTYPES_INCLUDED_
...@@ -85,6 +85,8 @@ ...@@ -85,6 +85,8 @@
#define TBaseList std::list #define TBaseList std::list
#define TBaseSet std::set #define TBaseSet std::set
namespace glslang {
// //
// Pool version of string. // Pool version of string.
// //
...@@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator; ...@@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
const int GlslangMaxTokenLength = 1024; const int GlslangMaxTokenLength = 1024;
} // end namespace glslang
#endif // _COMMON_INCLUDED_ #endif // _COMMON_INCLUDED_
...@@ -37,8 +37,9 @@ ...@@ -37,8 +37,9 @@
#ifndef _CONSTANT_UNION_INCLUDED_ #ifndef _CONSTANT_UNION_INCLUDED_
#define _CONSTANT_UNION_INCLUDED_ #define _CONSTANT_UNION_INCLUDED_
namespace glslang {
class constUnion { class TConstUnion {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
...@@ -103,7 +104,7 @@ public: ...@@ -103,7 +104,7 @@ public:
return false; return false;
} }
bool operator==(const constUnion& constant) const bool operator==(const TConstUnion& constant) const
{ {
if (constant.type != type) if (constant.type != type)
return false; return false;
...@@ -156,12 +157,12 @@ public: ...@@ -156,12 +157,12 @@ public:
return !operator==(b); return !operator==(b);
} }
bool operator!=(const constUnion& constant) const bool operator!=(const TConstUnion& constant) const
{ {
return !operator==(constant); return !operator==(constant);
} }
bool operator>(const constUnion& constant) const bool operator>(const TConstUnion& constant) const
{ {
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
...@@ -188,7 +189,7 @@ public: ...@@ -188,7 +189,7 @@ public:
return false; return false;
} }
bool operator<(const constUnion& constant) const bool operator<(const TConstUnion& constant) const
{ {
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
...@@ -215,9 +216,9 @@ public: ...@@ -215,9 +216,9 @@ public:
return false; return false;
} }
constUnion operator+(const constUnion& constant) const TConstUnion operator+(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break; case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
...@@ -229,9 +230,9 @@ public: ...@@ -229,9 +230,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator-(const constUnion& constant) const TConstUnion operator-(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break; case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
...@@ -243,9 +244,9 @@ public: ...@@ -243,9 +244,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator*(const constUnion& constant) const TConstUnion operator*(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break; case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
...@@ -257,9 +258,9 @@ public: ...@@ -257,9 +258,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator%(const constUnion& constant) const TConstUnion operator%(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break; case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
...@@ -270,9 +271,9 @@ public: ...@@ -270,9 +271,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator>>(const constUnion& constant) const TConstUnion operator>>(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
switch (type) { switch (type) {
case EbtInt: case EbtInt:
switch (constant.type) { switch (constant.type) {
...@@ -294,9 +295,9 @@ public: ...@@ -294,9 +295,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator<<(const constUnion& constant) const TConstUnion operator<<(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
switch (type) { switch (type) {
case EbtInt: case EbtInt:
switch (constant.type) { switch (constant.type) {
...@@ -318,9 +319,9 @@ public: ...@@ -318,9 +319,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator&(const constUnion& constant) const TConstUnion operator&(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break; case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
...@@ -331,9 +332,9 @@ public: ...@@ -331,9 +332,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator|(const constUnion& constant) const TConstUnion operator|(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break; case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
...@@ -344,9 +345,9 @@ public: ...@@ -344,9 +345,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator^(const constUnion& constant) const TConstUnion operator^(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break; case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
...@@ -357,9 +358,9 @@ public: ...@@ -357,9 +358,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator~() const TConstUnion operator~() const
{ {
constUnion returnValue; TConstUnion returnValue;
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break; case EbtInt: returnValue.setIConst(~iConst); break;
case EbtUint: returnValue.setUConst(~uConst); break; case EbtUint: returnValue.setUConst(~uConst); break;
...@@ -369,9 +370,9 @@ public: ...@@ -369,9 +370,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator&&(const constUnion& constant) const TConstUnion operator&&(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break; case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
...@@ -381,9 +382,9 @@ public: ...@@ -381,9 +382,9 @@ public:
return returnValue; return returnValue;
} }
constUnion operator||(const constUnion& constant) const TConstUnion operator||(const TConstUnion& constant) const
{ {
constUnion returnValue; TConstUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break; case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
...@@ -406,4 +407,6 @@ private: ...@@ -406,4 +407,6 @@ private:
TBasicType type; TBasicType type;
}; };
} // end namespace glslang
#endif // _CONSTANT_UNION_INCLUDED_ #endif // _CONSTANT_UNION_INCLUDED_
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "../Include/Common.h" #include "../Include/Common.h"
#include <math.h> #include <math.h>
namespace glslang {
// //
// TPrefixType is used to centralize how info log messages start. // TPrefixType is used to centralize how info log messages start.
// See below. // See below.
...@@ -131,10 +133,12 @@ protected: ...@@ -131,10 +133,12 @@ protected:
int outputStream; int outputStream;
}; };
} // end namespace glslang
class TInfoSink { class TInfoSink {
public: public:
TInfoSinkBase info; glslang::TInfoSinkBase info;
TInfoSinkBase debug; glslang::TInfoSinkBase debug;
}; };
#endif // _INFOSINK_INCLUDED_ #endif // _INFOSINK_INCLUDED_
...@@ -35,9 +35,13 @@ ...@@ -35,9 +35,13 @@
#ifndef __INITIALIZE_GLOBALS_INCLUDED_ #ifndef __INITIALIZE_GLOBALS_INCLUDED_
#define __INITIALIZE_GLOBALS_INCLUDED_ #define __INITIALIZE_GLOBALS_INCLUDED_
namespace glslang {
void InitializeGlobalPools(); void InitializeGlobalPools();
void FreeGlobalPools(); void FreeGlobalPools();
bool InitializePoolIndex(); bool InitializePoolIndex();
void FreePoolIndex(); void FreePoolIndex();
} // end namespace glslang
#endif // __INITIALIZE_GLOBALS_INCLUDED_ #endif // __INITIALIZE_GLOBALS_INCLUDED_
...@@ -65,6 +65,8 @@ ...@@ -65,6 +65,8 @@
#include <string.h> #include <string.h>
#include <vector> #include <vector>
namespace glslang {
// If we are using guard blocks, we must track each indivual // If we are using guard blocks, we must track each indivual
// allocation. If we aren't using guard blocks, these // allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact. // never get instantiated, so won't have any impact.
...@@ -316,4 +318,6 @@ protected: ...@@ -316,4 +318,6 @@ protected:
TPoolAllocator& allocator; TPoolAllocator& allocator;
}; };
} // end namespace glslang
#endif // _POOLALLOC_INCLUDED_ #endif // _POOLALLOC_INCLUDED_
...@@ -58,4 +58,5 @@ struct TBuiltInResource { ...@@ -58,4 +58,5 @@ struct TBuiltInResource {
int minProgramTexelOffset; int minProgramTexelOffset;
int maxProgramTexelOffset; int maxProgramTexelOffset;
}; };
#endif // _RESOURCE_LIMITS_INCLUDED_ #endif // _RESOURCE_LIMITS_INCLUDED_
...@@ -52,7 +52,6 @@ class TCompiler; ...@@ -52,7 +52,6 @@ class TCompiler;
class TLinker; class TLinker;
class TUniformMap; class TUniformMap;
// //
// The base class used to back handles returned to the driver. // The base class used to back handles returned to the driver.
// //
...@@ -78,6 +77,7 @@ public: ...@@ -78,6 +77,7 @@ public:
virtual TInfoSink& getInfoSink() { return infoSink; } virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink infoSink; TInfoSink infoSink;
}; };
class TIntermNode; class TIntermNode;
// //
...@@ -105,8 +105,8 @@ protected: ...@@ -105,8 +105,8 @@ protected:
// //
// Link operations are base on a list of compile results... // Link operations are base on a list of compile results...
// //
typedef TVector<TCompiler*> TCompilerList; typedef glslang::TVector<TCompiler*> TCompilerList;
typedef TVector<TShHandleBase*> THandleList; typedef glslang::TVector<TShHandleBase*> THandleList;
// //
// The base class for the machine dependent linker to derive from // The base class for the machine dependent linker to derive from
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "../Include/Common.h" #include "../Include/Common.h"
#include "../Include/BaseTypes.h" #include "../Include/BaseTypes.h"
namespace glslang {
const int GlslangMaxTypeLength = 200; const int GlslangMaxTypeLength = 200;
// //
...@@ -680,8 +682,8 @@ public: ...@@ -680,8 +682,8 @@ public:
return getBasicString(); return getBasicString();
} }
const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); } const char* getStorageQualifierString() const { return GetStorageQualifierString(qualifier.storage); }
const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); } const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
TTypeList* getStruct() { return structure; } TTypeList* getStruct() { return structure; }
TTypeList* getStruct() const { return structure; } TTypeList* getStruct() const { return structure; }
...@@ -753,4 +755,6 @@ protected: ...@@ -753,4 +755,6 @@ protected:
TString *typeName; // for structure field type name TString *typeName; // for structure field type name
}; };
} // end namespace glslang
#endif // _TYPES_INCLUDED_ #endif // _TYPES_INCLUDED_
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include "../Include/Types.h" #include "../Include/Types.h"
#include "../Include/ConstantUnion.h" #include "../Include/ConstantUnion.h"
namespace glslang {
// //
// Operators used by the high-level (parse tree) representation. // Operators used by the high-level (parse tree) representation.
// //
...@@ -324,34 +326,41 @@ class TIntermBranch; ...@@ -324,34 +326,41 @@ class TIntermBranch;
class TIntermTyped; class TIntermTyped;
class TIntermMethod; class TIntermMethod;
class TIntermSymbol; class TIntermSymbol;
class TInfoSink;
} // end namespace glslang
// //
// Base class for the tree nodes // Base class for the tree nodes
// //
// (Put outside the glslang namespace, as it's used as part of the external interface.)
//
class TIntermNode { class TIntermNode {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
TIntermNode() { loc.line = 0; loc.string = 0; } TIntermNode() { loc.line = 0; loc.string = 0; }
virtual TSourceLoc getLoc() const { return loc; } virtual glslang::TSourceLoc getLoc() const { return loc; }
virtual void setLoc(TSourceLoc l) { loc = l; } virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
virtual void traverse(TIntermTraverser*) = 0; virtual void traverse(glslang::TIntermTraverser*) = 0;
virtual TIntermTyped* getAsTyped() { return 0; } virtual glslang::TIntermTyped* getAsTyped() { return 0; }
virtual TIntermConstantUnion* getAsConstantUnion() { return 0; } virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual TIntermAggregate* getAsAggregate() { return 0; } virtual glslang::TIntermAggregate* getAsAggregate() { return 0; }
virtual TIntermUnary* getAsUnaryNode() { return 0; } virtual glslang::TIntermUnary* getAsUnaryNode() { return 0; }
virtual TIntermBinary* getAsBinaryNode() { return 0; } virtual glslang::TIntermBinary* getAsBinaryNode() { return 0; }
virtual TIntermSelection* getAsSelectionNode() { return 0; } virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
virtual TIntermSwitch* getAsSwitchNode() { return 0; } virtual glslang::TIntermSwitch* getAsSwitchNode() { return 0; }
virtual TIntermMethod* getAsMethodNode() { return 0; } virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
virtual TIntermSymbol* getAsSymbolNode() { return 0; } virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
virtual TIntermBranch* getAsBranchNode() { return 0; } virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
virtual ~TIntermNode() { } virtual ~TIntermNode() { }
protected: protected:
TSourceLoc loc; glslang::TSourceLoc loc;
}; };
class TInfoSink;
namespace glslang {
// //
// This is just to help yacc. // This is just to help yacc.
// //
...@@ -465,15 +474,15 @@ protected: ...@@ -465,15 +474,15 @@ protected:
class TIntermConstantUnion : public TIntermTyped { class TIntermConstantUnion : public TIntermTyped {
public: public:
TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { } TIntermConstantUnion(TConstUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
constUnion* getUnionArrayPointer() const { return unionArrayPointer; } TConstUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; } void setUnionArrayPointer(TConstUnion *c) { unionArrayPointer = c; }
virtual TIntermConstantUnion* getAsConstantUnion() { return this; } virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser* ); virtual void traverse(TIntermTraverser* );
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&); virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&); virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
protected: protected:
constUnion *unionArrayPointer; TConstUnion *unionArrayPointer;
}; };
// //
...@@ -646,4 +655,6 @@ public: ...@@ -646,4 +655,6 @@ public:
bool rightToLeft; bool rightToLeft;
}; };
} // end namespace glslang
#endif // __INTERMEDIATE_H #endif // __INTERMEDIATE_H
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <string.h> #include <string.h>
namespace glslang {
void TInfoSinkBase::append(const char *s) void TInfoSinkBase::append(const char *s)
{ {
if (outputStream & EString) { if (outputStream & EString) {
...@@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t) ...@@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t)
if (outputStream & EStdOut) if (outputStream & EStdOut)
fprintf(stdout, "%s", t.c_str()); fprintf(stdout, "%s", t.c_str());
} }
} // end namespace glslang
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
#include "Initialize.h" #include "Initialize.h"
namespace glslang {
const int FirstProfileVersion = 150; const int FirstProfileVersion = 150;
const bool ForwardCompatibility = false; const bool ForwardCompatibility = false;
...@@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb ...@@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
break; break;
} }
} }
} // end namespace glslang
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "SymbolTable.h" #include "SymbolTable.h"
#include "Versions.h" #include "Versions.h"
namespace glslang {
class TBuiltIns { class TBuiltIns {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
...@@ -71,4 +73,6 @@ protected: ...@@ -71,4 +73,6 @@ protected:
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&); void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources); void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_ #endif // _INITIALIZE_INCLUDED_
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
namespace glslang {
// //
// Traverse the intermediate representation tree, and // Traverse the intermediate representation tree, and
// call a node type specific function for each node. // call a node type specific function for each node.
...@@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it) ...@@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it)
if (visit && it->postVisit && it->visitSwitch) if (visit && it->postVisit && it->visitSwitch)
it->visitSwitch(false, this, it); it->visitSwitch(false, this, it);
} }
} // end namespace glslang
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "RemoveTree.h" #include "RemoveTree.h"
#include <float.h> #include <float.h>
namespace glslang {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //
// First set of functions are to help build the intermediate representation. // First set of functions are to help build the intermediate representation.
...@@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true ...@@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
// Returns the constant union node created. // 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); TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
node->setLoc(loc); node->setLoc(loc);
...@@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc) ...@@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc)
node->setLoc(loc); node->setLoc(loc);
TIntermConstantUnion* constIntNode; TIntermConstantUnion* constIntNode;
TIntermSequence &sequenceVector = node->getSequence(); TIntermSequence &sequenceVector = node->getSequence();
constUnion* unionArray; TConstUnion* unionArray;
for (int i = 0; i < fields.num; i++) { for (int i = 0; i < fields.num; i++) {
unionArray = new constUnion[1]; unionArray = new TConstUnion[1];
unionArray->setIConst(fields.offsets[i]); unionArray->setIConst(fields.offsets[i]);
constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc); constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
sequenceVector.push_back(constIntNode); sequenceVector.push_back(constIntNode);
...@@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC ...@@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
if (node->getType().isArray()) if (node->getType().isArray())
infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc()); infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
constUnion *rightUnionArray = node->getUnionArrayPointer(); TConstUnion *rightUnionArray = node->getUnionArrayPointer();
int size = node->getType().getObjectSize(); int size = node->getType().getObjectSize();
constUnion *leftUnionArray = new constUnion[size]; TConstUnion *leftUnionArray = new TConstUnion[size];
for (int i=0; i < size; i++) { for (int i=0; i < size; i++) {
switch (promoteTo) { switch (promoteTo) {
...@@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable) ...@@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
*pragmaTable = pTable; *pragmaTable = pTable;
} }
} // end namespace glslang
//
//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_
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "SymbolTable.h" #include "SymbolTable.h"
#include "localintermediate.h" #include "localintermediate.h"
namespace glslang {
typedef enum { typedef enum {
EBhRequire, EBhRequire,
EBhEnable, EBhEnable,
...@@ -55,12 +57,9 @@ struct TPragma { ...@@ -55,12 +57,9 @@ struct TPragma {
TPragmaTable pragmaTable; TPragmaTable pragmaTable;
}; };
class TScanContext;
class TPpContext; class TPpContext;
namespace glslang {
class TScanContext;
};
// //
// 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.
...@@ -70,7 +69,7 @@ public: ...@@ -70,7 +69,7 @@ public:
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&, TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault); bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
glslang::TScanContext* scanContext; TScanContext* scanContext;
TPpContext* ppContext; TPpContext* ppContext;
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 current language, version, and profile TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
...@@ -200,4 +199,6 @@ public: ...@@ -200,4 +199,6 @@ public:
void doubleCheck(TSourceLoc, const char* op); void doubleCheck(TSourceLoc, const char* op);
}; };
} // end namespace glslang
#endif // _PARSER_HELPER_INCLUDED_ #endif // _PARSER_HELPER_INCLUDED_
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "Include/InitializeGlobals.h" #include "Include/InitializeGlobals.h"
#include "osinclude.h" #include "osinclude.h"
namespace glslang {
OS_TLSIndex PoolIndex; OS_TLSIndex PoolIndex;
void InitializeGlobalPools() void InitializeGlobalPools()
...@@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const ...@@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc) for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
alloc->check(); alloc->check();
} }
} // end namespace glslang
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
namespace glslang {
class TAliveTraverser : public TIntermTraverser { class TAliveTraverser : public TIntermTraverser {
public: public:
TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q) TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
...@@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it) ...@@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
return true; return true;
} }
} // end namespace glslang
#endif #endif
...@@ -32,4 +32,8 @@ ...@@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE. //POSSIBILITY OF SUCH DAMAGE.
// //
namespace glslang {
bool QualifierWritten(TIntermNode* root, TStorageQualifier); bool QualifierWritten(TIntermNode* root, TStorageQualifier);
} // end namespace glslang
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
#include "RemoveTree.h" #include "RemoveTree.h"
namespace glslang {
// //
// Code to recursively delete the intermediate tree. // Code to recursively delete the intermediate tree.
// //
...@@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root) ...@@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root)
root->traverse(&it); root->traverse(&it);
} }
} // end namespace glslang
...@@ -32,4 +32,8 @@ ...@@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE. //POSSIBILITY OF SUCH DAMAGE.
// //
namespace glslang {
void RemoveAllTreeNodes(TIntermNode*); void RemoveAllTreeNodes(TIntermNode*);
} // end namespace glslang
...@@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile) ...@@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile)
return foundNonSpaceTab; return foundNonSpaceTab;
} }
}; // end glslang namespace
namespace glslang {
// Fill this in when doing glslang-level scanning, to hand back to the parser. // Fill this in when doing glslang-level scanning, to hand back to the parser.
class TParserToken { class TParserToken {
public: public:
...@@ -242,10 +238,10 @@ public: ...@@ -242,10 +238,10 @@ public:
YYSTYPE& sType; YYSTYPE& sType;
}; };
}; // end namespace glslang } // end namespace glslang
// This is the function the glslang parser (i.e., bison) calls to get its next token // 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); glslang::TParserToken token(*glslangTokenDesc);
...@@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage() ...@@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage()
return identifierOrType(); return identifierOrType();
} }
}; } // end namespace glslang
...@@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input); ...@@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input);
void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab); void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
bool ScanVersion(TInputScanner& input, int& version, EProfile& profile); bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
}; // end glslang namespace } // end namespace glslang
...@@ -40,11 +40,10 @@ ...@@ -40,11 +40,10 @@
#include "ParseHelper.h" #include "ParseHelper.h"
class TPpContext;
class TPpToken;
namespace glslang { namespace glslang {
class TPpContext;
class TPpToken;
class TParserToken; class TParserToken;
class TScanContext { class TScanContext {
...@@ -79,4 +78,4 @@ protected: ...@@ -79,4 +78,4 @@ protected:
int keyword; int keyword;
}; };
}; } // end namespace glslang
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
namespace { // anonymous namespace for file-local functions and symbols namespace { // anonymous namespace for file-local functions and symbols
using namespace glslang;
int MapVersionToIndex(int version) int MapVersionToIndex(int version)
{ {
switch(version) { switch(version) {
...@@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil ...@@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink); TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
TPpContext ppContext(parseContext); TPpContext ppContext(parseContext);
glslang::TScanContext scanContext(parseContext); TScanContext scanContext(parseContext);
parseContext.scanContext = &scanContext; parseContext.scanContext = &scanContext;
parseContext.ppContext = &ppContext; parseContext.ppContext = &ppContext;
...@@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile) ...@@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
return true; 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. // ShInitialize() should be called exactly once per process, not per thread.
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "SymbolTable.h" #include "SymbolTable.h"
namespace glslang {
// //
// TType helper function needs a place to live. // TType helper function needs a place to live.
// //
...@@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol ...@@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
if (copyOf.unionArray) { if (copyOf.unionArray) {
assert(!copyOf.type.getStruct()); assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1); assert(copyOf.type.getObjectSize() == 1);
unionArray = new constUnion[1]; unionArray = new TConstUnion[1];
unionArray[0] = copyOf.unionArray[0]; unionArray[0] = copyOf.unionArray[0];
} else } else
unionArray = 0; unionArray = 0;
...@@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf) ...@@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
for (unsigned int i = 0; i < copyOf.table.size(); ++i) for (unsigned int i = 0; i < copyOf.table.size(); ++i)
table.push_back(copyOf.table[i]->clone(remapper)); table.push_back(copyOf.table[i]->clone(remapper));
} }
} // end namespace glslang
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
#include "../Include/intermediate.h" #include "../Include/intermediate.h"
#include "../Include/InfoSink.h" #include "../Include/InfoSink.h"
namespace glslang {
// //
// Symbol base class. (Can build functions or variables out of these...) // Symbol base class. (Can build functions or variables out of these...)
// //
...@@ -126,16 +128,16 @@ public: ...@@ -126,16 +128,16 @@ public:
virtual void dump(TInfoSink &infoSink) const; virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstUnionPointer() { TConstUnion* getConstUnionPointer() {
if (!unionArray) if (!unionArray)
unionArray = new constUnion[type.getObjectSize()]; unionArray = new TConstUnion[type.getObjectSize()];
return unionArray; return unionArray;
} }
constUnion* getConstUnionPointer() const { return unionArray; } TConstUnion* getConstUnionPointer() const { return unionArray; }
void shareConstPointer( constUnion *constArray) void shareConstPointer( TConstUnion *constArray)
{ {
delete unionArray; delete unionArray;
unionArray = constArray; unionArray = constArray;
...@@ -150,7 +152,7 @@ protected: ...@@ -150,7 +152,7 @@ protected:
bool userType; bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray // we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed // 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 TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
}; };
...@@ -479,4 +481,6 @@ protected: ...@@ -479,4 +481,6 @@ protected:
unsigned int adoptedLevels; unsigned int adoptedLevels;
}; };
} // end namespace glslang
#endif // _SYMBOL_TABLE_INCLUDED_ #endif // _SYMBOL_TABLE_INCLUDED_
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#include "ParseHelper.h" #include "ParseHelper.h"
namespace glslang {
const char* StageName[EShLangCount] = { const char* StageName[EShLangCount] = {
"vertex", "vertex",
"tessellation control", "tessellation control",
...@@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op) ...@@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
profileRequires(loc, ECoreProfile, 400, 0, op); profileRequires(loc, ECoreProfile, 400, 0, op);
profileRequires(loc, ECompatibilityProfile, 400, 0, op); profileRequires(loc, ECompatibilityProfile, 400, 0, op);
} }
} // end namespace glslang
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
// //
/** /**
* This is bison grammar and production code for parsing the OpenGL 2.0 shading * This is bison grammar and productions for parsing all versions of the
* languages. * GLSL shading languages.
*/ */
%{ %{
...@@ -59,37 +59,39 @@ Jutta Degener, 1995 ...@@ -59,37 +59,39 @@ Jutta Degener, 1995
#include "ParseHelper.h" #include "ParseHelper.h"
#include "../Public/ShaderLang.h" #include "../Public/ShaderLang.h"
using namespace glslang;
%} %}
%union { %union {
struct { struct {
TSourceLoc loc; glslang::TSourceLoc loc;
union { union {
TString *string; glslang::TString *string;
int i; int i;
unsigned int u; unsigned int u;
bool b; bool b;
double d; double d;
}; };
TSymbol* symbol; glslang::TSymbol* symbol;
} lex; } lex;
struct { struct {
TSourceLoc loc; glslang::TSourceLoc loc;
TOperator op; glslang::TOperator op;
union { union {
TIntermNode* intermNode; TIntermNode* intermNode;
TIntermNodePair nodePair; glslang::TIntermNodePair nodePair;
TIntermTyped* intermTypedNode; glslang::TIntermTyped* intermTypedNode;
TIntermAggregate* intermAggregate; glslang::TIntermAggregate* intermAggregate;
}; };
union { union {
TPublicType type; glslang::TPublicType type;
TFunction* function; glslang::TFunction* function;
TParameter param; glslang::TParameter param;
TTypeLoc typeLine; glslang::TTypeLoc typeLine;
TTypeList* typeList; glslang::TTypeList* typeList;
TArraySizes arraySizes; glslang::TArraySizes arraySizes;
TIdentifierList* identifierList; glslang::TIdentifierList* identifierList;
}; };
} interm; } interm;
} }
...@@ -224,29 +226,29 @@ primary_expression ...@@ -224,29 +226,29 @@ primary_expression
$$ = $1; $$ = $1;
} }
| INTCONSTANT { | INTCONSTANT {
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst($1.i); unionArray->setIConst($1.i);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
} }
| UINTCONSTANT { | UINTCONSTANT {
parseContext.fullIntegerCheck($1.loc, "unsigned literal"); parseContext.fullIntegerCheck($1.loc, "unsigned literal");
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setUConst($1.u); unionArray->setUConst($1.u);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
} }
| FLOATCONSTANT { | FLOATCONSTANT {
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d); unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
} }
| DOUBLECONSTANT { | DOUBLECONSTANT {
parseContext.doubleCheck($1.loc, "double literal"); parseContext.doubleCheck($1.loc, "double literal");
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d); unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
} }
| BOOLCONSTANT { | BOOLCONSTANT {
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst($1.b); unionArray->setBConst($1.b);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
} }
...@@ -511,7 +513,7 @@ relational_expression ...@@ -511,7 +513,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -520,7 +522,7 @@ relational_expression ...@@ -520,7 +522,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -529,7 +531,7 @@ relational_expression ...@@ -529,7 +531,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -538,7 +540,7 @@ relational_expression ...@@ -538,7 +540,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -551,7 +553,7 @@ equality_expression ...@@ -551,7 +553,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray())) } else if (($1->isArray() || $3->isArray()))
...@@ -561,7 +563,7 @@ equality_expression ...@@ -561,7 +563,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray())) } else if (($1->isArray() || $3->isArray()))
...@@ -611,7 +613,7 @@ logical_and_expression ...@@ -611,7 +613,7 @@ logical_and_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -624,7 +626,7 @@ logical_xor_expression ...@@ -624,7 +626,7 @@ logical_xor_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -637,7 +639,7 @@ logical_or_expression ...@@ -637,7 +639,7 @@ logical_or_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc); $$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString()); parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1]; TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc); $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} }
...@@ -871,7 +873,7 @@ function_header ...@@ -871,7 +873,7 @@ function_header
: fully_specified_type IDENTIFIER LEFT_PAREN { : fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) { if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
parseContext.error($2.loc, "no qualifiers allowed for function return", 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) // Add the function as a prototype after parsing it (we do not support recursion)
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "localintermediate.h" #include "localintermediate.h"
namespace glslang {
// //
// Two purposes: // Two purposes:
// 1. Show an example of how to iterate tree. Functions can // 1. Show an example of how to iterate tree. Functions can
...@@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root) ...@@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root)
root->traverse(&it); root->traverse(&it);
} }
} // end namespace glslang
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "SymbolTable.h" #include "SymbolTable.h"
#include "Versions.h" #include "Versions.h"
namespace glslang {
struct TVectorFields { struct TVectorFields {
int offsets[4]; int offsets[4];
int num; int num;
...@@ -48,7 +50,6 @@ struct TVectorFields { ...@@ -48,7 +50,6 @@ struct TVectorFields {
// //
// Set of helper functions to help parse and build the tree. // Set of helper functions to help parse and build the tree.
// //
class TInfoSink;
class TIntermediate { class TIntermediate {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
...@@ -74,9 +75,9 @@ public: ...@@ -74,9 +75,9 @@ public:
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); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, 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*) ; 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); TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
TIntermBranch* addBranch(TOperator, TSourceLoc); TIntermBranch* addBranch(TOperator, TSourceLoc);
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc); TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
...@@ -97,4 +98,6 @@ private: ...@@ -97,4 +98,6 @@ private:
void operator=(TIntermediate&); // prevent assignments void operator=(TIntermediate&); // prevent assignments
}; };
} // end namespace glslang
#endif // _LOCAL_INTERMEDIATE_INCLUDED_ #endif // _LOCAL_INTERMEDIATE_INCLUDED_
...@@ -34,17 +34,19 @@ ...@@ -34,17 +34,19 @@
#include "ParseHelper.h" #include "ParseHelper.h"
namespace glslang {
// //
// Use this class to carry along data from node to node in // Use this class to carry along data from node to node in
// the traversal // the traversal
// //
class TConstTraverser : public TIntermTraverser { class TConstTraverser : public TIntermTraverser {
public: 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), constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;} matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
int index ; int index ;
constUnion *unionArray; TConstUnion *unionArray;
TOperator tOp; TOperator tOp;
const TType& type; const TType& type;
TOperator constructorType; TOperator constructorType;
...@@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse ...@@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{ {
TConstTraverser* oit = static_cast<TConstTraverser*>(it); TConstTraverser* oit = static_cast<TConstTraverser*>(it);
constUnion* leftUnionArray = oit->unionArray; TConstUnion* leftUnionArray = oit->unionArray;
int instanceSize = oit->type.getObjectSize(); int instanceSize = oit->type.getObjectSize();
if (oit->index >= instanceSize) if (oit->index >= instanceSize)
...@@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
if (!oit->singleConstantParam) { if (!oit->singleConstantParam) {
int size = node->getType().getObjectSize(); int size = node->getType().getObjectSize();
constUnion *rightUnionArray = node->getUnionArrayPointer(); TConstUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) { for (int i=0; i < size; i++) {
if (oit->index >= instanceSize) if (oit->index >= instanceSize)
return; return;
...@@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
matrixRows = oit->matrixRows; matrixRows = oit->matrixRows;
isMatrix = oit->isMatrix; isMatrix = oit->isMatrix;
totalSize = oit->index + size; totalSize = oit->index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer(); TConstUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) { if (!isMatrix) {
int count = 0; int count = 0;
for (int i = oit->index; i < totalSize; i++) { for (int i = oit->index; i < totalSize; i++) {
...@@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it) ...@@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
// Individual functions can be initialized to 0 to skip processing of that // Individual functions can be initialized to 0 to skip processing of that
// type of node. It's children will still be processed. // 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) if (root == 0)
return false; return false;
...@@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio ...@@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio
else else
return false; return false;
} }
} // end namespace glslang
...@@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc #undef malloc
#undef free #undef free
namespace glslang {
int TPpContext::InitCPP() int TPpContext::InitCPP()
{ {
TPpContext::AtomTable* atable = &atomTable; TPpContext::AtomTable* atable = &atomTable;
...@@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) { ...@@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) {
DeleteTokenStream(s->body); DeleteTokenStream(s->body);
} }
static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; } int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { } void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
void TPpContext::PushEofSrc() void TPpContext::PushEofSrc()
{ {
...@@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting() ...@@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting()
return 0; return 0;
} }
} // end namespace glslang
\ No newline at end of file
...@@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef realloc #undef realloc
#undef free #undef free
namespace {
using namespace glslang;
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// String table: ////////////////////////////////////// ////////////////////////////////////////// String table: //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
static const struct { const struct {
int val; int val;
const char *str; const char *str;
} tokens[] = { } tokens[] = {
...@@ -135,7 +139,6 @@ static const struct { ...@@ -135,7 +139,6 @@ static const struct {
* InitStringTable() - Initialize the string table. * InitStringTable() - Initialize the string table.
* *
*/ */
int InitStringTable(TPpContext::StringTable *stable) int InitStringTable(TPpContext::StringTable *stable)
{ {
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE); stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
...@@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable) ...@@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable)
* FreeStringTable() - Free the string table. * FreeStringTable() - Free the string table.
* *
*/ */
void FreeStringTable(TPpContext::StringTable *stable) void FreeStringTable(TPpContext::StringTable *stable)
{ {
if (stable->strings) if (stable->strings)
...@@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable) ...@@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable)
* HashString() - Hash a string with the base hash function. * HashString() - Hash a string with the base hash function.
* *
*/ */
int HashString(const char *s)
static int HashString(const char *s)
{ {
int hval = 0; int hval = 0;
...@@ -181,8 +182,7 @@ static int HashString(const char *s) ...@@ -181,8 +182,7 @@ static int HashString(const char *s)
* HashString2() - Hash a string with the incrimenting hash function. * HashString2() - Hash a string with the incrimenting hash function.
* *
*/ */
int HashString2(const char *s)
static int HashString2(const char *s)
{ {
int hval = 0; int hval = 0;
...@@ -197,8 +197,7 @@ static int HashString2(const char *s) ...@@ -197,8 +197,7 @@ static int HashString2(const char *s)
* AddString() - Add a string to a string table. Return it's offset. * AddString() - Add a string to a string table. Return it's offset.
* *
*/ */
int AddString(TPpContext::StringTable *stable, const char *s)
static int AddString(TPpContext::StringTable *stable, const char *s)
{ {
int len, loc; int len, loc;
char *str; char *str;
...@@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s) ...@@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s)
* InitHashTable() - Initialize the hash table. * InitHashTable() - Initialize the hash table.
* *
*/ */
int InitHashTable(TPpContext::HashTable *htable, int fsize)
static int InitHashTable(TPpContext::HashTable *htable, int fsize)
{ {
int ii; int ii;
...@@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize) ...@@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize)
* FreeHashTable() - Free the hash table. * FreeHashTable() - Free the hash table.
* *
*/ */
void FreeHashTable(TPpContext::HashTable *htable)
static void FreeHashTable(TPpContext::HashTable *htable)
{ {
if (htable->entry) if (htable->entry)
free(htable->entry); free(htable->entry);
...@@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable) ...@@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable)
* Empty() - See if a hash table entry is empty. * Empty() - See if a hash table entry is empty.
* *
*/ */
int Empty(TPpContext::HashTable *htable, int hashloc)
static int Empty(TPpContext::HashTable *htable, int hashloc)
{ {
assert(hashloc >= 0 && hashloc < htable->size); assert(hashloc >= 0 && hashloc < htable->size);
if (htable->entry[hashloc].index == 0) { if (htable->entry[hashloc].index == 0) {
...@@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc) ...@@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc)
* Match() - See if a hash table entry is matches a string. * Match() - See if a hash table entry is matches a string.
* *
*/ */
int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
{ {
int strloc; int strloc;
...@@ -302,7 +297,6 @@ static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, ...@@ -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. * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
* *
*/ */
int GrowAtomTable(TPpContext::AtomTable *atable, int size) int GrowAtomTable(TPpContext::AtomTable *atable, int size)
{ {
int *newmap, *newrev; int *newmap, *newrev;
...@@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size) ...@@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size)
* lReverse() - Reverse the bottom 20 bits of a 32 bit int. * lReverse() - Reverse the bottom 20 bits of a 32 bit int.
* *
*/ */
int lReverse(int fval)
static int lReverse(int fval)
{ {
unsigned int in = fval; unsigned int in = fval;
int result = 0, cnt = 0; int result = 0, cnt = 0;
...@@ -362,7 +355,6 @@ static int lReverse(int fval) ...@@ -362,7 +355,6 @@ static int lReverse(int fval)
* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1. * AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
* *
*/ */
int AllocateAtom(TPpContext::AtomTable *atable) int AllocateAtom(TPpContext::AtomTable *atable)
{ {
if (atable->nextFree >= atable->size) if (atable->nextFree >= atable->size)
...@@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable) ...@@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable)
* SetAtomValue() - Allocate a new atom associated with "hashindex". * SetAtomValue() - Allocate a new atom associated with "hashindex".
* *
*/ */
void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex) void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
{ {
atable->amap[atomnumber] = atable->htable.entry[hashindex].index; atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
...@@ -388,7 +379,6 @@ void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex) ...@@ -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. * FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
* *
*/ */
int FindHashLoc(TPpContext::AtomTable *atable, const char *s) int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
{ {
int hashloc, hashdelta, count; int hashloc, hashdelta, count;
...@@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s) ...@@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
return hashloc; return hashloc;
} // FindHashLoc } // FindHashLoc
} // end anonymous namespace
namespace glslang {
/* /*
* IncreaseHashTableSize() * IncreaseHashTableSize()
* *
*/ */
int TPpContext::IncreaseHashTableSize(AtomTable *atable) int TPpContext::IncreaseHashTableSize(AtomTable *atable)
{ {
int ii, strloc, oldhashloc, value, size; int ii, strloc, oldhashloc, value, size;
...@@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable) ...@@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable)
atable->size = 0; atable->size = 0;
} // FreeAtomTable } // FreeAtomTable
/////////////////////////////////////////////////////////////////////////////////////////////// } // end namespace glslang
///////////////////////////////////////// End of atom.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
...@@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h" #include "PpContext.h"
namespace glslang {
TPpContext::TPpContext(TParseContext& pc) : TPpContext::TPpContext(TParseContext& pc) :
parseContext(pc), preamble(0), strings(0), notAVersionToken(false), parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
ScopeList(0), CurrentScope(0), GlobalScope(0) ScopeList(0), CurrentScope(0), GlobalScope(0)
...@@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n) ...@@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n)
currentString = 0; currentString = 0;
} }
} }
} // end namespace glslang
...@@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../ParseHelper.h" #include "../ParseHelper.h"
namespace glslang {
class TPpToken { class TPpToken {
public: public:
static const int maxTokenLength = 1024; static const int maxTokenLength = 1024;
...@@ -386,5 +388,6 @@ protected: ...@@ -386,5 +388,6 @@ protected:
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2); int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
}; };
#endif // PPCONTEXT_H } // end namespace glslang
#endif // PPCONTEXT_H
...@@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc #undef malloc
#undef free #undef free
namespace glslang {
struct chunk { struct chunk {
struct chunk *next; struct chunk *next;
}; };
...@@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void ...@@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void
pool->cleanup = cleanup; pool->cleanup = cleanup;
return 0; return 0;
} }
} // end namespace glslang
...@@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h" #include "PpContext.h"
#include "PpTokens.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; return EOF;
} // eof_scan }
void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
{
}
static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {} TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
} // end anonymous namespace
namespace glslang {
int TPpContext::InitScanner(TPpContext *cpp) int TPpContext::InitScanner(TPpContext *cpp)
{ {
...@@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token) ...@@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token)
return 0; return 0;
} }
/////////////////////////////////////////////////////////////////////////////////////////////// } // end namespace glslang
/////////////////////////////////////// End of scanner.c //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
...@@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/////////////////////////////////// Symbol Table Variables: /////////////////////////////////// /////////////////////////////////// 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; TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
...@@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList) ...@@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList)
*(TPpContext::Scope**)scopeList = scope->next; *(TPpContext::Scope**)scopeList = scope->next;
} }
} // end anonymous namespace
namespace glslang {
/* /*
* NewScope() * NewScope()
* *
...@@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom) ...@@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
return NULL; return NULL;
} // LookUpSymbol } // LookUpSymbol
} // end namespace glslang
...@@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h" #include "PpContext.h"
#include "PpTokens.h" #include "PpTokens.h"
namespace glslang {
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// //////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
...@@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp) ...@@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////// } // end namespace glslang
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#define _vsnprintf vsnprintf #define _vsnprintf vsnprintf
namespace glslang {
void DetachThreadLinux(void *); void DetachThreadLinux(void *);
...@@ -60,7 +61,7 @@ bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); ...@@ -60,7 +61,7 @@ bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
bool OS_FreeTLSIndex(OS_TLSIndex nIndex); 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. // This function should return 0 if nIndex is invalid.
...@@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex) ...@@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
return pthread_getspecific(nIndex); return pthread_getspecific(nIndex);
} }
namespace glslang { void InitGlobalLock();
void InitGlobalLock(); void GetGlobalLock();
void GetGlobalLock(); void ReleaseGlobalLock();
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_Sleep(int milliseconds);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds); void OS_DumpMemoryCounters();
void OS_DumpMemoryCounters(); } // end namespace glslang
};
#endif // __OSINCLUDE_H #endif // __OSINCLUDE_H
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "osinclude.h" #include "osinclude.h"
#include "InitializeDll.h" #include "InitializeDll.h"
namespace glslang {
// //
// Thread cleanup // Thread cleanup
// //
...@@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex) ...@@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false; return false;
} }
namespace glslang { // TODO: if we need these on linux, flesh them out
// TODO: if we need these on linux, flesh them out void InitGlobalLock() { }
void InitGlobalLock() { } void GetGlobalLock() { }
void GetGlobalLock() { } void ReleaseGlobalLock() { }
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
...@@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!InitProcess()) if (! glslang::InitProcess())
return FALSE; return FALSE;
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
if (!InitThread()) if (! glslang::InitThread())
return FALSE; return FALSE;
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
if (!DetachThread()) if (! glslang::DetachThread())
return FALSE; return FALSE;
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
DetachProcess(); glslang::DetachProcess();
break; break;
default: default:
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#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
namespace glslang {
// //
// Thread Local Storage Operations // Thread Local Storage Operations
// //
...@@ -56,18 +58,18 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex); ...@@ -56,18 +58,18 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
void* OS_GetTLSValue(OS_TLSIndex nIndex); void* OS_GetTLSValue(OS_TLSIndex nIndex);
namespace glslang { void InitGlobalLock();
void InitGlobalLock(); void GetGlobalLock();
void GetGlobalLock(); void ReleaseGlobalLock();
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_Sleep(int milliseconds);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds); void OS_DumpMemoryCounters();
void OS_DumpMemoryCounters(); } // end namespace glslang
};
#endif // __OSINCLUDE_H #endif // __OSINCLUDE_H
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#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
namespace glslang {
// //
// Thread Local Storage Operations // Thread Local Storage Operations
// //
...@@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex) ...@@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false; return false;
} }
namespace glslang { HANDLE GlobalLock;
HANDLE GlobalLock;
void InitGlobalLock() void InitGlobalLock()
{ {
GlobalLock = CreateMutex(0, false, 0); GlobalLock = CreateMutex(0, false, 0);
} }
void GetGlobalLock() void GetGlobalLock()
{ {
WaitForSingleObject(GlobalLock, INFINITE); WaitForSingleObject(GlobalLock, INFINITE);
} }
void ReleaseGlobalLock() void ReleaseGlobalLock()
{ {
ReleaseMutex(GlobalLock); ReleaseMutex(GlobalLock);
} }
void* OS_CreateThread(TThreadEntrypoint entry) void* OS_CreateThread(TThreadEntrypoint entry)
{ {
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0); return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
//return CreateThread(0, 0, entry, 0, 0, 0); //return CreateThread(0, 0, entry, 0, 0, 0);
} }
void OS_WaitForAllThreads(void* threads, int numThreads) void OS_WaitForAllThreads(void* threads, int numThreads)
{ {
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE); WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
} }
void OS_Sleep(int milliseconds) void OS_Sleep(int milliseconds)
{ {
Sleep(milliseconds); Sleep(milliseconds);
} }
void OS_DumpMemoryCounters() void OS_DumpMemoryCounters()
{ {
PROCESS_MEMORY_COUNTERS counters; PROCESS_MEMORY_COUNTERS counters;
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
printf("Working set size: %d\n", counters.WorkingSetSize); printf("Working set size: %d\n", counters.WorkingSetSize);
} }
};
} // namespace glslang
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment