From: fennecdjay Date: Thu, 8 Dec 2022 13:32:54 +0000 (+0100) Subject: :art: update 'super' functions X-Git-Tag: nightly~207^2~56 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=34070956bbd2a642f8e023911c22dc2b2a26483a;p=gwion.git :art: update 'super' functions --- diff --git a/src/lib/object.c b/src/lib/object.c index 1193ed06..0570dd83 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -123,9 +123,6 @@ static ID_CHECK(opck_super) { const Exp self = exp_self(prim); if(!env->func) ERR_O(self->pos, "can't use 'super' outside of constructor"); -// move in emit? -// if(!self->is_call) -// ERR_O(self->pos, "'super' can only be used as a call"); const Type parent = env->class_def->info->parent; DECL_OO(const Value, v, = find_value(parent, insert_symbol("new"))); SET_FLAG(env->func, const); @@ -133,6 +130,10 @@ static ID_CHECK(opck_super) { } static ID_EMIT(opem_super) { + const Env env = emit->env; + const Exp self = exp_self(prim); + if(!self->is_call) + ERR_B(self->pos, "can only use 'super' as a function call"); emit_regpushmem(emit, 0, SZ_INT, false); emit_pushimm(emit, (m_uint)exp_self(prim)->type); return GW_OK;