From: fennecdjay Date: Wed, 31 Jan 2024 02:54:35 +0000 (+0100) Subject: :fire: more convenience macros X-Git-Tag: nightly~109 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=68a6e36646aa429a982e36d223d1a85d6d8ed092;p=gwion.git :fire: more convenience macros --- diff --git a/ast b/ast index 1c3afd60..0fc5575b 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 1c3afd609f38c79cdfa58346c8dbc6112bedcca4 +Subproject commit 0fc5575bcf9215b59c7b4723c7efd55615217c02 diff --git a/src/import/import_item.c b/src/import/import_item.c index 54233ea4..4dc49f17 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -19,14 +19,8 @@ ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, ANN static m_int gwi_item_tmpl(const Gwi gwi) { Stmt_List slist = new_mp_vector(gwi->gwion->mp, Stmt, 1); - mp_vector_set(slist, Stmt, 0, ((Stmt) { - .stmt_type = ae_stmt_exp, - .d = { .stmt_exp = { .val = gwi->ck->exp } }, - .loc = gwi->loc - })); + mp_vector_set(slist, Stmt, 0, MK_STMT_EXP(gwi->loc, gwi->ck->exp)); Section section = MK_SECTION(stmt, stmt_list, slist); -// const Ast body = new_ast(mp, section, NULL); -// gwi_body(gwi, body); gwi_body(gwi, §ion); mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck); gwi->ck = NULL; diff --git a/src/lib/closure.c b/src/lib/closure.c index 24c47d31..45b39c57 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -609,8 +609,7 @@ static OP_CHECK(opck_op_impl) { 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, MK_STMT(ae_stmt_return, impl->e->loc, - .stmt_exp = { .val = bin })); + mp_vector_set(code, Stmt, 0, MK_STMT_RETURN(impl->e->loc, 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 1234873a..5d7a7c1f 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -42,14 +42,13 @@ static OP_CHECK(opck_ctrl) { func->d.exp_binary.lhs = call; func->d.exp_binary.op = chuck; CHECK_BN(traverse_exp(env, func)); - Stmt one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; + Stmt one = MK_STMT_EXP(func->loc, func); Exp* samp = new_prim_id(mp, insert_symbol(env->gwion->st, "samp"), func->loc); Exp* _now = new_prim_id(mp, insert_symbol(env->gwion->st, "now"), func->loc); Exp* time = new_exp_binary(mp, samp, chuck, _now, func->loc); CHECK_BN(traverse_exp(env, time)); - Stmt two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; - + Stmt two = MK_STMT_EXP(func->loc, time); free_exp(mp, bin->lhs); free_exp(mp, bin->rhs); Stmt_List slist = new_mp_vector(mp, Stmt, 2); diff --git a/src/parse/check.c b/src/parse/check.c index decbd493..ff04cdf0 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1307,10 +1307,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { // casting while defining it* Exp* ret_id = new_prim_id(env->gwion->mp, insert_symbol("self"), when->loc); ret_id->d.prim.value = new_value(env, tdef->type, "self", tdef->tag.loc); - Stmt ret = { - .stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }}, - .loc = when->loc - }; + Stmt ret = MK_STMT_RETURN(when->loc, ret_id); mp_vector_set(fdef->d.code, Stmt, 1, ret); ret_id->type = tdef->type; } diff --git a/src/parse/partial.c b/src/parse/partial.c index 7967900b..eca38c03 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -169,8 +169,7 @@ ANN static Stmt_List partial_code(const Env env, Arg_List args, Exp* efun, Exp* Exp* arg = partial_call(env, args, earg); 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, MK_STMT(ae_stmt_return, efun->loc, - .stmt_exp = { .val = exp })); + mp_vector_set(code, Stmt, 0, MK_STMT_RETURN(efun->loc, exp)); return code; }