本文整理汇总了C#中TraitCollector类的典型用法代码示例。如果您正苦于以下问题:C# TraitCollector类的具体用法?C# TraitCollector怎么用?C# TraitCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TraitCollector类属于命名空间,在下文中一共展示了TraitCollector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:gh0std4ncer,项目名称:reko,代码行数:33,代码来源:TypeTransformTests.cs
示例2: DtbArrayAccess2
public void DtbArrayAccess2()
{
ProcedureBuilder m = new ProcedureBuilder();
Identifier ds = m.Local(PrimitiveType.SegmentSelector, "ds");
Identifier bx = m.Local16("bx");
Expression e = m.Array(PrimitiveType.Word32, m.Seq(ds, m.Word16(0x300)), m.IMul(bx, 8));
e.Accept(eqb);
TraitCollector coll = new TraitCollector(factory, store, dtb, program);
e.Accept(coll);
Verify("Typing/DtbArrayAccess2.txt");
}
开发者ID:nemerle,项目名称:reko,代码行数:12,代码来源:DataTypeBuilderTests.cs
示例3: 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);
}
开发者ID:gitter-badger,项目名称:reko,代码行数:13,代码来源:TypeVarReplacerTests.cs
示例4: 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();
}
}
开发者ID:relaxar,项目名称:reko,代码行数:46,代码来源:TypeTransformTests.cs
示例5: 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);
#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);
}
开发者ID:gitter-badger,项目名称:reko,代码行数:54,代码来源:TypeAnalyzer.cs
示例6: 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);
}
开发者ID:relaxar,项目名称:reko,代码行数:19,代码来源:ConstantPointerAnalysisTests.cs
示例7: 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);
}
开发者ID:relaxar,项目名称:reko,代码行数:20,代码来源:PtrPrimitiveReplacerTests.cs
示例8: 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);
}
}
}
开发者ID:killbug2004,项目名称:reko,代码行数:40,代码来源:TypedExpressionRewriterTests.cs
示例9: TvrReplaceInMem
public void TvrReplaceInMem()
{
var id1 = new Identifier("pptr", PrimitiveType.Word32, null);
var id2 = new Identifier("ptr", PrimitiveType.Word32, null);
var id3 = new Identifier("v", PrimitiveType.Word32, null);
var ass1 = new Assignment(id2, MemLoad(id1, 0, PrimitiveType.Word32));
var ass2 = new Assignment(id3, MemLoad(id2, 0, PrimitiveType.Word32));
eqb.VisitAssignment(ass1);
eqb.VisitAssignment(ass2);
var prog = new Program();
prog.Architecture = new FakeArchitecture();
prog.Platform = new DefaultPlatform(null, prog.Architecture);
trco = new TraitCollector(factory, store, dtb, prog);
trco.VisitAssignment(ass1);
trco.VisitAssignment(ass2);
dtb.BuildEquivalenceClassDataTypes();
var tvr = new TypeVariableReplacer(store);
tvr.ReplaceTypeVariables();
Verify("Typing/TvrReplaceInMem.txt");
}
开发者ID:nemerle,项目名称:reko,代码行数:22,代码来源:TypeVarReplacerTests.cs
示例10: DtbSegmentedDirectAddress
public void DtbSegmentedDirectAddress()
{
ProcedureBuilder m = new ProcedureBuilder();
var arch = new Decompiler.Arch.X86.IntelArchitecture(Decompiler.Arch.X86.ProcessorMode.Real);
var prog = new Program
{
Architecture = arch,
Platform = new DefaultPlatform(null, arch)
};
store.EnsureExpressionTypeVariable(factory, prog.Globals);
Identifier ds = m.Local16("ds");
Expression e = m.SegMem(PrimitiveType.Byte, ds, m.Int16(0x0200));
TraitCollector coll = new TraitCollector(factory, store, dtb, prog);
e = e.Accept(aen);
e.Accept(eqb);
e.Accept(coll);
dtb.BuildEquivalenceClassDataTypes();
Verify("Typing/DtbSegmentedDirectAddress.txt");
}
开发者ID:killbug2004,项目名称:reko,代码行数:21,代码来源:DataTypeBuilderTests.cs
示例11: DtbInductionVariables
public void DtbInductionVariables()
{
Identifier i = new Identifier("i", PrimitiveType.Word32, null);
MemoryAccess load = new MemoryAccess(MemoryIdentifier.GlobalMemory, i, PrimitiveType.Int32);
Identifier i2 = new Identifier("i2", PrimitiveType.Word32, null);
MemoryAccess ld2 = new MemoryAccess(MemoryIdentifier.GlobalMemory, i2, PrimitiveType.Int32);
LinearInductionVariable iv = new LinearInductionVariable(
Constant.Word32(0),
Constant.Word32(1),
Constant.Word32(10),
false);
LinearInductionVariable iv2 = new LinearInductionVariable(
Constant.Word32(0x0010000),
Constant.Word32(4),
Constant.Word32(0x0010040),
false);
prog.InductionVariables.Add(i, iv);
prog.InductionVariables.Add(i2, iv2);
prog.Platform = new DefaultPlatform(null, arch);
TraitCollector trco = new TraitCollector(factory, store, dtb, prog);
prog.Globals.Accept(eqb);
load.Accept(eqb);
ld2.Accept(eqb);
prog.Globals.Accept(trco);
load.Accept(trco);
ld2.Accept(trco);
dtb.BuildEquivalenceClassDataTypes();
Verify("Typing/DtbInductionVariables.txt");
}
开发者ID:killbug2004,项目名称:reko,代码行数:33,代码来源:DataTypeBuilderTests.cs
示例12: 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);
}
}
开发者ID:relaxar,项目名称:reko,代码行数:45,代码来源:TypedExpressionRewriterTests.cs
示例13: DtbRepeatedLoads
public void DtbRepeatedLoads()
{
Identifier pfoo = new Identifier("pfoo", PrimitiveType.Word32, null);
Identifier x = new Identifier("x", PrimitiveType.Word32, null);
Assignment ass1 = new Assignment(x, MemLoad(pfoo, 4, PrimitiveType.Word32));
Assignment ass2 = new Assignment(x, MemLoad(pfoo, 4, PrimitiveType.Word32));
ass1.Accept(eqb);
ass2.Accept(eqb);
TraitCollector trco = new TraitCollector(factory, store, dtb, prog);
trco.VisitAssignment(ass1);
trco.VisitAssignment(ass2);
dtb.BuildEquivalenceClassDataTypes();
Verify("Typing/DtbRepeatedLoads.txt");
}
开发者ID:killbug2004,项目名称:reko,代码行数:15,代码来源:DataTypeBuilderTests.cs
示例14: DtbSameMemFetch
public void DtbSameMemFetch()
{
Identifier foo = new Identifier("foo", PrimitiveType.Word32, null);
Identifier bar = new Identifier("bar", PrimitiveType.Word16, null);
Identifier baz = new Identifier("baz", PrimitiveType.Word16, null);
Assignment ass1 = new Assignment(bar, MemLoad(foo, 4, PrimitiveType.Word16));
Assignment ass2 = new Assignment(baz, MemLoad(foo, 4, PrimitiveType.Word16));
ass1.Accept(eqb);
ass2.Accept(eqb);
TraitCollector trco = new TraitCollector(factory, store, dtb, prog);
trco.VisitAssignment(ass1);
trco.VisitAssignment(ass2);
dtb.BuildEquivalenceClassDataTypes();
Verify("Typing/DtbSameMemFetch.txt");
}
开发者ID:killbug2004,项目名称:reko,代码行数:16,代码来源:DataTypeBuilderTests.cs
示例15: DtbSegmentedAccess
public void DtbSegmentedAccess()
{
ProcedureBuilder m = new ProcedureBuilder();
Identifier ds = m.Local16("ds");
Identifier bx = m.Local16("bx");
Expression e = m.SegMem(bx.DataType, ds, m.IAdd(bx, 4));
var arch = new Decompiler.Arch.X86.IntelArchitecture(Decompiler.Arch.X86.ProcessorMode.Real);
Program prog = new Program
{
Architecture = arch,
Platform = new DefaultPlatform(null, arch),
};
TraitCollector trco = new TraitCollector(factory, store, dtb, prog);
e = e.Accept(aen);
e.Accept(eqb);
e.Accept(trco);
dtb.BuildEquivalenceClassDataTypes();
Verify("Typing/DtbSegmentedAccess.txt");
}
开发者ID:killbug2004,项目名称:reko,代码行数:20,代码来源:DataTypeBuilderTests.cs
示例16: TerComplex
public void TerComplex()
{
Program program = new Program();
program.SegmentMap = new SegmentMap(Address.Ptr32(0x0010000));
program.Architecture = new FakeArchitecture();
program.Platform = new DefaultPlatform(null, program.Architecture);
SetupPreStages(program);
Identifier id = new Identifier("v0", PrimitiveType.Word32, null);
Expression cmp = MemLoad(id, 4, PrimitiveType.Word32);
program.Globals.Accept(eqb);
cmp.Accept(aen);
cmp.Accept(eqb);
coll = new TraitCollector(program.TypeFactory, program.TypeStore, dtb, program);
cmp.Accept(coll);
dtb.BuildEquivalenceClassDataTypes();
tvr.ReplaceTypeVariables();
trans.Transform();
ctn.RenameAllTypes(program.TypeStore);
ter = new TypedExpressionRewriter(program, null);
cmp = cmp.Accept(ter);
Assert.AreEqual("v0->dw0004", cmp.ToString());
}
开发者ID:relaxar,项目名称:reko,代码行数:25,代码来源:TypedExpressionRewriterTests.cs
示例17: TrcoArrayExpression
public void TrcoArrayExpression()
{
var b = new Identifier("base", PrimitiveType.Word32, null);
var i = new Identifier("idx", PrimitiveType.Word32, null);
var s = Constant.Word32(4);
ProcedureBuilder m = new ProcedureBuilder();
// e ::= Mem[(b+0x1003000)+(i*s):word16]
Expression e = m.Load(
PrimitiveType.Word16,
m.IAdd(m.IAdd(b, Constant.Word32(0x10030000)),
m.SMul(i, s)));
coll = CreateCollector();
e = e.Accept(en);
e.Accept(eqb);
e.Accept(coll);
Verify(null, "Typing/TrcoArrayExpression.txt");
}
开发者ID:gitter-badger,项目名称:reko,代码行数:19,代码来源:TraitCollectorTests.cs
示例18: 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();
}
}
开发者ID:gitter-badger,项目名称:reko,代码行数:18,代码来源:TraitCollectorTests.cs
示例19: TrcoGlobalArray
public void TrcoGlobalArray()
{
Program prog = CreateProgram();
ProcedureBuilder m = new ProcedureBuilder();
Identifier i = m.Local32("i");
Expression ea = m.IAdd(prog.Globals, m.IAdd(m.Shl(i, 2), 0x3000));
Expression e = m.Load(PrimitiveType.Int32, ea);
coll = CreateCollector(prog);
e = e.Accept(en);
e.Accept(eqb);
e.Accept(coll);
Verify(null, "Typing/TrcoGlobalArray.txt");
}
开发者ID:gitter-badger,项目名称:reko,代码行数:14,代码来源:TraitCollectorTests.cs
示例20: TrcoSegMem
public void TrcoSegMem()
{
ProcedureBuilder m = new ProcedureBuilder();
Identifier ds = m.Local16("ds");
Expression e = m.SegMemW(ds, m.Word16(0xC002U));
coll = CreateCollector();
e.Accept(eqb);
e.Accept(coll);
Verify(null, "Typing/TrcoSegMem.txt");
}
开发者ID:gitter-badger,项目名称:reko,代码行数:11,代码来源:TraitCollectorTests.cs
注:本文中的TraitCollector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论