<commit_before>#include "ops.h"

const char *str_expr_assign_compound()
{
	return "assign_compound";
}

void fold_expr_assign_compound(expr *e, symtable *stab)
{
	int type_ok;

	fold_inc_writes_if_sym(e->lhs, stab);

	{
		expr *addr = expr_new_addr();

		addr->lhs = e->lhs;

		e->lhs = addr;
		/* take the address of where we're assigning to - only eval once */
	}

	fold_expr(e->lhs, stab);
	fold_expr(e->rhs, stab);

	fold_coerce_assign(e->lhs->tree_type, e->rhs, &type_ok);

	/* skip the addr we inserted */
	if(!expr_is_lvalue(e->lhs->lhs, 0)){
		DIE_AT(&e->lhs->where, "compound target not an lvalue (%s)",
				e->lhs->f_str());
	}

	if(decl_is_const(e->lhs->tree_type))
		DIE_AT(&e->where, "can't modify const expression %s", e->lhs->f_str());

	UCC_ASSERT(op_can_compound(e->op), "non-compound op in compound expr");

	e->tree_type = decl_copy(e->lhs->lhs->tree_type);
}

void gen_expr_assign_compound(expr *e, symtable *stab)
{
	fold_disallow_st_un(e, "copy (TODO)"); /* yes this is meant to be in gen */

	gen_expr(e->lhs, stab);

	if(e->assign_is_post){
		out_dup();
		out_op_unary(op_deref);
		out_flush_volatile();
		out_swap();
		out_comment("saved for compound op");
	}

	out_dup();
	out_op_unary(op_deref);

	gen_expr(e->rhs, stab);

	out_op(op_plus);

	out_store();
<commit_msg>Pay attention to the actual compound op... duh<commit_after>#include "ops.h"

const char *str_expr_assign_compound()
{
	return "assign_compound";
}

void fold_expr_assign_compound(expr *e, symtable *stab)
{
	int type_ok;

	fold_inc_writes_if_sym(e->lhs, stab);

	{
		expr *addr = expr_new_addr();

		addr->lhs = e->lhs;

		e->lhs = addr;
		/* take the address of where we're assigning to - only eval once */
	}

	fold_expr(e->lhs, stab);
	fold_expr(e->rhs, stab);

	fold_coerce_assign(e->lhs->tree_type, e->rhs, &type_ok);

	/* skip the addr we inserted */
	if(!expr_is_lvalue(e->lhs->lhs, 0)){
		DIE_AT(&e->lhs->where, "compound target not an lvalue (%s)",
				e->lhs->f_str());
	}

	if(decl_is_const(e->lhs->tree_type))
		DIE_AT(&e->where, "can't modify const expression %s", e->lhs->f_str());

	UCC_ASSERT(op_can_compound(e->op), "non-compound op in compound expr");

	e->tree_type = decl_copy(e->lhs->lhs->tree_type);
}

void gen_expr_assign_compound(expr *e, symtable *stab)
{
	fold_disallow_st_un(e, "copy (TODO)"); /* yes this is meant to be in gen */

	gen_expr(e->lhs, stab);

	if(e->assign_is_post){
		out_dup();
		out_op_unary(op_deref);
		out_flush_volatile();
		out_swap();
		out_comment("saved for compound op");
	}

	out_dup();
	out_op_unary(op_deref);

	gen_expr(e->rhs, stab);

	out_op(e->op);

	out_store();

{'fraction_non_alphanumeric': 0.17512399847386495, 'fraction_numerical': 0.0007630675314765357, 'mean_word_length': 4.555084745762712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4021814', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1107, 'n_words': 217}