示例#1
0
                private void AddIfElseBranches(If control, JPF jpf, JMP jmp)
                {
                    Int32 endOfBlock = jmp.Index;

                    while (true)
                    {
                        Int32 newJpfIndex = jpf.Index;
                        JPF   newJpf      = _instructions[newJpfIndex] as JPF;
                        if (newJpf == null || newJpf.Index > endOfBlock)
                        {
                            control.AddElse(jpf.Index, endOfBlock);
                            return;
                        }

                        JMP newJmp = _instructions[newJpf.Index - 1] as JMP;
                        if (newJmp == null)
                        {
                            if (newJpf.Index == endOfBlock)
                            {
                                // if-elseif without jmp
                                _processed.Process(newJpf);
                                control.AddIf(newJpfIndex, newJpf.Index);
                            }
                            else
                            {
                                // if-else without jmp
                                control.AddElse(jpf.Index, endOfBlock);
                            }

                            return;
                        }

                        // Isn't our jump
                        if (newJmp.Index != endOfBlock)
                        {
                            control.AddElse(jpf.Index, endOfBlock);
                            return;
                        }

                        jpf = newJpf;
                        jmp = newJmp;
                        _processed.Process(jpf);
                        _processed.TryProcess(jmp);

                        control.AddIf(newJpfIndex, jpf.Index);

                        if (jpf.Index == endOfBlock)
                        {
                            return;
                        }
                    }
                }