From: Jérémie Astor Date: Fri, 18 Sep 2020 09:26:41 +0000 (+0200) Subject: :bug: Fix include X-Git-Tag: nightly~1276 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=aa545e2b49ac65fedba1b5d1b9d6613b453d6b75;p=gwion.git :bug: Fix include --- diff --git a/ast b/ast index 04876e5a..ab74f8fa 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 04876e5a68a4547238939b32e245f40b66fce14a +Subproject commit ab74f8faf9335b74d5bbad7513c20e0e5243cdc1 diff --git a/src/emit/emit.c b/src/emit/emit.c index 1206f21e..17d18020 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1823,7 +1823,8 @@ ANN static m_bool emit_stmt_pp(const Emitter emit, const struct Stmt_PP_* stmt) if(stmt->pp_type == ae_pp_pragma) { if(!strncmp(stmt->data, "memoize", strlen("memoize"))) emit->info->memoize = strtol(stmt->data + 7, NULL, 10); - } + } else if(stmt->pp_type == ae_pp_include) + emit->env->name = stmt->data; return GW_OK; } diff --git a/src/import/import_fdef.c b/src/import/import_fdef.c index d9ab14e1..4d25c4c5 100644 --- a/src/import/import_fdef.c +++ b/src/import/import_fdef.c @@ -106,14 +106,14 @@ ANN m_int gwi_fptr_ini(const Gwi gwi, const restrict m_str type, const restrict return dl_func_init(gwi, type, name); } -ANN static Fptr_Def import_fptr(const Gwi gwi, ae_flag flag) { +ANN static Fptr_Def import_fptr(const Gwi gwi) { Func_Base *base = gwi_func_base(gwi, gwi->ck); return new_fptr_def(gwi->gwion->mp, base); } ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { CHECK_BO(ck_ok(gwi, ck_fdef)) - DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi, flag)) + DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi)) // what happens if it is in a template class ? const m_bool ret = traverse_fptr_def(gwi->gwion->env, fptr); if(fptr->base->func) // is it needed ? diff --git a/src/parse/check.c b/src/parse/check.c index fbcb8bd1..08972de9 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1253,7 +1253,13 @@ ANN static m_bool check_stmt_match(const Env env, const Stmt_Match stmt) { #define check_stmt_while check_stmt_flow #define check_stmt_until check_stmt_flow -#define check_stmt_pp dummy_func + +ANN static m_bool check_stmt_pp(const Env env, const Stmt_PP stmt) { + if(stmt->pp_type == ae_pp_include) + env->name = stmt->data; + return GW_OK; +} + DECL_STMT_FUNC(check, m_bool , Env) ANN m_bool check_stmt(const Env env, const Stmt stmt) { diff --git a/src/parse/scan0.c b/src/parse/scan0.c index d533d6d7..845b40b2 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -359,6 +359,13 @@ ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) { return t; } +ANN static m_bool scan0_stmt_list(const Env env, Stmt_List list) { + do if(list->stmt->stmt_type == ae_stmt_pp && list->stmt->d.stmt_pp.pp_type == ae_pp_include) + env->name = list->stmt->d.stmt_pp.data; + while((list = list->next)); + return GW_OK; +} + ANN static m_bool scan0_section(const Env env, const Section* section) { if(section->section_type == ae_section_class) return scan0_class_def(env, section->d.class_def); @@ -370,6 +377,8 @@ ANN static m_bool scan0_section(const Env env, const Section* section) { return scan0_fptr_def(env, section->d.fptr_def); if(section->section_type == ae_section_type) return scan0_type_def(env, section->d.type_def); + if(section->section_type == ae_section_type) + return scan0_stmt_list(env, section->d.stmt_list); return GW_OK; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index c768d62d..094ae99e 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -450,7 +450,13 @@ ANN m_bool scan1_union_def(const Env env, const Union_Def udef) { #define scan1_stmt_break (void*)dummy_func #define scan1_stmt_jump (void*)dummy_func #define scan1_stmt_return scan1_stmt_exp -#define scan1_stmt_pp (void*)dummy_func + +ANN static m_bool scan1_stmt_pp(const Env env, const Stmt_PP stmt) { + if(stmt->pp_type == ae_pp_include) + env->name = stmt->data; + return GW_OK; +} + DECL_STMT_FUNC(scan1, m_bool, Env) ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) { diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 82be1bc1..2bb5b4a8 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -280,7 +280,12 @@ ANN m_bool scan2_union_def(const Env env, const Union_Def udef) { #define scan2_stmt_continue (void*)dummy_func #define scan2_stmt_break (void*)dummy_func #define scan2_stmt_return scan2_stmt_exp -#define scan2_stmt_pp dummy_func + +ANN static m_bool scan2_stmt_pp(const Env env, const Stmt_PP stmt) { + if(stmt->pp_type == ae_pp_include) + env->name = stmt->data; + return GW_OK; +} DECL_STMT_FUNC(scan2, m_bool, Env)