/// <summary> /// Adds a node to the current node so that it is linked to it. /// </summary> /// <param name="node">The node to link this one to</param> /// <returns> /// True if successfully added to the list that this node links to. /// False if this node already links to that node. /// </returns> public bool AddLinkedNode(Node node) { if (!LinksTo.Contains(node)) { LinksTo.Add(node); Parents.Add(node); return(true); } return(false); }
public BranchNode(NodeDiagram parent, ILInstruction instruction) : base(parent) { this.Instruction = instruction; string operand = instruction.GetOperandString(); Text = instruction.Offset.ToString("x4") + Environment.NewLine + instruction.Code.ToString() + (string.IsNullOrEmpty(operand) ? "" : Environment.NewLine + operand); using (System.Drawing.Graphics g = parent.CreateGraphics()) { SizeF s = g.MeasureString(Text, parent.Font); nodeSize = base.NodeSize; if (s.Width > base.NodeSize.Width) { nodeSize = new Size((int)s.Width, nodeSize.Height); } if (s.Height > base.NodeSize.Height) { nodeSize = new Size((int)nodeSize.Width, (int)s.Height); } } if (instruction.Code == OpCodes.Beq || instruction.Code == OpCodes.Beq_S) { jumpExpression = "=="; continueExpression = "!="; } else if (instruction.Code == OpCodes.Bge || instruction.Code == OpCodes.Bge_S || instruction.Code == OpCodes.Bge_Un || instruction.Code == OpCodes.Bge_Un_S) { jumpExpression = ">="; continueExpression = "<"; } else if (instruction.Code == OpCodes.Bgt || instruction.Code == OpCodes.Bgt_S || instruction.Code == OpCodes.Bgt_Un || instruction.Code == OpCodes.Bgt_Un_S) { jumpExpression = ">"; continueExpression = "<="; } else if (instruction.Code == OpCodes.Ble || instruction.Code == OpCodes.Ble_S || instruction.Code == OpCodes.Ble_Un || instruction.Code == OpCodes.Ble_Un_S) { jumpExpression = "<="; continueExpression = ">"; } else if (instruction.Code == OpCodes.Blt || instruction.Code == OpCodes.Blt_S || instruction.Code == OpCodes.Blt_Un || instruction.Code == OpCodes.Blt_Un_S) { jumpExpression = "<"; continueExpression = ">="; } else if (instruction.Code == OpCodes.Bne_Un || instruction.Code == OpCodes.Bne_Un_S) { jumpExpression = "!="; continueExpression = "=="; } else if (instruction.Code == OpCodes.Brfalse || instruction.Code == OpCodes.Brfalse_S) { jumpExpression = "false"; continueExpression = "true"; } else if (instruction.Code == OpCodes.Brtrue || instruction.Code == OpCodes.Brtrue_S) { jumpExpression = "true"; continueExpression = "false"; } LinksTo.Add(new Condition() { Text = continueExpression }); LinksTo.Add(new Condition() { Text = jumpExpression }); }