2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 #ifndef COMPILER_UTIL_H
8 #define COMPILER_UTIL_H
13 #include <GLSLANG/ShaderLang.h>
15 #include "compiler/translator/Types.h"
17 // atof_clamp is like atof but
18 // 1. it forces C locale, i.e. forcing '.' as decimal point.
19 // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens.
20 // Return false if overflow happens.
21 extern bool atof_clamp(const char *str, float *value);
23 // If overflow happens, clamp the value to INT_MIN or INT_MAX.
24 // Return false if overflow happens.
25 extern bool atoi_clamp(const char *str, int *value);
32 GLenum GLVariableType(const TType &type);
33 GLenum GLVariablePrecision(const TType &type);
34 bool IsVaryingIn(TQualifier qualifier);
35 bool IsVaryingOut(TQualifier qualifier);
36 bool IsVarying(TQualifier qualifier);
37 InterpolationType GetInterpolationType(TQualifier qualifier);
38 TString ArrayString(const TType &type);
40 class GetVariableTraverser
43 GetVariableTraverser(const TSymbolTable &symbolTable);
45 template <typename VarT>
46 void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
50 virtual void visitVariable(ShaderVariable *newVar) {}
53 // Helper function called by traverse() to fill specific fields
54 // for attributes/varyings/uniforms.
55 template <typename VarT>
56 void setTypeSpecificInfo(
57 const TType &type, const TString &name, VarT *variable) {}
59 const TSymbolTable &mSymbolTable;
61 DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
66 #endif // COMPILER_UTIL_H