#include "fold.h"
//#include "parser.h"
+#include "algo.h"
+
#define ast_instantiate(T, ctx, destroyfn) \
T* self = (T*)mem_a(sizeof(T)); \
if (!self) { \
}
ast_expression_delete((ast_expression*)self);
+ self->~ast_value();
mem_d(self);
}
if (self->refs & AST_REF_RIGHT) ast_unref(self->right);
ast_expression_delete((ast_expression*)self);
+ self->~ast_binary();
mem_d(self);
}
ast_unref(self->dest);
ast_unref(self->source);
ast_expression_delete((ast_expression*)self);
+ self->~ast_binstore();
mem_d(self);
}
{
if (self->operand) ast_unref(self->operand);
ast_expression_delete((ast_expression*)self);
+ self->~ast_unary();
mem_d(self);
}
if (self->operand)
ast_unref(self->operand);
ast_expression_delete((ast_expression*)self);
+ self->~ast_return();
mem_d(self);
}
ast_unref(self->entity);
ast_unref(self->field);
ast_expression_delete((ast_expression*)self);
+ self->~ast_entfield();
mem_d(self);
}
*/
ast_expression_delete((ast_expression*)self);
mem_d(self->name);
+ self->~ast_member();
mem_d(self);
}
if (self->index)
ast_unref(self->index);
ast_expression_delete((ast_expression*)self);
+ self->~ast_argpipe();
mem_d(self);
}
if (self->on_false)
ast_unref(self->on_false);
ast_expression_delete((ast_expression*)self);
+ self->~ast_ifthen();
mem_d(self);
}
if (self->on_true) ast_unref(self->on_true);
if (self->on_false) ast_unref(self->on_false);
ast_expression_delete((ast_expression*)self);
+ self->~ast_ternary();
mem_d(self);
}
if (self->body)
ast_unref(self->body);
ast_expression_delete((ast_expression*)self);
+ self->~ast_loop();
mem_d(self);
}
void ast_breakcont_delete(ast_breakcont *self)
{
ast_expression_delete((ast_expression*)self);
+ self->~ast_breakcont();
mem_d(self);
}
}
ast_expression_delete((ast_expression*)self);
+ self->~ast_switch();
mem_d(self);
}
{
mem_d((void*)self->name);
ast_expression_delete((ast_expression*)self);
+ self->~ast_label();
mem_d(self);
}
{
mem_d((void*)self->name);
ast_expression_delete((ast_expression*)self);
+ self->~ast_goto();
mem_d(self);
}
ast_unref(self->nextthink);
ast_expression_delete((ast_expression*)self);
+ self->~ast_state();
mem_d(self);
}
ast_unref(self->va_count);
ast_expression_delete((ast_expression*)self);
+ self->~ast_call();
mem_d(self);
}
ast_unref(self->dest);
ast_unref(self->source);
ast_expression_delete((ast_expression*)self);
+ self->~ast_store();
mem_d(self);
}
for (auto &it : self->locals) ast_delete(it);
for (auto &it : self->collect) ast_delete(it);
ast_expression_delete((ast_expression*)self);
+ self->~ast_block();
mem_d(self);
}
}
for (auto &it : self->static_names)
mem_d(it);
- for (auto &it : self->blocks)
- ast_delete(it);
+ // FIXME::DELME:: unique_ptr used on ast_block
+ //for (auto &it : self->blocks)
+ // ast_delete(it);
if (self->varargs)
ast_delete(self->varargs);
if (self->argc)
ast_unref(self->fixedparams);
if (self->return_value)
ast_unref(self->return_value);
+ self->~ast_function();
mem_d(self);
}
for (auto &it : self->blocks) {
cgen = it->codegen;
- if (!(*cgen)((ast_expression*)it, self, false, &dummy))
+ if (!(*cgen)(it.get(), self, false, &dummy))
return false;
}
if (!ir_block_create_jump(func->curblock, ast_ctx(self), merge))
return false;
- func->ir_func->blocks.erase(func->ir_func->blocks.begin() + merge_id);
- func->ir_func->blocks.emplace_back(merge);
+ algo::shiftback(func->ir_func->blocks.begin() + merge_id,
+ func->ir_func->blocks.end());
+ // FIXME::DELME::
+ //func->ir_func->blocks[merge_id].release();
+ //func->ir_func->blocks.erase(func->ir_func->blocks.begin() + merge_id);
+ //func->ir_func->blocks.emplace_back(merge);
func->curblock = merge;
phi = ir_block_create_phi(func->curblock, ast_ctx(self),
}
/* Move 'bout' to the end */
- func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bout_id);
- func->ir_func->blocks.emplace_back(bout);
+ algo::shiftback(func->ir_func->blocks.begin() + bout_id,
+ func->ir_func->blocks.end());
+ // FIXME::DELME::
+ //func->ir_func->blocks[bout_id].release(); // it's a vector<unique_ptr<>>
+ //func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bout_id);
+ //func->ir_func->blocks.emplace_back(bout);
return true;
}
/* enter the else and move it down */
func->curblock = bnot;
- func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bnot_id);
- func->ir_func->blocks.emplace_back(bnot);
+ algo::shiftback(func->ir_func->blocks.begin() + bnot_id,
+ func->ir_func->blocks.end());
+ // FIXME::DELME::
+ //func->ir_func->blocks[bnot_id].release();
+ //func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bnot_id);
+ //func->ir_func->blocks.emplace_back(bnot);
} else {
/* The default case */
/* Remember where to fall through from: */
func->breakblocks.pop_back();
/* Move 'bout' to the end, it's nicer */
- func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bout_id);
- func->ir_func->blocks.emplace_back(bout);
+ algo::shiftback(func->ir_func->blocks.begin() + bout_id,
+ func->ir_func->blocks.end());
+ // FIXME::DELME::
+ //func->ir_func->blocks[bout_id].release();
+ //func->ir_func->blocks.erase(func->ir_func->blocks.begin() + bout_id);
+ //func->ir_func->blocks.emplace_back(bout);
return true;
}