Пример #1
0
        public ExpressionSimplifier(SegmentMap segmentMap, EvaluationContext ctx, DecompilerEventListener listener)
        {
            this.segmentMap = segmentMap ?? throw new ArgumentNullException(nameof(SegmentMap));
            this.ctx        = ctx;
            this.cmp        = new ExpressionValueComparer();

            this.add2ids             = new AddTwoIdsRule(ctx);
            this.addEcc              = new Add_e_c_cRule(ctx);
            this.addMici             = new Add_mul_id_c_id_Rule(ctx);
            this.dpbConstantRule     = new DpbConstantRule();
            this.dpbdpbRule          = new DpbDpbRule(ctx);
            this.idConst             = new IdConstant(ctx, new Unifier(), listener);
            this.idCopyPropagation   = new IdCopyPropagationRule(ctx);
            this.idBinIdc            = new IdBinIdc_Rule(ctx);
            this.sliceConst          = new SliceConstant_Rule();
            this.sliceMem            = new SliceMem_Rule();
            this.sliceSegPtr         = new SliceSegmentedPointer_Rule(ctx);
            this.negSub              = new NegSub_Rule();
            this.constConstBin       = new ConstConstBin_Rule();
            this.shAdd               = new Shl_add_Rule(ctx);
            this.shMul               = new Shl_mul_e_Rule(ctx);
            this.shiftShift          = new ShiftShift_c_c_Rule(ctx);
            this.mpsRule             = new Mps_Constant_Rule(ctx);
            this.sliceShift          = new SliceShift(ctx);
            this.binopWithSelf       = new BinOpWithSelf_Rule();
            this.constDiv            = new ConstDivisionImplementedByMultiplication(ctx);
            this.selfdpbRule         = new SelfDpbRule(ctx);
            this.idProcConstRule     = new IdProcConstRule(ctx);
            this.castCastRule        = new CastCastRule(ctx);
            this.distributedCast     = new DistributedCastRule();
            this.distributedSlice    = new DistributedSliceRule();
            this.mkSeqFromSlicesRule = new MkSeqFromSlices_Rule(ctx);
            this.constOnLeft         = new ComparisonConstOnLeft();
            this.sliceSeq            = new SliceSequence(ctx);
        }
Пример #2
0
        public ExpressionSimplifier(EvaluationContext ctx, DecompilerEventListener listener)
        {
            this.ctx = ctx;

            this.add2ids           = new AddTwoIdsRule(ctx);
            this.addEcc            = new Add_e_c_cRule(ctx);
            this.addMici           = new Add_mul_id_c_id_Rule(ctx);
            this.dpbConstantRule   = new DpbConstantRule();
            this.dpbdpbRule        = new DpbDpbRule(ctx);
            this.idConst           = new IdConstant(ctx, new Unifier(), listener);
            this.idCopyPropagation = new IdCopyPropagationRule(ctx);
            this.idBinIdc          = new IdBinIdc_Rule(ctx);
            this.sliceConst        = new SliceConstant_Rule();
            this.sliceMem          = new SliceMem_Rule();
            this.sliceSegPtr       = new SliceSegmentedPointer_Rule(ctx);
            this.negSub            = new NegSub_Rule();
            this.constConstBin     = new ConstConstBin_Rule();
            this.shAdd             = new Shl_add_Rule(ctx);
            this.shMul             = new Shl_mul_e_Rule(ctx);
            this.shiftShift        = new ShiftShift_c_c_Rule(ctx);
            this.mpsRule           = new Mps_Constant_Rule(ctx);
            this.sliceShift        = new SliceShift(ctx);
            this.binopWithSelf     = new BinOpWithSelf_Rule();
            this.constDiv          = new ConstDivisionImplementedByMultiplication(ctx);
            this.selfdpbRule       = new SelfDpbRule(ctx);
            this.idProcConstRule   = new IdProcConstRule(ctx);
            this.castCastRule      = new CastCastRule(ctx);
        }
Пример #3
0
 public void Test2()
 {
     BinaryExpression b = m.IAdd(id, m.UMul(id, 5));
     Assignment ass = new Assignment(x, b);
     var rule = new Add_mul_id_c_id_Rule(new SsaEvaluationContext(null, ssaIds));
     Assert.IsTrue(rule.Match(b));
     ass.Src = rule.Transform();
     Assert.AreEqual("x = id *u 0x00000006", ass.ToString());
 }
