Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / compiler / translator / util.h
1 //
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.
5 //
6
7 #ifndef COMPILER_UTIL_H
8 #define COMPILER_UTIL_H
9
10 #include <stack>
11
12 #include "angle_gl.h"
13 #include <GLSLANG/ShaderLang.h>
14
15 #include "compiler/translator/Types.h"
16
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);
22
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);
26
27 class TSymbolTable;
28
29 namespace sh
30 {
31
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);
39
40 class GetVariableTraverser
41 {
42   public:
43     GetVariableTraverser(const TSymbolTable &symbolTable);
44
45     template <typename VarT>
46     void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
47
48   protected:
49     // May be overloaded
50     virtual void visitVariable(ShaderVariable *newVar) {}
51
52   private:
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) {}
58
59     const TSymbolTable &mSymbolTable;
60
61     DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
62 };
63
64 }
65
66 #endif // COMPILER_UTIL_H