nvc0/ir: fix lowering of textureGrad
[mesa.git] / src / glsl / ast_type.cpp
index b7488cf6e90e7f722c690162fbc00dae9dd768dd..6c44f8c41de621869fcf528ffed2c4d33a59867f 100644 (file)
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <cstdio>
 #include "ast.h"
 extern "C" {
 #include "program/symbol_table.h"
@@ -30,7 +29,7 @@ extern "C" {
 void
 ast_type_specifier::print(void) const
 {
-   if (type_specifier == ast_struct) {
+   if (structure) {
       structure->print();
    } else {
       printf("%s ", type_name);
@@ -47,72 +46,28 @@ ast_type_specifier::print(void) const
    }
 }
 
-ast_type_specifier::ast_type_specifier(int specifier)
-      : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL),
-       is_array(false), array_size(NULL), precision(ast_precision_high)
+bool
+ast_fully_specified_type::has_qualifiers() const
 {
-   static const char *const names[] = {
-      "void",
-      "float",
-      "int",
-      "uint",
-      "bool",
-      "vec2",
-      "vec3",
-      "vec4",
-      "bvec2",
-      "bvec3",
-      "bvec4",
-      "ivec2",
-      "ivec3",
-      "ivec4",
-      "uvec2",
-      "uvec3",
-      "uvec4",
-      "mat2",
-      "mat2x3",
-      "mat2x4",
-      "mat3x2",
-      "mat3",
-      "mat3x4",
-      "mat4x2",
-      "mat4x3",
-      "mat4",
-      "sampler1D",
-      "sampler2D",
-      "sampler2DRect",
-      "sampler3D",
-      "samplerCube",
-      "sampler1DShadow",
-      "sampler2DShadow",
-      "sampler2DRectShadow",
-      "samplerCubeShadow",
-      "sampler1DArray",
-      "sampler2DArray",
-      "sampler1DArrayShadow",
-      "sampler2DArrayShadow",
-      "isampler1D",
-      "isampler2D",
-      "isampler3D",
-      "isamplerCube",
-      "isampler1DArray",
-      "isampler2DArray",
-      "usampler1D",
-      "usampler2D",
-      "usampler3D",
-      "usamplerCube",
-      "usampler1DArray",
-      "usampler2DArray",
-
-      NULL, /* ast_struct */
-      NULL  /* ast_type_name */
-   };
+   return this->qualifier.flags.i != 0;
+}
 
-   type_name = names[specifier];
+bool ast_type_qualifier::has_interpolation() const
+{
+   return this->flags.q.smooth
+          || this->flags.q.flat
+          || this->flags.q.noperspective;
 }
 
-bool
-ast_fully_specified_type::has_qualifiers() const
+const char*
+ast_type_qualifier::interpolation_string() const
 {
-   return this->qualifier.flags.i != 0;
+   if (this->flags.q.smooth)
+      return "smooth";
+   else if (this->flags.q.flat)
+      return "flat";
+   else if (this->flags.q.noperspective)
+      return "noperspective";
+   else
+      return NULL;
 }