Пример #4
0
        public void Test1()
        {
            BinaryExpression b = m.IAdd(m.SMul(id, 4), id);
            Assignment ass = new Assignment(x, b);
            Statement stm = new Statement(0, ass, null);
            ssaIds[id].Uses.Add(stm);
            ssaIds[id].Uses.Add(stm);

            ctx.Statement = stm;
            Add_mul_id_c_id_Rule rule = new Add_mul_id_c_id_Rule(ctx);
            Assert.IsTrue(rule.Match(b));
            Assert.AreEqual(2, ssaIds[id].Uses.Count);
            ass.Src = rule.Transform();
            Assert.AreEqual("x = id *s 0x00000005", ass.ToString());
            Assert.AreEqual(1, ssaIds[id].Uses.Count);
        }
Пример #5
0
 public ExpressionSimplifier(SegmentMap segmentMap, EvaluationContext ctx, DecompilerEventListener listener)
 {
     this.segmentMap              = segmentMap ?? throw new ArgumentNullException(nameof(SegmentMap));
     this.ctx                     = ctx;
     this.cmp                     = new ExpressionValueComparer();
     this.m                       = new ExpressionEmitter();
     this.unifier                 = new Unifier();
     this.add2ids                 = new AddTwoIdsRule(ctx);
     this.addEcc                  = new Add_e_c_cRule(ctx);
     this.addMici                 = new Add_mul_id_c_id_Rule(ctx);
     this.idConst                 = new IdConstant(ctx, unifier, listener);
     this.idCopyPropagation       = new IdCopyPropagationRule(ctx);
     this.idBinIdc                = new IdBinIdc_Rule(ctx);
     this.sliceConst              = new SliceConstant_Rule();
     this.sliceMem                = new SliceMem_Rule();
     this.sliceSegPtr             = new SliceSegmentedPointer_Rule(ctx);
     this.negSub                  = new NegSub_Rule();
     this.constConstBin           = new ConstConstBin_Rule();
     this.shAdd                   = new Shl_add_Rule(ctx);
     this.shMul                   = new Shl_mul_e_Rule(ctx);
     this.shiftShift              = new ShiftShift_c_c_Rule(ctx);
     this.mpsRule                 = new Mps_Constant_Rule(ctx);
     this.sliceShift              = new SliceShift(ctx);
     this.binopWithSelf           = new BinOpWithSelf_Rule();
     this.constDiv                = new ConstDivisionImplementedByMultiplication(ctx);
     this.idProcConstRule         = new IdProcConstRule(ctx);
     this.convertConvertRule      = new ConvertConvertRule(ctx);
     this.distributedConvert      = new DistributedConversionRule();
     this.distributedCast         = new DistributedCastRule();
     this.distributedSlice        = new DistributedSliceRule();
     this.mkSeqFromSlicesRule     = new MkSeqFromSlices_Rule(ctx);
     this.constOnLeft             = new ComparisonConstOnLeft();
     this.sliceSeq                = new SliceSequence(ctx);
     this.sliceConvert            = new SliceConvert();
     this.logicalNotFollowedByNeg = new LogicalNotFollowedByNegRule();
     this.logicalNotFromBorrow    = new LogicalNotFromArithmeticSequenceRule();
     this.unaryNegEqZero          = new UnaryNegEqZeroRule();
     this.scaledIndexRule         = new ScaledIndexRule(ctx);
 }
Пример #6
0
        public ExpressionSimplifier(EvaluationContext ctx)
        {
            this.ctx = ctx;

            this.add2ids           = new AddTwoIdsRule(ctx);
            this.addEcc            = new Add_e_c_cRule(ctx);
            this.addMici           = new Add_mul_id_c_id_Rule(ctx);
            this.dpbConstantRule   = new DpbConstantRule();
            this.dpbdpbRule        = new DpbDpbRule(ctx);
            this.idConst           = new IdConstant(ctx, new Unifier());
            this.idCopyPropagation = new IdCopyPropagationRule(ctx);
            this.idBinIdc          = new IdBinIdc_Rule(ctx);
            this.sliceConst        = new SliceConstant_Rule();
            this.sliceMem          = new SliceMem_Rule();
            this.negSub            = new NegSub_Rule();
            this.constConstBin     = new ConstConstBin_Rule();
            this.shMul             = new Shl_mul_e_Rule(ctx);
            this.shiftShift        = new ShiftShift_c_c_Rule(ctx);
            this.mpsRule           = new Mps_Constant_Rule(ctx);
            this.sliceShift        = new SliceShift(ctx);
            this.binopWithSelf     = new BinOpWithSelf_Rule();
        }