From 5eb835f0332868fd56ac14ce7560e0ae9cfafec9 Mon Sep 17 00:00:00 2001 From: David Siher <32305650+dsiher@users.noreply.github.com> Date: Thu, 3 Feb 2022 19:16:54 -0800 Subject: Fixed naming conflicts in heterogeneous-hello-world (#2114) * Fixed naming conflicts in heterogeneous-hello-world Added 3 new modifiers (`__unmangled`, `__exportDirectly`, `__externLib`) `__unmangled` causes mangleName() to return the normal name of the decl. `__exportDirectly` changes parent decl name concatenation behavior to use "::" instead of "." (for Name Hint) and emits the name hint when it exists, otherwise it emits the mangled name. `__externLib` stops Slang from emitting the corresponding struct. Also made necessary changes to heterogeneous-hello-world so that this new functionality is shown off. * Undo unintentional formatting changes Co-authored-by: Yong He --- source/slang/slang-lower-to-ir.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index d4b069dca..b2a71a2e0 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1034,7 +1034,7 @@ static void addLinkageDecoration( inst = outerGeneric; } - if(isImportedDecl(context, decl)) + if (isImportedDecl(context, decl)) { builder->addImportDecoration(inst, mangledName); } @@ -1047,6 +1047,14 @@ static void addLinkageDecoration( builder->addPublicDecoration(inst); builder->addKeepAliveDecoration(inst); } + if (decl->findModifier<__exportDirectly>()) + { + builder->addExportDirectlyDecoration(inst); + } + if (decl->findModifier<__externLib>()) + { + builder->addExternLibDecoration(inst); + } } static void addLinkageDecoration( @@ -1986,7 +1994,12 @@ static String getNameForNameHint( StringBuilder sb; sb.append(parentName); - sb.append("."); + if (decl->hasModifier<__exportDirectly>()) { + sb.append("::"); + } + else { + sb.append("."); + } sb.append(leafName->text); return sb.ProduceString(); -- cgit v1.2.3