private void Walk(int index, IActionExaminer examiner, ArrayList visitedLabels) { while (index < actionRec.Count) { BaseAction a = (BaseAction)actionRec[index]; if (a is ActionLabel) { ActionLabel l = a as ActionLabel; if (visitedLabels.Contains(l.LabelId)) { //examiner.End(); return; } else { visitedLabels.Add(l.LabelId); } } examiner.Examine(index, a); if (a is ActionJump) { ActionJump j = a as ActionJump; index = (int)labelIndexTable[j.LabelId] - 1; } if (a is ActionIf) { ActionIf ai = a as ActionIf; if (!visitedLabels.Contains(ai.LabelId)) { Walk((int)labelIndexTable[ai.LabelId], examiner.Clone(), (ArrayList)visitedLabels.Clone()); } } if (a is ActionReturn) { //examiner.End(); return; } index++; } //examiner.End(); }
private void Walk(int index,IActionExaminer examiner,ArrayList visitedLabels) { while (index<actionRec.Count) { BaseAction a = (BaseAction)actionRec[index]; if (a is ActionLabel) { ActionLabel l = a as ActionLabel; if (visitedLabels.Contains(l.LabelId)) { //examiner.End(); return; } else { visitedLabels.Add(l.LabelId); } } examiner.Examine(index,a); if (a is ActionJump) { ActionJump j = a as ActionJump; index = (int)labelIndexTable[j.LabelId]-1; } if (a is ActionIf) { ActionIf ai = a as ActionIf; if (!visitedLabels.Contains(ai.LabelId)) { Walk( (int)labelIndexTable[ai.LabelId], examiner.Clone(), (ArrayList)visitedLabels.Clone() ); } } if (a is ActionReturn) { //examiner.End(); return; } index++; } //examiner.End(); }