Пример #1
0
        private static void RemoveJsrInstructions(ConstantPool pool, BasicBlock block, DataPoint
                                                  data)
        {
            ListStack <VarType> stack = data.GetStack();
            InstructionSequence seq   = block.GetSeq();

            for (int i = 0; i < seq.Length(); i++)
            {
                Instruction instr = seq.GetInstr(i);
                VarType     var   = null;
                if (instr.opcode == ICodeConstants.opc_astore || instr.opcode == ICodeConstants.opc_pop)
                {
                    var = stack.GetByOffset(-1);
                }
                InstructionImpact.StepTypes(data, instr, pool);
                switch (instr.opcode)
                {
                case ICodeConstants.opc_jsr:
                case ICodeConstants.opc_ret:
                {
                    seq.RemoveInstruction(i);
                    i--;
                    break;
                }

                case ICodeConstants.opc_astore:
                case ICodeConstants.opc_pop:
                {
                    if (var.type == ICodeConstants.Type_Address)
                    {
                        seq.RemoveInstruction(i);
                        i--;
                    }
                    break;
                }
                }
            }
            block.mark = 1;
            for (int i = 0; i < block.GetSuccs().Count; i++)
            {
                BasicBlock suc = block.GetSuccs()[i];
                if (suc.mark != 1)
                {
                    RemoveJsrInstructions(pool, suc, data.Copy());
                }
            }
            for (int i = 0; i < block.GetSuccExceptions().Count; i++)
            {
                BasicBlock suc = block.GetSuccExceptions()[i];
                if (suc.mark != 1)
                {
                    DataPoint point = new DataPoint();
                    point.SetLocalVariables(new List <VarType>(data.GetLocalVariables()));
                    point.GetStack().Push(new VarType(ICodeConstants.Type_Object, 0, null));
                    RemoveJsrInstructions(pool, suc, point);
                }
            }
        }