Skip to content

Commit

Permalink
Updated processor specialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
cesaref committed Nov 23, 2020
1 parent e66f736 commit e54f6c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/modules/soul_core/compiler/soul_ResolutionPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,6 @@ struct ResolutionPass final
return instance;

auto specialisationArgs = AST::CommaSeparatedList::getAsExpressionList (instance.specialisationArgs);
auto numArgs = specialisationArgs.size();
auto target = pool_ref<AST::ProcessorBase> (*p);

if (! validateSpecialisationArgs (specialisationArgs, target->specialisationParams))
Expand All @@ -1898,18 +1897,20 @@ struct ResolutionPass final
return instance;
}

if (target->owningInstance != nullptr || numArgs != 0)
bool requiresSpecialisation = ! target->specialisationParams.empty();

if (target->owningInstance != nullptr || requiresSpecialisation)
{
auto nameRoot = target->name.toString();

if (numArgs != 0)
if (requiresSpecialisation)
nameRoot = TokenisedPathString::join (nameRoot,
"_for_" + makeSafeIdentifierName (choc::text::replace (graph.getFullyQualifiedPath().toString(), ":", "_")
+ "_" + instance.instanceName->toString()));
auto& ns = target->getNamespace();
target = *cast<AST::ProcessorBase> (target->createClone (allocator, ns, ns.makeUniqueName (nameRoot)));

if (numArgs != 0)
if (requiresSpecialisation)
{
auto oldCloneFn = target->createClone;

Expand Down

0 comments on commit e54f6c5

Please sign in to comment.