Пример #1
0
 private CachedDecompiledMember DecompileMember(MethodDefinition method)
 {
     V_0 = null;
     if (method != null)
     {
         if (method.get_Body() != null)
         {
             if (this.get_IsCachingEnabled() && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
             {
                 return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
             }
             V_2 = this.DecompileMethod(method.get_Body(), out V_1);
             V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_2, V_1));
             if (this.get_IsCachingEnabled())
             {
                 this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, V_0);
             }
         }
         else
         {
             V_0 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
         }
     }
     return(V_0);
 }
Пример #2
0
 private CachedDecompiledMember FinishDecompilationOfMember(MethodDefinition method, BlockStatement block, DecompilationContext context)
 {
     if (this.get_IsCachingEnabled() && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
     {
         return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
     }
     V_1 = this.FinishDecompilationOfMethod(block, context, out V_0);
     V_2 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, V_0));
     if (this.get_IsCachingEnabled())
     {
         this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, V_2);
     }
     return(V_2);
 }
Пример #3
0
        private CachedDecompiledMember FinishDecompilationOfMember(MethodDefinition method, BlockStatement block, DecompilationContext context)
        {
            if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
            {
                return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
            }

            MethodSpecificContext  methodContext;
            BlockStatement         fullyDecompiledBlock   = this.FinishDecompilationOfMethod(block, context, out methodContext);
            CachedDecompiledMember cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), fullyDecompiledBlock, methodContext));

            if (this.IsCachingEnabled)
            {
                this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, cachedDecompiledMember);
            }

            return(cachedDecompiledMember);
        }
Пример #4
0
        private CachedDecompiledMember DecompileMember(MethodDefinition method)
        {
            CachedDecompiledMember cachedDecompiledMember = null;

            if (method != null)
            {
                if (method.Body == null)
                {
                    cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null));
                }
                else if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(method, this.language, this.renameInvalidMembers))
                {
                    return(this.cacheService.GetDecompiledMemberFromCache(method, this.language, this.renameInvalidMembers));
                }
                else
                {
                    MethodSpecificContext methodContext;
                    BlockStatement        block = this.DecompileMethod(method.Body, out methodContext);
                    cachedDecompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), block, methodContext));
                    if (this.IsCachingEnabled)
                    {
                        this.cacheService.AddDecompiledMemberToCache(method, this.language, this.renameInvalidMembers, cachedDecompiledMember);
                    }
                }
            }

            return(cachedDecompiledMember);
        }
Пример #5
0
        private bool DecompileAndCheckForAutoImplementedPropertyMethod(MethodDefinition method, out CachedDecompiledMember decompiledMember,
                                                                       bool needDecompiledMember, Func <BlockStatement, bool> checker)
        {
            decompiledMember = null;

            DecompilationContext context;
            BlockStatement       statements = this.DecompileMethodPartially(method.Body, out context, needDecompiledMember);

            if (statements == null && context == null)
            {
                if (needDecompiledMember)
                {
                    decompiledMember = DecompileMember(method);
                }

                return(false);
            }
            else if (statements.Statements.Count == 1 && statements.Statements[0].CodeNodeType == CodeNodeType.ExceptionStatement)
            {
                if (needDecompiledMember)
                {
                    decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), statements, new MethodSpecificContext(method.Body)));
                }

                return(false);
            }

            if (checker(statements))
            {
                if (needDecompiledMember)
                {
                    if (this.propertyDef.ShouldStaySplit())
                    {
                        decompiledMember = FinishDecompilationOfMember(method, statements, context);
                    }
                    else
                    {
                        decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), statements, context.MethodContext));
                    }
                }

                return(true);
            }
            else
            {
                if (needDecompiledMember)
                {
                    decompiledMember = FinishDecompilationOfMember(method, statements, context);
                }

                return(false);
            }
        }
Пример #6
0
 private bool DecompileAndCheckForAutoImplementedPropertyMethod(MethodDefinition method, out CachedDecompiledMember decompiledMember, bool needDecompiledMember, Func <BlockStatement, bool> checker)
 {
     decompiledMember = null;
     V_1 = this.DecompileMethodPartially(method.get_Body(), out V_0, needDecompiledMember);
     if (V_1 == null && V_0 == null)
     {
         if (needDecompiledMember)
         {
             decompiledMember = this.DecompileMember(method);
         }
         return(false);
     }
     if (V_1.get_Statements().get_Count() == 1 && V_1.get_Statements().get_Item(0).get_CodeNodeType() == 67)
     {
         if (needDecompiledMember)
         {
             decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, new MethodSpecificContext(method.get_Body())));
         }
         return(false);
     }
     if (!checker.Invoke(V_1))
     {
         if (needDecompiledMember)
         {
             decompiledMember = this.FinishDecompilationOfMember(method, V_1, V_0);
         }
         return(false);
     }
     if (needDecompiledMember)
     {
         if (!this.propertyDef.ShouldStaySplit())
         {
             decompiledMember = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), V_1, V_0.get_MethodContext()));
         }
         else
         {
             decompiledMember = this.FinishDecompilationOfMember(method, V_1, V_0);
         }
     }
     return(true);
 }