glsl: Track descriptions of some expressions that can't be l-values
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 23 Dec 2011 17:56:03 +0000 (09:56 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 6 Jan 2012 22:32:50 +0000 (14:32 -0800)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ast.h
src/glsl/ast_to_hir.cpp
src/glsl/glsl_parser_extras.cpp

index d899bc62a81dffe5d638121ab05a455cd0d77155..1f78af87e5a226696a1bedcd2f5a592e47c7bd1c 100644 (file)
@@ -207,6 +207,7 @@ public:
       subexpressions[1] = NULL;
       subexpressions[2] = NULL;
       primary_expression.identifier = (char *) identifier;
+      this->non_lvalue_description = NULL;
    }
 
    static const char *operator_string(enum ast_operators op);
@@ -234,6 +235,18 @@ public:
     * \c ast_function_call
     */
    exec_list expressions;
+
+   /**
+    * For things that can't be l-values, this describes what it is.
+    *
+    * This text is used by the code that generates IR for assignments to
+    * detect and emit useful messages for assignments to some things that
+    * can't be l-values.  For example, pre- or post-incerement expressions.
+    *
+    * \note
+    * This pointer may be \c NULL.
+    */
+   const char *non_lvalue_description;
 };
 
 class ast_expression_bin : public ast_expression {
index f0c92187507bd4041270f4b46b64efcf50da3ba2..2644ed285672881ac1fbbfdc5e9ba0ac8fd63161 100644 (file)
@@ -1463,6 +1463,9 @@ ast_expression::hir(exec_list *instructions,
 
    case ast_pre_inc:
    case ast_pre_dec: {
+      this->non_lvalue_description = (this->oper == ast_pre_inc)
+        ? "pre-increment operation" : "pre-decrement operation";
+
       op[0] = this->subexpressions[0]->hir(instructions, state);
       op[1] = constant_one_for_inc_dec(ctx, op[0]->type);
 
@@ -1481,6 +1484,8 @@ ast_expression::hir(exec_list *instructions,
 
    case ast_post_inc:
    case ast_post_dec: {
+      this->non_lvalue_description = (this->oper == ast_post_inc)
+        ? "post-increment operation" : "post-decrement operation";
       op[0] = this->subexpressions[0]->hir(instructions, state);
       op[1] = constant_one_for_inc_dec(ctx, op[0]->type);
 
index 0b4ccac531d668694a27d36335cba7e468658b69..0b53232e9e7538aa907347264534bc1ac98938cc 100644 (file)
@@ -626,6 +626,7 @@ ast_expression::ast_expression(int oper,
    this->subexpressions[0] = ex0;
    this->subexpressions[1] = ex1;
    this->subexpressions[2] = ex2;
+   this->non_lvalue_description = NULL;
 }