From 71c4064f6c82def3543ac64a12accbf9bedef6e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 22 Jul 2020 20:07:55 +0200 Subject: [PATCH] :fire: Move inherit --- include/env/type.h | 1 + src/env/type.c | 9 +++++++++ src/import/cdef.c | 9 --------- 3 files changed, 10 insertions(+), 9 deletions(-) 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; -- 2.43.0