public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ICSharpCode.Decompiler.ITextOutput output, DecompilationOptions options) { var cmethod = GetCompiledMethod(method); if ((cmethod != null) && (cmethod.DexMethod != null)) { try { var f = new MethodBodyDisassemblyFormatter(cmethod.DexMethod, MapFile); var formatOptions = FormatOptions.EmbedSourceCode | FormatOptions.ShowJumpTargets; if (ShowFullNames) { formatOptions |= FormatOptions.FullTypeNames; } if (DebugOperandTypes) { formatOptions |= FormatOptions.DebugOperandTypes; } var s = f.Format(formatOptions); output.Write(s); } catch (Exception) { output.Write("\n\n// Formatting error. Using Fallback.\n\n"); FallbackFormatting(output, cmethod); } } else { output.Write("Method not found in dex"); output.WriteLine(); } }
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); }