From 1f02ff4e8823aa4580111eb4369882f0645bbadf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 1 Mar 2020 15:44:45 +0100 Subject: [PATCH] :art: Remove warnings --- src/emit/emit.c | 10 ++++------ src/import/checker.c | 4 ++-- src/vm/vm.c | 6 ++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 7917fff2..f002c3a4 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -234,7 +234,7 @@ ANN void emit_ext_ctor(const Emitter emit, const VM_Code code) { regset->m_val2 = SZ_INT *2; const Instr push = emit_add_instr(emit, RegPush); push->m_val = SZ_INT *2; - const Instr prelude = emit_add_instr(emit, !GET_FLAG(code, builtin) ? FuncUsr : FuncMember); + const Instr prelude = emit_add_instr(emit, SetCode); prelude->m_val2 = 2; prelude->m_val = SZ_INT; emit_add_instr(emit, Reg2Mem); @@ -944,16 +944,14 @@ ANN static void tmpl_prelude(const Emitter emit, const Func f) { } ANN static Instr get_prelude(const Emitter emit, const Func f) { - Instr instr; const Type t = actual_type(emit->gwion, f->value_ref->type); - if(!is_fptr(emit->gwion, t)) - instr = emit_add_instr(emit, !GET_FLAG(f, builtin) ? FuncUsr : SetCode); - else { + if(is_fptr(emit->gwion, t)) { emit_except(emit, t); if(f->def->base->tmpl) tmpl_prelude(emit, f); - instr = emit_add_instr(emit, FuncPtr); + } + const Instr instr = emit_add_instr(emit, SetCode); instr->m_val2 = 1; return instr; } diff --git a/src/import/checker.c b/src/import/checker.c index ad565081..62edeaed 100644 --- a/src/import/checker.c +++ b/src/import/checker.c @@ -175,7 +175,7 @@ ANN static Type_List _str2tl(const Gwi gwi, const m_str s) { ANN Type_List tlnext(const Gwi gwi, const m_str s, size_t split) { char curr[split+1]; - strncpy(curr, s, split); + memcpy(curr, s, split); curr[split] = '\0'; const Type_List tl = _str2tl(gwi, curr); tl->next = str2tl(gwi, s + split + 1); @@ -290,7 +290,7 @@ ANN m_bool check_typename_def(const Gwi gwi, ImportCK *ck) { const m_str base = ck->name; char str[strlen(base) + 1]; const m_str c = strchr(ck->name, '<'); - strncpy(str, base, strlen(base) - (c ? strlen(c) : 0)); + memcpy(str, base, strlen(base) - (c ? strlen(c) : 0)); str[strlen(base) - (c ? strlen(c) : 0)] = '\0'; ck->name = str; CHECK_OB((ck->sym = str2sym(gwi, str))) diff --git a/src/vm/vm.c b/src/vm/vm.c index 66378e44..b6be206b 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -606,19 +606,17 @@ setcode: a.code = *(VM_Code*)(reg-SZ_INT); funcptr: PRAGMA_PUSH() + reg -= SZ_INT; + a.code = *(VM_Code*)reg; if(!GET_FLAG((VM_Code)a.code, builtin)) goto funcusr; PRAGMA_POP() funcmember: - reg -= SZ_INT; - a.code = *(VM_Code*)reg; mem += *(m_uint*)(reg + SZ_INT); next = eFuncMemberEnd; goto regpop; funcusr: { - reg -= SZ_INT; - a.code = *(VM_Code*)reg; register const m_uint push = *(m_uint*)(reg + SZ_INT) + *(m_uint*)(mem-SZ_INT); mem += push; *(m_uint*) mem = push;mem += SZ_INT; -- 2.43.0