本文整理汇总了C#中TraitCollector.CollectProgramTraits方法的典型用法代码示例。如果您正苦于以下问题:C# TraitCollector.CollectProgramTraits方法的具体用法?C# TraitCollector.CollectProgramTraits怎么用?C# TraitCollector.CollectProgramTraits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraitCollector
的用法示例。
在下文中一共展示了TraitCollector.CollectProgramTraits方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTest
protected override void RunTest(Program program, string outputFileName)
{
ExpressionNormalizer aen = new ExpressionNormalizer(program.Architecture.PointerType);
aen.Transform(program);
EquivalenceClassBuilder eq = new EquivalenceClassBuilder(factory, store);
eq.Build(program);
#if OLD
DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Architecture);
TraitCollector coll = new TraitCollector(factory, store, dtb, program);
coll.CollectProgramTraits(program);
dtb.BuildEquivalenceClassDataTypes();
#else
TypeCollector coll = new TypeCollector(factory, store, program);
coll.CollectTypes();
store.BuildEquivalenceClassDataTypes(factory);
#endif
TypeVariableReplacer tvr = new TypeVariableReplacer(store);
tvr.ReplaceTypeVariables();
TypeTransformer trans = new TypeTransformer(factory, store, program);
trans.Transform();
using (FileUnitTester fut = new FileUnitTester(outputFileName))
{
foreach (Procedure proc in program.Procedures.Values)
{
proc.Write(false, fut.TextWriter);
fut.TextWriter.WriteLine();
}
store.Write(fut.TextWriter);
fut.AssertFilesEqual();
}
}
示例2: RunTest
protected override void RunTest(Program prog, string outputFilename)
{
eqb.Build(prog);
trco = new TraitCollector(factory, store, dtb, prog);
trco.CollectProgramTraits(prog);
dtb.BuildEquivalenceClassDataTypes();
store.CopyClassDataTypesToTypeVariables();
TypeVariableReplacer tvr = new TypeVariableReplacer(store);
tvr.ReplaceTypeVariables();
Verify(outputFilename);
}
示例3: RunTest
protected override void RunTest(Program program, string outputFileName)
{
ExpressionNormalizer aen = new ExpressionNormalizer(program.Architecture.PointerType);
aen.Transform(program);
EquivalenceClassBuilder eq = new EquivalenceClassBuilder(factory, store);
eq.Build(program);
#if OLD
DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Architecture);
TraitCollector coll = new TraitCollector(factory, store, dtb, program);
coll.CollectProgramTraits(program);
sktore.BuildEquivalenceClassDataTypes(factory);
#else
TypeCollector coll = new TypeCollector(factory, store, program, new FakeDecompilerEventListener());
coll.CollectTypes();
store.BuildEquivalenceClassDataTypes(factory);
#endif
TypeVariableReplacer tvr = new TypeVariableReplacer(store);
tvr.ReplaceTypeVariables();
Exception theEx = null;
try
{
TypeTransformer trans = new TypeTransformer(factory, store, program);
trans.Transform();
} catch (Exception ex)
{
theEx = ex;
}
using (FileUnitTester fut = new FileUnitTester(outputFileName))
{
if (theEx != null)
{
fut.TextWriter.WriteLine(theEx.Message);
fut.TextWriter.WriteLine(theEx.StackTrace);
}
foreach (Procedure proc in program.Procedures.Values)
{
proc.Write(false, fut.TextWriter);
fut.TextWriter.WriteLine();
}
store.Write(fut.TextWriter);
fut.AssertFilesEqual();
}
}
示例4: RunTest
private void RunTest(Program program, string outputFile)
{
EquivalenceClassBuilder eqb = new EquivalenceClassBuilder(factory, store);
DataTypeBuilder dtb = new DataTypeBuilder(factory, store, program.Platform);
eqb.Build(program);
TraitCollector trco = new TraitCollector(factory, store, dtb, program);
trco.CollectProgramTraits(program);
dtb.BuildEquivalenceClassDataTypes();
var tv = new TypeVariableReplacer(store);
tv.ReplaceTypeVariables();
store.CopyClassDataTypesToTypeVariables();
var ppr = new PtrPrimitiveReplacer(factory, store, program);
ppr.ReplaceAll(new FakeDecompilerEventListener());
var cpa = new ConstantPointerAnalysis(factory, store, program);
cpa.FollowConstantPointers();
Verify(null, outputFile);
}
示例5: RunTest
protected override void RunTest(Program prog, string outputFilename)
{
TypeFactory factory = new TypeFactory();
store = new TypeStore();
EquivalenceClassBuilder eqb = new EquivalenceClassBuilder(factory, store);
eqb.Build(prog);
DataTypeBuilder dtb = new DataTypeBuilder(factory, store, prog.Platform);
TraitCollector trco = new TraitCollector(factory, store, dtb, prog);
trco.CollectProgramTraits(prog);
dtb.BuildEquivalenceClassDataTypes();
store.CopyClassDataTypesToTypeVariables();
TypeVariableReplacer tvr = new TypeVariableReplacer(store);
tvr.ReplaceTypeVariables();
PtrPrimitiveReplacer ppr = new PtrPrimitiveReplacer(factory, store, prog);
ppr.ReplaceAll(new FakeDecompilerEventListener());
Verify(prog, outputFilename);
}
示例6: RunTest
protected override void RunTest(Program program, string outputFile)
{
using (FileUnitTester fut = new FileUnitTester(outputFile))
{
fut.TextWriter.WriteLine("// Before ///////");
DumpProgram(program, fut);
SetupPreStages(program);
aen.Transform(program);
eqb.Build(program);
#if OLD
coll = new TraitCollector(factory, store, dtb, program);
coll.CollectProgramTraits(program);
#else
var coll = new TypeCollector(program.TypeFactory, program.TypeStore, program);
coll.CollectTypes();
#endif
program.TypeStore.BuildEquivalenceClassDataTypes(program.TypeFactory);
program.TypeStore.Dump();
tvr.ReplaceTypeVariables();
trans.Transform();
ctn.RenameAllTypes(program.TypeStore);
ter = new TypedExpressionRewriter(program);
try
{
ter.RewriteProgram(program);
}
catch (Exception ex)
{
fut.TextWriter.WriteLine("** Exception **");
fut.TextWriter.WriteLine(ex);
}
finally
{
fut.TextWriter.WriteLine("// After ///////");
DumpProgAndStore(program, fut);
}
}
}
示例7: RewriteProgram
/// <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);
dtb = new DataTypeBuilder(factory, store, program.Platform);
trco = new TraitCollector(factory, store, dtb, program);
//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);
eventListener.ShowStatus("Collecting datatype usage traits.");
trco.CollectProgramTraits(program);
eventListener.ShowStatus("Building equivalence classes.");
dtb.BuildEquivalenceClassDataTypes();
//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);
}
示例8: RunStringTest
protected void RunStringTest(Program program, string expectedOutput)
{
var sw = new StringWriter();
sw.WriteLine("// Before ///////");
DumpProgram(program, sw);
var eventListener = new FakeDecompilerEventListener();
SetupPreStages(program);
aen.Transform(program);
eqb.Build(program);
#if OLD
coll = new TraitCollector(program.TypeFactory, program.TypeStore, dtb, program);
coll.CollectProgramTraits(program);
#else
var coll = new TypeCollector(program.TypeFactory, program.TypeStore, program, eventListener);
coll.CollectTypes();
#endif
program.TypeStore.BuildEquivalenceClassDataTypes(program.TypeFactory);
tvr.ReplaceTypeVariables();
trans.Transform();
ctn.RenameAllTypes(program.TypeStore);
var ter = new TypedExpressionRewriter(program, eventListener);
try
{
ter.RewriteProgram(program);
}
catch (Exception ex)
{
sw.WriteLine("** Exception **");
sw.WriteLine(ex);
throw;
}
finally
{
sw.WriteLine("// After ///////");
DumpProgram(program, sw);
}
var sActual = sw.ToString();
if (expectedOutput != sActual)
{
Debug.Print(sActual);
Assert.AreEqual(expectedOutput, sActual);
}
}
示例9: RunTest
protected override void RunTest(Program prog, string outFile)
{
coll = CreateCollector(prog);
en.Transform(prog);
eqb.Build(prog);
coll.CollectProgramTraits(prog);
using (FileUnitTester fut = new FileUnitTester(outFile))
{
foreach (Procedure proc in prog.Procedures.Values)
{
proc.Write(false, fut.TextWriter);
fut.TextWriter.WriteLine();
}
handler.Traits.Write(fut.TextWriter);
fut.AssertFilesEqual();
}
}
示例10: TrcoStaggeredArraysMock
public void TrcoStaggeredArraysMock()
{
ProgramBuilder mock = new ProgramBuilder();
mock.Add(new StaggeredArraysFragment());
Program prog = mock.BuildProgram();
coll = CreateCollector(prog);
en.Transform(prog);
eqb.Build(prog);
coll.CollectProgramTraits(prog);
Verify(prog, "Typing/TrcoStaggeredArraysMock.txt");
}
示例11: TrcoCmpMock
public void TrcoCmpMock()
{
ProgramBuilder mock = new ProgramBuilder();
mock.Add(new CmpMock());
Program prog = mock.BuildProgram();
coll = CreateCollector(prog);
eqb.Build(prog);
coll.CollectProgramTraits(prog);
Verify(prog, "Typing/TrcoCmpMock.txt");
}