Ejemplo n.º 1
0
        public List <ILBasicBlock> GetAllCaseBlocks(IList <ILNode> body, ILBasicBlock head, int pos, out ILExpression condition, out ILLabel fallout)
        {
            ILExpression        fswitch    = new ILExpression(GMCode.Switch, null);
            List <ILBasicBlock> caseBlocks = new List <ILBasicBlock>();
            int     swtichStart            = pos;
            ILLabel trueLabel;
            ILLabel falseLabel;

            while (MatchSwitchCase(head, out trueLabel, out falseLabel, out condition))
            {
                caseBlocks.Add(head);
                head = body.ElementAtOrDefault(++swtichStart) as ILBasicBlock;
            }
            ILBasicBlock switchHead = caseBlocks.First();

            if (!switchHead.ElementAtLastOrDefault(5).isNodeResolved())
            {
                fallout = null; condition = null; return(null);
            }
            //   caseBlocks.Reverse(); // reverse the order so its correct
            Debug.Assert(switchHead.MatchLastAt(6, GMCode.Push, out condition)); // return false;
            switchHead.RemoveAt(switchHead.Body.Count - 6);                      // ugh, might have to change the matchLastAt
            fallout = caseBlocks.Last().OperandLabelLastAt(0);
            return(caseBlocks);
        }