From 3dc4a8a0c3456769f4dec952a2e55f68e0f860a1 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 24 Jul 2019 00:47:45 +0200 Subject: [PATCH] :shirt: Some clean --- ast | 2 +- src/parse/check.c | 8 ++++---- src/parse/scan0.c | 22 ++++++++++++++++++++++ src/parse/scan1.c | 3 --- src/parse/scan2.c | 21 --------------------- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/ast b/ast index 0edd6692..2a5fcf44 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 0edd66928516857b57cd1a8878197bb84eb6a08c +Subproject commit 2a5fcf44783a6bba322e4fa8586b1d78137203b9 diff --git a/src/parse/check.c b/src/parse/check.c index d0cad945..6cfa9fe9 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -611,12 +611,12 @@ ANN static Func get_template_func(const Env env, const Exp_Call* func, const Val ANN static Func predefined_func(const Env env, const Value v, Exp_Call *exp, const Tmpl *tm) { Tmpl tmpl = { .call=tm->call }; - ((Exp_Call*)exp)->tmpl = &tmpl; + exp->tmpl = &tmpl; DECL_OO(const Func, func, = get_template_func(env, exp, v)) return v->d.func_ref = func; } -ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { +ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) { const Exp call = exp->func; const Exp args = exp->args; DECL_OO(const Value, value, = nspc_lookup_value1(call->type->e->owner, insert_symbol(call->type->name))) @@ -628,7 +628,7 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { CHECK_BO(traverse_func_def(env, func->def)) env_pop(env, scope); } - ((Exp_Call*)exp)->m_func = func; + exp->m_func = func; return func->def->base->ret_type; } m_uint args_number = 0; @@ -701,7 +701,7 @@ ANN Type check_exp_call1(const Env env, const Exp_Call *exp) { if(exp->args) CHECK_OO(check_exp(env, exp->args)) if(GET_FLAG(exp->func->type, func)) - return check_exp_call_template(env, exp); + return check_exp_call_template(env, (Exp_Call*)exp); const Func func = find_func_match(env, exp->func->type->e->d.func, exp->args); return (exp_self(exp)->d.exp_call.m_func = func) ? func->def->base->ret_type : function_alternative(env, exp->func->type, exp->args, exp_self(exp)->pos); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 6461e680..4e5c95d0 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -33,6 +33,28 @@ ANN static inline m_bool scan0_defined(const Env env, const Symbol s, const loc_ return already_defined(env, s, pos); } + +ANN static void fptr_assign(const Env env, const Fptr_Def fptr) { + const Func_Def def = fptr->type->e->d.func->def; + if(GET_FLAG(fptr->base->td, global)) { + SET_FLAG(fptr->value, global); + SET_FLAG(fptr->base->func, global); + SET_FLAG(def, global); + } else if(!GET_FLAG(fptr->base->td, static)) { + SET_FLAG(fptr->value, member); + SET_FLAG(fptr->base->func, member); + SET_FLAG(def, member); + def->stack_depth += SZ_INT; + } else { + SET_FLAG(fptr->value, static); + SET_FLAG(fptr->base->func, static); + SET_FLAG(def, static); + } + if(GET_FLAG(def, variadic)) + def->stack_depth += SZ_INT; + fptr->value->owner_class = env->class_def; +} + static void fptr_def(const Env env, const Fptr_Def fptr) { const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, fptr->base->td, fptr->base->xid, fptr->base->args), NULL,fptr->base->td->flag, loc_cpy(env->gwion->mp, td_pos(fptr->base->td))); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index ce80cc19..3ef50ce0 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -21,7 +21,6 @@ ANN static Type void_type(const Env env, const Type_Decl* td) { ERR_O(td_pos(td), _("cannot declare variables of size '0' (i.e. 'void')...")) } - ANN static inline Type get_base_type(const Env env, const Type t) { const m_str decl_name = get_type_name(env, t->name, 0); return nspc_lookup_type1(env->curr, insert_symbol(decl_name)); @@ -366,8 +365,6 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { } ANN m_bool scan1_class_def(const Env env, const Class_Def cdef) { - if(!cdef->base.type) - CHECK_BB(scan0_class_def(env, cdef)) if(tmpl_base(cdef->base.tmpl)) return GW_OK; SET_FLAG(cdef->base.type, scan1); diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 7ca3cc48..35f9a6b3 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -83,27 +83,6 @@ ANN static Value scan2_func_assign(const Env env, const Func_Def d, } -ANN void fptr_assign(const Env env, const Fptr_Def fptr) { - const Func_Def def = fptr->type->e->d.func->def; - if(GET_FLAG(fptr->base->td, global)) { - SET_FLAG(fptr->value, global); - SET_FLAG(fptr->base->func, global); - SET_FLAG(def, global); - } else if(!GET_FLAG(fptr->base->td, static)) { - SET_FLAG(fptr->value, member); - SET_FLAG(fptr->base->func, member); - SET_FLAG(def, member); - def->stack_depth += SZ_INT; - } else { - SET_FLAG(fptr->value, static); - SET_FLAG(fptr->base->func, static); - SET_FLAG(def, static); - } - if(GET_FLAG(def, variadic)) - def->stack_depth += SZ_INT; - fptr->value->owner_class = env->class_def; -} - ANN m_bool scan2_fptr_def(const Env env, const Fptr_Def fptr) { const Func_Def def = fptr->type->e->d.func->def; if(!tmpl_base(fptr->base->tmpl)) { -- 2.43.0