Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <summary>
        /// Optimize the RL structure.
        /// </summary>
        private void OptimizeRL(Dex target)
        {
            if (rlIsOptimized)
            {
                return;
            }
            var rlBody = RLBody;

            if (rlBody == null)
            {
                throw new ArgumentException("No RL body set");
            }

            // Optimize RL code
            RLTransformations.Transform(target, rlBody);
            rlIsOptimized = true;
        }