From 6b5d358473ec289a7f759b3384eeab27c388ee55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 28 Jun 2021 01:12:15 +0200 Subject: [PATCH] :art: Improve name mangling --- src/emit/emit.c | 7 ++----- src/vm/vm_name.c | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index b1c8f71e..c254727d 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2508,11 +2508,8 @@ ANN static inline void emit_func_def_fglobal(const Emitter emit, set_mem->m_val2 = (m_uint)value->d.func_ref->code; } -ANN static void emit_func_def_init(const Emitter emit, const Func func) { - const Type t = emit->env->class_def; - char c[(t ? strlen(t->name) + 1 : 0) + strlen(func->name) + 6]; - sprintf(c, "%s%s%s(...)", t ? t->name : "", t ? "." : "", func->name); - emit_push_code(emit, c); +ANN static inline void emit_func_def_init(const Emitter emit, const Func func) { + emit_push_code(emit, func->name); } ANN static void emit_func_def_args(const Emitter emit, Arg_List a) { diff --git a/src/vm/vm_name.c b/src/vm/vm_name.c index 49b9c931..8142280e 100644 --- a/src/vm/vm_name.c +++ b/src/vm/vm_name.c @@ -2,6 +2,11 @@ #include "gwion_ast.h" m_str code_name_set(MemPool p, const m_str name, const m_str file) { + const m_str search = strrchr(name, '@'); + const m_str is_file = search ? search + 1 : name; + if(!strcmp(is_file, file)) { + return mstrdup(p, name); + } const size_t len = strlen(name) + strlen(file) + 2; const m_str str = (const m_str)_mp_malloc(p, len); sprintf(str, "%s$%s", name, file); -- 2.43.0