From: fennecdjay Date: Thu, 26 Jan 2023 12:28:39 +0000 (+0100) Subject: :art: put more of default_args in scan2 X-Git-Tag: nightly~206^2~11 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=74005623626e72a6f89de20759ea2f18d622ad9e;p=gwion.git :art: put more of default_args in scan2 --- diff --git a/include/default_args.h b/include/default_args.h index 3e1e1782..96373374 100644 --- a/include/default_args.h +++ b/include/default_args.h @@ -1,4 +1,4 @@ #ifndef __DEFAULT_ARGS #define __DEFAULT_ARGS -ANN void default_args(const Env, const Section *, Ast *acc); +ANN Func_Def default_args(const Env env, Func_Base *fb, Ast *acc, uint32_t max); #endif diff --git a/src/parse/default_arg.c b/src/parse/default_arg.c index 0de4a28d..68264436 100644 --- a/src/parse/default_arg.c +++ b/src/parse/default_arg.c @@ -60,7 +60,7 @@ ANN static Stmt_List new_code(const Env env, Func_Base *base, const uint32_t max } -ANN static Func_Def _default_args(const Env env, Func_Base *fb, Ast *acc, uint32_t max) { +ANN Func_Def default_args(const Env env, Func_Base *fb, Ast *acc, uint32_t max) { Func_Base *const base = cpy_func_base(env->gwion->mp, fb); Stmt_List code = strcmp(s_name(base->xid), "new") ? std_code(env, fb, max) @@ -70,17 +70,3 @@ ANN static Func_Def _default_args(const Env env, Func_Base *fb, Ast *acc, uint32 mp_vector_add(env->gwion->mp, acc, Section, section); return fdef; } - -ANN void default_args(const Env env, const Section *s, Ast *acc) { - Func_Base *const fb = s->d.func_def->base; - Arg_List args = fb->args; - uint32_t len = args->len; - while(args->len--) { - const Arg *arg = mp_vector_at(args, Arg, args->len); - if(!arg->exp) break; - const Func_Def fdef = _default_args(env, fb, acc, len); - scan1_func_def(env, fdef); - scan2_func_def(env, fdef); - } - args->len = len; -} diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 443a6be9..9b6786b2 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -625,6 +625,20 @@ ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) { return GW_OK; } +ANN void scan2_default_args(const Env env, const Section *s, Ast *acc) { + Func_Base *const fb = s->d.func_def->base; + Arg_List args = fb->args; + uint32_t len = args->len; + while(args->len--) { + const Arg *arg = mp_vector_at(args, Arg, args->len); + if(!arg->exp) break; + const Func_Def fdef = default_args(env, fb, acc, len); + scan1_func_def(env, fdef); + scan2_func_def(env, fdef); + } + args->len = len; +} + ANN m_bool scan2_ast(const Env env, Ast *ast) { Ast a = *ast; Ast acc = new_mp_vector(env->gwion->mp, Section, 0); @@ -640,7 +654,7 @@ ANN m_bool scan2_ast(const Env env, Ast *ast) { for(uint32_t i = 0; i < acc->len; i++) { Section *section = mp_vector_at(acc, Section, i); - default_args(env, section, ast); + scan2_default_args(env, section, ast); } free_mp_vector(env->gwion->mp, Section, acc); return ret;