for (i = 0; i < count; ++i) {
if (ast_istype(self->params[i], ast_argpipe)) {
- // warn about type safety instead
+ /* warn about type safety instead */
if (i+1 != count) {
compile_error(ast_ctx(self), "argpipe must be the last parameter to a function call");
return false;
if (count > vec_size(func->params) && func->varparam) {
for (; i < count; ++i) {
if (ast_istype(self->params[i], ast_argpipe)) {
- // warn about type safety instead
+ /* warn about type safety instead */
if (i+1 != count) {
compile_error(ast_ctx(self), "argpipe must be the last parameter to a function call");
return false;
{
ast_instantiate(ast_function, ctx, ast_function_delete);
- if (!vtype ||
- vtype->hasvalue ||
- vtype->expression.vtype != TYPE_FUNCTION)
- {
+ if (!vtype) {
+ compile_error(ast_ctx(self), "internal error: ast_function_new condition 0");
+ goto cleanup;
+ } else if (vtype->hasvalue || vtype->expression.vtype != TYPE_FUNCTION) {
compile_error(ast_ctx(self), "internal error: ast_function_new condition %i %i type=%i (probably 2 bodies?)",
(int)!vtype,
(int)vtype->hasvalue,
vtype->expression.vtype);
- mem_d(self);
- return NULL;
+ goto cleanup;
}
self->vtype = vtype;
self->return_value = NULL;
return self;
+
+cleanup:
+ mem_d(self);
+ return NULL;
}
void ast_function_delete(ast_function *self)
return true;
error: /* clean up */
- ir_value_delete(v);
+ if(v) ir_value_delete(v);
return false;
}
if (bprecond)
{
ir_block *ontrue, *onfalse;
- if (bbody) ontrue = bbody;
+ ontrue = bbody; /* can never be null */
+
+ /* all of this is dead code
else if (bincrement) ontrue = bincrement;
- else if (bpostcond) ontrue = bpostcond;
- else ontrue = bprecond;
+ else ontrue = bpostcond;
+ */
+
onfalse = bout;
if (self->pre_not) {
tmpblock = ontrue;
{
ir_block *ontrue, *onfalse;
if (bprecond) ontrue = bprecond;
- else if (bbody) ontrue = bbody;
+ else ontrue = bbody; /* can never be null */
+
+ /* all of this is dead code
else if (bincrement) ontrue = bincrement;
else ontrue = bpostcond;
+ */
+
onfalse = bout;
if (self->post_not) {
tmpblock = ontrue;