コード例 #1
0
        static List<CStatement> B_C(uint pc, uint instruction)
        {
            Instruction i = new Instruction(instruction);
            List<CStatement> stats = new List<CStatement>();

            uint destination = (uint) SignExtend24(i.LI() << 2);
            if ((instruction & 2) != 2)
                destination += pc;

            Function f = decompiler.Functions.Find(delegate(Function fn) { return fn.Address == destination; });
            String destName;
            if (f != null)
                destName = f.Name;
            else
                destName = "L" + destination.ToString("X8");

            CStatement branch = new CStatement();
            if (i.LK())
            {
                if (f != null && decompiler.IgnoredCalls.Contains(f))
                    return new List<CStatement>();

                if (f != null && f.Returns.Name == "void" && f.Returns.Kind == CType.TypeKind.ValueType)
                {
                    branch.Kind = CStatement.Kinds.Call;
                    branch.CallFuncName = destName;
                    branch.CalledFunction = f;
                }
                else
                {
                    branch.Kind = CStatement.Kinds.Assignment;
                    branch.Op1 = new CStatement.COperand("r3");

                    CStatement realBranch = new CStatement(CStatement.Kinds.Call);
                    realBranch.CallFuncName = destName;
                    realBranch.CalledFunction = f;

                    branch.Op2 = new CStatement.COperand(realBranch);
                }
            }
            else
            {
                if (f != null && decompiler.CallIsRet.Contains(f))
                    branch.Kind = CStatement.Kinds.Return;
                else
                {
                    branch.Kind = CStatement.Kinds.Goto;
                    branch.BranchDestination = destName;
                    branch.BranchDestinationAddr = destination;
                }
            }

            stats.Add(branch);
            return stats;
        }