self->dest = left;
self->source = right;
+ self->keep_dest = false;
+
self->expression.vtype = left->expression.vtype;
if (left->expression.next) {
self->expression.next = ast_type_copy(ctx, left);
void ast_binstore_delete(ast_binstore *self)
{
- ast_unref(self->dest);
+ if (!self->keep_dest)
+ ast_unref(self->dest);
ast_unref(self->source);
ast_expression_delete((ast_expression*)self);
mem_d(self);
int opbin;
ast_expression *dest;
ast_expression *source;
+ /* for &~= which uses the destination in a binary in source we can use this */
+ bool keep_dest;
};
ast_binstore* ast_binstore_new(lex_ctx ctx,
int storeop,
ast_expression *exprs[3];
ast_block *blocks[3];
ast_value *asvalue[3];
+ ast_binstore *asbinstore;
size_t i, assignop, addop, subop;
qcint generated_op = 0;
if (ast_istype(exprs[0], ast_value) && asvalue[0]->constant) {
parseerror(parser, "assignment to constant `%s`", asvalue[0]->name);
}
- out = (ast_expression*)ast_binstore_new(ctx, assignop, INSTR_SUB_F, exprs[0], out);
+ asbinstore = ast_binstore_new(ctx, assignop, INSTR_SUB_F, exprs[0], out);
+ asbinstore->keep_dest = true;
+ out = (ast_expression*)asbinstore;
break;
}
#undef NotSameType