本文整理汇总了C#中ITextOutput.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ITextOutput.Write方法的具体用法?C# ITextOutput.Write怎么用?C# ITextOutput.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextOutput
的用法示例。
在下文中一共展示了ITextOutput.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
public static void WriteTo(this ExceptionHandler exceptionHandler, ITextOutput writer, MethodDef method)
{
writer.Write("Try", TextTokenType.Keyword);
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.TryStart, method);
writer.Write('-', TextTokenType.Operator);
WriteOffsetReference(writer, exceptionHandler.TryEnd, method);
writer.WriteSpace();
writer.Write(exceptionHandler.HandlerType.ToString(), TextTokenType.Keyword);
if (exceptionHandler.FilterStart != null) {
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.FilterStart, method);
writer.WriteSpace();
writer.Write("handler", TextTokenType.Keyword);
writer.WriteSpace();
}
if (exceptionHandler.CatchType != null) {
writer.WriteSpace();
exceptionHandler.CatchType.WriteTo(writer);
}
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.HandlerStart, method);
writer.Write('-', TextTokenType.Operator);
WriteOffsetReference(writer, exceptionHandler.HandlerEnd, method);
}
示例2: WriteILOffset
static void WriteILOffset(ITextOutput output, uint offset) {
// Offsets are always in hex
if (offset <= ushort.MaxValue)
output.Write(string.Format(GetHexFormatUInt16(), offset), TextTokenType.Number);
else
output.Write(string.Format(GetHexFormatUInt32(), offset), TextTokenType.Number);
}
示例3: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
if (!method.HasBody) {
return;
}
ILAstBuilder astBuilder = new ILAstBuilder();
ILBlock ilMethod = new ILBlock();
ilMethod.Body = astBuilder.Build(method, inlineVariables);
if (abortBeforeStep != null) {
DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method };
new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value);
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive<ILExpression>().Select(e => e.Operand as ILVariable)
.Where(v => v != null && !v.IsParameter).Distinct();
foreach (ILVariable v in allVariables) {
output.WriteDefinition(v.Name, v);
if (v.Type != null) {
output.Write(" : ");
if (v.IsPinned)
output.Write("pinned ");
v.Type.WriteTo(output, ILNameSyntax.ShortTypeName);
}
output.WriteLine();
}
output.WriteLine();
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output);
output.WriteLine();
}
}
示例4: DecompileMethod
public override void DecompileMethod(MethodDef method, ITextOutput output, DecompilationOptions options)
{
WriteComment(output, "Method: ");
output.WriteDefinition(IdentifierEscaper.Escape(method.FullName), method, TextTokenType.Comment, false);
output.WriteLine();
if (!method.HasBody) {
return;
}
StartKeywordBlock(output, ".body", method);
ILAstBuilder astBuilder = new ILAstBuilder();
ILBlock ilMethod = new ILBlock();
DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method };
ilMethod.Body = astBuilder.Build(method, inlineVariables, context);
if (abortBeforeStep != null) {
new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value);
}
if (context.CurrentMethodIsAsync) {
output.Write("async", TextTokenType.Keyword);
output.Write('/', TextTokenType.Operator);
output.WriteLine("await", TextTokenType.Keyword);
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive<ILExpression>().Select(e => e.Operand as ILVariable)
.Where(v => v != null && !v.IsParameter).Distinct();
foreach (ILVariable v in allVariables) {
output.WriteDefinition(IdentifierEscaper.Escape(v.Name), v, v.IsParameter ? TextTokenType.Parameter : TextTokenType.Local);
if (v.Type != null) {
output.WriteSpace();
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
if (v.IsPinned) {
output.Write("pinned", TextTokenType.Keyword);
output.WriteSpace();
}
v.Type.WriteTo(output, ILNameSyntax.ShortTypeName);
}
if (v.IsGenerated) {
output.WriteSpace();
output.Write('[', TextTokenType.Operator);
output.Write("generated", TextTokenType.Keyword);
output.Write(']', TextTokenType.Operator);
}
output.WriteLine();
}
var memberMapping = new MemberMapping(method);
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output, memberMapping);
if (!node.WritesNewLine)
output.WriteLine();
}
output.AddDebugSymbols(memberMapping);
EndKeywordBlock(output);
}
示例5: WriteLabelList
static void WriteLabelList(ITextOutput writer, Instruction[] instructions)
{
writer.Write("(");
for(int i = 0; i < instructions.Length; i++) {
if(i != 0) writer.Write(", ");
WriteOffsetReference(writer, instructions[i]);
}
writer.Write(")");
}
示例6: Write
protected override void Write(ITextOutput output) {
output.Write(string.Format("{0}", index + 1), TextTokenType.Number);
if (infoTuple != null) {
output.WriteSpace();
output.Write('-', TextTokenType.Operator);
output.WriteSpace();
infoTuple.Item2(output);
}
}
示例7: Write
public static ITextOutput Write(ITextOutput output, FieldDef field, Language language) {
output.Write(UIUtils.CleanUpIdentifier(field.Name), TextTokenHelper.GetTextTokenType(field));
output.WriteSpace();
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
language.TypeToString(output, field.FieldType.ToTypeDefOrRef(), false, field);
field.MDToken.WriteSuffixString(output);
return output;
}
示例8: Write
protected override void Write(ITextOutput output) {
output.Write(string.Format("{0:X2}", (byte)tablesStreamVM.Table), TextTokenType.Number);
output.WriteSpace();
output.Write(string.Format("{0}", tablesStreamVM.Table), TextTokenType.Type);
output.WriteSpace();
output.Write('(', TextTokenType.Operator);
output.Write(string.Format("{0}", tablesStreamVM.Rows), TextTokenType.Number);
output.Write(')', TextTokenType.Operator);
}
示例9: Write
public static ITextOutput Write(ITextOutput output, EventDef ev, Language language) {
output.Write(UIUtils.CleanUpIdentifier(ev.Name), TextTokenHelper.GetTextTokenType(ev));
output.WriteSpace();
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
language.TypeToString(output, ev.EventType, false, ev);
ev.MDToken.WriteSuffixString(output);
return output;
}
示例10: Write
protected override void Write(ITextOutput output) {
output.Write("Section", TextTokenType.Keyword);
output.WriteSpace();
output.Write('#', TextTokenType.Operator);
output.Write(sectionNumber.ToString(), TextTokenType.Number);
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
output.Write(string.Format("{0}", imageSectionHeaderVM.NameVM.String), TextTokenType.Type);
}
示例11: WriteTo
public static void WriteTo(this Instruction instruction, ITextOutput writer)
{
writer.WriteDefinition(CecilExtensions.OffsetToString(instruction.Offset), instruction);
writer.Write(": ");
writer.WriteReference(instruction.OpCode.Name, instruction.OpCode);
if(null != instruction.Operand) {
writer.Write(' ');
WriteOperand(writer, instruction.Operand);
}
}
示例12: Write
protected override void Write(ITextOutput output, Language language) {
if (hidesParent) {
output.Write('(', TextTokenType.Operator);
output.Write("hides", TextTokenType.Text);
output.Write(')', TextTokenType.Operator);
output.WriteSpace();
}
Language.TypeToString(output, analyzedEvent.DeclaringType, true);
output.Write('.', TextTokenType.Operator);
EventTreeNode.Write(output, analyzedEvent, Language);
}
示例13: Write
public static ITextOutput Write(ITextOutput output, string name)
{
if (name.Length == 0)
output.Write('-', TextTokenType.Operator);
else {
var parts = name.Split('.');
for (int i = 0; i < parts.Length; i++) {
if (i > 0)
output.Write('.', TextTokenType.Operator);
output.Write(IdentifierEscaper.Escape(parts[i]), TextTokenType.NamespacePart);
}
}
return output;
}
示例14: DecompileMethod
public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
var xMethod = GetXMethodDefinition(method);
var ilMethod = xMethod as XBuilder.ILMethodDefinition;
CompiledMethod cmethod;
if (ilMethod == null || !ilMethod.OriginalMethod.HasBody)
{
output.Write("");
output.WriteLine("// not an il method or method without body.");
return;
}
var methodSource = new MethodSource(xMethod, ilMethod.OriginalMethod);
var target = (DexTargetPackage) AssemblyCompiler.TargetPackage;
var dMethod = (MethodDefinition)xMethod.GetReference(target);
DexMethodBodyCompiler.TranslateToRL(AssemblyCompiler, target, methodSource, dMethod, GenerateSetNextInstructionCode, out cmethod);
var rlBody = cmethod.RLBody;
// Optimize RL code
string lastApplied = RLTransformations.Transform(target.DexFile, rlBody, StopOptimizationAfter == -1?int.MaxValue:StopOptimizationAfter);
if(lastApplied != null)
output.WriteLine("// Stop after " + lastApplied);
PrintMethod(cmethod, output, options);
}
示例15: WriteTo
public static void WriteTo(this Instruction instruction, ITextOutput writer, Func<OpCode, string> getOpCodeDocumentation)
{
writer.WriteDefinition(DnlibExtensions.OffsetToString(instruction.GetOffset()), instruction, TextTokenType.Label, false);
writer.Write(':', TextTokenType.Operator);
writer.WriteSpace();
writer.WriteReference(instruction.OpCode.Name, instruction.OpCode, TextTokenType.OpCode);
if (instruction.Operand != null) {
writer.WriteSpace();
if (instruction.OpCode == OpCodes.Ldtoken) {
var member = instruction.Operand as IMemberRef;
if (member != null && member.IsMethod) {
writer.Write("method", TextTokenType.Keyword);
writer.WriteSpace();
}
else if (member != null && member.IsField) {
writer.Write("field", TextTokenType.Keyword);
writer.WriteSpace();
}
}
WriteOperand(writer, instruction.Operand);
}
if (getOpCodeDocumentation != null) {
var doc = getOpCodeDocumentation(instruction.OpCode);
if (doc != null) {
writer.Write("\t", TextTokenType.Text);
writer.Write("// " + doc, TextTokenType.Comment);
}
}
}