}
MEM_VEC_FUNCTIONS(ast_block, ast_value*, locals)
MEM_VEC_FUNCTIONS(ast_block, ast_expression*, exprs)
+MEM_VEC_FUNCTIONS(ast_block, ast_expression*, collect)
void ast_block_delete(ast_block *self)
{
size_t i;
+ for (i = 0; i < self->collect_count; ++i)
+ ast_unref(self->collect[i]);
+ MEM_VECTOR_CLEAR(self, collect);
for (i = 0; i < self->exprs_count; ++i)
ast_unref(self->exprs[i]);
MEM_VECTOR_CLEAR(self, exprs);
MEM_VECTOR_MAKE(ast_value*, locals);
MEM_VECTOR_MAKE(ast_expression*, exprs);
+ MEM_VECTOR_MAKE(ast_expression*, collect);
};
ast_block* ast_block_new(lex_ctx ctx);
void ast_block_delete(ast_block*);
MEM_VECTOR_PROTO(ast_block, ast_value*, locals);
MEM_VECTOR_PROTO(ast_block, ast_expression*, exprs);
+MEM_VECTOR_PROTO(ast_block, ast_expression*, collect);
bool ast_block_codegen(ast_block*, ast_function*, bool lvalue, ir_value**);
(void)!parser_t_locals_add(parser, vx);
(void)!parser_t_locals_add(parser, vy);
(void)!parser_t_locals_add(parser, vz);
+ if (!ast_block_locals_add(localblock, var) ||
+ !ast_block_collect_add(localblock, vx.var) ||
+ !ast_block_collect_add(localblock, vy.var) ||
+ !ast_block_collect_add(localblock, vz.var))
+ {
+ parser_pop_local(parser);
+ parser_pop_local(parser);
+ parser_pop_local(parser);
+ parser_pop_local(parser);
+ ast_value_delete(var);
+ return false;
+ }
}
}
else
ast_value_delete(var);
return false;
}
- }
- if (localblock && !ast_block_locals_add(localblock, var))
- {
- parser_pop_local(parser);
- ast_value_delete(var);
- return false;
+ if (localblock && !ast_block_locals_add(localblock, var))
+ {
+ parser_pop_local(parser);
+ ast_value_delete(var);
+ return false;
+ }
}
if (!parser_next(parser)) {