public UnconditionalBranchNode(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); } } }
public StatementNode(NodeDiagram parent, Statement statement) : base(parent) { this.Statement = statement; Text = statement.Expression; 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); } } }
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 }); }