Пример #1
0
        private static bool HandleBranching(string opcodeStr, int offset,
                                            MetaMidRepresentationOperationFactory operationFactory)
        {
            #region Branching

            if (opcodeStr == OpcodeBranchNames.Leave ||
                opcodeStr == OpcodeBranchNames.LeaveS
                )
            {
                operationFactory.AlwaysBranch(offset);
                operationFactory.LeaveTo(offset);
                operationFactory.ClearStack();
                return(true);
            }


            if (opcodeStr == OpcodeBranchNames.BrTrueS ||
                opcodeStr == OpcodeBranchNames.BrTrue ||
                opcodeStr == OpcodeBranchNames.BrInstS ||
                opcodeStr == OpcodeBranchNames.BrInst)
            {
                operationFactory.BranchIfTrue(offset);
                return(true);
            }
            if (opcodeStr == OpcodeBranchNames.BrFalseS ||
                opcodeStr == OpcodeBranchNames.BrFalse ||
                opcodeStr == OpcodeBranchNames.BrNullS ||
                opcodeStr == OpcodeBranchNames.BrNull ||
                opcodeStr == OpcodeBranchNames.BrZeroS ||
                opcodeStr == OpcodeBranchNames.BrZero)
            {
                operationFactory.BranchIfFalse(offset);
                return(true);
            }

            if (opcodeStr == OpcodeBranchNames.Beq || opcodeStr == OpcodeBranchNames.BeqS)
            {
                operationFactory.BranchIfEqual(offset);
                return(true);
            }

            if (opcodeStr == OpcodeBranchNames.Bge || opcodeStr == OpcodeBranchNames.BgeS)
            {
                operationFactory.BranchIfGreaterOrEqual(offset);
                return(true);
            }
            if (opcodeStr == OpcodeBranchNames.Bgt || opcodeStr == OpcodeBranchNames.BgtS)
            {
                operationFactory.BranchIfGreater(offset);
                return(true);
            }
            if (opcodeStr == OpcodeBranchNames.Ble || opcodeStr == OpcodeBranchNames.BleS)
            {
                operationFactory.BranchIfLessOrEqual(offset);
                return(true);
            }
            if (opcodeStr == OpcodeBranchNames.Blt || opcodeStr == OpcodeBranchNames.BltS)
            {
                operationFactory.BranchIfLess(offset);
                return(true);
            }
            if (opcodeStr == OpcodeBranchNames.Bne ||
                opcodeStr == OpcodeBranchNames.BneUn ||
                opcodeStr == OpcodeBranchNames.BneUnS ||
                opcodeStr == OpcodeBranchNames.BneS)
            {
                operationFactory.BranchIfNotEqual(offset);
                return(true);
            }

            if (opcodeStr == OpcodeBranchNames.BrS || opcodeStr == OpcodeBranchNames.Br)
            {
                operationFactory.AlwaysBranch(offset);
                return(true);
            }

            #endregion

            return(false);
        }