Exemplo n.º 1
0
        protected override void RunTest(Program program, TextWriter writer)
        {
            var importResolver = MockRepository.GenerateStub <IImportResolver>();

            importResolver.Replay();
            var dfa = new DataFlowAnalysis(program, importResolver, new FakeDecompilerEventListener());

            dfa.UntangleProcedures();
            foreach (Procedure proc in program.Procedures.Values)
            {
                Aliases alias = new Aliases(proc, program.Architecture);
                alias.Transform();
                SsaTransform sst = new SsaTransform(
                    dfa.ProgramDataFlow,
                    proc,
                    importResolver,
                    proc.CreateBlockDominatorGraph(),
                    new HashSet <RegisterStorage>());
                SsaState            ssa  = sst.SsaState;
                GrfDefinitionFinder grfd = new GrfDefinitionFinder(ssa.Identifiers);
                foreach (SsaIdentifier sid in ssa.Identifiers)
                {
                    var id = sid.OriginalIdentifier as Identifier;
                    if (id == null || !(id.Storage is FlagGroupStorage) || sid.Uses.Count == 0)
                    {
                        continue;
                    }
                    writer.Write("{0}: ", sid.DefStatement.Instruction);
                    grfd.FindDefiningExpression(sid);
                    string fmt = grfd.IsNegated ? "!{0};" : "{0}";
                    writer.WriteLine(fmt, grfd.DefiningExpression);
                }
            }
        }
Exemplo n.º 2
0
        protected override void RunTest(Program program, TextWriter writer)
        {
            var dynamicLinker = new Mock <IDynamicLinker>();
            var flow          = new ProgramDataFlow(program);
            var sst           = new SsaTransform(
                program,
                program.Procedures.Values[0],
                new HashSet <Procedure>(),
                dynamicLinker.Object,
                flow);
            var ssa  = sst.Transform();
            var grfd = new GrfDefinitionFinder(ssa.Identifiers);

            foreach (SsaIdentifier sid in ssa.Identifiers)
            {
                var id = sid.OriginalIdentifier;
                if (id == null || !(id.Storage is FlagGroupStorage) || sid.Uses.Count == 0)
                {
                    continue;
                }
                writer.Write("{0}: ", sid.DefStatement.Instruction);
                grfd.FindDefiningExpression(sid);
                string fmt = grfd.IsNegated ? "!{0};" : "{0}";
                writer.WriteLine(fmt, grfd.DefiningExpression);
            }
        }