ANN Map env_label(const Env);
ANN Type scan_type(const Env, const Type, Type_Decl*);
ANN Value mk_class(const Env env, const Type base);
-
-// those functions return a mp_alloced string
-ANEW ANN m_str tl2str(const Env, const Type_List); // in type_decl.c
-ANEW ANN m_str type2str(const Env env, const Type 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 void func_checker_clean(const Gwi gwi, struct ImportCK *ck);
ANN m_bool check_typename_def(const Gwi gwi, struct ImportCK *ck);
-ANN Symbol str2sym(const Gwion gwi, const m_str path, const loc_t pos);
-ANN ID_List str2symlist(const Gwion gwi, const m_str path, const loc_t);
+ANN Symbol str2sym(const Gwion, const m_str, const loc_t);
+ANN ID_List str2symlist(const Gwion, const m_str, const loc_t);
ANN Var_Decl str2var(const Gwion, const m_str, const loc_t);
ANN Var_Decl_List str2varlist(const Gwion, const m_str, const loc_t);
ANN Type_Decl* str2td(const Gwion, const m_str, const loc_t);
ANN Type str2type(const Gwion, const m_str, const loc_t);
+
+// those functions return a mp_alloced string
+ANEW ANN m_str tl2str(const Gwion, const Type_List, const loc_t);
+ANEW ANN m_str type2str(const Gwion, const Type, const loc_t);
+
ANN static inline Type_Decl* type2td(const Gwion gwion, const Type t, const loc_t pos) {
- const m_str str = type2str(gwion->env, t);
+ const m_str str = type2str(gwion, t, pos);
Type_Decl *td = str2td(gwion, str, pos);
free_mstr(gwion->mp, str);
return td;
return t;
}
+struct td_info {
+ Type_List tl;
+ GwText text;
+};
+
+ANN static void td_fullname(const Env env, GwText *text, const Type t) {
+ const Type owner = t->info->owner_class;
+ if(owner) {
+ td_fullname(env, text, owner);
+ text_add(text, ".");
+ }
+ text_add(text, t->name);
+}
+
+ANN static m_bool td_info_run(const Env env, struct td_info* info) {
+ Type_List tl = info->tl;
+ do {
+ DECL_OB(const Type, t, = known_type(env, tl->td))
+ td_fullname(env, &info->text, t);
+ if(tl->next)
+ text_add(&info->text, ",");
+ } while((tl = tl->next));
+ return GW_OK;
+}
+
+ANEW ANN m_str type2str(const Gwion gwion, const Type t, const loc_t pos NUSED) {
+ GwText text = { .mp=gwion->mp };
+ if(t->info->owner_class)
+ td_fullname(gwion->env, &text, t->info->owner_class);
+ text_add(&text, t->name);
+ return text.str;
+}
+
+ANEW ANN m_str tl2str(const Gwion gwion, const Type_List tl, const loc_t pos NUSED) {
+ struct td_info info = { .tl=tl, { .mp=gwion->mp} };
+ CHECK_BO(td_info_run(gwion->env, &info))
+ return info.text.str;
+}
+
ANN static inline m_bool ac_finish(const Gwion gwion, const struct AC *ac) {
if(*ac->str == ']')
return GW_OK;
const m_str name = f->name;
const Emitter emit = shred->info->vm->gwion->emit;
emit->env->name = "runtime";
- m_str tmpl_name = tl2str(emit->env, dt->tl);
+ struct loc_t_ pos = {};
+ m_str tmpl_name = tl2str(emit->gwion, dt->tl, &pos);
for(m_uint i = 0 ; i <= f->value_ref->from->offset; ++i) {
const Symbol sym = func_symbol(emit->env, f->value_ref->from->owner->name,
name, tmpl_name, i);
#include "operator.h"
#include "traverse.h"
#include "parse.h"
+#include "object.h"
+#include "instr.h"
+#include "import.h"
#include "tmpl_info.h"
ANN static inline m_str tmpl_get(struct tmpl_info* info, m_str str) {
}
ANN static ssize_t template_size(const Env env, struct tmpl_info* info) {
- DECL_OB(const m_str, str, = tl2str(env, info->td->types))
+ DECL_OB(const m_str, str, = tl2str(env->gwion, info->td->types, info->td->pos))
const size_t tmpl_sz = tmpl_set(info, str);
- const m_str base = type2str(env, info->base);
+ const m_str base = type2str(env->gwion, info->base, info->td->pos);
return tmpl_sz + tmpl_set(info, base) + 4;
}
}
ANN static m_bool predefined_call(const Env env, const Type t, const loc_t pos) {
- const m_str str = tl2str(env, t->info->func->def->base->tmpl->call);
+ const m_str str = tl2str(env->gwion, t->info->func->def->base->tmpl->call, pos);
env_err(env, pos, _("Type '%s' has '%s' as pre-defined types."),
t->name, str);
free_mstr(env->gwion->mp, str);
}
ANN static Func _find_template_match(const Env env, const Value v, const Exp_Call* exp) {
- DECL_OO(const m_str, tmpl_name, = tl2str(env, exp->tmpl->call))
+ DECL_OO(const m_str, tmpl_name, = tl2str(env->gwion, exp->tmpl->call, exp->func->pos))
const Func f = find_tmpl(env, v, exp, tmpl_name);
free_mstr(env->gwion->mp, tmpl_name);
return f;
#include "parse.h"
#include "gwion.h"
#include "operator.h"
+#include "instr.h"
+#include "object.h"
+#include "import.h"
ANN static m_bool push_types(const Env env, const Tmpl *tmpl) {
ID_List list = tmpl->list;
}
static ANN Type scan_func(const Env env, const Type t, const Type_Decl* td) {
- DECL_OO(const m_str, tl_name, = tl2str(env, td->types))
+ DECL_OO(const m_str, tl_name, = tl2str(env->gwion, td->types, td->pos))
const Symbol sym = func_symbol(env, t->info->owner->name, t->info->func->name, tl_name, 0);
free_mstr(env->gwion->mp, tl_name);
const Type base_type = nspc_lookup_type1(t->info->owner, sym);
return !td->array ? ret : array_type(env, ret, td->array->depth);
}
-struct td_info {
- Type_List tl;
- GwText text;
-};
-
-ANN static void td_fullname(const Env env, GwText *text, const Type t) {
- const Type owner = t->info->owner_class;
- if(owner) {
- td_fullname(env, text, owner);
- text_add(text, ".");
- }
- text_add(text, t->name);
-}
-
-ANN static m_bool td_info_run(const Env env, struct td_info* info) {
- Type_List tl = info->tl;
- do {
- DECL_OB(const Type, t, = known_type(env, tl->td))
- td_fullname(env, &info->text, t);
- if(tl->next)
- text_add(&info->text, ",");
- } while((tl = tl->next));
- return GW_OK;
-}
-
-ANEW ANN m_str type2str(const Env env, const Type t) {
- GwText text = { .mp=env->gwion->mp };
- if(t->info->owner_class)
- td_fullname(env, &text, t->info->owner_class);
- text_add(&text, t->name);
- return text.str;
-}
-
-ANEW ANN m_str tl2str(const Env env, Type_List tl) {
- struct td_info info = { .tl=tl, { .mp=env->gwion->mp} };
- CHECK_BO(td_info_run(env, &info))
- return info.text.str;
-}
-
ANN static inline void* type_unknown(const Env env, const Type_Decl* td) {
env_err(env, td->pos, _("unknown type '%s'"), s_name(td->xid));
return NULL;