Match() public method

public Match ( Identifier id ) : bool
id Identifier
return bool
Ejemplo n.º 1
0
 public virtual Expression VisitIdentifier(Identifier id)
 {
     if (idConst.Match(id))
     {
         Changed = true;
         return(idConst.Transform());
     }
     if (idProcConstRule.Match(id))
     {
         Changed = true;
         return(idProcConstRule.Transform());
     }
     // jkl: Copy propagation causes real problems when used during trashed register analysis.
     // If needed in other passes, it should be an option for expression e
     if (idCopyPropagation.Match(id))
     {
         Changed = true;
         return(idCopyPropagation.Transform());
     }
     if (idBinIdc.Match(id))
     {
         Changed = true;
         return(idBinIdc.Transform());
     }
     return(id);
 }
Ejemplo n.º 2
0
        public void Idc_ConstantReferenceInt()
        {
            var dword = new TypeReference("DWORD", PrimitiveType.Int32);
            Identifier edx = new Identifier("edx", dword, Registers.edx);

            var ctx = new SymbolicEvaluationContext(null, null);
            ctx.SetValue(edx, Constant.Int32(321));

            IdConstant ic = new IdConstant(ctx, new Unifier(null));
            Assert.IsTrue(ic.Match(edx));
            Expression e = ic.Transform();
            Assert.AreEqual("321", e.ToString());
            Assert.AreEqual("int32", e.DataType.ToString());
        }
Ejemplo n.º 3
0
		public void ConstantPropagate()
		{
			Identifier ds = m.Frame.EnsureRegister(Registers.ds);
            var c = Constant.Word16(0x1234);
            m.Assign(ds, c);
			m.SideEffect(ds);
            var def = m.Block.Statements[0];
            var use = m.Block.Statements[1];
			SsaIdentifier sid_ds = ssa.Add(ds, def, c, false);
            var ass = (Assignment)def.Instruction;
            ass.Dst = sid_ds.Identifier;
            ((SideEffect)use.Instruction).Expression = sid_ds.Identifier;
			sid_ds.Uses.Add(use);

			IdConstant ic = new IdConstant(new SsaEvaluationContext(ssa), new Unifier(null));
            Assert.IsTrue(ic.Match(sid_ds.Identifier));
			Expression e = ic.Transform();
			Assert.AreEqual("selector", e.DataType.ToString());
		}
Ejemplo n.º 4
0
        public void Idc_ConstantReferencePointerToInt()
        {
            var intptr = new TypeReference("INTPTR", new Pointer(PrimitiveType.Int32, 4));
            Identifier edx = new Identifier("edx", intptr, Registers.edx);

            var ctx = new SymbolicEvaluationContext(null, null);
            ctx.SetValue(edx, Constant.Int32(0x567));

            IdConstant ic = new IdConstant(ctx, new Unifier(null));
            Assert.IsTrue(ic.Match(edx));
            Expression e = ic.Transform();
            Assert.AreEqual("00000567", e.ToString());
            Assert.AreEqual("(ptr int32)", e.DataType.ToString());
        }