public void Visit(string methodName, UCFG ucfg) { writer.WriteGraphStart(methodName); writer.WriteNode("ENTRY", "ENTRY", ucfg.Parameters.ToArray()); foreach (var entry in ucfg.Entries) { writer.WriteEdge("ENTRY", entry, string.Empty); } foreach (var block in ucfg.BasicBlocks) { Visit(block); } writer.WriteNode("EXIT", "EXIT"); writer.WriteGraphEnd(); }
private void WriteNode(Block block, SyntaxNode terminator = null) { var header = block.GetType().Name.SplitCamelCaseToWords().First().ToUpperInvariant(); if (terminator != null) { // shorten the text var terminatorType = terminator.GetType().Name.Replace("Syntax", string.Empty); header += ":" + terminatorType; } writer.WriteNode(blockId.Get(block), header, block.Instructions.Select(i => i.ToString()).ToArray()); }