(node)-> poison = true; \
} while(false)
+#define POISON_SECTION(ok, env, node) \
+ do { \
+ if(node->section_type != ae_section_stmt) \
+ POISON_NODE(ok, env, node); \
+ else \
+ env->context->error = true; \
+} while(false)
+
#define ERR_OK_NODE(ok, a, b, c, ...) \
do { \
env_err(env, (b), (c), ##__VA_ARGS__); \
env_weight(env, 1);
do {
if(curr->type) continue;
- if(curr->poison) continue;
+ if(curr->poison) { ok = false; continue;}
if(!(curr->type = check_exp_func[curr->exp_type](env, &curr->d)) || curr->type->error) {
POISON_NODE(ok, env, curr);
continue;
bool ok = true;
for(m_uint i = 0; i < l->len; i++) {
Stmt* stmt = mp_vector_at(l, Stmt, i);
+ if(stmt->poison) { ok = false; continue;}
if(!check_stmt(env, stmt))
POISON_NODE(ok, env, stmt);
}
vector_pop(v);
}
-ANN static void check_extend(const Env env, Ast ast) {
+ANN static bool check_extend(const Env env, Ast ast) {
+ bool ok = true;
for(m_uint i = 0; i < ast->len; i++) {
Section * section = mp_vector_at(ast, Section, i);
if(section->poison) continue;
if(!check_section(env, section)) {
- section->poison = true;
+ POISON_SECTION(ok, env, section);
continue;
}
mp_vector_add(env->gwion->mp, &env->context->tree, Section, *section);
}
free_mp_vector(env->gwion->mp, Section, env->context->extend);
env->context->extend = NULL;
+ return ok;
}
ANN bool check_ast(const Env env, Ast *ast) {
bool ok = true;
for(m_uint i = 0; i < a->len; i++) {
Section * section = mp_vector_at(a, Section, i);
- if(section->poison) continue;
+ if(section->poison) { ok = false; continue;}
if(!check_section(env, section))
- POISON_NODE(ok, env, section);
+ POISON_SECTION(ok, env, section);
}
if(env->context->extend) check_extend(env, env->context->extend);
if(ok && vector_size(&env->scope->effects)) check_unhandled(env);
bool ok = true;
for(m_uint i = 0; i < l->len; i++) {
Stmt* stmt = mp_vector_at(l, Stmt, i);
+ if(stmt->poison) { ok = false; continue; }
if (stmt->stmt_type == ae_stmt_pp) {
if (stmt->d.stmt_pp.pp_type == ae_pp_include)
env->name = stmt->d.stmt_pp.data;
bool ok = true;
for(m_uint i = 0; i < ast->len; i++) {
Section *section = mp_vector_at(ast, Section, i);
+ if(section->poison) { ok = false; continue; }
if (section->section_type == ae_section_func) {
const Func_Def fdef = section->d.func_def;
if (fdef->base->flag != ae_flag_none &&
Stmt_List list = section->d.stmt_list;
for(uint32_t i = 0; i < list->len; i++) {
Stmt* stmt = mp_vector_at(list, Stmt, i);
+ if(stmt->poison) { ok = false; continue;}
if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl)
ERR_OK(ok, stmt->loc, "trait can only contains variable requests and functions");
}
bool ok = true;
for(m_uint i = 0; i < a->len; i++) {
Section * section = mp_vector_at(a, Section, i);
+ if(section->poison) { ok = false; continue;}
if(!scan0_section(env, section))
- POISON_NODE(ok, env, section);
+ POISON_SECTION(ok, env, section);
}
return ok;
}
bool ok = true;
for(i = 0; i < l->len; i++) {
Stmt* stmt = mp_vector_at(l, Stmt, i);
+ if(stmt->poison) { ok = false; continue;}
if(!scan1_stmt(env, stmt)) {
POISON_NODE(ok, env, stmt);
continue;
Ast body = new_mp_vector(mp, Section, 1); // room for ctor
for(uint32_t i = 0; i < base->len; i++) {
Section section = *mp_vector_at(base, Section, i);
+ if(section.poison) continue;
if(section.section_type == ae_section_stmt) {
Stmt_List list = section.d.stmt_list;
for(uint32_t j = 0; j < list->len; j++) {
Stmt* stmt = mp_vector_at(list, Stmt, j);
+ if(stmt->poison) continue;
mp_vector_add(mp, &ctor, Stmt, *stmt);
}
} else mp_vector_add(mp, &body, Section, section);
bool ok = true;
for(m_uint i = 0; i < a->len; i++) {
Section *section = mp_vector_at(a, Section, i);
- if(section->poison) continue;
+ if(section->poison) { ok = false; continue;}
if(!scan1_section(env, section))
- POISON_NODE(ok, env, section);
+ POISON_SECTION(ok, env, section);
}
return ok;
}
bool ok = true;
for(m_uint i = 0; i < l->len; i++) {
Stmt* stmt = mp_vector_at(l, Stmt, i);
+ if(stmt->poison) { ok = false; continue; }
if(!scan2_stmt(env, stmt))
POISON_NODE(ok, env, stmt);
}
bool ok = true;
for(m_uint i = 0; i < a->len; i++) {
Section *section = mp_vector_at(a, Section, i);
- if(section->poison) continue;
+ if(section->poison) { ok = false; continue;}
if(!scan2_section(env, section)) {
- POISON_NODE(ok, env, section);
+ POISON_SECTION(ok, env, section);
continue;
}
if (section->section_type == ae_section_func &&
bool ok = true;
for(m_uint i = 0; i < ast->len; i++) {
Section *section = mp_vector_at(ast, Section, i);
- if(section->poison) continue;
+ if(section->poison) { ok = false; continue; }
if(!f(env, section))
- POISON_NODE(ok, env, section);
+ POISON_SECTION(ok, env, section);
}
return ok;
}