From: Jérémie Astor Date: Wed, 22 Jul 2020 18:07:55 +0000 (+0200) Subject: :fire: Move inherit X-Git-Tag: nightly~1430 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=71c4064f6c82def3543ac64a12accbf9bedef6e9;p=gwion.git :fire: Move inherit --- diff --git a/include/env/type.h b/include/env/type.h index bffe5aa4..44cc592a 100644 --- a/include/env/type.h +++ b/include/env/type.h @@ -44,6 +44,7 @@ ANN static inline m_uint env_push_type(const Env env, const Type type) { return ANN m_bool is_fptr(const struct Gwion_*, const Type t); ANN m_bool is_class(const struct Gwion_*, const Type t); ANN m_uint get_depth(const Type type); +ANN void inherit(const Type); __attribute__((returns_nonnull)) ANN static inline Type get_gack(Type t) { diff --git a/src/env/type.c b/src/env/type.c index 6cefe46f..d67dea02 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -198,3 +198,12 @@ ANN inline m_bool is_class(const struct Gwion_* gwion, const Type t) { ANN Type actual_type(const struct Gwion_* gwion, const Type t) { return is_class(gwion, t) ? t->e->d.base_type : t; } + +ANN void inherit(const Type t) { + const Nspc nspc = t->nspc, parent = t->e->parent->nspc; + if(!nspc || !parent) + return; + nspc->info->offset = parent->info->offset; + if(parent->info->vtable.ptr) + vector_copy2(&parent->info->vtable, &nspc->info->vtable); +} diff --git a/src/import/cdef.c b/src/import/cdef.c index 814ffa5b..32b62f49 100644 --- a/src/import/cdef.c +++ b/src/import/cdef.c @@ -35,15 +35,6 @@ ANN2(1,2) static inline m_bool class_parent(const Env env, Type t) { return GW_OK; } -ANN void inherit(const Type t) { - const Nspc nspc = t->nspc, parent = t->e->parent->nspc; - if(!nspc || !parent) - return; - nspc->info->offset = parent->info->offset; - if(parent->info->vtable.ptr) - vector_copy2(&parent->info->vtable, &nspc->info->vtable); -} - ANN2(1,2) static void import_class_ini(const Env env, const Type t) { t->nspc = new_nspc(env->gwion->mp, t->name); t->nspc->parent = env->curr;