-Subproject commit 7d64efec6200c89dd2e02dd5ee70ceacb1cea8a2
+Subproject commit 0e66073509c6e408d69c2930c9f6ddae9fd2e892
ANN static inline m_uint env_push_global(const Env env) { return env_push(env, NULL, env->global_nspc); }
ANN void env_pop(const Env, const m_uint);
ANN Type scan_type(const Env, const Type, Type_Decl*);
-ANN Value mk_class(const Env env, const Type base);
+ANN Value mk_class(const Env env, const Type base, const loc_t);
ANN m_bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def);
ANN Type known_type(const Env env, Type_Decl*);
ANN Type prim_ref(const Env env, const Type t, const Type_Decl* td);
ANN m_bool env_access(const Env env, const ae_flag flag, const loc_t pos);
ANN m_bool env_storage(const Env env, ae_flag flag, const loc_t pos);
-ANN void env_add_type(const Env, const Type);
+ANN void env_add_type(const Env, const Type, const loc_t);
ANN Type find_type(const Env, Type_Decl*);
ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
ANN m_bool traverse_func_template(const Env, const Func_Def);
Type owner_class;
struct Context_ *ctx;
size_t offset;
+ m_str filename;
+ loc_t loc;
};
enum vflag {
FLAG_FUNC(Value, v)
ANEW ANN Value new_value(MemPool p, const Type type, const m_str name);
-ANN void valuefrom(const Env, struct ValueFrom_*);
+ANN void valuefrom(const Env, struct ValueFrom_*, const loc_t loc);
#endif
const Symbol sym = insert_symbol("==");
struct Exp_ exp = {};
struct Op_Import opi = { .op=sym, .lhs=arg->type, .rhs=arg->type,
- .pos=me->fdef->pos, .data=(uintptr_t)&exp.d };
+ .pos=me->fdef->base->pos, .data=(uintptr_t)&exp.d };
CHECK_BB(op_emit(emit, &opi))
const Instr instr = emit_add_instr(emit, BranchEqInt);
vector_add(&me->branch, (vtype)instr);
env->scope->depth = scope;
}
-ANN void env_add_type(const Env env, const Type type) {
+ANN void env_add_type(const Env env, const Type type, const loc_t loc) {
type->info->owner = env->curr;
type->info->owner_class = env->class_def; // t owner_class ?
const Symbol sym = insert_symbol(type->name);
nspc_add_type_front(env->curr, sym, type);
- const Value v = mk_class(env, type);
+ const Value v = mk_class(env, type, loc);
SET_FLAG(v, global);
set_vflag(v, vflag_builtin);
set_tflag(type, tflag_scan0 | tflag_scan1 | tflag_scan2 | tflag_check | tflag_emit);
return t;
}
-ANN Value mk_class(const Env env, const Type base) {
+ANN Value mk_class(const Env env, const Type base, const loc_t loc) {
const Type t = class_type(env, base);
const Symbol sym = insert_symbol(base->name);
const Value v = new_value(env->gwion->mp, t, s_name(sym));
- valuefrom(env, v->from);
+ valuefrom(env, v->from, loc);
SET_FLAG(v, const);
set_vflag(v, vflag_valid);
nspc_add_value_front(base->info->owner, sym, v);
return a;
}
-ANN void valuefrom(const Env env, struct ValueFrom_ *from) {
+ANN void valuefrom(const Env env, struct ValueFrom_ *from, const loc_t loc) {
from->owner = env->curr;
from->owner_class = env->class_def;
from->ctx = env->context;
+ from->filename = env->name;
+ from->loc = loc;
}
if(env->class_def)
gwerr_secondary("in class:", env->name, env->class_def->info->cdef->pos);
if(env->func && env->func != (Func)1 && env->func->def)
- gwerr_secondary("in function:", env->name, env->func->def->pos);
+ gwerr_secondary("in function:", env->name, env->func->def->base->pos);
}
ANN static void env_xxx(const Env env, const loc_t pos, const m_str fmt, va_list arg) {
ANEW ANN static Func_Base* gwi_func_base(const Gwi gwi, ImportCK *ck) {
const Arg_List arg_list = make_dll_arg_list(&gwi->ck->v);
- Func_Base *base = new_func_base(gwi->gwion->mp, ck->td, ck->sym, arg_list, ck->flag);
+ Func_Base *base = new_func_base(gwi->gwion->mp, ck->td, ck->sym, arg_list, ck->flag, gwi->loc);
if(ck->variadic)
base->fbflag |= fbflag_variadic;
ck->td = NULL;
ANEW ANN static Func_Def import_fdef(const Gwi gwi, ImportCK *ck) {
Func_Base* base = gwi_func_base(gwi, ck);
- const Func_Def fdef = new_func_def(gwi->gwion->mp, base, NULL, gwi->loc);
+ const Func_Def fdef = new_func_def(gwi->gwion->mp, base, NULL);
return fdef;
}
}
ANN void gwi_add_type(const Gwi gwi, const Type type) {
- return env_add_type(gwi->gwion->env, type);
+ return env_add_type(gwi->gwion->env, type, gwi->loc);
}
ANN void gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te) {
if(isa(info->exp->type, env->gwion->type[et_lambda]) < 0) {
CHECK_BB(fptr_check(env, info))
if(!(info->exp->type = fptr_type(env, info)))
- ERR_B(info->lhs->def->pos, _("no match found"))
+ ERR_B(info->lhs->def->base->pos, _("no match found"))
return GW_OK;
}
Exp_Lambda *l = &info->exp->d.exp_lambda;
Exp template_arg = exp->args;
while(arg && template_arg) {
if(list->xid == arg->td->xid) {
- tl[args_number] = mk_type_list(env, template_arg->type, fdef->pos);
+ tl[args_number] = mk_type_list(env, template_arg->type, fdef->base->pos);
if(args_number)
tl[args_number - 1]->next = tl[args_number];
++args_number;
free_mstr(env->gwion->mp, str);
if(tflag(t, tflag_typedef)) {
gwerr_secondary("from definition:",
- env->name, t->info->func->def->pos);
+ env->name, t->info->func->def->base->pos);
}
return GW_ERROR;
}
if(tdef->when) {
const Var_Decl decl = new_var_decl(env->gwion->mp, insert_symbol("self"), NULL, tdef->when->pos);
const Arg_List args = new_arg_list(env->gwion->mp, cpy_type_decl(env->gwion->mp, tdef->ext), decl, NULL);
- Func_Base *fb = new_func_base(env->gwion->mp, type2td(env->gwion, tdef->type, tdef->when->pos),
- insert_symbol("@implicit"), args, ae_flag_none);
+ Func_Base *fb = new_func_base(env->gwion->mp, type2td(env->gwion, tdef->type, tdef->pos),
+ insert_symbol("@implicit"), args, ae_flag_none, tdef->pos);
set_fbflag(fb, fbflag_op);
const Exp helper = new_prim_id(env->gwion->mp, insert_symbol("@predicate"), tdef->when->pos);
tdef->when->next = helper;
const Stmt stmt = new_stmt_exp(env->gwion->mp, ae_stmt_exp, cpy_exp(env->gwion->mp, tdef->when), tdef->when->pos);// copy exp
const Stmt_List body = new_stmt_list(env->gwion->mp, stmt, NULL);//ret_list);
const Stmt code = new_stmt_code(env->gwion->mp, body, tdef->when->pos);
- const Func_Def fdef = new_func_def(env->gwion->mp, fb, code, tdef->when->pos);
+ const Func_Def fdef = new_func_def(env->gwion->mp, fb, code);
CHECK_BB(traverse_func_def(env, fdef))
const Exp predicate = stmt->d.stmt_exp.val;
if(isa(predicate->type, env->gwion->type[et_bool]) < 0) {
if(env->class_def && env->class_def->info->parent) {
const Value override = find_value(env->class_def->info->parent, fdef->base->xid);
if(override && override->from->owner_class && isa(override->type, env->gwion->type[et_function]) < 0)
- ERR_B(fdef->pos,
+ ERR_B(fdef->base->pos,
_("function name '%s' conflicts with previously defined value...\n"
" from super class '%s'..."),
s_name(fdef->base->xid), override->from->owner_class->name)
while(scope_iter(&iter, &value) > 0) {
if(vector_find(v, (vtype)value->name) > 0 &&!strcmp(name, value->name))
continue;
- if(wagner_fisher(name, value->name))
- vector_add(v, (vtype)value->name);
+ if(wagner_fisher(name, value->name)) {
+ if(!vflag(value, vflag_builtin))
+ gwerr_secondary("declared here", value->from->filename, value->from->loc);
+ }
}
}
vector_init(&v);
do ressembles(&v, nspc, name);
while((nspc = nspc->parent));
- for(m_uint i = 0; i < vector_size(&v); ++i)
- gw_err(DYM_FMT, (m_str)vector_at(&v, i));
- vector_release(&v);
}
#undef did_you_mean_type
vector_init(&v);
do ressembles(&v, t->nspc, name);
while((t = t->info->parent) && t->nspc);
- for(m_uint i = 0; i < vector_size(&v); ++i)
- gw_err(DYM_FMT, (m_str)vector_at(&v, i));
- vector_release(&v);
}
static void fptr_def(const Env env, const Fptr_Def fptr) {
const Func_Def def = new_func_def(env->gwion->mp,
cpy_func_base(env->gwion->mp, fptr->base),
- NULL, fptr->base->td->pos);
+ NULL);
fptr->base->func = new_func(env->gwion->mp, s_name(fptr->base->xid), def);
fptr->value->d.func_ref = fptr->base->func;
fptr->base->func->value_ref = fptr->value;
t->nspc = new_nspc(env->gwion->mp, name);
t->flag |= fptr->base->flag;
fptr->type = t;
- fptr->value = mk_class(env, t);
- valuefrom(env, fptr->value->from);
+ fptr->value = mk_class(env, t, fptr->base->pos);
+ valuefrom(env, fptr->value->from, fptr->base->pos);
fptr_def(env, fptr);
if(env->class_def)
fptr_assign(env, fptr);
set_vflag(fptr->value, vflag_func);
add_type(env, t->info->owner, t);
- mk_class(env, t);
+ mk_class(env, t, fptr->base->pos);
type_addref(t);
return GW_OK;
}
tdef->type->name = s_name(tdef->xid);
tdef->type->info->parent = base;
add_type(env, env->curr, tdef->type);
- mk_class(env, tdef->type);
+ mk_class(env, tdef->type, tdef->pos);
if(base->info->func->def->base->tmpl)
set_tflag(tdef->type, tflag_ftmpl);
}
t->info->owner = nspc;
t->info->owner_class = env->class_def;
add_type(env, nspc, t);
- mk_class(env, t);
+ mk_class(env, t, edef->pos);
// scan0_implicit_similar(env, t, env->gwion->type[et_int]);
return t;
}
return GW_OK;
}
-ANN static Type union_type(const Env env, const Symbol s) {
+ANN static Type union_type(const Env env, const Symbol s, const loc_t loc) {
const m_str name = s_name(s);
const Type t = new_type(env->gwion->mp, name, env->gwion->type[et_union]);
t->nspc = new_nspc(env->gwion->mp, name);
t->info->owner_class = env->class_def;
t->info->tuple = new_tupleform(env->gwion->mp, NULL); // ???
add_type(env, env->curr, t);
- mk_class(env, t);
+ mk_class(env, t, loc);
SET_FLAG(t, final);
if(strncmp(t->name, "Option", 6))
SET_FLAG(t, abstract);
if(GET_FLAG(udef, global))
context_global(env);
CHECK_BB(scan0_defined(env, udef->xid, udef->pos))
- udef->type = union_type(env, udef->xid);
+ udef->type = union_type(env, udef->xid, udef->pos);
Union_List l = udef->l;
do udef->type->nspc->info->offset += SZ_INT;
while((l = l->next));
set_tflag(cdef->base.type, tflag_scan0);
if(cdef->body)
CHECK_BB(env_body(env, cdef, scan0_section))
- (void)mk_class(env, cdef->base.type);
+ (void)mk_class(env, cdef->base.type, cdef->pos);
return GW_OK;
}
SET_FLAG(v, late);
v->flag |= decl->td->flag;
if(!env->scope->depth) {
- valuefrom(env, v->from);
+ valuefrom(env, v->from, var->pos);
if(env->class_def) {
if(env->class_def->info->tuple)
tuple_contains(env, v);
do {
CHECK_BB(already_defined(env, list->xid, edef->pos))
const Value v = new_value(env->gwion->mp, edef->t, s_name(list->xid));
- valuefrom(env, v->from);
+ valuefrom(env, v->from, edef->pos);
if(env->class_def) {
SET_FLAG(v, static);
SET_ACCESS(edef, v)
m_uint sz = 0;
const Value v = new_value(env->gwion->mp, env->gwion->type[et_int], "@index");
nspc_add_value_front(env->curr, insert_symbol("@index"), v);
- valuefrom(env ,v->from);
+ valuefrom(env, v->from, udef->pos);
do {
DECL_OB(const Type, t, = known_type(env, l->td))
if(nspc_lookup_value0(env->curr, l->xid))
if(!tflag(t, tflag_scan1)) // ???
tuple_contains(env, v); // ???
v->from->offset = SZ_INT;
- valuefrom(env ,v->from);
+ valuefrom(env ,v->from, udef->pos);
nspc_add_value_front(env->curr, l->xid, v);
if(t->size > sz)
sz = t->size;
if(isa(actual_type(env->gwion, v->type), env->gwion->type[et_function]) > 0)
return GW_OK;
if((!env->class_def || !GET_FLAG(env->class_def, final)) && !nspc_lookup_value0(env->curr, fdef->base->xid))
- ERR_B(fdef->pos, _("function '%s' has already been defined in the same scope..."),
+ ERR_B(fdef->base->pos, _("function '%s' has already been defined in the same scope..."),
s_name(fdef->base->xid))
return GW_OK;
}
ANN static Value scan2_func_assign(const Env env, const Func_Def d,
const Func f, const Value v) {
- valuefrom(env, v->from);
+ valuefrom(env, v->from, d->base->pos);
SET_FLAG(v, const);
set_vflag(v, vflag_func);
if(!env->class_def) {
const m_bool fptr = is_fptr(env->gwion, overload->type);
if(isa(overload->type, env->gwion->type[et_function]) < 0 || is_fptr(env->gwion, overload->type)) {
if(!fbflag(f->base, fbflag_internal))
- ERR_B(f->pos, _("function name '%s' is already used by another value"), overload->name)
+ ERR_B(f->base->pos, _("function name '%s' is already used by another value"), overload->name)
}
const Func obase = !fptr ? overload->d.func_ref : _class_base(overload->type)->info->func;
if(GET_FLAG(obase->def->base, final))
- ERR_B(f->pos, _("can't overload final function %s"), overload->name)
+ ERR_B(f->base->pos, _("can't overload final function %s"), overload->name)
const m_bool base = tmpl_base(f->base->tmpl);
const m_bool tmpl = fflag(obase, fflag_tmpl);
if((!tmpl && base) || (tmpl && !base && !f->base->tmpl))
- ERR_B(f->pos, _("must overload template function with template"))
+ ERR_B(f->base->pos, _("must overload template function with template"))
return GW_OK;
}
const Value overload) {
const Type t = func_type(env, f);
const Value v = new_value(env->gwion->mp, t, t->name);
- valuefrom(env, v->from);
+ valuefrom(env, v->from, f->def->base->pos);
CHECK_OO(scan2_func_assign(env, f->def, f, v))
if(!overload) {
value_addref(v);
}
if(compat_func(ff->def, f) > 0) {
if(ff->value_ref->from->owner == env->curr)
- ERR_B(f->pos, "template function '%s' already defined with those arguments in this namespace", name)
+ ERR_B(f->base->pos, "template function '%s' already defined with those arguments in this namespace", name)
const Symbol sym = func_symbol(env, env->curr->name, name,
"template", ff->vt_index);
nspc_add_value(env->curr, sym, value);
ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) {
const m_str str = s_name(f->base->xid);
struct Op_Func opfunc = { .ck=strcmp(str, "@implicit") ? 0 : opck_usr_implicit };
- struct Op_Import opi = { .ret=f->base->ret_type, .pos=f->pos,
+ struct Op_Import opi = { .ret=f->base->ret_type, .pos=f->base->pos,
.data=(uintptr_t)f->base->func, .func=&opfunc };
func_operator(f, &opi);
CHECK_BB(add_op(env->gwion, &opi))
Plug plug = new_plug(h->mp, dl);
map_set(h->map, (vtype)strdup(name), (vtype)plug);
} else
- gw_err(_("error in %s."), DLERROR());
+ gw_err(_("{+R}error{0} in {/+}%s{0}."), DLERROR());
}
ANN static void plug_get_all(struct PlugHandle *h, const m_str name) {
+++ /dev/null
-#! [contains] in function:
-class C {
- fun void test() {
- <<< b >>>;
- }
-}