protected override void RunTest(Program program, TextWriter writer) { SetCSignatures(program); IImportResolver importResolver = mr.Stub <IImportResolver>(); importResolver.Replay(); dfa = new DataFlowAnalysis(program, importResolver, new FakeDecompilerEventListener()); dfa.AnalyzeProgram(); foreach (Procedure proc in program.Procedures.Values) { ProcedureFlow flow = dfa.ProgramDataFlow[proc]; writer.Write("// "); var sig = flow.Signature ?? proc.Signature; sig.Emit(proc.Name, FunctionType.EmitFlags.ArgumentKind | FunctionType.EmitFlags.LowLevelInfo, writer); flow.Emit(program.Architecture, writer); proc.Write(false, writer); writer.WriteLine(); } }
public void RunTest(IEnumerable <Procedure> procs) { importResolver = MockRepository.GenerateStub <IImportResolver>(); importResolver.Replay(); var flow = new ProgramDataFlow(program); var scc = new Dictionary <Procedure, SsaState>(); foreach (var proc in procs) { Aliases alias = new Aliases(proc, program.Architecture, flow); alias.Transform(); // Transform the procedure to SSA state. When encountering 'call' instructions, // they can be to functions already visited. If so, they have a "ProcedureFlow" // associated with them. If they have not been visited, or are computed destinations // (e.g. vtables) they will have no "ProcedureFlow" associated with them yet, in // which case the the SSA treats the call as a "hell node". var doms = proc.CreateBlockDominatorGraph(); var sst = new SsaTransform( flow, proc, importResolver, doms, program.Platform.CreateImplicitArgumentRegisters()); sst.AddUseInstructions = true; sst.Transform(); var ssa = sst.SsaState; scc.Add(proc, ssa); } this.dataFlow = new DataFlow2(); var regp = new RegisterPreservation(scc, dataFlow); regp.Compute(); }