Add support for ast_to_hir of pre inc/dec.
authorEric Anholt <eric@anholt.net>
Fri, 26 Mar 2010 19:16:54 +0000 (12:16 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 27 Mar 2010 00:51:41 +0000 (17:51 -0700)
ast_to_hir.cpp

index f8ca3710340b9cd6782aef080ae03702af64b05b..67fed4cc8931600b411b51bdd8fbaee4eef8f952 100644 (file)
@@ -656,7 +656,26 @@ ast_expression::hir(exec_list *instructions,
    case ast_conditional:
 
    case ast_pre_inc:
-   case ast_pre_dec:
+   case ast_pre_dec: {
+      op[0] = this->subexpressions[0]->hir(instructions, state);
+      if (op[0]->type->base_type == GLSL_TYPE_FLOAT)
+        op[1] = new ir_constant(1.0f);
+      else
+        op[1] = new ir_constant(1);
+
+      type = arithmetic_result_type(op[0]->type, op[1]->type,
+                                   false, state);
+
+      struct ir_rvalue *temp_rhs;
+      temp_rhs = new ir_expression(operations[this->oper], type,
+                                  op[0], op[1]);
+
+      result = do_assignment(instructions, state, op[0], temp_rhs,
+                            this->subexpressions[0]->get_location());
+      type = result->type;
+      error_emitted = op[0]->type->is_error();
+      break;
+   }
 
    case ast_post_inc:
    case ast_post_dec: {