From: fennecdjay Date: Wed, 31 Jan 2024 01:40:42 +0000 (+0100) Subject: :fire: Stmt macros X-Git-Tag: nightly~111 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=06909456c9b3491dbd7f26c91bc8cfca72a91847;p=gwion.git :fire: Stmt macros --- diff --git a/ast b/ast index b412aa92..23c2894a 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit b412aa9281f85e4d9f9cd1bb3a0716dbfd1a9432 +Subproject commit 23c2894a2dd6b0f0b3531f7995a3395020fc45bb diff --git a/plug b/plug index 713f9a6e..a8194c5a 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 713f9a6e94f8d3462082ea90ca679f112b449219 +Subproject commit a8194c5a7b1b874d1475cb5af245770327605f9b diff --git a/src/import/import_fdef.c b/src/import/import_fdef.c index 89779089..2cdfcddd 100644 --- a/src/import/import_fdef.c +++ b/src/import/import_fdef.c @@ -59,10 +59,7 @@ ANEW ANN static Func_Def import_fdef(const Gwi gwi, ImportCK *ck) { } ANN static m_bool section_fdef(const Gwi gwi, const Func_Def fdef) { - Section section = (Section) { - .section_type = ae_section_func, - .d = { .func_def = fdef } - }; + Section section = MK_SECTION(func, func_def, fdef); gwi_body(gwi, §ion); return GW_OK; } @@ -120,10 +117,7 @@ ANN static Fptr_Def import_fptr(const Gwi gwi) { } ANN static m_bool section_fptr(const Gwi gwi, const Fptr_Def fdef) { - Section section = (Section) { - .section_type = ae_section_fptr, - .d = { .fptr_def = fdef } - }; + Section section = MK_SECTION(fptr, fptr_def, fdef); gwi_body(gwi, §ion); return GW_OK; } diff --git a/src/import/import_item.c b/src/import/import_item.c index daadd16c..54233ea4 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -24,11 +24,7 @@ ANN static m_int gwi_item_tmpl(const Gwi gwi) { .d = { .stmt_exp = { .val = gwi->ck->exp } }, .loc = gwi->loc })); - Section section = (Section) { - .section_type = ae_section_stmt, - .d = { .stmt_list = slist } - }; -// Section * section = new_section_stmt_list(mp, slist); + Section section = MK_SECTION(stmt, stmt_list, slist); // const Ast body = new_ast(mp, section, NULL); // gwi_body(gwi, body); gwi_body(gwi, §ion); diff --git a/src/lib/closure.c b/src/lib/closure.c index 674ac0a3..3b09eda4 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -608,11 +608,8 @@ static OP_CHECK(opck_op_impl) { const Exp bin = new_exp_binary(env->gwion->mp, lhs, impl->e->d.prim.d.var, rhs, impl->e->loc); Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 1); - mp_vector_set(code, Stmt, 0, - ((Stmt) { - .stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = bin }}, - .loc = impl->e->loc - })); + mp_vector_set(code, Stmt, 0, MK_STMT(ae_stmt_return, impl->e->loc, + .stmt_exp = { .val = bin })); const Func_Def def = new_func_def(env->gwion->mp, base, code); def->base->tag.sym = impl->e->d.prim.d.var; // use envset diff --git a/src/lib/sift.c b/src/lib/sift.c index c0d17dd1..659948de 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -61,16 +61,12 @@ static OP_CHECK(opck_ctrl) { check_exp(env, cond); const Stmt_List code = new_mp_vector(mp, Stmt, 1); - mp_vector_set(code, Stmt, 0, ((Stmt) { - .stmt_type = ae_stmt_while, - .d = { + mp_vector_set(code, Stmt, 0, MK_STMT(ae_stmt_while, func->loc, .stmt_flow = { .cond = cond, .body = stmt } - }, - .loc = func->loc - })); + )); exp->exp_type = ae_exp_unary; exp->d.exp_unary.unary_type = unary_code; exp->d.exp_unary.code = code; diff --git a/src/parse/check.c b/src/parse/check.c index df56cd5d..a9b81f33 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1289,16 +1289,8 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { tdef->when = NULL; when->next = helper; Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 2); - mp_vector_set(code, Stmt, 0, - ((Stmt) { - .stmt_type = ae_stmt_exp, .d = { .stmt_exp = { .val = when }}, - .loc = when->loc - })); - mp_vector_set(code, Stmt, 1, - ((Stmt) { - .stmt_type = ae_stmt_exp, - .loc = when->loc - })); + mp_vector_set(code, Stmt, 0, MK_STMT_EXP(when->loc, when)); + mp_vector_set(code, Stmt, 1, MK_STMT_EXP(when->loc, NULL)); const Func_Def fdef = new_func_def(env->gwion->mp, fb, code); tdef->when_def = fdef; CHECK_BB(traverse_func_def(env, fdef)); diff --git a/src/parse/default_arg.c b/src/parse/default_arg.c index 89a751d0..6a389862 100644 --- a/src/parse/default_arg.c +++ b/src/parse/default_arg.c @@ -36,11 +36,7 @@ ANN static Stmt_List code(const MemPool p, const Exp func, const Arg_List lst, const Exp arg = mk_args(p, lst, max); const Exp call = new_exp_call(p, func, arg, func->loc); Stmt_List code = new_mp_vector(p, Stmt, 1); - mp_vector_set(code, Stmt, 0, - ((Stmt) { - .stmt_type = type, .d = { .stmt_exp = { .val = call }}, - .loc = func->loc - })); + mp_vector_set(code, Stmt, 0, MK_STMT(ae_stmt_return, func->loc, .stmt_exp = { .val = call})); return code; } diff --git a/src/parse/partial.c b/src/parse/partial.c index 3ee9d089..89c0f9f9 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -168,14 +168,9 @@ ANN static Stmt_List partial_code(const Env env, Arg_List args, const Exp efun, const Exp arg = partial_call(env, args, earg); const Exp exp = new_exp_call(env->gwion->mp, efun, arg, efun->loc); Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 1); - mp_vector_set(code, Stmt, 0, ((Stmt) { - .stmt_type = ae_stmt_return, - .d = { .stmt_exp = { .val = exp }} - })); -// stmt->stmt_type = ae_stmt_return; -// stmt->d.stmt_exp.val = exp; + mp_vector_set(code, Stmt, 0, MK_STMT(ae_stmt_return, efun->loc, + .stmt_exp = { .val = exp })); return code; -// return new_stmt_code(env->gwion->mp, slist, efun->loc); } ANN static uint32_t count_args_exp(Exp args) {