From: fennecdjay Date: Wed, 11 Jan 2023 18:54:21 +0000 (+0100) Subject: :art: use functions for ext_ctor X-Git-Tag: nightly~207^2~11 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=aef2d4fbc23f6d9adc2e73558844c31fb0145668;p=gwion.git :art: use functions for ext_ctor --- diff --git a/include/instr.h b/include/instr.h index 72e733b5..25724cf7 100644 --- a/include/instr.h +++ b/include/instr.h @@ -68,7 +68,6 @@ struct dottmpl_ { ANN m_bool traverse_dot_tmpl(const Emitter emit, const Func_Def fdef, const Value v); INSTR(SetFunc); -INSTR(SetCtor); INSTR(FuncWait); #include "opcode.h" diff --git a/src/emit/emit.c b/src/emit/emit.c index 1b437e92..01f1dbab 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -406,24 +406,14 @@ static ArrayInfo *emit_array_extend_inner(const Emitter emit, const Type t, return info; } +ANN static void call_finish(const Emitter emit, const Func f,const bool); ANN void emit_ext_ctor(const Emitter emit, const Type t) { const Instr cpy = emit_add_instr(emit, Reg2Reg); cpy->m_val2 = -SZ_INT; - if (t->nspc->pre_ctor) - emit_setimm(emit, (m_uint)t->nspc->pre_ctor, SZ_INT); - else { - const Instr instr = emit_add_instr(emit, SetCtor); - instr->m_val = (m_uint)t; - } - const m_uint offset = emit_code_offset(emit); - emit_setimm(emit, offset, SZ_INT*2); - emit_regmove(emit, SZ_INT*2); - const Instr prelude = emit_add_instr(emit, SetCode); - prelude->m_val = -SZ_INT * 2; - prelude->udata.one = 2; - (void)emit_regtomem(emit, 0, 0); - const Instr next = emit_add_instr(emit, Overflow); - next->m_val2 = offset; + const Func f = (Func)vector_front(&t->nspc->vtable); + emit_regmove(emit, SZ_INT); + emit_pushfunc(emit, f); + call_finish(emit, f, false); } ANN static inline void emit_notpure(const Emitter emit) { diff --git a/src/lib/instr.c b/src/lib/instr.c index 97162dd9..2b9e4009 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -134,13 +134,6 @@ INSTR(SetFunc) { shred->reg += SZ_INT; } -INSTR(SetCtor) { - BYTE(eRegSetImm) - const Type t = (Type)instr->m_val; - VAL = *(m_uint *)(shred->reg + SZ_INT) = (m_uint)t->nspc->pre_ctor; - VAL2 = SZ_INT; -} - INSTR(FuncWait) { const Func f = (Func)instr->m_val; if(f->_wait->len - instr->m_val2) { diff --git a/src/parse/check.c b/src/parse/check.c index 60ba8e9b..ce9ee9ea 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -19,7 +19,7 @@ #include "array.h" ANN m_bool check_stmt_list(const Env env, Stmt_List list); -ANN m_bool check_class_def(const Env env, const Class_Def class_def); +ANN m_bool check_class_def(const Env env, const Class_Def class_def); ANN static Type check_internal(const Env env, const Symbol sym, const Exp e, const Type t) { diff --git a/src/vm/vm.c b/src/vm/vm.c index df8c917a..4cc46bca 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -1574,8 +1574,6 @@ _other: instr->opcode = (m_uint)&&noop; else if(exec == SetFunc) instr->opcode = (m_uint)&®pushimm; - else if(exec == SetCtor) - instr->opcode = (m_uint)&®setimm; prepare_code += BYTECODE_SZ; goto *_dispatch[*(m_bit*)prepare_code]; }