Example #1
0
        public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
        {
            HashSet <Instruction> mappedInstructions = new HashSet <Instruction>(body.UnderlyingSameMethodInstructions);

            if (context.MethodContext.IsMethodBodyChanged)
            {
                context.MethodContext.Method.RefreshBody();
                context.MethodContext.IsMethodBodyChanged = false;
            }

            List <Instruction> unmappedInstructions = new List <Instruction>();

            foreach (Instruction instruction in context.MethodContext.Method.Body.Instructions)
            {
                if (!mappedInstructions.Contains(instruction))
                {
                    unmappedInstructions.Add(instruction);
                }
            }

            if (unmappedInstructions.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder("Found unmapped instructions.\n");
                foreach (Instruction unmappedInstruction in unmappedInstructions)
                {
                    stringBuilder.AppendLine(unmappedInstruction.ToString());
                }
                throw new Exception(stringBuilder.ToString());
            }

            return(body);
        }
Example #2
0
 public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
 {
     this.methodContext = context.MethodContext;
     mappedInstructions.UnionWith(body.UnderlyingSameMethodInstructions);
     Visit(body);
     return(body);
 }
        public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
        {
            Visit(body);
            List <Instruction> instructions = new List <Instruction>(body.UnderlyingSameMethodInstructions);
            List <Instruction> nonUniques   = GetNonUniqueInstructions(instructions);

            if (nonUniques.Count > 0)
            {
                throw new Exception("Instruction duplication detected after: " + previousStep);
            }
            return(body);
        }
Example #4
0
        public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
        {
            if (!new ExpressionTreesFinder().ContainsExpressionTree(body))
            {
                return(body);
            }

            this.context    = context;
            this.typeSystem = context.TypeContext.CurrentType.Module.TypeSystem;
            this.failure    = false;
            BlockStatement clone = (BlockStatement)Visit(body.Clone());

            if (failure || usedVariables.Count == 0 || !TryRemoveUnusedVariableAssignments(clone))
            {
                return(body);
            }
            clone = (BlockStatement) new ClosureVariablesRemover(context.MethodContext).Visit(clone);
            clone = new CombinedTransformerStep().Process(context, clone);
            return(clone);
        }
 public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
 {
     body = (BlockStatement) new LinqQueriesRebuilder(context.MethodContext).Visit(body);
     return(body);
 }
Example #6
0
 public Ast.Statements.BlockStatement Process(Decompiler.DecompilationContext context, Ast.Statements.BlockStatement body)
 {
     this.context    = context;
     this.typeSystem = context.TypeContext.CurrentType.Module.TypeSystem;
     return((Telerik.JustDecompiler.Ast.Statements.BlockStatement)Visit(body));
 }