From: Jérémie Astor Date: Sun, 27 Jun 2021 23:12:15 +0000 (+0200) Subject: :art: Improve name mangling X-Git-Tag: nightly~563 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=6b5d358473ec289a7f759b3384eeab27c388ee55;p=gwion.git :art: Improve name mangling --- 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);