From 8eba2b676134f9acf63039ef5a4fb09734211a20 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 21 Sep 2019 01:12:18 +0200 Subject: [PATCH] :art: Imrove check_udef --- ast | 2 +- src/lib/func.c | 2 +- src/parse/check.c | 38 +++++++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ast b/ast index 0a0c0d67..a25da541 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 0a0c0d67d0ccfd81b1011e917e031a364fc07d6f +Subproject commit a25da541f1e646470e82fe562925d27c828e5e2b diff --git a/src/lib/func.c b/src/lib/func.c index 24c31a82..5b939e3a 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -238,7 +238,7 @@ static OP_EMIT(opem_fptr_cast) { if(GET_FLAG(cast->exp->type->e->d.func, member) && !(GET_FLAG(cast->exp->type, nonnull) || GET_FLAG(exp_self(cast)->type, nonnull))) member_fptr(emit); - return (Instr)GW_OK;// ??? + return (Instr)GW_OK; } static OP_CHECK(opck_fptr_impl) { diff --git a/src/parse/check.c b/src/parse/check.c index d6092133..ce43b6a9 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1117,9 +1117,22 @@ ANN static m_bool check_stmt_jump(const Env env, const Stmt_Jump stmt) { return GW_OK; } -ANN m_bool check_union_def(const Env env, const Union_Def udef) { - if(tmpl_base(udef->tmpl)) // there's a func for this - return GW_OK; +ANN m_bool check_union_decl(const Env env, const Union_Def udef) { + Decl_List l = udef->l; + do { + CHECK_OB(check_exp(env, l->self)) + if(isa(l->self->type, t_object) > 0) { + Var_Decl_List list = l->self->d.exp_decl.list; + do SET_FLAG(list->self->value, pure); + while((list = list->next)); + } + if(l->self->type->size > udef->s) + udef->s = l->self->type->size; + } while((l = l->next)); + return GW_OK; +} + +ANN void check_udef(const Env env, const Union_Def udef) { if(udef->xid) { if(env->class_def) (!GET_FLAG(udef, static) ? decl_member : decl_static)(env, udef->value); @@ -1131,20 +1144,15 @@ ANN m_bool check_union_def(const Env env, const Union_Def udef) { env->class_def->nspc->info->class_data_size += SZ_INT; } } +} +ANN m_bool check_union_def(const Env env, const Union_Def udef) { + if(tmpl_base(udef->tmpl)) // there's a func for this + return GW_OK; + check_udef(env, udef); const m_uint scope = union_push(env, udef); - Decl_List l = udef->l; - do { - CHECK_OB(check_exp(env, l->self)) - if(isa(l->self->type, t_object) > 0) { - Var_Decl_List list = l->self->d.exp_decl.list; - do SET_FLAG(list->self->value, pure); - while((list = list->next)); - } - if(l->self->type->size > udef->s) - udef->s = l->self->type->size; - } while((l = l->next)); + const m_bool ret = check_union_decl(env, udef); union_pop(env, udef, scope); - return GW_OK; + return ret; } ANN static m_bool check_stmt_exp(const Env env, const Stmt_Exp stmt) { -- 2.43.0