/// <summary> /// Performs type analysis and rewrites program based on the inferred /// information. /// </summary> /// <remarks> /// For instance, all MemoryAccesses will be converted to structure /// field accesses or array accesses as appropriate. /// </remarks> /// <param name="program"></param> public void RewriteProgram(Program program) { factory = program.TypeFactory; store = program.TypeStore; aen = new ExpressionNormalizer(program.Platform.PointerType); eqb = new EquivalenceClassBuilder(factory, store, eventListener); tyco = new TypeCollector( program.TypeFactory, program.TypeStore, program, eventListener); //dpa = new DerivedPointerAnalysis(factory, store, program.Architecture); tvr = new TypeVariableReplacer(store); trans = new TypeTransformer(factory, store,program, eventListener); ctn = new ComplexTypeNamer(); ter = new TypedExpressionRewriter(program, eventListener); // RestrictProcedures(program, 0, 60, true); // Re-enable this for debugging aen.Transform(program); eqb.Build(program); tyco.CollectTypes(); store.BuildEquivalenceClassDataTypes(factory); //dpa.FollowConstantPointers(prog); tvr.ReplaceTypeVariables(); eventListener.ShowStatus("Transforming datatypes."); var ppr = new PtrPrimitiveReplacer(factory, store, program); ppr.ReplaceAll(eventListener); trans.Transform(); ctn.RenameAllTypes(store); ter.RewriteProgram(program); }
/// <summary> /// Performs type analysis and rewrites program based on the inferred information. /// </summary> /// <remarks> /// For instance, all MemoryAccesses will be converted to structure field /// accesses or array accesses as appropriate. /// </remarks> /// <param name="program"></param> public void RewriteProgram(Program program) { factory = program.TypeFactory; store = program.TypeStore; aen = new ExpressionNormalizer(program.Platform.PointerType); eqb = new EquivalenceClassBuilder(factory, store); #if OLD dtb = new DataTypeBuilder(factory, store, program.Platform); trco = new TraitCollector(factory, store, dtb, program); #else tyco = new TypeCollector(program.TypeFactory, program.TypeStore, program); #endif //dpa = new DerivedPointerAnalysis(factory, store, program.Architecture); tvr = new TypeVariableReplacer(store); trans = new TypeTransformer(factory, store, program, eventListener); ctn = new ComplexTypeNamer(); ter = new TypedExpressionRewriter(program); // RestrictProcedures(program, 0, 1, true); // Re-enable this for debugging eventListener.ShowStatus("Gathering primitive datatypes from instructions."); aen.Transform(program); eqb.Build(program); #if OLD eventListener.ShowStatus("Collecting datatype usage traits."); trco.CollectProgramTraits(program); eventListener.ShowStatus("Building equivalence classes."); dtb.BuildEquivalenceClassDataTypes(); #else eventListener.ShowStatus("Collecting data types"); tyco.CollectTypes(); store.BuildEquivalenceClassDataTypes(factory); #endif //dpa.FollowConstantPointers(prog); tvr.ReplaceTypeVariables(); eventListener.ShowStatus("Transforming datatypes."); var ppr = new PtrPrimitiveReplacer(factory, store, program); ppr.ReplaceAll(); trans.Transform(); ctn.RenameAllTypes(store); store.Dump(); eventListener.ShowStatus("Rewriting expressions."); ter.RewriteProgram(program); }
/// <summary> /// Performs type analysis and rewrites program based on the inferred /// information. /// </summary> /// <remarks> /// For instance, all MemoryAccesses will be converted to structure /// field accesses or array accesses as appropriate. /// </remarks> /// <param name="program"></param> public void RewriteProgram(Program program) { factory = program.TypeFactory; store = program.TypeStore; var timer = new Stopwatch(); aen = new ExpressionNormalizer(program.Platform.PointerType); eqb = new EquivalenceClassBuilder(factory, store, eventListener); tyco = new TypeCollector( program.TypeFactory, program.TypeStore, program, eventListener); //dpa = new DerivedPointerAnalysis(factory, store, program.Architecture); tvr = new TypeVariableReplacer(store); trans = new TypeTransformer(factory, store, program, eventListener); ctn = new ComplexTypeNamer(); ter = new TypedExpressionRewriter(program, eventListener); // RestrictProcedures(program, 0, 60, true); // Re-enable this for debugging Time("Normalizing expressions", () => aen.Transform(program)); Time("Building equivalence classes", () => eqb.Build(program)); Time("Collecting data types", tyco.CollectTypes); Time("Build eq. class data types", () => store.BuildEquivalenceClassDataTypes(factory)); //dpa.FollowConstantPointers(program); Time("Replacing type variables", tvr.ReplaceTypeVariables); eventListener.ShowStatus("Transforming datatypes."); Time("Replace primitive types", () => { var ppr = new PtrPrimitiveReplacer(factory, store, program); ppr.ReplaceAll(eventListener); }); Time("Transforming data types", trans.Transform); Time("Renaming data types", () => ctn.RenameAllTypes(store)); Time("Rewriting program with type information", () => ter.RewriteProgram(program)); }