From: fennecdjay Date: Tue, 30 Jan 2024 16:28:46 +0000 (+0100) Subject: :fire: update to no pos X-Git-Tag: nightly~115 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=9bc9b6d37044c2d89dfc5851d84ae8dcbc630d5a;p=gwion.git :fire: update to no pos --- diff --git a/ast b/ast index aa633ad7..3095d656 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit aa633ad736df71d78d94346d79f0ed61bf5ef0d3 +Subproject commit 3095d6563e507c752ad0010ac384ca487573b0fe diff --git a/plug b/plug index 04994e9d..b873e18a 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 04994e9dbc6acf0ff93c78c772a73ce4aab56b0e +Subproject commit b873e18a508dcb46d9d0e3e6335cd262e3a9d6f8 diff --git a/src/emit/emit.c b/src/emit/emit.c index 2e801ec4..dd92eab6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -509,7 +509,7 @@ ANN static m_bool _emit_symbol(const Emitter emit, const Symbol *data) { ANN static m_bool emit_symbol(const Emitter emit, const Exp_Primary *prim) { if (!prim->value) // assume it's an operator - ERR_B(exp_self(prim)->pos, "missing value for operator"); + ERR_B(exp_self(prim)->loc, "missing value for operator"); return _emit_symbol(emit, &prim->d.var); } @@ -615,7 +615,7 @@ ANN static m_bool emit_prim_range(const Emitter emit, Range **data) { assert(e); struct Op_Import opi = {.op = sym, .lhs = e->type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)prim_exp(data)}; CHECK_BB(op_emit(emit, &opi)); emit_local_exp(emit, prim_exp(data)); @@ -630,7 +630,7 @@ ANN static m_bool emit_prim_dict(const Emitter emit, Exp *data) { Exp e = *data; const Type key = e->type; const Type val = e->next->type; - const Type t = dict_type(emit->gwion, key, val, e->pos); + const Type t = dict_type(emit->gwion, key, val, e->loc); const Instr init = emit_add_instr(emit, dict_ctor_alt); const Exp next = e->next; e->next = NULL; @@ -706,7 +706,7 @@ ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice *range) { struct Op_Import opi = {.op = sym, .lhs = e->type, .rhs = range->base->type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)exp_self(range)}; CHECK_BB(op_emit(emit, &opi)); emit_local_exp(emit, exp_self(range)); @@ -1128,7 +1128,7 @@ ANN static m_bool emit_decl(const Emitter emit, Exp_Decl *const decl) { ANN /*static */ m_bool emit_exp_decl(const Emitter emit, Exp_Decl *const decl) { const Type t = decl->type; if(decl->args && !strncmp(decl->args->type->name, "partial:", 8)) - ERR_B(decl->args->pos, "unresolved partial"); + ERR_B(decl->args->loc, "unresolved partial"); CHECK_BB(ensure_emit(emit, t)); const m_bool global = GET_FLAG(decl->var.td, global); const m_uint scope = @@ -1326,7 +1326,7 @@ ANN static m_bool _emit_exp_call(const Emitter emit, const Exp_Call *call) { struct Op_Import opi = {.op = insert_symbol("call_type"), .rhs = t, .data = (uintptr_t)call, - .loc = exp_self(call)->pos}; + .loc = exp_self(call)->loc}; CHECK_BB(op_emit(emit, &opi)); } const Func f = t->info->func; @@ -1390,7 +1390,7 @@ ANN static m_bool emit_exp_binary(const Emitter emit, const Exp_Binary *bin) { struct Op_Import opi = {.op = bin->op, .lhs = lhs->type, .rhs = rhs->type, - .loc = exp_self(bin)->pos, + .loc = exp_self(bin)->loc, .data = (uintptr_t)bin}; return op_emit(emit, &opi); } @@ -1524,7 +1524,7 @@ static m_bool me_cmp(MemoizeEmitter *me, const Arg *arg) { struct Exp_ lhs = { .exp_type = ae_exp_primary, .type = arg->type, - .pos = arg->var.td->tag.loc, + .loc = arg->var.td->tag.loc, .d = { .prim = { .prim_type = ae_prim_id } } @@ -1532,7 +1532,7 @@ static m_bool me_cmp(MemoizeEmitter *me, const Arg *arg) { struct Exp_ rhs = { .exp_type = ae_exp_primary, .type = me->emit->gwion->type[et_bool], - .pos = arg->var.td->tag.loc, + .loc = arg->var.td->tag.loc, .d = { .prim = { .prim_type = ae_prim_id } } @@ -1540,7 +1540,7 @@ static m_bool me_cmp(MemoizeEmitter *me, const Arg *arg) { struct Exp_ bin = { .exp_type = ae_exp_binary, .type = arg->type, - .pos = arg->var.td->tag.loc, + .loc = arg->var.td->tag.loc, .d = { .exp_binary = { .lhs = &lhs, @@ -1690,7 +1690,7 @@ ANN static m_bool spork_prepare_func(const Emitter emit, if(!f->code && f != emit->env->func) CHECK_BB(emit_ensure_func(emit, f)); push_spork_code(emit, sp->is_spork ? SPORK_FUNC_PREFIX : FORK_CODE_PREFIX, - sp->exp->pos); + sp->exp->loc); return emit_exp_call1(emit, f, f->def->base->ret_type->size, false); } @@ -1736,7 +1736,7 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary *unary) { .code = unary->unary_type == unary_code ? unary->code : NULL, .type = exp_self(unary)->type, .captures = unary->captures, - .loc = exp_self(unary)->pos, + .loc = exp_self(unary)->loc, .is_spork = (unary->op == insert_symbol("spork")), .emit_var = exp_getvar(exp_self(unary))}; CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker))); @@ -1804,13 +1804,13 @@ ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary *unary) { ANN static m_bool emit_implicit_cast(const Emitter emit, const restrict Exp from, const restrict Type to) { - const struct Implicit imp = { .e=from, .t=to, . loc = from->pos}; + const struct Implicit imp = { .e=from, .t=to, . loc = from->loc}; // no pos struct Op_Import opi = {.op = insert_symbol("@implicit"), .lhs = from->type, .rhs = to, .data = (m_uint)&imp, - .loc = from->pos + .loc = from->loc }; return op_emit(emit, &opi); } @@ -1830,7 +1830,7 @@ ANN2(1,2) static Instr _flow(const Emitter emit, const Exp e, Instr *const instr struct Op_Import opi = { .op = insert_symbol(b ? "@conditional" : "@unconditional"), .rhs = e->type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)e}; CHECK_BO(op_emit(emit, &opi)); return (Instr)vector_back(&emit->code->instr); @@ -1949,9 +1949,9 @@ DECL_EXP_FUNC(emit, m_bool, Emitter) ANN2(1) /*static */ m_bool emit_exp(const Emitter emit, /* const */ Exp e) { Exp exp = e; do { - if (emit->info->debug && emit->status.line < e->pos.first.line) { + if (emit->info->debug && emit->status.line < e->loc.first.line) { const Instr instr = emit_add_instr(emit, DebugLine); - instr->m_val = emit->status.line = e->pos.first.line; + instr->m_val = emit->status.line = e->loc.first.line; } CHECK_BB(emit_exp_func[exp->exp_type](emit, &exp->d)); if (exp->cast_to) CHECK_BB(emit_implicit_cast(emit, exp, exp->cast_to)); @@ -1960,7 +1960,7 @@ ANN2(1) /*static */ m_bool emit_exp(const Emitter emit, /* const */ Exp e) { e->exp_type == ae_exp_decl && GET_FLAG(e->d.exp_decl.var.td, late) && exp_getuse(e) && !exp_getvar(e) && GET_FLAG(e->d.exp_decl.var.vd.value, late)) - emit_fast_except(emit, e->d.exp_decl.var.vd.value->from, e->pos); + emit_fast_except(emit, e->d.exp_decl.var.vd.value->from, e->loc); } while ((exp = exp->next)); return GW_OK; } @@ -2428,12 +2428,12 @@ ANN static m_bool emit_case_head(const Emitter emit, const Exp base, CHECK_BB(emit_exp1(emit, base)); CHECK_BB(emit_exp1(emit, e)); const Exp_Binary bin = {.lhs = base, .rhs = e, .op = op}; - struct Exp_ ebin = { .d = {.exp_binary = bin}, .exp_type = ae_exp_binary, .pos = e->pos }; + struct Exp_ ebin = { .d = {.exp_binary = bin}, .exp_type = ae_exp_binary, .loc = e->loc }; struct Op_Import opi = {.op = op, .lhs = base->type, .rhs = e->type, .data = (uintptr_t)&ebin.d.exp_binary, - .loc = e->pos}; + .loc = e->loc}; CHECK_BB(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(v, (vtype)instr); @@ -2503,12 +2503,12 @@ ANN static Symbol case_op(const Emitter emit, const Exp base, const Exp e, emit_regmove(emit, SZ_INT); CHECK_BO(emit_exp(emit, e)); const Exp_Binary bin = {.lhs = base, .rhs = e, .op = insert_symbol("?=")}; - struct Exp_ ebin = {.d = {.exp_binary = bin}, .pos = e->pos }; + struct Exp_ ebin = {.d = {.exp_binary = bin}, .loc = e->loc }; struct Op_Import opi = {.op = insert_symbol("?="), .lhs = base->type, .rhs = e->type, .data = (uintptr_t)&ebin.d.exp_binary, - .loc = e->pos}; + .loc = e->loc}; CHECK_BO(op_emit(emit, &opi)); const Instr instr = emit_add_instr(emit, BranchEqInt); vector_add(vec, (vtype)instr); @@ -2633,7 +2633,7 @@ ANN static m_bool emit_exp_dot(const Emitter emit, const Exp_Dot *member) { .lhs = member->base->type, .rhs = exp_self(member)->type, .data = (uintptr_t)member, - .loc = exp_self(member)->pos}; + .loc = exp_self(member)->loc}; return op_emit(emit, &opi); } diff --git a/src/import/import_prim.c b/src/import/import_prim.c index 9376770d..8e7a2b39 100644 --- a/src/import/import_prim.c +++ b/src/import/import_prim.c @@ -107,11 +107,11 @@ static OP_EMIT(opem_bit_exp) { static OP_CHECK(opck_bit_access) { Array_Sub array = data; const Exp e = array->exp; - if(e->next) ERR_N(e->next->pos, "too many expressions for bit access"); + if(e->next) ERR_N(e->next->loc, "too many expressions for bit access"); if(is_prim_int(e)) { m_int idx = e->d.prim.d.gwint.num; if(idx < 0 || idx >= (m_int)array->type->size * CHAR_BIT) - ERR_N(e->pos, "bit access out of bound"); + ERR_N(e->loc, "bit access out of bound"); } return env->gwion->type[et_bool]; } diff --git a/src/lib/array.c b/src/lib/array.c index d47954ba..d49fd251 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -139,14 +139,14 @@ static OP_CHECK(opck_array_at) { const Exp_Binary *bin = (Exp_Binary *)data; CHECK_NN(opck_const_rhs(env, data)); if (bin->lhs->type != env->gwion->type[et_error]) { - ARRAY_OPCK(bin->lhs, bin->rhs, exp_self(bin)->pos) + ARRAY_OPCK(bin->lhs, bin->rhs, exp_self(bin)->loc) if (bin->lhs->type->array_depth != bin->rhs->type->array_depth) - ERR_N(exp_self(bin)->pos, _("array depths do not match.")); + ERR_N(exp_self(bin)->loc, _("array depths do not match.")); } if (bin->rhs->exp_type == ae_exp_decl) { Type_Decl *td = bin->rhs->d.exp_decl.var.td; if (td->array && td->array->exp) - ERR_N(exp_self(bin)->pos, + ERR_N(exp_self(bin)->loc, _("do not provide array for 'xxx => declaration'.")); SET_FLAG(bin->rhs->d.exp_decl.var.vd.value, late); } @@ -174,12 +174,12 @@ ANN static Type check_array_shift(const Env env, const Exp a, const Exp b, static OP_CHECK(opck_array_sl) { const Exp_Binary *bin = (Exp_Binary *)data; - return check_array_shift(env, bin->lhs, bin->rhs, "<<", exp_self(bin)->pos); + return check_array_shift(env, bin->lhs, bin->rhs, "<<", exp_self(bin)->loc); } static OP_CHECK(opck_array_sr) { const Exp_Binary *bin = (Exp_Binary *)data; - return check_array_shift(env, bin->rhs, bin->lhs, ">>", exp_self(bin)->pos); + return check_array_shift(env, bin->rhs, bin->lhs, ">>", exp_self(bin)->loc); } ANN static inline m_bool emit_array_shift(const Emitter emit, @@ -268,7 +268,7 @@ static OP_CHECK(opck_array_cast) { } parent = parent->info->parent; } - struct Exp_ e = { .type = l, .pos = cast->exp->pos }; + struct Exp_ e = { .type = l, .loc = cast->exp->loc }; CHECK_BN(check_implicit(env, &e, r)); return t; } @@ -382,7 +382,7 @@ static OP_CHECK(opck_array) { while ((e = e->next)); const Type t = get_array_type(array->type); if (t->array_depth >= array->depth) - return array_type(env, array_base(t), t->array_depth - array->depth, array->exp->pos); + return array_type(env, array_base(t), t->array_depth - array->depth, array->exp->loc); const Exp curr = take_exp(array->exp, t->array_depth); struct Array_Sub_ next = {curr->next, array_base(t), @@ -887,12 +887,12 @@ ANN static inline Type foreach_type(const Env env, const Exp exp) { DECL_OO(const Type, t, = array_base_simple(base)); if(!tflag(base, tflag_ref)) { const m_uint depth = base->array_depth - 1; - return depth ? array_type(env, t, depth, exp->pos) : t; + return depth ? array_type(env, t, depth, exp->loc) : t; } const Type inner = (Type)vector_front(&base->info->tuple->contains); const Type refbase = array_base_simple(inner); const m_uint depth = inner->array_depth - 1; - return depth ? array_type(env, refbase, depth, exp->pos) : refbase; + return depth ? array_type(env, refbase, depth, exp->loc) : refbase; } // rewrite me @@ -900,7 +900,7 @@ static OP_CHECK(opck_array_each_val) { const Exp exp = (const Exp) data; DECL_ON(const Type, base, = foreach_type(env, exp)); CHECK_BN(ensure_traverse(env, base)); - return ref_type(env->gwion, base, exp->pos); + return ref_type(env->gwion, base, exp->loc); } static OP_EMIT(opem_array_each) { @@ -1197,7 +1197,7 @@ ANN2(1,2) m_bool check_array_instance(const Env env, Type_Decl *td, const Exp ar } else { if(args) gwerr_warn("array is empty", "no need to provide a lambda", - NULL, env->name, td->array->exp->pos); + NULL, env->name, td->array->exp->loc); } return GW_OK; } diff --git a/src/lib/closure.c b/src/lib/closure.c index c4f77f00..ac7b6979 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -215,14 +215,14 @@ ANN static m_bool fptr_args(const Env env, Func_Base *base[2]) { ANN static bool fptr_effects(const Env env, struct FptrInfo *info) { if (!info->lhs->def->base->effects.ptr) return true; if (!info->rhs->def->base->effects.ptr) { - gwerr_secondary("too many effects", env->name, info->exp->pos); + gwerr_secondary("too many effects", env->name, info->exp->loc); return false; } const Vector lhs = &info->lhs->def->base->effects; const Vector rhs = &info->rhs->def->base->effects; for (m_uint i = 0; i < vector_size(lhs); i++) { if (vector_find(rhs, vector_at(lhs, 0)) == -1) { - gwerr_secondary("effect not handled", env->name, info->exp->pos); + gwerr_secondary("effect not handled", env->name, info->exp->loc); return false; } } @@ -233,7 +233,7 @@ ANN static m_bool fptr_check(const Env env, struct FptrInfo *info) { // if(!info->lhs->def->base->tmpl != !info->rhs->def->base->tmpl) // return GW_ERROR; if(!info->lhs) - ERR_B(info->exp->pos, + ERR_B(info->exp->loc, _("can't resolve operator")) return GW_OK; } @@ -281,7 +281,7 @@ ANN static m_bool _check_lambda(const Env env, Exp_Lambda *l, Arg_List bases = fdef->base->args; Arg_List args = l->def->base->args; if (mp_vector_len(bases) != mp_vector_len(args)) - ERR_B(exp_self(l)->pos, _("argument number does not match for lambda")) + ERR_B(exp_self(l)->loc, _("argument number does not match for lambda")) if(l->def->captures) { // here move to arguments @@ -313,11 +313,11 @@ ANN static m_bool _check_lambda(const Env env, Exp_Lambda *l, Arg *base = mp_vector_at(bases, Arg, i); Arg *arg = mp_vector_at(args, Arg, i); DECL_OB(const Type, arg_type, = known_type(env, base->var.td)); - arg->var.td = type2td(env->gwion, arg_type, exp_self(l)->pos); + arg->var.td = type2td(env->gwion, arg_type, exp_self(l)->loc); } } DECL_OB(const Type, ret_type, = known_type(env, fdef->base->td)); - l->def->base->td = type2td(env->gwion, ret_type, exp_self(l)->pos); + l->def->base->td = type2td(env->gwion, ret_type, exp_self(l)->loc); /*Type*/ owner = fdef->base->func->value_ref->from->owner_class; Upvalues upvalues = { @@ -370,7 +370,7 @@ ANN static m_bool fptr_do(const Env env, struct FptrInfo *info) { if(info->exp->type->info->func) { CHECK_BB(fptr_check(env, info)); if (!(info->exp->type = fptr_type(env, info))) - ERR_B(info->exp->pos, _("no match found")) + ERR_B(info->exp->loc, _("no match found")) return GW_OK; } Exp_Lambda *l = &info->exp->d.exp_lambda; @@ -394,9 +394,9 @@ static OP_CHECK(opck_auto_fptr) { // we'll only deal with auto fptr declaration if (bin->rhs->exp_type != ae_exp_decl && bin->rhs->d.exp_decl.var.td->tag.sym != insert_symbol("auto")) - ERR_N(bin->lhs->pos, "invalid {G+}function{0} {+}:=>{0} {+G}function{0} assignment"); + ERR_N(bin->lhs->loc, "invalid {G+}function{0} {+}:=>{0} {+G}function{0} assignment"); if (bin->lhs->exp_type == ae_exp_td) - ERR_N(bin->lhs->pos, "can't use {/}type decl expressions{0} in auto function pointer declarations"); + ERR_N(bin->lhs->loc, "can't use {/}type decl expressions{0} in auto function pointer declarations"); // if(!bin->lhs->type->info->func) if(!bin->lhs->type->info->func || !strncmp(bin->lhs->type->name, "partial:", 8)) return partial2auto(env, bin); @@ -408,10 +408,10 @@ static OP_CHECK(opck_auto_fptr) { Func_Base *const fbase = cpy_func_base(env->gwion->mp, bin->lhs->type->info->func->def->base); const Fptr_Def fptr_def = new_fptr_def(env->gwion->mp, fbase); - char name[13 + strlen(env->curr->name) + num_digit(bin->rhs->pos.first.line) + - num_digit(bin->rhs->pos.first.column)]; - sprintf(name, "generated@%s@%u:%u", env->curr->name, bin->rhs->pos.first.line, - bin->rhs->pos.first.column); + char name[13 + strlen(env->curr->name) + num_digit(bin->rhs->loc.first.line) + + num_digit(bin->rhs->loc.first.column)]; + sprintf(name, "generated@%s@%u:%u", env->curr->name, bin->rhs->loc.first.line, + bin->rhs->loc.first.column); fptr_def->base->tag.sym = insert_symbol(name); const m_bool ret = traverse_fptr_def(env, fptr_def); const Type t = fptr_def->cdef->base.type; @@ -486,7 +486,7 @@ static m_bool op_call_narg(const Env env, Exp arg, const loc_t loc) { } ANN Type check_op_call(const Env env, Exp_Call *const exp) { - CHECK_BO(op_call_narg(env, exp->args, exp->func->pos)); + CHECK_BO(op_call_narg(env, exp->args, exp->func->loc)); const Exp base = exp_self(exp); const Exp op_exp = exp->func; base->exp_type = ae_exp_binary; @@ -537,7 +537,7 @@ static OP_EMIT(opem_op_impl) { static OP_CHECK(opck_op_impl) { struct Implicit *impl = (struct Implicit *)data; const Func func = closure_def(impl->t)->base->func; - CHECK_BN(op_impl_narg(env, func->def, impl->e->pos)); + CHECK_BN(op_impl_narg(env, func->def, impl->e->loc)); op_impl_ensure_types(env, func); const Symbol lhs_sym = insert_symbol("@lhs"); const Symbol rhs_sym = insert_symbol("@rhs"); @@ -547,13 +547,13 @@ static OP_CHECK(opck_op_impl) { .d = {.prim = {.d = {.var = lhs_sym}, .prim_type = ae_prim_id}}, .exp_type = ae_exp_primary, .type = arg0->type, - .pos = arg0->var.td->tag.loc}; + .loc = arg0->var.td->tag.loc}; struct Exp_ _rhs = { .d = {.prim = {.d = {.var = rhs_sym}, .prim_type = ae_prim_id}}, .exp_type = ae_exp_primary, .type = arg1->type, - .pos = arg1->var.td->tag.loc}; - struct Exp_ self = {.pos = impl->e->pos}; + .loc = arg1->var.td->tag.loc}; + struct Exp_ self = {.loc = impl->e->loc}; self.d.exp_binary.lhs = &_lhs; self.d.exp_binary.rhs = &_rhs; self.d.exp_binary.op = impl->e->d.prim.d.var; @@ -561,13 +561,13 @@ static OP_CHECK(opck_op_impl) { .lhs = arg0->type, .rhs = arg1->type, .data = (uintptr_t)&self.d.exp_binary, - .loc = impl->e->pos}; + .loc = impl->e->loc}; vector_add(&env->scope->effects, 0); DECL_ON(const Type, t, = op_check(env, &opi)); CHECK_BN(isa(t, func->def->base->ret_type)); // error message? MP_Vector *const eff = (MP_Vector*)vector_back(&env->scope->effects); // if (eff && !check_effect_overload(eff, func)) -// ERR_N(impl->pos, _("`{+Y}%s{0}` has effects not present in `{+G}%s{0}`\n"), +// ERR_N(impl->loc, _("`{+Y}%s{0}` has effects not present in `{+G}%s{0}`\n"), // s_name(impl->e->d.prim.d.var), func->name); const Value v = nspc_lookup_value0(opi.nspc, impl->e->d.prim.d.var); if (v) { @@ -592,8 +592,8 @@ static OP_CHECK(opck_op_impl) { larg0->var.vd.tag.sym = lhs_sym; larg1->var.vd.tag.sym = rhs_sym; Func_Base *base = - new_func_base(env->gwion->mp, type2td(env->gwion, t, impl->e->pos), - impl->e->d.prim.d.var, args, ae_flag_none, impl->e->pos); + new_func_base(env->gwion->mp, type2td(env->gwion, t, impl->e->loc), + impl->e->d.prim.d.var, args, ae_flag_none, impl->e->loc); if (eff) { for (m_uint i = 0; i < eff->len; i++) { struct ScopeEffect *effect = mp_vector_at(eff, struct ScopeEffect, i); @@ -602,16 +602,16 @@ static OP_CHECK(opck_op_impl) { free_mp_vector(env->gwion->mp, struct ScopeEffect, eff); } const Exp lhs = - new_prim_id(env->gwion->mp, larg0->var.vd.tag.sym, impl->e->pos); + new_prim_id(env->gwion->mp, larg0->var.vd.tag.sym, impl->e->loc); const Exp rhs = - new_prim_id(env->gwion->mp, larg1->var.vd.tag.sym, impl->e->pos); + 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->pos); + 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_type = ae_stmt_return, .d = { .stmt_exp = { .val = bin }}, - .loc = impl->e->pos + .loc = impl->e->loc })); const Func_Def def = new_func_def(env->gwion->mp, base, code); def->base->tag.sym = impl->e->d.prim.d.var; @@ -642,7 +642,7 @@ static OP_CHECK(opck_class_partial) { Exp_Call *call = (Exp_Call*)data; struct Op_Import opi = {.op = insert_symbol("@partial"), .lhs = actual_type(env->gwion, call->func->type), - .loc = call->func->pos, + .loc = call->func->loc, .data = (uintptr_t)data}; return op_check(env, &opi); } diff --git a/src/lib/deep_equal.c b/src/lib/deep_equal.c index cbae67b7..50babccd 100644 --- a/src/lib/deep_equal.c +++ b/src/lib/deep_equal.c @@ -20,7 +20,7 @@ static OP_##ACTION(op##action##_deep_##_t##_any) { \ .rhs = bin->rhs->type, \ .op = insert_symbol(_data->gwion->st, #_op), \ .data = (m_uint)bin, \ - .loc = exp_self(bin)->pos \ + .loc = exp_self(bin)->loc \ }; \ return op_##_name(_data, &opi); \ } @@ -79,7 +79,7 @@ ANN static inline void check_deep_equal_exp(const Env env, const Exp e, const Ve }, \ .type = _value->type, \ .exp_type = ae_exp_dot, \ - .pos = _exp->pos \ + .loc = _exp->loc \ } #define MK_BIN(_lhs, _rhs, _bin) \ @@ -92,7 +92,7 @@ ANN static inline void check_deep_equal_exp(const Env env, const Exp e, const Ve } \ }, \ .exp_type = ae_exp_binary, \ - .pos = exp_self(_bin)->pos \ + .loc = exp_self(_bin)->loc \ } static bool deep_check(const Env env, const Exp_Binary *bin, @@ -121,7 +121,7 @@ static OP_CHECK(opck_deep_equal) { .lhs = bin->lhs->type, .rhs = bin->rhs->type, .data = (uintptr_t)bin, - .loc = exp_self(bin)->pos}; + .loc = exp_self(bin)->loc}; if(op_get(env, &opi)) { bin->op = base_op; return op_check(env, &opi); @@ -139,7 +139,7 @@ static OP_CHECK(opck_deep_equal) { const Type ret_type = check_exp(env, exp_self(bin)); env_set_error(env, false); if(ret_type) return env->gwion->type[et_bool]; - ERR_N(exp_self(bin)->pos, "no deep operation for: {G+/}%s{0} {+}%s{0} {G+/}%s{0}", + ERR_N(exp_self(bin)->loc, "no deep operation for: {G+/}%s{0} {+}%s{0} {G+/}%s{0}", bin->lhs->type->name, s_name(op), bin->rhs->type->name); } @@ -158,9 +158,9 @@ ANN static inline Type deep_type(const Gwion gwion, const Type t) { ANN static void deep_emit_init(const Emitter emit, struct DeepEmit *d, const m_int offset) { char name[256]; - sprintf(name, "@%u:%u", d->exp->pos.first.line, d->exp->pos.first.column); - d->val = new_value(emit->env, deep_type(emit->gwion, d->exp->type), name, d->exp->pos); - d->tmp = new_prim_id(emit->gwion->mp, insert_symbol(emit->gwion->st, d->val->name), d->exp->pos); + sprintf(name, "@%u:%u", d->exp->loc.first.line, d->exp->loc.first.column); + d->val = new_value(emit->env, deep_type(emit->gwion, d->exp->type), name, d->exp->loc); + d->tmp = new_prim_id(emit->gwion->mp, insert_symbol(emit->gwion->st, d->val->name), d->exp->loc); d->tmp->d.prim.value = d->val; d->tmp->type = d->val->type; check_deep_equal_exp(emit->env, d->exp, &d->vec); diff --git a/src/lib/dict.c b/src/lib/dict.c index 78bd06b5..c5af5357 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -297,7 +297,7 @@ static OP_CHECK(opck_dict_remove_toop) { const Type t = e->d.exp_binary.rhs->type; HMapInfo *const hinfo = (HMapInfo*)t->nspc->class_data; if(isa(args->type, hinfo->key) < 0 || args->next) - ERR_N(e->pos, "dict.remove must be called with one Key argument"); + ERR_N(e->loc, "dict.remove must be called with one Key argument"); return e->type = env->gwion->type[et_void]; } diff --git a/src/lib/lib_class.c b/src/lib/lib_class.c index 69b11157..7ed463dd 100644 --- a/src/lib/lib_class.c +++ b/src/lib/lib_class.c @@ -35,7 +35,7 @@ static OP_CHECK(opck_class_call) { static OP_CHECK(opck_basic_ctor) { const Exp_Call *call = (Exp_Call *)data; // change to *no know constructor for {+G}%s{0}*? - ERR_N(call->func->pos, _("can't call a non-callable value")); + ERR_N(call->func->loc, _("can't call a non-callable value")); } /* static OP_EMIT(opem_implicit_class) { diff --git a/src/lib/modules.c b/src/lib/modules.c index 737add0b..2297adf4 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -206,14 +206,14 @@ static OP_CHECK(opck_usrugen) { Exp_Binary * bin = (Exp_Binary *)data; const Arg_List arg = bin->lhs->type->info->func->def->base->args; if (!arg || arg->len > 1) - ERR_N(exp_self(bin)->pos, + ERR_N(exp_self(bin)->loc, _("Tick function take one and only one argument")); if (isa(((Arg*)(arg->ptr))->type, env->gwion->type[et_float]) < 0) - ERR_N(exp_self(bin)->pos, + ERR_N(exp_self(bin)->loc, _("Tick functions argument must be of type float")); if (isa(bin->lhs->type->info->func->def->base->ret_type, env->gwion->type[et_float]) < 0) - ERR_N(exp_self(bin)->pos, _("Tick function must return float")); + ERR_N(exp_self(bin)->loc, _("Tick function must return float")); if (bin->lhs->type->info->func->value_ref->from->owner_class) CHECK_BN(isa(bin->lhs->type->info->func->value_ref->from->owner_class, bin->rhs->type)); diff --git a/src/lib/object.c b/src/lib/object.c index fa892fc6..97cdc77b 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -94,11 +94,11 @@ ANN void free_object(MemPool p, const M_Object o) { static ID_CHECK(opck_this) { if (!env->class_def) - ERR_O(exp_self(prim)->pos, + ERR_O(exp_self(prim)->loc, _("keyword 'this' can be used only inside class definition...")) if(env->func) { if (!vflag(env->func->value_ref, vflag_member)) - ERR_O(exp_self(prim)->pos, + ERR_O(exp_self(prim)->loc, _("keyword 'this' cannot be used inside static functions...")) if (!exp_getuse(exp_self(prim)) && !strcmp(s_name(env->func->def->base->tag.sym), "@gack")) @@ -122,7 +122,7 @@ static ID_EMIT(opem_this) { static ID_CHECK(opck_super) { const Exp self = exp_self(prim); if(!env->func || is_ctor(env->func->def)) - ERR_O(self->pos, "can't use 'super' outside of constructor"); + ERR_O(self->loc, "can't use 'super' outside of constructor"); const Type parent = env->class_def->info->parent; DECL_OO(const Value, v, = find_value(parent, insert_symbol("new"))); SET_FLAG(env->func, const); @@ -133,7 +133,7 @@ static ID_EMIT(opem_super) { const Env env = emit->env; const Exp self = exp_self(prim); if(!self->is_call) - ERR_B(self->pos, "can only use 'super' as a function call"); + ERR_B(self->loc, "can only use 'super' as a function call"); emit_regpushmem(emit, 0, SZ_INT, false); emit_pushimm(emit, (m_uint)exp_self(prim)->type); return GW_OK; diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 9c0b4ded..657b14d3 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -80,9 +80,9 @@ static OP_CHECK(opck_object_cast) { const Type to = known_type(env, cast->td); if (isa(cast->exp->type, to) < 0) { if (isa(to, cast->exp->type) > 0) - ERR_N(exp_self(cast)->pos, _("can't upcast '%s' to '%s'"), + ERR_N(exp_self(cast)->loc, _("can't upcast '%s' to '%s'"), cast->exp->type->name, to->name); - ERR_N(exp_self(cast)->pos, _("can't cast '%s' to '%s'"), + ERR_N(exp_self(cast)->loc, _("can't cast '%s' to '%s'"), cast->exp->type->name, to->name); } return exp_self(cast)->type; @@ -189,7 +189,7 @@ ANN static m_bool member_access(const Env env, const Exp exp, const Value value) if (!env->class_def || isa(env->class_def, value->from->owner_class) < 0) { if (GET_FLAG(value, private)) { gwerr_basic("invalid variable access", "is private", NULL, env->name, - exp->pos, 0); + exp->loc, 0); env_error_footer(env); defined_here(value); env_set_error(env, true); @@ -215,16 +215,16 @@ OP_CHECK(opck_object_dot) { return v->type; } } - env_err(env, self->pos, _("class '%s' has no member '%s'"), + env_err(env, self->loc, _("class '%s' has no member '%s'"), the_base->name, str); if (member->base->type->nspc) did_you_mean_type(the_base, str); return env->gwion->type[et_error]; } - CHECK_BN(not_from_owner_class(env, the_base, value, self->pos)); + CHECK_BN(not_from_owner_class(env, the_base, value, self->loc)); CHECK_BN(member_access(env, self, value)); if ((base_static && vflag(value, vflag_member)) || (value->from->owner_class != env->class_def && isa(value->from->owner_class, env->class_def) > 0)) - ERR_N(self->pos, + ERR_N(self->loc, _("cannot access member '%s.%s' without object instance..."), the_base->name, str); if (GET_FLAG(value, const)) exp_setmeta(self, true); @@ -270,7 +270,7 @@ OP_EMIT(opem_object_dot) { if(isa(value->type, emit->gwion->type[et_object]) > 0 && !exp_getvar(exp_self(member)) && (GET_FLAG(value, static) || GET_FLAG(value, late))) - emit_fast_except(emit, value->from, exp_self(member)->pos); + emit_fast_except(emit, value->from, exp_self(member)->loc); return GW_OK; } diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index 7c869ebb..1d3f2d76 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -37,9 +37,9 @@ OP_CHECK(opck_usr_implicit) { if(f) { // TODO: add call exp struct Exp_ call = { .exp_type=ae_exp_call, - .d={.exp_call={.args=imp->e}}, .pos=imp->e->pos, .type=f->value_ref->type }; + .d={.exp_call={.args=imp->e}}, .pos=imp->e->loc, .type=f->value_ref->type }; struct Op_Import opi = { .op=insert_symbol("@func_check"), - .rhs=f->value_ref->type, .pos=imp->e->pos, .data=(uintptr_t)&call }; + .rhs=f->value_ref->type, .pos=imp->e->loc, .data=(uintptr_t)&call }; CHECK_NN(op_check(env, &opi)); } } @@ -62,7 +62,7 @@ OP_CHECK(opck_const_rhs) { const Exp_Binary *bin = (Exp_Binary *)data; const m_str access = exp_access(bin->rhs); if (access) - ERR_N(bin->rhs->pos, + ERR_N(bin->rhs->loc, _("cannot assign '%s' on types '%s' and '%s'.\n" " ... (reason: --- right-side operand is %s.)"), s_name(bin->op), bin->lhs->type->name, bin->rhs->type->name, access); @@ -93,7 +93,7 @@ OP_CHECK(opck_unary) { const Exp_Unary *unary = (Exp_Unary *)data; const m_str access = exp_access(unary->exp); if (access) - ERR_N(unary->exp->pos, + ERR_N(unary->exp->loc, _("unary operator '%s' cannot be used on %s data-types."), s_name(unary->op), access); exp_setvar(unary->exp, 1); @@ -105,7 +105,7 @@ OP_CHECK(opck_post) { const Exp_Postfix *post = (Exp_Postfix *)data; const m_str access = exp_access(post->exp); if (access) - ERR_N(post->exp->pos, + ERR_N(post->exp->loc, _("post operator '%s' cannot be used on %s data-type."), s_name(post->op), access); exp_setvar(post->exp, 1); @@ -138,9 +138,9 @@ OP_CHECK(opck_new) { if(unary->ctor.exp) { const Exp self = exp_self(unary); const Exp args = cpy_exp(env->gwion->mp, unary->ctor.exp); - const Exp base = new_exp_unary2(env->gwion->mp, unary->op, unary->ctor.td, unary->ctor.exp, self->pos); + const Exp base = new_exp_unary2(env->gwion->mp, unary->op, unary->ctor.td, unary->ctor.exp, self->loc); base->type = t; - const Exp func = new_exp_dot(env->gwion->mp, base, insert_symbol("new"), self->pos); + const Exp func = new_exp_dot(env->gwion->mp, base, insert_symbol("new"), self->loc); self->d.exp_call.func = func; self->d.exp_call.args = args; self->d.exp_call.tmpl = NULL; @@ -153,7 +153,7 @@ OP_CHECK(opck_new) { ERR_N(unary->ctor.td->tag.loc, _("can't use 'new' on abstract type '%s'\n"), t->name); if (isa(t, env->gwion->type[et_object]) < 0) - ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n")); + ERR_N(exp_self(unary)->loc, _("can't use 'new' on non-object types...\n")); return t; } diff --git a/src/lib/prim.c b/src/lib/prim.c index cf344ee1..10602199 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -31,7 +31,7 @@ static OP_CHECK(opck_##ntype##_##name) { \ /*const*/ Exp_Binary *bin = (Exp_Binary *)data; \ const Type t = TYPE; \ - if (!exp_self(bin)->pos.first.line) return t; \ + if (!exp_self(bin)->loc.first.line) return t; \ pre if (!funcl(bin->lhs) || !funcr(bin->rhs)) return t; \ const ctype num = \ bin->lhs->d.prim.d.lmember OP bin->rhs->d.prim.d.rmember; \ @@ -48,10 +48,10 @@ static OP_CHECK(opck_##ntype##_##name) { \ /*const*/ Exp_Binary *bin = (Exp_Binary *)data; \ const Type t = TYPE; \ - if (!exp_self(bin)->pos.first.line) return t; \ + if (!exp_self(bin)->loc.first.line) return t; \ const bool rconst = funcr(bin->rhs); \ if(rconst && !bin->rhs->d.prim.d.retmember) \ - ERR_N(bin->rhs->pos, _("ZeroDivideException")); \ + ERR_N(bin->rhs->loc, _("ZeroDivideException")); \ pre if (!funcl(bin->lhs) || !rconst) return t; \ const ctype num = \ bin->lhs->d.prim.d.lmember OP bin->rhs->d.prim.d.rmember; \ @@ -195,7 +195,7 @@ static OP_CHECK(opck_int_range) { const Exp exp = (Exp)data; const Range *range = exp->d.prim.d.range; const Exp e = range->start ?: range->end; - return array_type(env, e->type, 1, e->pos); + return array_type(env, e->type, 1, e->loc); } static OP_EMIT(opem_int_range) { @@ -254,7 +254,7 @@ static OP_CHECK(bool2float) { struct Implicit *impl = (struct Implicit *)data; if(!env->context->error) { gwerr_basic("Can't implicitely cast {G+}bool{0} to {G+}float{0}", NULL, "Did you forget a cast?", - env->name, impl->e->pos, 0); + env->name, impl->e->loc, 0); env_set_error(env, true); } return env->gwion->type[et_error]; diff --git a/src/lib/ref.c b/src/lib/ref.c index 3d87e42c..4fd56d62 100644 --- a/src/lib/ref.c +++ b/src/lib/ref.c @@ -27,7 +27,7 @@ ANN Type ref_type(const Gwion gwion, const Type t, const loc_t loc) { static m_bool ref_access(const Env env, const Exp e) { const m_str access = exp_access(e); if (!access) return GW_OK; - env_err(env, e->pos, _("operand is %s"), access); + env_err(env, e->loc, _("operand is %s"), access); return GW_ERROR; } diff --git a/src/lib/sift.c b/src/lib/sift.c index 025ee10b..c1e8ffce 100644 --- a/src/lib/sift.c +++ b/src/lib/sift.c @@ -16,7 +16,7 @@ static OP_CHECK(opck_sift) { 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); 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->pos); + 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? fst->d.stmt_exp.val = next; const Exp exp = exp_self(bin); @@ -32,32 +32,32 @@ static OP_CHECK(opck_ctrl) { Exp_Binary *bin = (Exp_Binary*)data; MemPool mp = env->gwion->mp; if(bin->lhs->exp_type == ae_exp_decl) - ERR_N(bin->lhs->pos, _("can't use declaration to start sift `|>` operator")); + ERR_N(bin->lhs->loc, _("can't use declaration to start sift `|>` operator")); const Symbol chuck = insert_symbol(env->gwion->st, "=>"); Exp exp = exp_self(data); Exp func = cpy_exp(mp, exp); - const Exp dot = new_exp_dot(mp, func->d.exp_binary.lhs, insert_symbol(env->gwion->st, "last"), func->pos); - const Exp call = new_exp_call(mp, dot, NULL, func->pos); + const Exp dot = new_exp_dot(mp, func->d.exp_binary.lhs, insert_symbol(env->gwion->st, "last"), func->loc); + const Exp call = new_exp_call(mp, dot, NULL, func->loc); 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->pos }; + struct 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->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); + 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->pos }; + struct 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); - const Stmt stmt = new_stmt_code(mp, slist, func->pos); + const Stmt stmt = new_stmt_code(mp, slist, func->loc); - const Exp cond = new_prim_id(mp, insert_symbol(env->gwion->st, "true"), func->pos); + 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); @@ -69,7 +69,7 @@ static OP_CHECK(opck_ctrl) { .body = stmt } }, - .loc = func->pos + .loc = func->loc })); exp->exp_type = ae_exp_unary; exp->d.exp_unary.unary_type = unary_code; diff --git a/src/lib/union.c b/src/lib/union.c index 868df059..616cec3d 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -71,13 +71,13 @@ static OP_CHECK(opck_union_is) { const Exp_Call *call = &e->d.exp_call; const Exp exp = call->args; if(!exp) - ERR_N(e->pos, "Union.is() takes one argument of form id"); + ERR_N(e->loc, "Union.is() takes one argument of form id"); if (exp->exp_type != ae_exp_primary || exp->d.prim.prim_type != ae_prim_id) - ERR_N(exp->pos, "Union.is() argument must be of form id"); + ERR_N(exp->loc, "Union.is() argument must be of form id"); const Type t = call->func->d.exp_dot.base->type; const Value v = find_value(t, exp->d.prim.d.var); if (!v) - ERR_N(exp->pos, "'%s' has no member '%s'", t->name, + ERR_N(exp->loc, "'%s' has no member '%s'", t->name, s_name(exp->d.prim.d.var)); const Map map = &t->nspc->info->value->map; for (m_uint i = 0; i < map_size(map); ++i) { @@ -89,8 +89,8 @@ static OP_CHECK(opck_union_is) { e->d.exp_binary.lhs = cpy_exp(env->gwion->mp, exp_func); e->d.exp_binary.lhs->d.exp_dot.xid = insert_symbol(env->gwion->st, "index"); - // e->d.exp_binary.rhs = new_prim_int(env->gwion->mp, i+1, e->pos); - e->d.exp_binary.rhs = new_prim_int(env->gwion->mp, i, e->pos); + // e->d.exp_binary.rhs = new_prim_int(env->gwion->mp, i+1, e->loc); + e->d.exp_binary.rhs = new_prim_int(env->gwion->mp, i, e->loc); free_exp(env->gwion->mp, exp_func); free_exp(env->gwion->mp, exp_args); e->d.exp_binary.op = insert_symbol(env->gwion->st, "=="); @@ -116,10 +116,10 @@ static OP_CHECK(opck_union_new) { Exp_Call *call = (Exp_Call *)data; const Exp name = call->args; if (!name) - ERR_N(call->func->pos, "Union constructor takes one or two arguments, " + ERR_N(call->func->loc, "Union constructor takes one or two arguments, " "'id' and 'value'"); if (name->exp_type != ae_exp_primary || name->d.prim.prim_type != ae_prim_id) - ERR_N(call->func->pos, "Union constructor first argument me be an identifier"); + ERR_N(call->func->loc, "Union constructor first argument me be an identifier"); const Exp val = name->next; const Type base = call->func->d.exp_dot.base->type; const Map map = &base->nspc->info->value->map; @@ -131,21 +131,21 @@ static OP_CHECK(opck_union_new) { name->d.prim.d.gwint.num = i; name->type = env->gwion->type[et_int]; if(!val && v->type == env->gwion->type[et_none]) { - const Exp e = new_prim_int(env->gwion->mp, SZ_INT, name->pos); + const Exp e = new_prim_int(env->gwion->mp, SZ_INT, name->loc); e->next = name; e->type = env->gwion->type[et_int]; - name->next = new_prim_int(env->gwion->mp, 0, name->pos); + name->next = new_prim_int(env->gwion->mp, 0, name->loc); name->next->type = env->gwion->type[et_int]; call->args = e; } else { if (val->next) - ERR_N(call->func->pos, "too many arguments for union constructor"); + ERR_N(call->func->loc, "too many arguments for union constructor"); DECL_ON(const Type, t, = check_exp(env, val)); if (check_implicit(env, val, v->type) < 0) { // add implicit - ERR_N(val->pos, "Invalid type '%s' for '%s', should be '%s'", t->name, + ERR_N(val->loc, "Invalid type '%s' for '%s', should be '%s'", t->name, v->name, v->type->name); } - const Exp e = new_prim_int(env->gwion->mp, t->size + SZ_INT, val->pos); + const Exp e = new_prim_int(env->gwion->mp, t->size + SZ_INT, val->loc); e->next = name; e->type = env->gwion->type[et_int]; call->args = e; @@ -153,7 +153,7 @@ static OP_CHECK(opck_union_new) { return base; } } - ERR_N(name->pos, "%s has no member %s\n", base->name, s_name(name->d.prim.d.var)); + ERR_N(name->loc, "%s has no member %s\n", base->name, s_name(name->d.prim.d.var)); } ANN GWION_IMPORT(union) { diff --git a/src/lib/xork.c b/src/lib/xork.c index 5fe5ba37..02b65294 100644 --- a/src/lib/xork.c +++ b/src/lib/xork.c @@ -19,11 +19,11 @@ ANN static Type fork_type(const Env env, const Exp_Unary *unary) { sprintf(c, "TypedFork:[%s]", t->name); const Type fork = env->gwion->type[et_fork]; UNSET_FLAG(fork, final); - const Type typed = str2type(env->gwion, "TypedFork", exp_self(unary)->pos); + const Type typed = str2type(env->gwion, "TypedFork", exp_self(unary)->loc); if (typed->nspc->offset == fork->nspc->offset) typed->nspc->offset += t->size; UNSET_FLAG(typed, final); - const Type ret = str2type(env->gwion, c, exp_self(unary)->pos); + const Type ret = str2type(env->gwion, c, exp_self(unary)->loc); SET_FLAG(typed, final); SET_FLAG(fork, final); return ret; @@ -62,7 +62,7 @@ static OP_CHECK(opck_spork) { struct Value_ value = { .type = env->gwion->type[et_function]}; if(env->class_def) set_vflag(&value, vflag_member); - struct Func_Base_ fbase = { .tag=MK_TAG(insert_symbol("in spork"), exp_self(unary)->pos), .values = &upvalues, .fbflag = fbflag_lambda}; + struct Func_Base_ fbase = { .tag=MK_TAG(insert_symbol("in spork"), exp_self(unary)->loc), .values = &upvalues, .fbflag = fbflag_lambda}; struct Func_Def_ fdef = { .base = &fbase}; struct Func_ func = { .name = "in spork", .def = &fdef, .value_ref = &value}; env->func = &func; @@ -75,7 +75,7 @@ static OP_CHECK(opck_spork) { return env->gwion ->type[unary->op == insert_symbol("spork") ? et_shred : et_fork]; } - ERR_O(exp_self(unary)->pos, _("only function calls can be sporked...")) + ERR_O(exp_self(unary)->loc, _("only function calls can be sporked...")) } static OP_EMIT(opem_spork) { diff --git a/src/parse/check.c b/src/parse/check.c index 36365275..8333fbed 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -23,12 +23,12 @@ ANN m_bool check_class_def(const Env env, const Class_Def class_def); ANN static Type check_internal(const Env env, const Symbol sym, const Exp e, const Type t) { - struct Implicit imp = {.e = e, .t = t, .loc = e->pos}; + struct Implicit imp = {.e = e, .t = t, .loc = e->loc}; struct Op_Import opi = {.op = sym, .lhs = e->type, .rhs = t, .data = (uintptr_t)&imp, - .loc = e->pos}; + .loc = e->loc}; return op_check(env, &opi); } @@ -47,11 +47,11 @@ ANN m_bool check_subscripts(Env env, const Array_Sub array, do { if (is_decl) { if(check_implicit(env, e, env->gwion->type[et_int]) < 0) - ERR_B(array->exp->pos, _("invalid array declaration index type.")) + ERR_B(array->exp->loc, _("invalid array declaration index type.")) } } while (++depth && (e = e->next)); if (depth != array->depth) - ERR_B(array->exp->pos, _("invalid array access expression.")) + ERR_B(array->exp->loc, _("invalid array access expression.")) return GW_OK; } @@ -206,14 +206,14 @@ ANN static m_bool check_collection(const Env env, Type type, const Exp e, // suggested fix: rewrite int 2 as float 2.0" char sec[16 + strlen(e->type->name)]; sprintf(sec, "got `{+/}%s{0}`", e->type->name); - gwerr_secondary(sec, env->name, e->pos); + gwerr_secondary(sec, env->name, e->loc); return GW_ERROR; } ANN static inline Type prim_array_match(const Env env, Exp e) { const Type type = e->type; bool err = false; - const loc_t loc = e->pos; + const loc_t loc = e->loc; do if (check_collection(env, type, e, loc) < 0) err = true; while ((e = e->next)); @@ -237,7 +237,7 @@ ANN static m_bool check_range(const Env env, Range *range) { if (range->end) CHECK_OB(check_exp(env, range->end)); if (range->start && range->end) { if (isa(range->end->type, range->start->type) < 0) - ERR_B(range->start->pos, _("range types do not match")) + ERR_B(range->start->loc, _("range types do not match")) } return GW_OK; } @@ -251,7 +251,7 @@ ANN static Type check_prim_range(const Env env, Range **data) { const Symbol sym = insert_symbol("[:]"); struct Op_Import opi = {.op = sym, .lhs = e->type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)prim_exp(data)}; return op_check(env, &opi); } @@ -262,7 +262,7 @@ ANN static Type check_prim_dict(const Env env, Exp *data) { const Type key = base->type; const Type val = base->next->type; bool err = false; - const loc_t loc = base->pos; + const loc_t loc = base->loc; Exp e = base; env_weight(env, 1); do { @@ -270,7 +270,7 @@ ANN static Type check_prim_dict(const Env env, Exp *data) { e = e->next; if (check_collection(env, val, e, loc) < 0) err = true; } while ((e = e->next)); - if (!err) return dict_type(env->gwion, key, val, base->pos); + if (!err) return dict_type(env->gwion, key, val, loc); env_set_error(env, true); return NULL; } @@ -356,7 +356,7 @@ ANN static Type check_dot(const Env env, const Exp_Dot *member) { struct Op_Import opi = {.op = insert_symbol("."), .lhs = member->base->type, .data = (uintptr_t)member, - .loc = exp_self(member)->pos}; + .loc = exp_self(member)->loc}; env_weight(env, 1); return op_check(env, &opi); } @@ -364,7 +364,7 @@ ANN static Type check_dot(const Env env, const Exp_Dot *member) { ANN static m_bool check_upvalue(const Env env, const Exp_Primary *prim, const Value v) { if(not_upvalue(env, v)) return GW_OK; - gwerr_basic(_("value not in lambda scope"), NULL, NULL, env->name, exp_self(prim)->pos, 4242); + gwerr_basic(_("value not in lambda scope"), NULL, NULL, env->name, exp_self(prim)->loc, 4242); declared_here(v); gw_err("{-}hint:{0} try adding it to capture list"); env_set_error(env, true); @@ -512,7 +512,7 @@ ANN Type check_array_access(const Env env, const Array_Sub array) { struct Op_Import opi = {.op = sym, .lhs = array->exp->type, .rhs = array->type, - .loc = array->exp->pos, + .loc = array->exp->loc, .data = (uintptr_t)array}; return op_check(env, &opi); } @@ -534,7 +534,7 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice *range) { struct Op_Import opi = {.op = sym, .lhs = e->type, .rhs = range->base->type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)exp_self(range)}; return op_check(env, &opi); } @@ -729,7 +729,7 @@ ANN static Func get_template_func(const Env env, Exp_Call *const func, } ((Exp_Call *)func)->tmpl = NULL; assert(exp_self(func)); - ERR_O(exp_self(func)->pos, + ERR_O(exp_self(func)->loc, _("function is a template for which automatic type inference is not fully implemented")); } @@ -822,7 +822,7 @@ ANN static TmplArg_List check_template_args(const Env env, Exp_Call *exp, } } if (args_number < len) //TODO: free tmplarg_list - ERR_O(exp->func->pos, _("not able to infer types for template call.")) + ERR_O(exp->func->loc, _("not able to infer types for template call.")) if(spread) { Exp e = exp->args; @@ -831,7 +831,7 @@ ANN static TmplArg_List check_template_args(const Env env, Exp_Call *exp, while(e) { TmplArg targ = { .type = tmplarg_td, - .d = { .td = type2td(env->gwion, e->type, e->pos) } + .d = { .td = type2td(env->gwion, e->type, e->loc) } }; mp_vector_add(env->gwion->mp, &tl, TmplArg, targ); e = e->next; @@ -916,7 +916,7 @@ ANN static Type check_lambda_call(const Env env, Exp_Call *const exp) { Exp e = exp->args; for(uint32_t i = 0; i < (args ? args->len : 0); i++) { if(!e) - ERR_O(exp_self(exp)->pos, _("argument number does not match for lambda")) + ERR_O(exp_self(exp)->loc, _("argument number does not match for lambda")) Arg *arg = mp_vector_at(args, Arg, i); arg->type = e->type; if(is_class(env->gwion, arg->type)) @@ -924,7 +924,7 @@ ANN static Type check_lambda_call(const Env env, Exp_Call *const exp) { e = e->next; } if(e) - ERR_O(exp_self(exp)->pos, _("argument number does not match for lambda")) + ERR_O(exp_self(exp)->loc, _("argument number does not match for lambda")) Upvalues upvalues = { .values = env->curr->info->value}; if(env->func && env->func->def->base->values) upvalues.parent = env->func->def->base->values; @@ -945,7 +945,7 @@ ANN m_bool func_check(const Env env, Exp_Call *const exp) { exp->func->is_call = true; CHECK_OB(check_exp(env, exp->func)); if (exp->func->exp_type == ae_exp_decl) - ERR_B(exp->func->pos, _("Can't call late function pointer at declaration " + ERR_B(exp->func->loc, _("Can't call late function pointer at declaration " "site. did you meant to use `:=>`?")) const Type t = actual_type(env->gwion, exp->func->type); if (is_func(env->gwion, t) && exp->func->exp_type == ae_exp_dot && // is_callable @@ -956,7 +956,7 @@ ANN m_bool func_check(const Env env, Exp_Call *const exp) { const Exp e = exp_self(exp); struct Op_Import opi = {.op = insert_symbol("@func_check"), .rhs = t, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)e}; if(op_get(env, &opi)) CHECK_OB(op_check(env, &opi)); @@ -984,7 +984,7 @@ ANN Type call_type(const Env env, Exp_Call *const exp) { struct Op_Import opi = {.op = insert_symbol("call_type"), .rhs = actual_type(env->gwion, exp->func->type), .data = (uintptr_t)exp, - .loc = exp_self(exp)->pos}; + .loc = exp_self(exp)->loc}; return op_check(env, &opi); } @@ -998,7 +998,7 @@ ANN static Type call_return(const Env env, Exp_Call *const exp, const Func func) { const Value v = func->value_ref; exp->func->type = v->type; - call_add_effect(env, func, exp->func->pos); + call_add_effect(env, func, exp->func->loc); if(func->def->base->ret_type != env->gwion->type[et_auto]) return func->def->base->ret_type; if(tflag(v->from->owner_class, tflag_struct)) @@ -1035,7 +1035,7 @@ ANN static Type check_static(const Env env, const Exp e) { !t->info->func || !GET_FLAG(t->info->func->def->base, abstract) || !is_static_call(env->gwion, e)) return t; - env_err(env, e->pos, "making a static call to an abstract function"); + env_err(env, e->loc, "making a static call to an abstract function"); declared_here(t->info->value); return NULL; } @@ -1057,7 +1057,7 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { if(t) return t; } } - function_alternative(env, exp->func->type, exp->args, exp->func->pos); + function_alternative(env, exp->func->type, exp->args, exp->func->loc); return NULL; } @@ -1100,7 +1100,7 @@ ANN static Type check_exp_binary(const Env env, const Exp_Binary *bin) { .lhs = bin->lhs->type, .rhs = bin->rhs->type, .data = (uintptr_t)bin, - .loc = exp_self(bin)->pos}; + .loc = exp_self(bin)->loc}; exp_setuse(bin->lhs, 1); exp_setuse(bin->rhs, 1); const Type ret = op_check(env, &opi); @@ -1116,7 +1116,7 @@ ANN static Type check_exp_cast(const Env env, const Exp_Cast *cast) { .lhs = t, .rhs = exp_self(cast)->type, .data = (uintptr_t)cast, - .loc = exp_self(cast)->pos}; + .loc = exp_self(cast)->loc}; return op_check(env, &opi); } @@ -1124,7 +1124,7 @@ ANN static Type check_exp_post(const Env env, const Exp_Postfix *post) { struct Op_Import opi = {.op = post->op, .lhs = check_exp(env, post->exp), .data = (uintptr_t)post, - .loc = exp_self(post)->pos}; + .loc = exp_self(post)->loc}; CHECK_OO(opi.lhs); exp_setuse(post->exp, 1); const Type t = op_check(env, &opi); @@ -1172,7 +1172,7 @@ ANN static bool tl_match(const Env env, const TmplArg_List tl0, const TmplArg_Li ANN static Type check_exp_call_tmpl(const Env env, Exp_Call *exp, const Type t) { if (exp->args) CHECK_OO(check_exp(env, exp->args)); if (!t->info->func->def->base->tmpl) - ERR_O(exp_self(exp)->pos, _("template call of non-template function.")) + ERR_O(exp_self(exp)->loc, _("template call of non-template function.")) if (t->info->func->def->base->tmpl->call) { if (env->func == t->info->func) { exp->func->type = env->func->value_ref->type; @@ -1180,7 +1180,7 @@ ANN static Type check_exp_call_tmpl(const Env env, Exp_Call *exp, const Type t) } else { if(tl_match(env, t->info->func->def->base->tmpl->call, exp->tmpl->call)) return check_exp_call1(env, exp); - CHECK_BO(predefined_call(env, t, exp_self(exp)->pos)); + CHECK_BO(predefined_call(env, t, exp_self(exp)->loc)); } } const Value v = type_value(env->gwion, t); @@ -1194,7 +1194,7 @@ ANN static Type check_exp_call(const Env env, Exp_Call *exp) { CHECK_OO(check_exp(env, exp->func)); struct Op_Import opi = {.op = insert_symbol("@partial"), .lhs = exp->func->type, - .loc = exp->func->pos, + .loc = exp->func->loc, .data = (uintptr_t)exp}; return op_check(env, &opi); } @@ -1224,7 +1224,7 @@ ANN static Type check_exp_unary(const Env env, const Exp_Unary *unary) { struct Op_Import opi = {.op = unary->op, .rhs = rhs, .data = (uintptr_t)unary, - .loc = exp_self(unary)->pos}; + .loc = exp_self(unary)->loc}; DECL_OO(const Type, ret, = op_check(env, &opi)); return ret; } @@ -1234,7 +1234,7 @@ ANN static Type _flow(const Env env, const Exp e, const m_bool b) { struct Op_Import opi = { .op = insert_symbol(b ? "@conditional" : "@unconditional"), .rhs = type, - .loc = e->pos, + .loc = e->loc, .data = (uintptr_t)e}; return op_check(env, &opi); } @@ -1255,11 +1255,11 @@ ANN static Type check_exp_if(const Env env, Exp_If *const exp_if) { exp_setmeta(exp_self(exp_if), meta); const Type ret = find_common_anc(if_exp, else_exp); if (!ret) - ERR_O(exp_self(exp_if)->pos, + ERR_O(exp_self(exp_if)->loc, _("incompatible types '%s' and '%s' in if expression..."), if_exp->name, else_exp->name) if (isa(if_exp, else_exp) < 0) - ERR_O(exp_self(exp_if)->pos, _("condition type '%s' does not match '%s'"), + ERR_O(exp_self(exp_if)->loc, _("condition type '%s' does not match '%s'"), cond->name, ret->name) exp_setuse(exp_if->cond, true); exp_setuse(exp_if->if_exp, true); @@ -1275,7 +1275,7 @@ ANN static Type check_exp_dot(const Env env, Exp_Dot *member) { ANN m_bool check_type_def(const Env env, const Type_Def tdef) { if (tdef->when) { set_tflag(tdef->type, tflag_contract); - struct Var_Decl_ decl = { .tag = MK_TAG(insert_symbol("self"), tdef->when->pos) }; + struct Var_Decl_ decl = { .tag = MK_TAG(insert_symbol("self"), tdef->when->loc) }; Type_Decl *td = cpy_type_decl(env->gwion->mp, tdef->ext); Arg_List args = new_mp_vector(env->gwion->mp, Arg, 1); mp_vector_set(args, Arg, 0, ((Arg) { .var = MK_VAR(td, decl)})); @@ -1284,7 +1284,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { insert_symbol("@implicit"), args, ae_flag_none, tdef->tag.loc); set_fbflag(fb, fbflag_op); const Exp helper = new_prim_id(env->gwion->mp, insert_symbol("@predicate"), - tdef->when->pos); + tdef->when->loc); const Exp when = tdef->when; tdef->when = NULL; when->next = helper; @@ -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 }}, - .loc = when->pos + .loc = when->loc })); mp_vector_set(code, struct Stmt_, 1, ((struct Stmt_) { .stmt_type = ae_stmt_exp, - .loc = when->pos + .loc = when->loc })); const Func_Def fdef = new_func_def(env->gwion->mp, fb, code); tdef->when_def = fdef; @@ -1306,7 +1306,7 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { char explain[strlen(when->type->name) + 20]; sprintf(explain, "found `{/+}%s{0}`", when->type->name); gwerr_basic("Invalid `{/+}when{0}` predicate expression type", explain, - "use `{/+}bool{0}`", env->name, when->pos, 0); + "use `{/+}bool{0}`", env->name, when->loc, 0); char from[strlen(tdef->type->name) + 39]; sprintf(from, "in `{/+}%s{0}` definition", tdef->type->name); gwerr_secondary(from, env->name, tdef->tag.loc); @@ -1315,11 +1315,11 @@ ANN m_bool check_type_def(const Env env, const Type_Def tdef) { } // we handle the return after, so that we don't get *cant' use implicit // casting while defining it* - const Exp ret_id = new_prim_id(env->gwion->mp, insert_symbol("self"), when->pos); + 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_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }}, - .loc = when->pos + .loc = when->loc }; mp_vector_set(fdef->d.code, struct Stmt_, 1, ret); ret_id->type = tdef->type; @@ -1337,7 +1337,7 @@ ANN static Type check_exp_lambda(const Env env, const Exp_If *exp_if NUSED) { ANN static Type check_exp_td(const Env env, Type_Decl **td) { DECL_OO(const Type, t, = known_type(env, *td)); if(t == env->gwion->type[et_class]) - ERR_O(exp_self(td)->pos, "can't use {G+}Class{0} in type decl expression"); + ERR_O(exp_self(td)->loc, "can't use {G+}Class{0} in type decl expression"); if (!is_func(env->gwion, t)) return type_class(env->gwion, t); return t; } @@ -1428,7 +1428,7 @@ ANN static Type check_each_val(const Env env, const Exp exp) { .lhs = exp->type, .op = insert_symbol("@each_val"), .data = (m_uint)exp, - .loc = exp->pos + .loc = exp->loc }; return op_check(env, &opi); } @@ -1455,7 +1455,7 @@ ANN static inline m_bool repeat_type(const Env env, const Exp e) { sprintf(explain, "expected `{/+}int{0}`, got `{/+}%s{0}`", e->type->name); gwerr_basic(_("invalid repeat condition type"), explain, _("use an integer or cast to int if possible"), env->name, - e->pos, 0); + e->loc, 0); env_set_error(env, true); return GW_ERROR; } @@ -1499,7 +1499,7 @@ ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { } if (isa(ret_type, env->func->def->base->ret_type) > 0) return GW_OK; if (tflag(ret_type, tflag_noret)) - ERR_B(stmt->val->pos, _("Can't use type `{+G}%s{+G}` for return"), + ERR_B(stmt->val->loc, _("Can't use type `{+G}%s{+G}` for return"), ret_type->name); if (stmt->val) { Arg *arg = mp_vector_at(env->func->def->base->args, Arg, 0); @@ -1560,7 +1560,7 @@ ANN Symbol case_basic_op(const Env env, const Type base, const Exp e) { .lhs = base, .rhs = e->type, .data = (uintptr_t)NULL, - .loc = e->pos}; + .loc = e->loc}; return op_get(env, &opi) ? insert_symbol("==") : insert_symbol("?="); @@ -1594,7 +1594,7 @@ ANN static Symbol case_op(const Env env, const Type base, const Exp e) { ANN static m_bool match_case_exp(const Env env, Exp e) { Exp last = e; for (m_uint i = 0; i < vector_size(&env->scope->match->cond); e = e->next, ++i) { - if (!e) ERR_B(last->pos, _("no enough to match")) + if (!e) ERR_B(last->loc, _("no enough to match")) last = e; const Exp base = (Exp)vector_at(&env->scope->match->cond, i); const Symbol op = case_op(env, base->type, e); @@ -1605,7 +1605,7 @@ ANN static m_bool match_case_exp(const Env env, Exp e) { e->next = next; CHECK_OB(t); Exp_Binary bin = {.lhs = cpy_exp(env->gwion->mp, base), .rhs = cpy_exp(env->gwion->mp, e), .op = op}; - struct Exp_ ebin = {.d = {.exp_binary = bin}, .exp_type = ae_exp_binary, .pos = e->pos }; + struct Exp_ ebin = {.d = {.exp_binary = bin}, .exp_type = ae_exp_binary, .loc = e->loc }; CHECK_BB(traverse_exp(env, &ebin)); const Type ret = ebin.type; if(ebin.exp_type == ae_exp_binary) { @@ -1615,7 +1615,7 @@ ANN static m_bool match_case_exp(const Env env, Exp e) { CHECK_OB(ret); } } - if (e) ERR_B(e->pos, _("too many expression to match")) + if (e) ERR_B(e->loc, _("too many expression to match")) return GW_OK; } @@ -1893,7 +1893,7 @@ ANN static m_bool fdef_const_generic_typecheck(const Env env, const Specialized tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name); gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0); tcol_snprintf(msg, 255, "got {G+}%s{0}", targ->d.exp->type->name); - gwerr_secondary(msg, env->name, targ->d.exp->pos); + gwerr_secondary(msg, env->name, targ->d.exp->loc); return GW_ERROR; } return GW_OK; @@ -2233,7 +2233,7 @@ ANN static m_bool check_class_tmpl(const Env env, const Tmpl *tmpl, const Nspc n if(likely(targ.type == tmplarg_td)) continue; CHECK_OB(check_exp(env, targ.d.exp)); const Specialized spec = *mp_vector_at(tmpl->list, Specialized, i); - const Value v = new_value(env, targ.d.exp->type, s_name(spec.tag.sym), targ.d.exp->pos); + const Value v = new_value(env, targ.d.exp->type, s_name(spec.tag.sym), targ.d.exp->loc); valuefrom(env, v->from); set_vflag(v, vflag_valid); nspc_add_value(nspc, spec.tag.sym, v); diff --git a/src/parse/default_arg.c b/src/parse/default_arg.c index 48550996..4ece6b19 100644 --- a/src/parse/default_arg.c +++ b/src/parse/default_arg.c @@ -34,12 +34,12 @@ ANN static Exp mk_args(const MemPool p, const Arg_List args, const uint32_t max) 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->pos); + 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_type = type, .d = { .stmt_exp = { .val = call }}, - .loc = func->pos + .loc = func->loc })); return code; } diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index d6a8286d..ea64b455 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -51,7 +51,7 @@ ANN static Func ensure_tmpl(const Env env, const Func_Def fdef, const Func func = find_func_match(env, f, exp); nspc_pop_type(env->gwion->mp, env->curr); if (func) - call_add_effect(env, func, exp->func->pos); + call_add_effect(env, func, exp->func->loc); return func; } @@ -168,7 +168,7 @@ ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, ANN static Func __find_template_match(const Env env, const Value v, Exp_Call *const exp) { DECL_OO(const m_str, tmpl_name, - = tl2str(env->gwion, exp->tmpl->call, exp->func->pos)); + = tl2str(env->gwion, exp->tmpl->call, exp->func->loc)); const Func f = find_tmpl(env, v, exp, tmpl_name); free_mstr(env->gwion->mp, tmpl_name); return f; @@ -184,13 +184,13 @@ ANN static Func _find_template_match(const Env env, const Value v, TmplArg arg = *mp_vector_at(tl, TmplArg, i); if(unlikely(spec->td)) { if(unlikely(arg.type == tmplarg_td)) - ERR_O(exp_self(exp)->pos, "expected contant, not type"); + ERR_O(exp_self(exp)->loc, "expected contant, not type"); // check argument in call exp continue; } else { if(unlikely(arg.type == tmplarg_exp)) { - ERR_O(exp_self(exp)->pos, "expected type, not constant"); + ERR_O(exp_self(exp)->loc, "expected type, not constant"); // check argument in call exp? continue; } @@ -205,7 +205,7 @@ ANN static Func _find_template_match(const Env env, const Value v, ANN static inline m_bool check_call(const Env env, const Exp_Call *exp) { const ae_exp_t et = exp->func->exp_type; if (et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast) - ERR_B(exp->func->pos, _("invalid expression for function call.")) + ERR_B(exp->func->loc, _("invalid expression for function call.")) return GW_OK; } @@ -225,5 +225,5 @@ ANN Func find_template_match(const Env env, const Value value, } t = t->info->parent; } - ERR_O(exp_self(exp)->pos, _("arguments do not match for template call")) + ERR_O(exp_self(exp)->loc, _("arguments do not match for template call")) } diff --git a/src/parse/operator.c b/src/parse/operator.c index f08875e0..eff79b81 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -298,7 +298,7 @@ ANN void* op_get(const Env env, struct Op_Import *opi) { ANN static Type chuck_rewrite(const Env env, const struct Op_Import *opi, const m_str op, const size_t len) { Exp_Binary *base = (Exp_Binary*)opi->data; const Exp lhs = cpy_exp(env->gwion->mp, base->lhs); // no need to copy - const Exp call = new_exp_call(env->gwion->mp, cpy_exp(env->gwion->mp, base->rhs), NULL, lhs->pos); + const Exp call = new_exp_call(env->gwion->mp, cpy_exp(env->gwion->mp, base->rhs), NULL, lhs->loc); char c[len - 1]; strncpy(c, op, len - 2); c[len - 2] = '\0'; @@ -308,7 +308,7 @@ ANN static Type chuck_rewrite(const Env env, const struct Op_Import *opi, const env_set_error(env, true); return NULL; } - const Exp bin = new_exp_binary(env->gwion->mp, lhs, insert_symbol(env->gwion->st, c), call, exp_self(base)->pos); + const Exp bin = new_exp_binary(env->gwion->mp, lhs, insert_symbol(env->gwion->st, c), call, exp_self(base)->loc); base->lhs = bin; base->op = insert_symbol(env->gwion->st, "=>"); const Type ret = check_exp(env, exp_self(base)); diff --git a/src/parse/partial.c b/src/parse/partial.c index f4ee2a99..70e66a38 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -48,9 +48,9 @@ ANN static Exp partial_exp(const Env env, Arg_List args, Exp e, const uint i) { if(is_hole(env, e) || is_typed_hole(env, e)) { char c[256]; sprintf(c, "@%u", i); - const Exp exp = new_prim_id(env->gwion->mp, insert_symbol(c), e->pos); + const Exp exp = new_prim_id(env->gwion->mp, insert_symbol(c), e->loc); exp->type = known_type(env, mp_vector_at(args, Arg, i)->var.td); - exp->d.prim.value = new_value(env, exp->type, c, e->pos); + exp->d.prim.value = new_value(env, exp->type, c, e->loc); valid_value(env, insert_symbol(c), exp->d.prim.value); return exp; } @@ -166,7 +166,7 @@ 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->pos); + 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_type = ae_stmt_return, @@ -175,7 +175,7 @@ ANN static Stmt_List partial_code(const Env env, Arg_List args, const Exp efun, // stmt->stmt_type = ae_stmt_return; // stmt->d.stmt_exp.val = exp; return code; -// return new_stmt_code(env->gwion->mp, slist, efun->pos); +// return new_stmt_code(env->gwion->mp, slist, efun->loc); } ANN static uint32_t count_args_exp(Exp args) { @@ -210,18 +210,18 @@ ANN static Exp expand(const Env env, const Func func, const Exp e, const loc_t l ANN Type partial_type(const Env env, Exp_Call *const call) { const Func base = call->func->type->info->func; - if(!base) ERR_O(call->func->pos, _("can't do partial application on a literal lambda")); - const Func f = partial_match(env, base, call->args, call->func->pos); + if(!base) ERR_O(call->func->loc, _("can't do partial application on a literal lambda")); + const Func f = partial_match(env, base, call->args, call->func->loc); if(!f) { - const Exp e = expand(env, call->func->type->info->func, call->args, call->func->pos); + const Exp e = expand(env, call->func->type->info->func, call->args, call->func->loc); if(e) { call->args = e; return partial_type(env, call); } - ERR_O(call->func->pos, _("no match found for partial application")); + ERR_O(call->func->loc, _("no match found for partial application")); } nspc_push_value(env->gwion->mp, env->curr); - Func_Base *const fbase = partial_base(env, f->def->base, call->args, call->func->pos); + Func_Base *const fbase = partial_base(env, f->def->base, call->args, call->func->loc); const Stmt_List code = partial_code(env, f->def->base->args, call->func, call->args); const Exp exp = exp_self(call); exp->d.exp_lambda.def = new_func_def(env->gwion->mp, fbase, code); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index b2ac1075..a0f1e20b 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -317,7 +317,7 @@ ANN static Type cdef_parent(const Env env, const Class_Def cdef) { Exp e = cdef->base.ext->array ? cdef->base.ext->array->exp : NULL; while(e) { if(!is_prim_int(e)) - ERR_O(e->pos, "non null array type extension must be literal"); + ERR_O(e->loc, "non null array type extension must be literal"); e = e->next; } if (tmpl_base(cdef->base.tmpl)) return get_parent_base(env, cdef->base.ext); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a851ab11..f49df21e 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -75,9 +75,9 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl *decl) { return NULL; if (decl->var.td->tag.sym == insert_symbol("auto") && decl->type) return decl->type; if (GET_FLAG(t, private) && t->info->value->from->owner != env->curr) - ERR_O(exp_self(decl)->pos, _("can't use private type %s"), t->name) + ERR_O(exp_self(decl)->loc, _("can't use private type %s"), t->name) if (GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0)) - ERR_O(exp_self(decl)->pos, _("can't use protected type %s"), t->name) + ERR_O(exp_self(decl)->loc, _("can't use protected type %s"), t->name) return t; } @@ -99,7 +99,7 @@ ANN m_bool abstract_array(const Env env, const Array_Sub array) { Exp e = array->exp; while(e) { if(!exp_is_zero(e)) - ERR_B(e->pos, _("arrays of abstract type should use `0` size")); + ERR_B(e->loc, _("arrays of abstract type should use `0` size")); e = e->next; } return GW_OK; @@ -116,7 +116,7 @@ ANN static m_bool scan1_decl(const Env env, Exp_Decl *const decl) { if (!GET_FLAG(decl->var.td, late) && !decl->var.td->array->exp) ERR_B(decl->var.td->tag.loc, _("arrays with no expressions should be declared `late`")); if (GET_FLAG(decl->var.td, late) && decl->var.td->array->exp) - ERR_B(decl->var.td->array->exp->pos, _("late array should have no size")); + ERR_B(decl->var.td->array->exp->loc, _("late array should have no size")); if (!decl->args && GET_FLAG(base, abstract)) CHECK_BB(abstract_array(env, decl->var.td->array)); } const Value v = vd->value = @@ -152,7 +152,7 @@ ANN static m_bool scan1_decl(const Env env, Exp_Decl *const decl) { } ANN m_bool scan1_exp_decl(const Env env, Exp_Decl *const decl) { - CHECK_BB(env_storage(env, decl->var.td->flag, exp_self(decl)->pos)); + CHECK_BB(env_storage(env, decl->var.td->flag, exp_self(decl)->loc)); ((Exp_Decl *)decl)->type = scan1_exp_decl_type(env, (Exp_Decl *)decl); CHECK_OB(decl->type); if(decl->args) CHECK_BB(scan1_exp(env, decl->args)); @@ -160,7 +160,7 @@ ANN m_bool scan1_exp_decl(const Env env, Exp_Decl *const decl) { if (global) { if (env->context) env->context->global = true; if (!type_global(env, decl->type)) - ERR_B(exp_self(decl)->pos, _("type '%s' is not global"), decl->type->name) + ERR_B(exp_self(decl)->loc, _("type '%s' is not global"), decl->type->name) } const m_uint scope = !global ? env->scope->depth : env_push_global(env); const m_bool ret = scan1_decl(env, decl); @@ -216,7 +216,7 @@ ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix *post) { CHECK_BB(scan1_exp(env, post->exp)); const m_str access = exp_access(post->exp); if (!access) return GW_OK; - ERR_B(post->exp->pos, + ERR_B(post->exp->loc, _("post operator '%s' cannot be used" " on %s data-type..."), s_name(post->op), access); @@ -850,7 +850,7 @@ ANN static m_bool scan1_class_tmpl(const Env env, const Class_Def c) { break; } /* - const Value v = new_value(env, env->gwion->type[et_int], s_name(spec.xid), targ.d.exp->pos); + const Value v = new_value(env, env->gwion->type[et_int], s_name(spec.xid), targ.d.exp->loc); valuefrom(env, v->from); valid_value(env, spec.xid, v); SET_FLAG(v, const| ae_flag_static);