if(!stmt->is_label)
stmt->data.instr = emit_add_instr(emit, Goto);
else {
- if(switch_inside(emit->env, stmt_self(stmt)->pos) && !strcmp(s_name(stmt->name), "default")) {
+ if(switch_inside(emit->env, stmt_self(stmt)->pos) > 0 && !strcmp(s_name(stmt->name), "default")) {
// if(!strcmp(s_name(stmt->name), "default"))
// vector_release(&stmt->data.v);
return switch_default(emit->env, emit_code_size(emit), stmt_self(stmt)->pos);
}
ANN m_bool switch_default(const Env env, const m_uint pc, const loc_t pos) {
+ if(!VLEN(env->scope->swi))
+ ERR_B(pos, "'default'case found outside switch statement.")
const Switch sw = (Switch)_scope_back(env->scope->swi);
if(sw->default_case_index)
ERR_B(pos, "default case already defined")
}
ANN m_bool switch_pop(const Env env) {
+ const Switch sw = (Switch)_scope_back(env->scope->swi);
+ sw->ok = 1;
_scope_pop(env->scope->swi);
return GW_OK;
}
ANN m_bool switch_end(const Env env, const loc_t pos) {
const Switch sw = (Switch)_scope_pop(env->scope->swi);
const vtype index = VKEY(&env->scope->swi->map, VLEN(&env->scope->swi->map) - 1);
- sw->ok = 1;
+// sw->ok = 1;
if(!VLEN(sw->cases) && !VLEN(&sw->exp))
ERR_B(pos, "switch statement with no cases.")
map_remove(&env->scope->swi->map, index);