#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
}
-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)
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;
-}
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);
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;