From: fennecdjay Date: Tue, 30 Jan 2024 17:18:15 +0000 (+0100) Subject: :fire: rename Stmt_ X-Git-Tag: nightly~113 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0574369fa36c8a61318758958c4c03cf6d979e64;p=gwion.git :fire: rename Stmt_ --- diff --git a/ast b/ast index cc1bdcbd..a83bf5da 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit cc1bdcbd2b43cc3eb08c80de725dbdb1b94cb3ef +Subproject commit a83bf5dab86a2a9c682bb93fa6c85f95f779ca68 diff --git a/fmt b/fmt index b9bb73a2..379c80d6 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit b9bb73a25ec8c235c6c6ba9bb9711104f01bc573 +Subproject commit 379c80d6914e8e204739d49f97c45cfe386b749f diff --git a/src/clean.c b/src/clean.c index 30ec780f..7370c2ce 100644 --- a/src/clean.c +++ b/src/clean.c @@ -201,7 +201,7 @@ ANN static void clean_stmt_return(Clean *a, Stmt_Exp b) { ANN static void clean_case_list(Clean *a, Stmt_List b) { for(m_uint i = 0; i < b->len; i++) { - Stmt* stmt = mp_vector_at(b, struct Stmt_, i); + Stmt* stmt = mp_vector_at(b, Stmt, i); clean_stmt_case(a, &stmt->d.stmt_match); } } @@ -264,7 +264,7 @@ ANN static void clean_arg_list(Clean *a, Arg_List b) { ANN static void clean_stmt_list(Clean *a, Stmt_List b) { for(m_uint i = 0; i < b->len; i++) { - Stmt* stmt = mp_vector_at(b, struct Stmt_, i); + Stmt* stmt = mp_vector_at(b, Stmt, i); clean_stmt(a, stmt); } } diff --git a/src/emit/emit.c b/src/emit/emit.c index 4dc9c437..4b1efdbc 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -841,7 +841,7 @@ ANN m_bool emit_ensure_func(const Emitter emit, const Func f) { ANN static m_bool emit_prim_locale(const Emitter emit, const Symbol *id) { if(emit->locale->def->d.code) { - const Stmt* stmt = mp_vector_at((emit->locale->def->d.code), struct Stmt_, 0); + const Stmt* stmt = mp_vector_at((emit->locale->def->d.code), Stmt, 0); const Func f = stmt->d.stmt_exp.val->d.exp_call.func->type->info->func; CHECK_OB(emit_ensure_func(emit, f)); } @@ -2555,7 +2555,7 @@ ANN static inline void match_unvec(struct Match_ *const match, ANN static m_bool emit_stmt_cases(const Emitter emit, Stmt_List list) { for(m_uint i = 0; i < list->len; i++) { - const Stmt* stmt = mp_vector_at(list, struct Stmt_, i); + const Stmt* stmt = mp_vector_at(list, Stmt, i); CHECK_BB(emit_stmt_match_case(emit, &stmt->d.stmt_match)); } return GW_OK; @@ -2621,7 +2621,7 @@ ANN static m_bool emit_stmt(const Emitter emit, Stmt* stmt) { ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) { for(m_uint i = 0; i < l->len; i++) { - Stmt* stmt = mp_vector_at(l, struct Stmt_, i); + Stmt* stmt = mp_vector_at(l, Stmt, i); CHECK_BB(emit_stmt(emit, stmt)); } return GW_OK; diff --git a/src/import/import_item.c b/src/import/import_item.c index 082a2cf0..daadd16c 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -18,8 +18,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, struct Stmt_, 1); - mp_vector_set(slist, struct Stmt_, 0, ((struct Stmt_) { + 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 diff --git a/src/lib/closure.c b/src/lib/closure.c index becb08dc..674ac0a3 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -16,7 +16,7 @@ #include "tmp_resolve.h" ANN static Exp uncurry(const Env env, const Exp_Binary *bin) { - const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0); + const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, Stmt, 0); const Exp ecall = stmt->d.stmt_exp.val; const Exp_Call *call = &ecall->d.exp_call; Exp args = call->args; @@ -60,7 +60,7 @@ ANN static Type mk_call(const Env env, const Exp e, const Exp func, const Exp ar static OP_CHECK(opck_func_call) { Exp_Binary *bin = (Exp_Binary *)data; if(!strncmp(bin->rhs->type->name, "partial:", 8)) { - const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0); + const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, Stmt, 0); const Exp_Call *call = &stmt->d.stmt_exp.val->d.exp_call; DECL_ON(const Exp, args, = uncurry(env, bin)); return mk_call(env, exp_self(bin), call->func, args); @@ -607,9 +607,9 @@ static OP_CHECK(opck_op_impl) { new_prim_id(env->gwion->mp, larg1->var.vd.tag.sym, impl->e->loc); 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, struct Stmt_, 1); - mp_vector_set(code, struct Stmt_, 0, - ((struct Stmt_) { + 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 })); diff --git a/src/lib/sift.c b/src/lib/sift.c index c043d7f0..c0d17dd1 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -13,8 +13,8 @@ static OP_CHECK(opck_sift) { Exp_Binary *bin = (Exp_Binary*)data; const Exp lhs = bin->lhs; - Stmt* stmt = mp_vector_at(lhs->d.exp_unary.code, struct Stmt_, 0); - Stmt* fst = mp_vector_at(stmt->d.stmt_flow.body->d.stmt_code.stmt_list, struct Stmt_, 0); + Stmt* stmt = mp_vector_at(lhs->d.exp_unary.code, Stmt, 0); + Stmt* fst = mp_vector_at(stmt->d.stmt_flow.body->d.stmt_code.stmt_list, Stmt, 0); const Symbol chuck = insert_symbol(env->gwion->st, "=>"); Exp next = new_exp_binary(env->gwion->mp, fst->d.stmt_exp.val, chuck, bin->rhs, bin->rhs->loc); CHECK_BN(traverse_exp(env, next)); // how do we free it? @@ -42,26 +42,26 @@ static OP_CHECK(opck_ctrl) { func->d.exp_binary.lhs = call; func->d.exp_binary.op = chuck; CHECK_BN(traverse_exp(env, func)); - struct Stmt_ one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; + Stmt one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; 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)); - struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; + Stmt two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->loc }; free_exp(mp, bin->lhs); free_exp(mp, bin->rhs); - Stmt_List slist = new_mp_vector(mp, struct Stmt_, 2); - mp_vector_set(slist, struct Stmt_, 0, one); - mp_vector_set(slist, struct Stmt_, 1, two); + Stmt_List slist = new_mp_vector(mp, Stmt, 2); + mp_vector_set(slist, Stmt, 0, one); + mp_vector_set(slist, Stmt, 1, two); Stmt* stmt = new_stmt_code(mp, slist, func->loc); const Exp cond = new_prim_id(mp, insert_symbol(env->gwion->st, "true"), func->loc); check_exp(env, cond); - const Stmt_List code = new_mp_vector(mp, struct Stmt_, 1); - mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) { + const Stmt_List code = new_mp_vector(mp, Stmt, 1); + mp_vector_set(code, Stmt, 0, ((Stmt) { .stmt_type = ae_stmt_while, .d = { .stmt_flow = { diff --git a/src/parse/check.c b/src/parse/check.c index df46e610..df56cd5d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1288,14 +1288,14 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { const Exp when = tdef->when; tdef->when = NULL; when->next = helper; - Stmt_List code = new_mp_vector(env->gwion->mp, struct Stmt_, 2); - mp_vector_set(code, struct Stmt_, 0, - ((struct Stmt_) { + 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, struct Stmt_, 1, - ((struct Stmt_) { + mp_vector_set(code, Stmt, 1, + ((Stmt) { .stmt_type = ae_stmt_exp, .loc = when->loc })); @@ -1317,11 +1317,11 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { // casting while defining it* const 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); - struct Stmt_ ret = { + Stmt ret = { .stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }}, .loc = when->loc }; - mp_vector_set(fdef->d.code, struct Stmt_, 1, ret); + mp_vector_set(fdef->d.code, Stmt, 1, ret); ret_id->type = tdef->type; } if (tflag(tdef->type, tflag_cdef)) @@ -1630,7 +1630,7 @@ ANN static m_bool check_stmt_case(const Env env, const Stmt_Match stmt) { ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) { for(m_uint i = 0; i < stmt->list->len; i++) { - Stmt* s = mp_vector_at(stmt->list, struct Stmt_, i); + Stmt* s = mp_vector_at(stmt->list, Stmt, i); CHECK_BB(check_stmt_case(env, &s->d.stmt_match)); } return GW_OK; @@ -1736,7 +1736,7 @@ ANN m_bool check_stmt(const Env env, Stmt* stmt) { ANN m_bool check_stmt_list(const Env env, Stmt_List l) { for(m_uint i = 0; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); CHECK_BB(check_stmt(env, s)); } return GW_OK; @@ -2056,7 +2056,7 @@ ANN static m_bool _check_trait_def(const Env env, const Trait_Def pdef) { if (section->section_type == ae_section_stmt) { Stmt_List l = section->d.stmt_list; for(m_uint i = 0; i < l->len; i++) { - const Stmt* stmt = mp_vector_at(l, struct Stmt_, i); + const Stmt* stmt = mp_vector_at(l, Stmt, i); if (stmt->stmt_type == ae_stmt_exp) { CHECK_BB(traverse_exp(env, stmt->d.stmt_exp.val)); Var_Decl vd = stmt->d.stmt_exp.val->d.exp_decl.var.vd; @@ -2133,7 +2133,7 @@ ANN static bool class_def_has_body(Ast ast) { if(strcmp(s_name(f->base->tag.sym), "@ctor"))return false; Stmt_List l = f->d.code; for(m_uint i = 0; i < l->len; i++) { - const Stmt* stmt = mp_vector_at(l, struct Stmt_, i); + const Stmt* stmt = mp_vector_at(l, Stmt, i); if (stmt->stmt_type == ae_stmt_pp) continue; if (stmt->stmt_type == ae_stmt_exp) { const Exp exp = stmt->d.stmt_exp.val; diff --git a/src/parse/default_arg.c b/src/parse/default_arg.c index 4ece6b19..89a751d0 100644 --- a/src/parse/default_arg.c +++ b/src/parse/default_arg.c @@ -35,9 +35,9 @@ ANN static Stmt_List code(const MemPool p, const Exp func, const Arg_List lst, const uint32_t max, const ae_stmt_t type) { 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, struct Stmt_, 1); - mp_vector_set(code, struct Stmt_, 0, - ((struct Stmt_) { + 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 })); diff --git a/src/parse/partial.c b/src/parse/partial.c index 70e66a38..3ee9d089 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -167,8 +167,8 @@ ANN static Func partial_match(const Env env, const Func up, const Exp args, cons ANN static Stmt_List partial_code(const Env env, Arg_List args, const Exp efun, const Exp earg) { 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, struct Stmt_, 1); - mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) { + 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 }} })); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 44d6a2bf..1618d08e 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -403,7 +403,7 @@ ANN static bool spreadable(const Env env) { ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) { for(m_uint i = 0; i < l->len; i++) { - Stmt* stmt = mp_vector_at(l, struct Stmt_, i); + Stmt* stmt = mp_vector_at(l, Stmt, i); if (stmt->stmt_type == ae_stmt_pp) { if (stmt->d.stmt_pp.pp_type == ae_pp_include) env->name = stmt->d.stmt_pp.data; @@ -479,7 +479,7 @@ ANN static m_bool _scan0_trait_def(const Env env, const Trait_Def pdef) { } else if (section->section_type == ae_section_stmt) { Stmt_List list = section->d.stmt_list; for(uint32_t i = 0; i < list->len; i++) { - Stmt* stmt = mp_vector_at(list, struct Stmt_, i); + Stmt* stmt = mp_vector_at(list, Stmt, i); if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl) ERR_B(stmt->loc, "trait can only contains variable requests and functions"); } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 2cb0a1c9..836fc163 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -268,7 +268,7 @@ ANN static inline m_bool if (stmt->where) CHECK_BB(scan1_stmt(env, stmt->where)); Stmt_List l = stmt->list; for(m_uint i = 0; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); CHECK_BB(scan1_stmt_match_case(env, &s->d.stmt_match)); } return GW_OK; @@ -358,7 +358,7 @@ ANN static inline bool if_stmt_is_return(Stmt* stmt) { if (stmt->stmt_type == ae_stmt_return) return true; if (stmt->stmt_type == ae_stmt_code) { if (mp_vector_len(stmt->d.stmt_code.stmt_list)) { - Stmt* s = mp_vector_back(stmt->d.stmt_code.stmt_list, struct Stmt_); + Stmt* s = mp_vector_back(stmt->d.stmt_code.stmt_list, Stmt); if (s->stmt_type == ae_stmt_return) return true; } } @@ -614,7 +614,7 @@ ANN static inline bool end_flow(Stmt* s) { ANN static void dead_code(const Env env, Stmt_List l, uint32_t len) { for(uint32_t i = len; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); free_stmt(env->gwion->mp, s); } l->len = len; @@ -623,7 +623,7 @@ ANN static void dead_code(const Env env, Stmt_List l, uint32_t len) { ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) { uint32_t i; for(i = 0; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); CHECK_BB(scan1_stmt(env, s)); if(end_flow(s)) break; } @@ -812,15 +812,15 @@ ANN static m_bool scan1_class_def_body(const Env env, const Class_Def cdef) { isa(cdef->base.type, env->gwion->type[et_dict]) < 0) { MemPool mp = env->gwion->mp; Ast base = cdef->body; - Stmt_List ctor = new_mp_vector(mp, struct Stmt_, 0); + Stmt_List ctor = new_mp_vector(mp, Stmt, 0); Ast body = new_mp_vector(mp, Section, 1); // room for ctor for(uint32_t i = 0; i < base->len; i++) { Section section = *mp_vector_at(base, Section, i); if(section.section_type == ae_section_stmt) { Stmt_List list = section.d.stmt_list; for(uint32_t j = 0; j < list->len; j++) { - Stmt* stmt = mp_vector_at(list, struct Stmt_, j); - mp_vector_add(mp, &ctor, struct Stmt_, *stmt); + Stmt* stmt = mp_vector_at(list, Stmt, j); + mp_vector_add(mp, &ctor, Stmt, *stmt); } } else mp_vector_add(mp, &body, Section, section); } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 24d69279..071e9637 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -175,7 +175,7 @@ ANN static inline m_bool if (stmt->where) CHECK_BB(scan2_stmt(env, stmt->where)); Stmt_List l = stmt->list; for(m_uint i = 0; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); CHECK_BB(scan2_stmt_match_case(env, &s->d.stmt_match)); } return GW_OK; @@ -268,7 +268,7 @@ ANN static m_bool scan2_stmt(const Env env, Stmt* stmt) { ANN static m_bool scan2_stmt_list(const Env env, Stmt_List l) { for(m_uint i = 0; i < l->len; i++) { - Stmt* s = mp_vector_at(l, struct Stmt_, i); + Stmt* s = mp_vector_at(l, Stmt, i); CHECK_BB(scan2_stmt(env, s)); } return GW_OK; diff --git a/src/parse/spread.c b/src/parse/spread.c index 37c56df3..79b81ffa 100644 --- a/src/parse/spread.c +++ b/src/parse/spread.c @@ -62,7 +62,7 @@ ANN Ast spread_class(const Env env, const Ast body) { Stmt_List list = section.d.stmt_list; Stmt_List acc = NULL; for(uint32_t j = 0; j < list->len; j++) { - const struct Stmt_ stmt = *mp_vector_at(list, struct Stmt_, j); + const Stmt stmt = *mp_vector_at(list, Stmt, j); if(stmt.stmt_type == ae_stmt_spread) { if(acc) { mp_vector_add(env->gwion->mp, &new_body, Section, MK_SECTION(stmt, stmt_list, acc)); @@ -80,8 +80,8 @@ ANN Ast spread_class(const Env env, const Ast body) { } } else { if(!acc) - acc = new_mp_vector(env->gwion->mp, struct Stmt_, 0); - mp_vector_add(env->gwion->mp, &acc, struct Stmt_, stmt); + acc = new_mp_vector(env->gwion->mp, Stmt, 0); + mp_vector_add(env->gwion->mp, &acc, Stmt, stmt); } } if(acc) { @@ -96,10 +96,10 @@ ANN Ast spread_class(const Env env, const Ast body) { ANN Stmt_List spread_func(const Env env, const Stmt_List body) { const Ast extend = env->context->extend; - Ast new_body = new_mp_vector(env->gwion->mp, struct Stmt_, 0); + Ast new_body = new_mp_vector(env->gwion->mp, Stmt, 0); uint32_t offset = 0; for(uint32_t i = 0; i < body->len; i++) { - const struct Stmt_ stmt = *mp_vector_at(body, struct Stmt_, i); + const Stmt stmt = *mp_vector_at(body, Stmt, i); if(stmt.stmt_type == ae_stmt_spread) { for(; offset < extend->len; offset++) { const Section section = *mp_vector_at(extend, Section, offset); @@ -109,13 +109,13 @@ ANN Stmt_List spread_func(const Env env, const Stmt_List body) { ERR_O(stmt.loc, "invalid section in variadic func"); const Stmt_List list = section.d.stmt_list; for(uint32_t j = 0; j < list->len; j++) { - const struct Stmt_ stmt = *mp_vector_at(list, struct Stmt_, j); - mp_vector_add(env->gwion->mp, &new_body, struct Stmt_, stmt); + const Stmt stmt = *mp_vector_at(list, Stmt, j); + mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt); } break; } } else { - mp_vector_add(env->gwion->mp, &new_body, struct Stmt_, stmt); + mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt); } } free_mp_vector(env->gwion->mp, Stmt_List, body);