From: Jérémie Astor Date: Fri, 29 Apr 2022 14:42:49 +0000 (+0200) Subject: fix c++ linkage X-Git-Tag: nightly~275^2~17 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=44b8fb8fc992fe0807e628624ec3ed49d73b0457;p=gwion.git fix c++ linkage --- diff --git a/ast b/ast index 1b0fc513..c296c9b9 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 1b0fc5136209bc7ab709ad88c803a7819cf704c5 +Subproject commit c296c9b96cd54440f1dbaf7073c92ed62f82f298 diff --git a/include/env/func.h b/include/env/func.h index 9ce27c7a..42230c69 100644 --- a/include/env/func.h +++ b/include/env/func.h @@ -45,6 +45,6 @@ ANN static inline Value upvalues_lookup(const Upvalues *upvalues, const Symbol s ANN static inline m_uint captures_sz(const Capture_List captures) { const Capture *cap = mp_vector_at(captures, Capture, (captures->len - 1)); - return cap->new->from->offset + cap->new->type->size; + return cap->temp->from->offset + cap->temp->type->size; } #endif diff --git a/include/env/nspc.h b/include/env/nspc.h index 6ebe139c..63e1b8b7 100644 --- a/include/env/nspc.h +++ b/include/env/nspc.h @@ -1,13 +1,13 @@ #ifndef __NSPC #define __NSPC -struct NspcInfo_ { +typedef struct NspcInfo_ { struct Map_ op_map; Scope value; Scope type; Scope func; Scope trait; struct Vector_ op_tmpl; -}; +} NspcInfo; struct Nspc_ { struct Vector_ vtable; @@ -16,7 +16,7 @@ struct Nspc_ { struct VM_Code_ * dtor; Nspc parent; m_str name; - struct NspcInfo_ *info; + NspcInfo *info; uint16_t offset; uint16_t ref; uint16_t class_data_size; diff --git a/src/clean.c b/src/clean.c index 2e9e7f12..7475da75 100644 --- a/src/clean.c +++ b/src/clean.c @@ -71,7 +71,7 @@ ANN static void clean_exp_binary(Clean *a, Exp_Binary *b) { ANN static void clean_captures(Clean *a, Capture_List b) { for(uint32_t i = 0; i < b->len; i++) { const Capture *cap = mp_vector_at(b, Capture, i); - if(cap->new) value_remref(cap->new, a->gwion); + if(cap->temp) value_remref(cap->temp, a->gwion); } } diff --git a/src/import/import_checker.c b/src/import/import_checker.c index d8861dcf..8e681269 100644 --- a/src/import/import_checker.c +++ b/src/import/import_checker.c @@ -201,9 +201,19 @@ ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc) { } ANN Type_Decl *str2td(const Gwion gwion, const m_str str, const loc_t pos) { +puts(str); struct td_checker tdc = {.str = str, .pos = pos}; DECL_OO(Type_Decl *, td, = _str2td(gwion, &tdc)); - if (*tdc.str) { +//*(m_uint*)0 = 1; + if(*tdc.str) { + Type_Decl *tmp = td; + while(tmp->next) tmp = tmp->next; + while(!strcmp(tdc.str, "[]")) { + tdc.str += 2; + if(!td->array) td->array = new_array_sub(gwion->mp, NULL); + else td->array->depth++; + return td; + } free_type_decl(gwion->mp, td); GWION_ERR_O(pos, "excedental character '%c' in '%s'", *tdc.str, str); } @@ -248,6 +258,7 @@ ANEW ANN m_str type2str(const Gwion gwion, const Type t, const Type owner = t->info->value->from->owner_class; if (owner) { td_fullname(gwion->env, &text, owner); +printf("%s %s\n", text.str, t->name); text_add(&text, "."); } text_add(&text, t->name); @@ -258,6 +269,7 @@ 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)); +printf("=== %s ===\n", info.text.str); return info.text.str; } diff --git a/src/lib/instr.c b/src/lib/instr.c index f9f546e4..afb2f687 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -39,6 +39,9 @@ ANN static Func_Def from_base(const Env env, struct dottmpl_ *const dt, def->base->tmpl->call = cpy_type_list(env->gwion->mp, dt->tl); def->base->tmpl->base = dt->base->base->tmpl->base; dt->def = def; +printf("%s %p\n", v->from->owner->name, v->from->owner_class); +printf("%p %p\n", v->from->owner->parent, v->from->owner); +printf("%p %p\n", v->from->owner->parent->parent, v->from->owner); dt->owner = v->from->owner; dt->owner_class = v->from->owner_class; return def; diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index 5356b213..344ffbd8 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -669,9 +669,9 @@ static OP_CHECK(opck_spork) { for(uint32_t i = 0; i < unary->captures->len; i++) { Capture *const cap = mp_vector_at(unary->captures, Capture, i); DECL_OO(const Type, t, = upvalue_type(env, cap)); - cap->new = new_value(env, t, s_name(cap->xid), cap->pos); - cap->new->from->offset = offset; - offset += cap->new->type->size; + cap->temp = new_value(env, t, s_name(cap->xid), cap->pos); + cap->temp->from->offset = offset; + offset += cap->temp->type->size; } } Upvalues upvalues = { .values = env->curr->info->value }; @@ -681,7 +681,7 @@ static OP_CHECK(opck_spork) { if(unary->captures) { for(uint32_t i = 0; i < unary->captures->len; i++) { Capture *const cap = mp_vector_at(unary->captures, Capture, i); - valid_value(env, cap->xid, cap->new); + valid_value(env, cap->xid, cap->temp); } } const Func f = env->func; diff --git a/src/lib/tmpl_info.c b/src/lib/tmpl_info.c index 65705889..efe18be3 100644 --- a/src/lib/tmpl_info.c +++ b/src/lib/tmpl_info.c @@ -44,8 +44,11 @@ ANN static inline size_t tmpl_set(struct tmpl_info *info, const m_str str) { ANN static ssize_t template_size(const Env env, struct tmpl_info *info) { DECL_OB(const m_str, str, = tl2str(env->gwion, info->td->types, info->td->pos)); +printf("ùù %s ùù\n", str); const size_t tmpl_sz = tmpl_set(info, str); +puts("jeje"); const m_str base = type2str(env->gwion, info->base, info->td->pos); +printf("mm %s mm\n", str); return tmpl_sz + tmpl_set(info, base) + 4; // return tmpl_sz + tmpl_set(info, info->base->name) + 4; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index b6c232c8..2777ce0d 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -41,6 +41,7 @@ ANN static m_bool check_global(const Env env, const Type t, const loc_t pos) { if(!GET_FLAG(t, global) && !from_global_nspc(env, from->owner)) { if(from->owner_class && type_global(env, from->owner_class)) return true; +puts(t->name); gwerr_basic("can't use non-global type in a global class", NULL, NULL, env->name, pos, 0); gwerr_secondary("not declared global", from->filename, from->loc); const struct ValueFrom_ *ownerFrom = env->class_def->info->value->from; diff --git a/src/parse/template.c b/src/parse/template.c index 4052bec8..88403d47 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -69,6 +69,7 @@ ANN Tmpl *mk_tmpl(const Env env, const Tmpl *tm, const Type_List types) { static ANN Type scan_func(const Env env, const Type t, const Type_Decl *td) { DECL_OO(const m_str, tl_name, = tl2str(env->gwion, td->types, td->pos)); +printf("||| %s ||| \n", tl_name); const Symbol sym = func_symbol(env, t->info->value->from->owner->name, t->info->func->name, tl_name, 0); free_mstr(env->gwion->mp, tl_name);