ralloc: a new MIT-licensed recursive memory allocator.
[mesa.git] / src / glsl / ast.h
index cd933cfc58850cd221633d474098707e2af2c294..878f48b20706613373c7959c998c499559ecf616 100644 (file)
@@ -49,23 +49,23 @@ struct YYLTYPE;
  */
 class ast_node {
 public:
-   /* Callers of this talloc-based new need not call delete. It's
-    * easier to just talloc_free 'ctx' (or any of its ancestors). */
+   /* Callers of this ralloc-based new need not call delete. It's
+    * easier to just ralloc_free 'ctx' (or any of its ancestors). */
    static void* operator new(size_t size, void *ctx)
    {
       void *node;
 
-      node = talloc_zero_size(ctx, size);
+      node = rzalloc_size(ctx, size);
       assert(node != NULL);
 
       return node;
    }
 
    /* If the user *does* call delete, that's OK, we will just
-    * talloc_free in that case. */
+    * ralloc_free in that case. */
    static void operator delete(void *table)
    {
-      talloc_free(table);
+      ralloc_free(table);
    }
 
    /**
@@ -318,7 +318,8 @@ public:
 
 
 enum {
-   ast_precision_high = 0, /**< Default precision. */
+   ast_precision_none = 0, /**< Absence of precision qualifier. */
+   ast_precision_high,
    ast_precision_medium,
    ast_precision_low
 };
@@ -349,6 +350,14 @@ struct ast_type_qualifier {
          * qualifier is used.
          */
         unsigned explicit_location:1;
+
+         /** \name Layout qualifiers for GL_AMD_conservative_depth */
+         /** \{ */
+         unsigned depth_any:1;
+         unsigned depth_greater:1;
+         unsigned depth_less:1;
+         unsigned depth_unchanged:1;
+         /** \} */
       }
       /** \brief Set of flags, accessed by name. */
       q;
@@ -364,6 +373,23 @@ struct ast_type_qualifier {
     * This field is only valid if \c explicit_location is set.
     */
    unsigned location;
+
+   /**
+    * Return true if and only if an interpolation qualifier is present.
+    */
+   bool has_interpolation() const;
+
+   /**
+    * \brief Return string representation of interpolation qualifier.
+    *
+    * If an interpolation qualifier is present, then return that qualifier's
+    * string representation. Otherwise, return null. For example, if the
+    * noperspective bit is set, then this returns "noperspective".
+    *
+    * If multiple interpolation qualifiers are somehow present, then the
+    * returned string is undefined but not null.
+    */
+   const char *interpolation_string() const;
 };
 
 class ast_struct_specifier : public ast_node {
@@ -444,7 +470,8 @@ public:
    /** Construct a type specifier from a type name */
    ast_type_specifier(const char *name) 
       : type_specifier(ast_type_name), type_name(name), structure(NULL),
-       is_array(false), array_size(NULL), precision(ast_precision_high)
+       is_array(false), array_size(NULL), precision(ast_precision_none),
+       is_precision_statement(false)
    {
       /* empty */
    }
@@ -452,7 +479,8 @@ public:
    /** Construct a type specifier from a structure definition */
    ast_type_specifier(ast_struct_specifier *s)
       : type_specifier(ast_struct), type_name(s->name), structure(s),
-       is_array(false), array_size(NULL), precision(ast_precision_high)
+       is_array(false), array_size(NULL), precision(ast_precision_none),
+       is_precision_statement(false)
    {
       /* empty */
    }
@@ -474,6 +502,8 @@ public:
    ast_expression *array_size;
 
    unsigned precision:2;
+
+   bool is_precision_statement;
 };
 
 
@@ -584,25 +614,6 @@ private:
 };
 
 
-class ast_declaration_statement : public ast_node {
-public:
-   ast_declaration_statement(void);
-
-   enum {
-      ast_function,
-      ast_declaration,
-      ast_precision
-   } mode;
-
-   union {
-      class ast_function *function;
-      ast_declarator_list *declarator;
-      ast_type_specifier *type;
-      ast_node *node;
-   } declaration;
-};
-
-
 class ast_expression_statement : public ast_node {
 public:
    ast_expression_statement(ast_expression *);