self->ir_v = func->value;
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
+ if (self->expression.flags & AST_FLAG_ERASEABLE)
+ self->ir_v->flags |= IR_FLAG_ERASEABLE;
/* The function is filled later on ast_function_codegen... */
return true;
}
v->unique_life = true;
v->locked = true;
array->ir_v = self->ir_v = v;
+
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
+ if (self->expression.flags & AST_FLAG_ERASEABLE)
+ self->ir_v->flags |= IR_FLAG_ERASEABLE;
namelen = strlen(self->name);
name = (char*)mem_a(namelen + 16);
self->ir_v = v;
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
+
+ if (self->expression.flags & AST_FLAG_ERASEABLE)
+ self->ir_v->flags |= IR_FLAG_ERASEABLE;
}
return true;
}
v->context = ast_ctx(self);
v->unique_life = true;
v->locked = true;
+
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
v->flags |= IR_FLAG_INCLUDE_DEF;
+ if (self->expression.flags & AST_FLAG_ERASEABLE)
+ self->ir_v->flags |= IR_FLAG_ERASEABLE;
namelen = strlen(self->name);
name = (char*)mem_a(namelen + 16);
/* link us to the ir_value */
v->cvq = self->cvq;
self->ir_v = v;
+
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
+ if (self->expression.flags & AST_FLAG_ERASEABLE)
+ self->ir_v->flags |= IR_FLAG_ERASEABLE;
/* initialize */
if (self->hasvalue) {
return true;
}
+static bool starts_a_label(ast_expression *ex)
+{
+ while (ex && ast_istype(ex, ast_block)) {
+ ast_block *b = (ast_block*)ex;
+ ex = b->exprs[0];
+ }
+ if (!ex)
+ return false;
+ return ast_istype(ex, ast_label);
+}
+
/* Note, you will not see ast_block_codegen generate ir_blocks.
* To the AST and the IR, blocks are 2 different things.
* In the AST it represents a block of code, usually enclosed in
for (i = 0; i < vec_size(self->exprs); ++i)
{
ast_expression_codegen *gen;
- if (func->curblock->final && !ast_istype(self->exprs[i], ast_label)) {
+ if (func->curblock->final && !starts_a_label(self->exprs[i])) {
if (compile_warning(ast_ctx(self->exprs[i]), WARN_UNREACHABLE_CODE, "unreachable statement"))
return false;
continue;