Example #1
0
        /// <summary>
        /// Rename the methods and their references
        /// </summary>
        /// <param name="references">the pool to rename</param>
        /// <param name="id">the id used to build the new name</param>
        private void RenameAllMethods(ReferencesPool references, HashSet<MethodDefinition> renameFreeMethods, ref int id)
        {
            foreach (var method in references.MethodsReferences)
            {
                if (renameFreeMethods.Contains(method.Key) || !(method.Key is MethodDefinition))
                    continue;

                foreach (var methodRef in method.Value)
                {
                    var targetMre = methodRef.Target as MemberReferenceExpression;
                    if (targetMre != null)
                    {
                        var vre = new VariableReferenceExpression();
                        methodRef.Target = vre;
                        vre.TypeInference.Declaration = targetMre.TypeInference.Declaration;
                        vre.TypeInference.TargetType = targetMre.TypeInference.TargetType;
                    }

                    var targetVre = methodRef.Target as VariableReferenceExpression;
                    targetVre.Name = method.Key.Name;
                }
                
                method.Key.Name.Text += "_id" + id;
                ++id;
            }
            references.RegenKeys();
        }