From 4ca2c44b083568048d409e6e95482ea2dc234697 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Tue, 13 Feb 2024 00:41:44 +0100 Subject: [PATCH] :fire: handle multiple passes --- src/parse/check.c | 18 +++++++++++++----- src/parse/scan1.c | 1 - src/pass.c | 10 +++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index 4fb877fa..35982546 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -2306,7 +2306,11 @@ ANN static inline void check_unhandled(const Env env) { ANN static void check_extend(const Env env, Ast ast) { for(m_uint i = 0; i < ast->len; i++) { Section * section = mp_vector_at(ast, Section, i); - (void)check_section(env, section); + if(section->poison) continue; + if(!check_section(env, section)) { + section->poison = true; + continue; + } mp_vector_add(env->gwion->mp, &env->context->tree, Section, *section); } free_mp_vector(env->gwion->mp, Section, env->context->extend); @@ -2315,15 +2319,19 @@ ANN static void check_extend(const Env env, Ast ast) { ANN bool check_ast(const Env env, Ast *ast) { Ast a = *ast; + bool ok = true; for(m_uint i = 0; i < a->len; i++) { Section * section = mp_vector_at(a, Section, i); - if(section->poison) return false; + if(section->poison) { + ok = false; + continue; + } if(!check_section(env, section)) { section->poison = true; - return false; + ok = false; } } - if(vector_size(&env->scope->effects)) check_unhandled(env); if(env->context->extend) check_extend(env, env->context->extend); - return true; + if(ok && vector_size(&env->scope->effects)) check_unhandled(env); + return ok; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 812c3452..f929b5e8 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -911,7 +911,6 @@ ANN bool scan1_ast(const Env env, Ast *ast) { if(!scan1_section(env, section)) { section->poison = true; ok = false; - return false; } } return ok; diff --git a/src/pass.c b/src/pass.c index f050c0d1..fdde35a5 100644 --- a/src/pass.c +++ b/src/pass.c @@ -13,8 +13,16 @@ static m_bool typecheck_ast(const Env env, Ast *ast) { env->scope->poison = false; // move me - CHECK_b(traverse_ast(env, ast)); + scan0_ast(env, ast); if(env->scope->poison)env->context->error = true; + scan1_ast(env, ast); + if(env->scope->poison)env->context->error = true; + scan2_ast(env, ast); + if(env->scope->poison)env->context->error = true; + CHECK_b(check_ast(env, ast)); + if(env->scope->poison)env->context->error = true; +// CHECK_b(traverse_ast(env, ast)); +// if(env->scope->poison)env->context->error = true; if(env->context->error)return GW_ERROR; return GW_OK; } -- 2.43.0