diff options
author | Michal Strehovský <michals@microsoft.com> | 2017-03-10 22:27:10 +0300 |
---|---|---|
committer | Michal Strehovský <michals@microsoft.com> | 2017-03-10 22:27:10 +0300 |
commit | de440e995b53662d1fac764dd85792b22e8e0eb3 (patch) | |
tree | 2f1d3b4e18c927c7a0624bed3831e14096f0727a /src/ILCompiler.DependencyAnalysisFramework | |
parent | 3f3a835d7b38ed7c5f0e61aaf23694789ef549b3 (diff) |
Move GetName method to the generic dependency node
Diffstat (limited to 'src/ILCompiler.DependencyAnalysisFramework')
11 files changed, 37 insertions, 42 deletions
diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs index f8af55798..88ac931fc 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs @@ -108,16 +108,16 @@ namespace ILCompiler.DependencyAnalysisFramework return _markedNodes; } - public override sealed void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor logNodeVisitor) + public override sealed void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor) { - foreach (DependencyNode node in MarkedNodesEnumerable()) + foreach (DependencyNodeCore<DependencyContextType> node in MarkedNodesEnumerable()) { logNodeVisitor.VisitNode(node); } _marker.VisitLogNodes(MarkedNodesEnumerable(), logNodeVisitor); } - public override sealed void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor) + public override sealed void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor) { _marker.VisitLogEdges(MarkedNodesEnumerable(), logEdgeVisitor); } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs index 295836ad5..809db8713 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs @@ -62,12 +62,12 @@ namespace ILCompiler.DependencyAnalysisFramework /// Used to walk all nodes that should be emitted to a log. Not intended for other purposes. /// </summary> /// <param name="logNodeVisitor"></param> - public abstract void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor logNodeVisitor); + public abstract void VisitLogNodes(IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor); /// <summary> /// Used to walk the logical edges in the graph as part of log building. /// </summary> /// <param name="logEdgeVisitor"></param> - public abstract void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor); + public abstract void VisitLogEdges(IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNode.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNode.cs index 340ae3626..ae8d3af57 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNode.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNode.cs @@ -39,14 +39,6 @@ namespace ILCompiler.DependencyAnalysisFramework } } - // Force all non-abstract nodes to provide a name - protected internal abstract string GetName(); - - public override string ToString() - { - return GetName(); - } - public sealed override bool Equals(object obj) { return Object.ReferenceEquals(this, obj); diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs index a4956702a..b0eefd4ad 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs @@ -138,5 +138,8 @@ namespace ILCompiler.DependencyAnalysisFramework { // Do nothing by default } + + // Force all non-abstract nodes to provide a name + protected internal abstract string GetName(); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs index 58addb9e8..0e891493f 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs @@ -18,7 +18,7 @@ namespace ILCompiler.DependencyAnalysisFramework } } - internal class DgmlWriter<DependencyContextType> : IDisposable, IDependencyAnalyzerLogEdgeVisitor, IDependencyAnalyzerLogNodeVisitor + internal class DgmlWriter<DependencyContextType> : IDisposable, IDependencyAnalyzerLogEdgeVisitor<DependencyContextType>, IDependencyAnalyzerLogNodeVisitor<DependencyContextType> { private XmlWriter _xmlWrite; private bool _done = false; @@ -101,7 +101,7 @@ namespace ILCompiler.DependencyAnalysisFramework private Dictionary<object, int> _nodeMappings = new Dictionary<object, int>(); private int _nodeNextId = 0; - private void AddNode(DependencyNode node) + private void AddNode(DependencyNodeCore<DependencyContextType> node) { AddNode(node, node.GetName()); } @@ -128,7 +128,7 @@ namespace ILCompiler.DependencyAnalysisFramework _xmlWrite.WriteEndElement(); } - void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependedOn, string reason) + void IDependencyAnalyzerLogEdgeVisitor<DependencyContextType>.VisitEdge(DependencyNodeCore<DependencyContextType> nodeDepender, DependencyNodeCore<DependencyContextType> nodeDependedOn, string reason) { _xmlWrite.WriteStartElement("Link"); _xmlWrite.WriteAttributeString("Source", _nodeMappings[nodeDepender].ToString()); @@ -138,12 +138,12 @@ namespace ILCompiler.DependencyAnalysisFramework _xmlWrite.WriteEndElement(); } - void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(string root, DependencyNode dependedOn) + void IDependencyAnalyzerLogEdgeVisitor<DependencyContextType>.VisitEdge(string root, DependencyNodeCore<DependencyContextType> dependedOn) { AddReason(root, dependedOn, null); } - void IDependencyAnalyzerLogNodeVisitor.VisitCombinedNode(Tuple<DependencyNode, DependencyNode> node) + void IDependencyAnalyzerLogNodeVisitor<DependencyContextType>.VisitCombinedNode(Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>> node) { string label1 = node.Item1.GetName(); string label2 = node.Item2.GetName(); @@ -151,11 +151,11 @@ namespace ILCompiler.DependencyAnalysisFramework AddNode(node, string.Concat("(", label1, ", ", label2, ")")); } - private HashSet<Tuple<DependencyNode, DependencyNode>> _combinedNodesEdgeVisited = new HashSet<Tuple<DependencyNode, DependencyNode>>(); + private HashSet<Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>> _combinedNodesEdgeVisited = new HashSet<Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>>(); - void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependerOther, DependencyNode nodeDependedOn, string reason) + void IDependencyAnalyzerLogEdgeVisitor<DependencyContextType>.VisitEdge(DependencyNodeCore<DependencyContextType> nodeDepender, DependencyNodeCore<DependencyContextType> nodeDependerOther, DependencyNodeCore<DependencyContextType> nodeDependedOn, string reason) { - Tuple<DependencyNode, DependencyNode> combinedNode = new Tuple<DependencyNode, DependencyNode>(nodeDepender, nodeDependerOther); + var combinedNode = new Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>(nodeDepender, nodeDependerOther); if (!_combinedNodesEdgeVisited.Contains(combinedNode)) { _combinedNodesEdgeVisited.Add(combinedNode); @@ -183,12 +183,12 @@ namespace ILCompiler.DependencyAnalysisFramework _xmlWrite.WriteEndElement(); } - void IDependencyAnalyzerLogNodeVisitor.VisitNode(DependencyNode node) + void IDependencyAnalyzerLogNodeVisitor<DependencyContextType>.VisitNode(DependencyNodeCore<DependencyContextType> node) { AddNode(node); } - void IDependencyAnalyzerLogNodeVisitor.VisitRootNode(string rootName) + void IDependencyAnalyzerLogNodeVisitor<DependencyContextType>.VisitRootNode(string rootName) { AddNode(rootName, rootName); } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/FirstMarkLogStrategy.cs b/src/ILCompiler.DependencyAnalysisFramework/src/FirstMarkLogStrategy.cs index e55616b20..bde004ce1 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/FirstMarkLogStrategy.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/FirstMarkLogStrategy.cs @@ -64,9 +64,9 @@ namespace ILCompiler.DependencyAnalysisFramework return true; } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor logNodeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor) { - HashSet<Tuple<DependencyNode, DependencyNode>> combinedNodesReported = new HashSet<Tuple<DependencyNode, DependencyNode>>(); + var combinedNodesReported = new HashSet<Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>>(); if (_reasonStringOnlyNodes != null) { @@ -84,7 +84,7 @@ namespace ILCompiler.DependencyAnalysisFramework if (markData.Reason2 != null) { - Tuple<DependencyNode, DependencyNode> combinedNode = new Tuple<DependencyNode, DependencyNode>(markData.Reason1, markData.Reason2); + var combinedNode = new Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>(markData.Reason1, markData.Reason2); if (!combinedNodesReported.Contains(combinedNode)) { @@ -95,7 +95,7 @@ namespace ILCompiler.DependencyAnalysisFramework } } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor) { foreach (DependencyNodeCore<DependencyContextType> node in nodeList) { diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/FullGraphLogStrategy.cs b/src/ILCompiler.DependencyAnalysisFramework/src/FullGraphLogStrategy.cs index 38507c871..b85842dc2 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/FullGraphLogStrategy.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/FullGraphLogStrategy.cs @@ -135,9 +135,9 @@ namespace ILCompiler.DependencyAnalysisFramework return newlyMarked; } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor logNodeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor) { - HashSet<Tuple<DependencyNode, DependencyNode>> combinedNodesReported = new HashSet<Tuple<DependencyNode, DependencyNode>>(); + var combinedNodesReported = new HashSet<Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>>(); if (_reasonStringOnlyNodes != null) { @@ -156,7 +156,7 @@ namespace ILCompiler.DependencyAnalysisFramework { if (markData.Reason2 != null) { - Tuple<DependencyNode, DependencyNode> combinedNode = new Tuple<DependencyNode, DependencyNode>(markData.Reason1, markData.Reason2); + var combinedNode = new Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>(markData.Reason1, markData.Reason2); if (!combinedNodesReported.Contains(combinedNode)) { @@ -168,7 +168,7 @@ namespace ILCompiler.DependencyAnalysisFramework } } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor) { foreach (DependencyNodeCore<DependencyContextType> node in nodeList) { diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalysisMarkStrategy.cs b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalysisMarkStrategy.cs index 5c2b76598..02b1ca2f5 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalysisMarkStrategy.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalysisMarkStrategy.cs @@ -19,8 +19,8 @@ namespace ILCompiler.DependencyAnalysisFramework /// <returns>true if the node is newly marked</returns> bool MarkNode(DependencyNodeCore<DependencyContextType> node, DependencyNodeCore<DependencyContextType> reasonNode, DependencyNodeCore<DependencyContextType> reasonNode2, string reason); - void VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor logNodeVisitor); + void VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor); - void VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor); + void VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogEdgeVisitor.cs b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogEdgeVisitor.cs index 343136ccf..a8c5756f5 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogEdgeVisitor.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogEdgeVisitor.cs @@ -10,10 +10,10 @@ using System.Threading.Tasks; namespace ILCompiler.DependencyAnalysisFramework { - public interface IDependencyAnalyzerLogEdgeVisitor + public interface IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> { - void VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependedOn, string reason); - void VisitEdge(string root, DependencyNode dependedOn); - void VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependerOther, DependencyNode nodeDependedOn, string reason); + void VisitEdge(DependencyNodeCore<DependencyContextType> nodeDepender, DependencyNodeCore<DependencyContextType> nodeDependedOn, string reason); + void VisitEdge(string root, DependencyNodeCore<DependencyContextType> dependedOn); + void VisitEdge(DependencyNodeCore<DependencyContextType> nodeDepender, DependencyNodeCore<DependencyContextType> nodeDependerOther, DependencyNodeCore<DependencyContextType> nodeDependedOn, string reason); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogNodeVisitor.cs b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogNodeVisitor.cs index 15d09ff6f..630bb56c4 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogNodeVisitor.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/IDependencyAnalyzerLogNodeVisitor.cs @@ -6,10 +6,10 @@ using System; namespace ILCompiler.DependencyAnalysisFramework { - public interface IDependencyAnalyzerLogNodeVisitor + public interface IDependencyAnalyzerLogNodeVisitor<DependencyContextType> { - void VisitCombinedNode(Tuple<DependencyNode, DependencyNode> node); - void VisitNode(DependencyNode node); + void VisitCombinedNode(Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>> node); + void VisitNode(DependencyNodeCore<DependencyContextType> node); void VisitRootNode(string rootName); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/NoLogStrategy.cs b/src/ILCompiler.DependencyAnalysisFramework/src/NoLogStrategy.cs index 67d02e2ea..530a1db4f 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/NoLogStrategy.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/NoLogStrategy.cs @@ -32,13 +32,13 @@ namespace ILCompiler.DependencyAnalysisFramework return true; } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor logEdgeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogEdges(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogEdgeVisitor<DependencyContextType> logEdgeVisitor) { // This marker does not permit logging. return; } - void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor logNodeVisitor) + void IDependencyAnalysisMarkStrategy<DependencyContextType>.VisitLogNodes(IEnumerable<DependencyNodeCore<DependencyContextType>> nodeList, IDependencyAnalyzerLogNodeVisitor<DependencyContextType> logNodeVisitor) { // This marker does not permit logging. return; |