private void addASTNode(CmdTreeNode parent, BJKCore.Cmd c) { CmdTreeNode child = null; if (c.IsChoice) { child = new CmdTreeNode("Choose {...} or {...}"); BJKCore.Cmd.Choice choice = c as BJKCore.Cmd.Choice; addASTNode(child, choice.Item1); addASTNode(child, choice.Item2); } else if (c.IsAssume) { BJKCore.Cmd.Assume assume = c as BJKCore.Cmd.Assume; string boolExpr = boolExprString(assume.Item); child = new CmdTreeNode("Assume (" + boolExpr + ")"); } else if (c.IsAssumeNot) { BJKCore.Cmd.AssumeNot assumeNot = c as BJKCore.Cmd.AssumeNot; string coBoolExp = coBoolExprString(assumeNot.Item); child = new CmdTreeNode("Assume (" + coBoolExp + ")"); } else if (c.IsWhile) { BJKCore.Cmd.While whle = c as BJKCore.Cmd.While; string boolExpr = boolExprString(whle.Item1); child = new CmdTreeNode("While (" + boolExpr + ")"); addASTNode(child, whle.Item2); } else if (c.IsSeq) { child = new CmdTreeNode("Sequence"); BJKCore.Cmd.Seq seq = c as BJKCore.Cmd.Seq; addASTNode(child, seq.Item1); addASTNode(child, seq.Item2); } else if (c.IsSkip) { child = new CmdTreeNode("Skip"); } else if (c.IsAsgn) { BJKCore.Cmd.Asgn asgn = c as BJKCore.Cmd.Asgn; string expr = exprString(asgn.Item2); int varIndex = asgn.Item1; string varName = getVarNameByVarIndex(varIndex); child = new CmdTreeNode(varName + " := " + expr); } else if (c.IsLoop) { BJKCore.Cmd.Loop loop = c as BJKCore.Cmd.Loop; child = new CmdTreeNode("Loop*"); addASTNode(child, loop.Item); } else if (c.IsWidening) { child = new CmdTreeNode("Widening"); } parent.Nodes.Add(child); }
private void addASTNode(CmdTreeNode parent, BJKCore.Cmd c) { CmdTreeNode child = null; if (c.IsChoice) { child = new CmdTreeNode("Choose {...} or {...}"); BJKCore.Cmd.Choice choice = c as BJKCore.Cmd.Choice; addASTNode(child, choice.Item1); addASTNode(child, choice.Item2); } else if (c.IsAssume) { BJKCore.Cmd.Assume assume = c as BJKCore.Cmd.Assume; string boolExpr = boolExprString(assume.Item); child = new CmdTreeNode("Assume (" + boolExpr + ")"); } else if (c.IsAssumeNot) { BJKCore.Cmd.AssumeNot assumeNot = c as BJKCore.Cmd.AssumeNot; string coBoolExp = coBoolExprString(assumeNot.Item); child = new CmdTreeNode("Assume (" + coBoolExp + ")"); } else if (c.IsWhile) { BJKCore.Cmd.While whle = c as BJKCore.Cmd.While; string boolExpr = boolExprString(whle.Item1); child = new CmdTreeNode("While (" + boolExpr + ")"); addASTNode(child, whle.Item2); } else if (c.IsSeq) { child = new CmdTreeNode("Sequence"); BJKCore.Cmd.Seq seq = c as BJKCore.Cmd.Seq; addASTNode(child, seq.Item1); addASTNode(child, seq.Item2); } else if (c.IsSkip) { child = new CmdTreeNode("Skip"); } else if (c.IsAsgn) { BJKCore.Cmd.Asgn asgn = c as BJKCore.Cmd.Asgn; string expr = exprString(asgn.Item2); int varIndex = asgn.Item1; string varName = getVarNameByVarIndex(varIndex); child = new CmdTreeNode(varName + " := " + expr); } else if (c.IsLoop) { BJKCore.Cmd.Loop loop = c as BJKCore.Cmd.Loop; child = new CmdTreeNode("Loop*"); addASTNode(child, loop.Item); } else if (c.IsWidening) { child = new CmdTreeNode("Widening"); } parent.Nodes.Add(child); }