MCPcopy Create free account
hub / github.com/csyonghe/Spire / CheckCircularReference

Function CheckCircularReference

Source/SpireCore/Closure.cpp:639–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637 }
638
639 bool CheckCircularReference(DiagnosticSink * err, ShaderClosure * shader)
640 {
641 bool rs = false;
642 for (auto & comp : shader->AllComponents)
643 {
644 for (auto & impl : comp.Value.Symbol->Implementations)
645 {
646 // check circular references
647 HashSet<ShaderComponentSymbol*> set;
648 List<ShaderComponentSymbol*> referredComponents;
649 referredComponents.Add(comp.Value.Symbol);
650 for (int i = 0; i < referredComponents.Count(); i++)
651 {
652 auto xcomp = referredComponents[i];
653 for (auto & xcompImpl : xcomp->Implementations)
654 {
655 for (auto & rcomp : xcompImpl->DependentComponents)
656 {
657 if (set.Add(rcomp.Key))
658 {
659 referredComponents.Add(rcomp.Key);
660 }
661 if (rcomp.Key == comp.Value.Symbol)
662 {
663 err->diagnose(impl->SyntaxNode->Position, Diagnostics::circularReferenceNotAllowed, rcomp.Key->Name);
664 rs = true;
665 }
666 }
667 }
668 }
669 }
670 }
671 return rs;
672 }
673
674 void PropagateArgumentConstraints(ShaderComponentSymbol * requirement, ShaderComponentSymbol * arg)
675 {

Callers 1

FlattenShaderClosureFunction · 0.85

Calls 3

diagnoseMethod · 0.80
AddMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected