private String GetCodeForReloc(Relocation reloc, DependencyNode node, NodeFactory factory) { CppGenerationBuffer relocCode = new CppGenerationBuffer(); if (reloc.Target is CppMethodCodeNode) { var method = reloc.Target as CppMethodCodeNode; relocCode.Append("(void*)&"); relocCode.Append(GetCppMethodDeclarationName(method.Method.OwningType, GetCppMethodName(method.Method))); } else if (reloc.Target is EETypeNode && node is EETypeNode) { relocCode.Append(GetCppMethodDeclarationName((reloc.Target as EETypeNode).Type, "__getMethodTable")); relocCode.Append("()"); } // Node is either an non-emitted type or a generic composition - both are ignored for CPP codegen else if ((reloc.Target is TypeManagerIndirectionNode || reloc.Target is InterfaceDispatchMapNode || reloc.Target is EETypeOptionalFieldsNode || reloc.Target is GenericCompositionNode) && !(reloc.Target as ObjectNode).ShouldSkipEmittingObjectNode(factory)) { string mangledTargetName = reloc.Target.GetMangledName(); bool shouldReplaceNamespaceQualifier = reloc.Target is GenericCompositionNode || reloc.Target is EETypeOptionalFieldsNode; relocCode.Append(shouldReplaceNamespaceQualifier ? mangledTargetName.Replace("::", "_") : mangledTargetName); relocCode.Append("()"); } else if (reloc.Target is ObjectAndOffsetSymbolNode && (reloc.Target as ObjectAndOffsetSymbolNode).Target is ArrayOfEmbeddedPointersNode<InterfaceDispatchMapNode>) { relocCode.Append("dispatchMapModule"); } else { relocCode.Append("NULL"); } return relocCode.ToString(); }
private String GetCodeForNodeStruct(List<NodeDataSection> nodeDataDivs, DependencyNode node) { CppGenerationBuffer nodeStructDecl = new CppGenerationBuffer(); int relocCounter = 1; int i = 0; nodeStructDecl.Indent(); for (i = 0; i < nodeDataDivs.Count; i++) { NodeDataSection section = nodeDataDivs[i]; if (section.SectionType == NodeDataSectionType.Relocation) { nodeStructDecl.Append("void* reloc"); nodeStructDecl.Append(relocCounter); nodeStructDecl.Append(";"); relocCounter++; } else { nodeStructDecl.Append("unsigned char data"); nodeStructDecl.Append((i + 1) - relocCounter); nodeStructDecl.Append("["); nodeStructDecl.Append(section.SectionSize); nodeStructDecl.Append("];"); } nodeStructDecl.AppendLine(); } nodeStructDecl.Exdent(); return nodeStructDecl.ToString(); }
void IDependencyAnalyzerLogNodeVisitor.VisitNode(DependencyNode node) { AddNode(node); }
private String GetCodeForNodeData(List<NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset, NodeFactory factory) { CppGenerationBuffer nodeDataDecl = new CppGenerationBuffer(); int relocCounter = 0; int divisionStartIndex = offset; nodeDataDecl.Indent(); nodeDataDecl.Indent(); nodeDataDecl.AppendLine(); for (int i = 0; i < nodeDataSections.Count; i++) { if (nodeDataSections[i].SectionType == NodeDataSectionType.Relocation) { Relocation reloc = relocs[relocCounter]; nodeDataDecl.Append(GetCodeForReloc(reloc, node, factory)); nodeDataDecl.Append(","); relocCounter++; } else { AppendFormattedByteArray(nodeDataDecl, byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize); nodeDataDecl.Append(","); } divisionStartIndex += nodeDataSections[i].SectionSize; nodeDataDecl.AppendLine(); } return nodeDataDecl.ToString(); }
void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependerOther, DependencyNode nodeDependedOn, string reason) { Tuple <DependencyNode, DependencyNode> combinedNode = new Tuple <DependencyNode, DependencyNode>(nodeDepender, nodeDependerOther); if (!_combinedNodesEdgeVisited.Contains(combinedNode)) { _combinedNodesEdgeVisited.Add(combinedNode); _xmlWrite.WriteStartElement("Link"); _xmlWrite.WriteAttributeString("Source", _nodeMappings[nodeDepender].ToString()); _xmlWrite.WriteAttributeString("Target", _nodeMappings[combinedNode].ToString()); _xmlWrite.WriteAttributeString("Reason", "Primary"); _xmlWrite.WriteAttributeString("Stroke", "#00FF00"); _xmlWrite.WriteEndElement(); _xmlWrite.WriteStartElement("Link"); _xmlWrite.WriteAttributeString("Source", _nodeMappings[nodeDependerOther].ToString()); _xmlWrite.WriteAttributeString("Target", _nodeMappings[combinedNode].ToString()); _xmlWrite.WriteAttributeString("Reason", "Secondary"); _xmlWrite.WriteAttributeString("Stroke", "#00FF00"); _xmlWrite.WriteEndElement(); } _xmlWrite.WriteStartElement("Link"); _xmlWrite.WriteAttributeString("Source", _nodeMappings[combinedNode].ToString()); _xmlWrite.WriteAttributeString("Target", _nodeMappings[nodeDependedOn].ToString()); _xmlWrite.WriteAttributeString("Reason", reason); _xmlWrite.WriteAttributeString("Stroke", "#0000FF"); _xmlWrite.WriteEndElement(); }
void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(string root, DependencyNode dependedOn) { AddReason(root, dependedOn, null); }
void IDependencyAnalyzerLogEdgeVisitor.VisitEdge(DependencyNode nodeDepender, DependencyNode nodeDependedOn, string reason) { _xmlWrite.WriteStartElement("Link"); _xmlWrite.WriteAttributeString("Source", _nodeMappings[nodeDepender].ToString()); _xmlWrite.WriteAttributeString("Target", _nodeMappings[nodeDependedOn].ToString()); _xmlWrite.WriteAttributeString("Reason", reason); _xmlWrite.WriteAttributeString("Stroke", "#FF0000"); _xmlWrite.WriteEndElement(); }
private String GetCodeForNodeData(List<NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset) { CppGenerationBuffer nodeDataDecl = new CppGenerationBuffer(); int relocCounter = 0; int divisionStartIndex = offset; nodeDataDecl.Indent(); nodeDataDecl.AppendLine(); for (int i = 0; i < nodeDataSections.Count; i++) { nodeDataDecl.Indent(); if (nodeDataSections[i].SectionType == NodeDataSectionType.Relocation) { Relocation reloc = relocs[relocCounter]; if (reloc.Target is CppMethodCodeNode) { var method = reloc.Target as CppMethodCodeNode; nodeDataDecl.Append("(void*)&"); nodeDataDecl.Append(GetCppMethodDeclarationName(method.Method.OwningType, GetCppMethodName(method.Method))); nodeDataDecl.Append(","); } else if (reloc.Target is EETypeNode && node is EETypeNode && _emittedTypes.Contains((reloc.Target as EETypeNode).Type)) { nodeDataDecl.Append(GetCppMethodDeclarationName((reloc.Target as EETypeNode).Type, "__getMethodTable")); nodeDataDecl.Append("(),"); } else { // TODO Add support for other relocs nodeDataDecl.Append("NULL,"); } relocCounter++; } else { AppendFormattedByteArray(nodeDataDecl, byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize); nodeDataDecl.Append(","); } divisionStartIndex += nodeDataSections[i].SectionSize; nodeDataDecl.AppendLine(); nodeDataDecl.Exdent(); } return nodeDataDecl.ToString(); }
private String GetCodeForReloc(Relocation reloc, DependencyNode node, NodeFactory factory) { CppGenerationBuffer relocCode = new CppGenerationBuffer(); if (reloc.Target is CppMethodCodeNode) { var method = reloc.Target as CppMethodCodeNode; relocCode.Append("(void*)&"); relocCode.Append(GetCppMethodDeclarationName(method.Method.OwningType, GetCppMethodName(method.Method))); } else if (reloc.Target is EETypeNode && node is EETypeNode && (reloc.Target as EETypeNode).Marked) { relocCode.Append(GetCppMethodDeclarationName((reloc.Target as EETypeNode).Type, "__getMethodTable")); relocCode.Append("()"); } // Node is either an non-emitted type or a generic composition - both are ignored for CPP codegen else if ((reloc.Target is ModuleManagerIndirectionNode || reloc.Target is InterfaceDispatchMapNode || reloc.Target is EETypeOptionalFieldsNode) && !(reloc.Target as ObjectNode).ShouldSkipEmittingObjectNode(factory)) { relocCode.Append(reloc.Target.MangledName); relocCode.Append("()"); } else if (reloc.Target is ObjectAndOffsetSymbolNode && (reloc.Target as ObjectAndOffsetSymbolNode).GetName().Contains("DispatchMap")) { relocCode.Append("dispatchMapModule"); } else { relocCode.Append("NULL"); } return relocCode.ToString(); }