| 7 | namespace Compiler |
| 8 | { |
| 9 | void CheckComponentRedefinition(DiagnosticSink * err, ShaderClosure * parent, ShaderClosure * child) |
| 10 | { |
| 11 | for (auto & comp : child->Components) |
| 12 | { |
| 13 | RefPtr<ShaderComponentSymbol> ccomp; |
| 14 | RefPtr<ShaderClosure> su; |
| 15 | if ((comp.Value->Implementations.First()->SyntaxNode->IsPublic() || |
| 16 | comp.Value->Implementations.First()->SyntaxNode->IsOutput())) |
| 17 | { |
| 18 | if (parent->Components.TryGetValue(comp.Key, ccomp)) |
| 19 | { |
| 20 | err->diagnose(comp.Value->Implementations.First()->SyntaxNode, Diagnostics::nameAlreadyDefinedInCurrentScope, comp.Key); |
| 21 | err->diagnose(ccomp->Implementations.First()->SyntaxNode, Diagnostics::seePreviousDefinition); |
| 22 | } |
| 23 | else if (parent->SubClosures.TryGetValue(comp.Key, su)) |
| 24 | { |
| 25 | err->diagnose(comp.Value->Implementations.First()->SyntaxNode->Position, Diagnostics::nameAlreadyDefinedInCurrentScope, comp.Key); |
| 26 | err->diagnose(su->UsingPosition, Diagnostics::seePreviousDefinition); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | for (auto & c : child->SubClosures) |
| 31 | { |
| 32 | if (c.Value->IsInPlace) |
| 33 | { |
| 34 | RefPtr<ShaderComponentSymbol> ccomp; |
| 35 | RefPtr<ShaderClosure> su; |
| 36 | if (parent->Components.TryGetValue(c.Key, ccomp)) |
| 37 | { |
| 38 | err->diagnose(c.Value->UsingPosition, Diagnostics::nameAlreadyDefinedInCurrentScope, c.Key); |
| 39 | err->diagnose(ccomp->Implementations.First()->SyntaxNode, Diagnostics::seePreviousDefinition); |
| 40 | } |
| 41 | else if (parent->SubClosures.TryGetValue(c.Key, su)) |
| 42 | { |
| 43 | err->diagnose(c.Value->UsingPosition, Diagnostics::nameAlreadyDefinedInCurrentScope, c.Key); |
| 44 | err->diagnose(su->UsingPosition, Diagnostics::seePreviousDefinition); |
| 45 | } |
| 46 | for (auto & sc : c.Value->SubClosures) |
| 47 | if (sc.Value->IsInPlace) |
| 48 | CheckComponentRedefinition(err, parent, sc.Value.Ptr()); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | RefPtr<ShaderClosure> CreateShaderClosure(DiagnosticSink * err, SymbolTable * symTable, ShaderSymbol * shader, CodePosition usingPos, |
| 53 | ShaderClosure * rootShader, |
| 54 | const EnumerableDictionary<String, RefPtr<ShaderComponentSymbol>>& pRefMap) |
no test coverage detected