From 81093b94b214b581e5d2a67ea741c157e14f605a Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Tue, 30 Jan 2024 15:15:15 +0100 Subject: [PATCH] :art: rename Stmt->pos to loc --- ast | 2 +- src/emit/emit.c | 2 +- src/import/import_item.c | 2 +- src/lib/closure.c | 2 +- src/lib/sift.c | 6 +++--- src/parse/check.c | 20 ++++++++++---------- src/parse/default_arg.c | 2 +- src/parse/scan0.c | 6 +++--- src/parse/scan1.c | 8 ++++---- src/parse/spread.c | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ast b/ast index 56d8b92b..aa633ad7 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 56d8b92b822a2d2891e4d4cea954936538698a28 +Subproject commit aa633ad736df71d78d94346d79f0ed61bf5ef0d3 diff --git a/src/emit/emit.c b/src/emit/emit.c index d2840770..2e801ec4 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2053,7 +2053,7 @@ ANN static inline m_bool emit_jump(const Emitter emit, const Stmt_Index stmt, vector_add(v, (vtype)emit_add_instr(emit, Goto)); else if (stmt->idx) { if (emit_jump_index(emit, v, stmt->idx) < 0) - ERR_B(stmt_self(stmt)->pos, _("too many jumps required.")) + ERR_B(stmt_self(stmt)->loc, _("too many jumps required.")) } return GW_OK; } diff --git a/src/import/import_item.c b/src/import/import_item.c index 882e351a..082a2cf0 100644 --- a/src/import/import_item.c +++ b/src/import/import_item.c @@ -22,7 +22,7 @@ ANN static m_int gwi_item_tmpl(const Gwi gwi) { mp_vector_set(slist, struct Stmt_, 0, ((struct Stmt_) { .stmt_type = ae_stmt_exp, .d = { .stmt_exp = { .val = gwi->ck->exp } }, - .pos = gwi->loc + .loc = gwi->loc })); Section section = (Section) { .section_type = ae_section_stmt, diff --git a/src/lib/closure.c b/src/lib/closure.c index c2819902..c4f77f00 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -611,7 +611,7 @@ static OP_CHECK(opck_op_impl) { mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) { .stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = bin }}, - .pos = impl->e->pos + .loc = impl->e->pos })); const Func_Def def = new_func_def(env->gwion->mp, base, code); def->base->tag.sym = impl->e->d.prim.d.var; diff --git a/src/lib/sift.c b/src/lib/sift.c index c8d266f6..025ee10b 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -42,13 +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)); - struct Stmt_ one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .pos = func->pos }; + struct Stmt_ one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->pos }; Exp samp = new_prim_id(mp, insert_symbol(env->gwion->st, "samp"), func->pos); Exp _now = new_prim_id(mp, insert_symbol(env->gwion->st, "now"), func->pos); Exp time = new_exp_binary(mp, samp, chuck, _now, func->pos); CHECK_BN(traverse_exp(env, time)); - struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .pos = func->pos }; + struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->pos }; free_exp(mp, bin->lhs); free_exp(mp, bin->rhs); @@ -69,7 +69,7 @@ static OP_CHECK(opck_ctrl) { .body = stmt } }, - .pos = func->pos + .loc = func->pos })); exp->exp_type = ae_exp_unary; exp->d.exp_unary.unary_type = unary_code; diff --git a/src/parse/check.c b/src/parse/check.c index f76c17f1..36365275 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1292,12 +1292,12 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) { .stmt_type = ae_stmt_exp, .d = { .stmt_exp = { .val = when }}, - .pos = when->pos + .loc = when->pos })); mp_vector_set(code, struct Stmt_, 1, ((struct Stmt_) { .stmt_type = ae_stmt_exp, - .pos = when->pos + .loc = when->pos })); const Func_Def fdef = new_func_def(env->gwion->mp, fb, code); tdef->when_def = fdef; @@ -1319,7 +1319,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { ret_id->d.prim.value = new_value(env, tdef->type, "self", tdef->tag.loc); struct Stmt_ ret = { .stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }}, - .pos = when->pos + .loc = when->pos }; mp_vector_set(fdef->d.code, struct Stmt_, 1, ret); ret_id->type = tdef->type; @@ -1394,7 +1394,7 @@ ANN static m_bool check_conts(const Env env, const Stmt a, const Stmt b) { ANN static inline m_bool for_empty(const Env env, const Stmt_For stmt) { if (!stmt->c2 || !stmt->c2->d.stmt_exp.val) - ERR_B(stmt_self(stmt)->pos, + ERR_B(stmt_self(stmt)->loc, _("empty for loop condition..." "...(note: explicitly use 'true' if it's the intent)" "...(e.g., 'for(; true;){{ /*...*/ }')")) @@ -1487,7 +1487,7 @@ stmt_func_xxx(each, Stmt_Each, env_inline_mult(env, 1.5), do_stmt_each(env, stmt ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { if (is_new(env->func->def)) { if(stmt->val) - ERR_B(stmt_self(stmt)->pos, + ERR_B(stmt_self(stmt)->loc, _("'return' statement inside constructor function should have no expression")) return GW_OK; } @@ -1505,23 +1505,23 @@ ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { Arg *arg = mp_vector_at(env->func->def->base->args, Arg, 0); if (env->func->def->base->tag.sym == insert_symbol("@implicit") && ret_type == arg->type) - ERR_B(stmt_self(stmt)->pos, + ERR_B(stmt_self(stmt)->loc, _("can't use implicit casting while defining it")) if (check_implicit(env, stmt->val, env->func->def->base->ret_type) > 0) return GW_OK; - ERR_B(stmt_self(stmt)->pos, + ERR_B(stmt_self(stmt)->loc, _("invalid return type: got '%s', expected '%s'"), ret_type->name, env->func->def->base->ret_type->name) } if (isa(env->func->def->base->ret_type, env->gwion->type[et_void]) > 0) return GW_OK; - ERR_B(stmt_self(stmt)->pos, _("missing value for return statement")) + ERR_B(stmt_self(stmt)->loc, _("missing value for return statement")) } #define describe_check_stmt_stack(stack, name) \ ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) { \ if (!vector_size(&env->scope->stack)) \ - ERR_B(stmt->pos, _("'" #name "' found outside of for/while/until...")) \ + ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")) \ return GW_OK; \ } describe_check_stmt_stack(conts, continue); @@ -1710,7 +1710,7 @@ ANN static m_bool check_stmt_pp(const Env env, const Stmt_PP stmt) { !strncmp(stmt->data, "memoize", strlen("memoize"))) env->func->memoize = strtol(stmt->data + 7, NULL, 10); else if(stmt->pp_type == ae_pp_locale) { - const loc_t loc = stmt_self(stmt)->pos; + const loc_t loc = stmt_self(stmt)->loc; const Exp id = new_prim_id(env->gwion->mp, stmt->xid, loc); const Exp arg = new_prim_id(env->gwion->mp, insert_symbol("_"), loc); arg->next = stmt->exp; diff --git a/src/parse/default_arg.c b/src/parse/default_arg.c index aa74c15f..48550996 100644 --- a/src/parse/default_arg.c +++ b/src/parse/default_arg.c @@ -39,7 +39,7 @@ ANN static Stmt_List code(const MemPool p, const Exp func, const Arg_List lst, mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) { .stmt_type = type, .d = { .stmt_exp = { .val = call }}, - .pos = func->pos + .loc = func->pos })); return code; } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 04a7a482..b2ac1075 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -408,10 +408,10 @@ ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) { if (stmt->d.stmt_pp.pp_type == ae_pp_include) env->name = stmt->d.stmt_pp.data; else if (stmt->d.stmt_pp.pp_type == ae_pp_import) - CHECK_BB(plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->pos)); + CHECK_BB(plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->loc)); } else if (stmt->stmt_type == ae_stmt_spread) { if(!spreadable(env)) - ERR_B(stmt->pos, "spread statement outside of variadic environment"); + ERR_B(stmt->loc, "spread statement outside of variadic environment"); if(!env->context->extend) env->context->extend = new_mp_vector(env->gwion->mp, Section, 0); CHECK_BB(spread_tmpl(env, &stmt->d.stmt_spread)); @@ -481,7 +481,7 @@ ANN static m_bool _scan0_trait_def(const Env env, const Trait_Def pdef) { for(uint32_t i = 0; i < list->len; i++) { Stmt stmt = mp_vector_at(list, struct Stmt_, i); if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl) - ERR_B(stmt->pos, "trait can only contains variable requests and functions"); + ERR_B(stmt->loc, "trait can only contains variable requests and functions"); } } else ERR_B(pdef->tag.loc, "invalid section for trait definition"); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 242748d6..a851ab11 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -303,7 +303,7 @@ ANN static inline m_bool scan1_stmt_try(const restrict Env env, ANN static inline m_bool stmt_each_defined(const restrict Env env, const Stmt_Each stmt) { if (nspc_lookup_value1(env->curr, stmt->tag.sym)) - ERR_B(stmt_self(stmt)->pos, _("foreach value '%s' is already defined"), + ERR_B(stmt_self(stmt)->loc, _("foreach value '%s' is already defined"), s_name(stmt->tag.sym)) if (stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->var.tag.sym)) ERR_B(stmt->idx->var.tag.loc, _("foreach index '%s' is already defined"), @@ -575,7 +575,7 @@ ANN m_bool scan1_union_def(const Env env, const Union_Def udef) { ANN static m_bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) { if (!env->func) - ERR_B(stmt_self(stmt)->pos, + ERR_B(stmt_self(stmt)->loc, _("'return' statement found outside function definition")) if (env->scope->depth == 1) env->func->memoize = 1; if(stmt->val) CHECK_BB(scan1_exp(env, stmt->val)); @@ -586,7 +586,7 @@ ANN static m_bool scan1_stmt_pp(const Env env, const Stmt_PP stmt) { if (stmt->pp_type == ae_pp_include) env->name = stmt->data; if (stmt->pp_type == ae_pp_pragma && !strcmp(stmt->data, "packed")) { if(env->class_def && !tflag(env->class_def, tflag_union)) set_tflag(env->class_def, tflag_packed); - else ERR_B(stmt_self(stmt)->pos, "`packed` pragma outside of {G+}class{0} or {G+}struct{0} declaration"); + else ERR_B(stmt_self(stmt)->loc, "`packed` pragma outside of {G+}class{0} or {G+}struct{0} declaration"); } return GW_OK; } @@ -596,7 +596,7 @@ ANN static m_bool scan1_stmt_defer(const Env env, const Stmt_Defer stmt) { } ANN static m_bool scan1_stmt_spread(const Env env, const Spread_Def spread) { - ERR_B(stmt_self(spread)->pos, "spread statement outside of variadic environment"); + ERR_B(stmt_self(spread)->loc, "spread statement outside of variadic environment"); } DECL_STMT_FUNC(scan1, m_bool, Env) diff --git a/src/parse/spread.c b/src/parse/spread.c index 7e232196..37c56df3 100644 --- a/src/parse/spread.c +++ b/src/parse/spread.c @@ -106,7 +106,7 @@ ANN Stmt_List spread_func(const Env env, const Stmt_List body) { if(section.section_type == ae_section_stmt && !section.d.stmt_list) break; if(section.section_type != ae_section_stmt) - ERR_O(stmt.pos, "invalid section in variadic func"); + 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); -- 2.43.0