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.
21extern 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.
25extern bool atoi_clamp(const char *str, int *value);
26
27namespace sh
28{
29
30GLenum GLVariableType(const TType &type);
31GLenum GLVariablePrecision(const TType &type);
32bool IsVaryingIn(TQualifier qualifier);
33bool IsVaryingOut(TQualifier qualifier);
34bool IsVarying(TQualifier qualifier);
35InterpolationType GetInterpolationType(TQualifier qualifier);
36TString ArrayString(const TType &type);
37
38class GetVariableTraverser
39{
40  public:
41    GetVariableTraverser() {}
42
43    template <typename VarT>
44    void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
45
46  protected:
47    // May be overloaded
48    virtual void visitVariable(ShaderVariable *newVar) {}
49
50  private:
51    DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
52};
53
54}
55
56#endif // COMPILER_UTIL_H
57