Add support for %= in ast_to_hir.
authorEric Anholt <eric@anholt.net>
Fri, 26 Mar 2010 18:57:46 +0000 (11:57 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 27 Mar 2010 00:51:41 +0000 (17:51 -0700)
ast_to_hir.cpp

index a75177dcc88d0b768c6f82d1a2ca6f1a0e23b5b0..6fe7da646b6edcfb7ae56e5793b628cad0323c1e 100644 (file)
@@ -602,7 +602,26 @@ ast_expression::hir(exec_list *instructions,
       break;
    }
 
-   case ast_mod_assign:
+   case ast_mod_assign: {
+      op[0] = this->subexpressions[0]->hir(instructions, state);
+      op[1] = this->subexpressions[1]->hir(instructions, state);
+
+      error_emitted = op[0]->type->is_error() || op[1]->type->is_error();
+
+      type = modulus_result_type(op[0]->type, op[1]->type);
+
+      assert(operations[this->oper] == ir_binop_mod);
+
+      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_ls_assign:
    case ast_rs_assign: