From 82483fd5dce3acbbf36c651012ba34b1c091f14a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 15 Dec 2020 02:38:49 +0100 Subject: [PATCH] :art: Cleaning (notably owned symbol) --- ast | 2 +- src/emit/emit.c | 11 ----------- src/lib/object_op.c | 30 ------------------------------ src/parse/check.c | 14 +++++++------- 4 files changed, 8 insertions(+), 49 deletions(-) diff --git a/ast b/ast index f8589bde..810bd99f 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit f8589bde72faa61d9552ca6fbce4a2ba541031f9 +Subproject commit 810bd99f395edf47635393d771eefd73a34f00e1 diff --git a/src/emit/emit.c b/src/emit/emit.c index 4fc0a294..e5816909 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -372,15 +372,6 @@ ANN2(1,2) m_bool emit_instantiate_decl(const Emitter emit, const Type type, return ret; } -ANN Exp symbol_owned_exp(const Gwion gwion, const Symbol *data); -ANN static m_bool emit_symbol_owned(const Emitter emit, const Symbol *data) { - const Exp dot = symbol_owned_exp(emit->gwion, data); - dot->info->nspc = prim_exp(data)->info->nspc; - const m_bool ret = emit_exp_dot(emit, &dot->d.exp_dot); - free_exp(emit->gwion->mp, dot); - return ret; -} - ANN static m_bool emit_symbol_builtin(const Emitter emit, const Symbol *data) { const Value v = prim_self(data)->value; if(vflag(v, vflag_direct)) { @@ -410,8 +401,6 @@ ANN static m_bool _emit_symbol(const Emitter emit, const Symbol *data) { regpushi(emit, (m_uint)actual_type(emit->gwion, v->type)); return GW_OK; } - if(v->from->owner_class) - return emit_symbol_owned(emit, data); if(vflag(v, vflag_builtin) || vflag(v, vflag_direct) || vflag(v, vflag_enum)) return emit_symbol_builtin(emit, data); if(!strncmp(v->type->name, "@Foreach:[", 10)) { diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 3ee96890..eadb944f 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -263,43 +263,13 @@ puts("here"); return exists != env->gwion->type[et_error] ? exists : NULL; struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)scan0_cdef, .scope=env->scope->depth, .flag=tflag_scan0 }; -// CHECK_BO(envset_push(&es, t->info->owner_class, t->info->ctx ? t->info->ctx->nspc : env->curr)) -//const Nspc former = env->curr; -//if(env->class_def) -//const Type cdef = env->class_def; CHECK_BO(envset_push(&es, t->info->owner_class, t->info->ctx ? t->info->ctx->nspc : env->curr)) -// CHECK_BO(envset_push(&es, t->info->owner_class, t->info->owner)) -/*{ -nspc_push_type(env->gwion->mp, env->curr); - Type_List tl = td->types; - do { - nspc_add_type(env->curr, tl->td->xid, nspc_lookup_type0(former, tl->td->xid)); - } while((tl = tl->next)); -}*/ const Type ret = _scan_class(env, &info); -//nspc_pop_type(env->gwion->mp, env->curr); if(es.run) envset_pop(&es, t->info->owner_class); return ret; } -ANN static inline Symbol dot_symbol(SymTable *st, const Value v) { - const m_str name = !GET_FLAG(v, static) ? "this" : v->from->owner_class->name; - return insert_symbol(st, name); -} - -ANN Exp symbol_owned_exp(const Gwion gwion, const Symbol *data) { - const Value v = prim_self(data)->value; - const Exp base = new_prim_id(gwion->mp, dot_symbol(gwion->st, v), loc_cpy(gwion->mp, prim_pos(data))); - const Exp dot = new_exp_dot(gwion->mp, base, *data, loc_cpy(gwion->mp, prim_pos(data))); - const Type owner = v->from->owner_class; - dot->d.exp_dot.t_base = dot->d.exp_dot.base->info->type = !GET_FLAG(v, static) ? - owner : type_class(gwion, owner); - dot->info->type = prim_exp(data)->info->type; - exp_setvar(dot, exp_getvar(prim_exp(data))); - return dot; -} - ANN void struct_release(const VM_Shred shred, const Type base, const m_bit *ptr) { const Vector types = &base->info->tuple->types; const Vector offsets = &base->info->tuple->offset; diff --git a/src/parse/check.c b/src/parse/check.c index 9ffa89f5..08b0c8c3 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -284,8 +284,6 @@ ANN static Value check_non_res_value(const Env env, const Symbol *data) { return value; } -ANN Exp symbol_owned_exp(const Gwion gwion, const Symbol *data); - ANN static Type check_dot(const Env env, const Exp_Dot *member) { struct Op_Import opi = { .op=insert_symbol("@dot"), .lhs=member->t_base, .data=(uintptr_t)member, .pos=exp_self(member)->pos, .op_type=op_dot }; @@ -333,11 +331,13 @@ ANN static Type prim_id_non_res(const Env env, const Symbol *data) { if(GET_FLAG(v, const)) exp_setmeta(prim_exp(data), 1); if(v->from->owner_class) { - const Exp exp = symbol_owned_exp(env->gwion, data); - const Type ret = check_dot(env, &exp->d.exp_dot); - prim_exp(data)->info->nspc = exp->info->nspc; - free_exp(env->gwion->mp, exp); - CHECK_OO(ret); + const Exp exp = exp_self(prim_exp(data)); + const m_str name = !GET_FLAG(v, static) ? "this" : v->from->owner_class->name; + const Exp base = new_prim_id(env->gwion->mp, insert_symbol(name), loc_cpy(env->gwion->mp, prim_pos(data))); + exp->exp_type = ae_exp_dot; + exp->d.exp_dot.base = base; + exp->d.exp_dot.xid = sym; + return check_exp(env, exp); } return v->type; } -- 2.43.0