Esempio n. 1
0
        private void CombineChains(VChain source, VChain target)
        {
            if (source.Types.Count > target.Types.Count)
            {
                var t = source;
                source = target;
                target = t;
            }

            var name = source.Name;

            Debug.Assert(name == target.Name);
            var set = new HashSet <ITypeKey>(source.Types);

            set.ExceptWith(target.Types);
            target.Types.UnionWith(set);
            target.DontRename |= source.DontRename;
            foreach (var t in set)
            {
                if (_chains.TryGetValue(t, out var names) && names.TryGetValue(name, out var ch))
                {
                    if (ch != target)
                    {
                        names[name] = target;
                    }
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
Esempio n. 2
0
        private void AddNameToChain(IVTableSlot slot)
        {
            var method = slot.MethodDef;
            var type = method.DeclaringType;
            var name = method.Name;
            var otherType = slot.Parent?.MethodDef.DeclaringType;
            Dictionary <string, VChain> chains, otherChains = null;
            VChain   chain, otherChain = null;
            ITypeKey key = type.CreateKey(), otherKey = null;

            if (!_chains.TryGetValue(key, out chains))
            {
                _chains.Add(key, chains = new Dictionary <string, VChain>());
            }
            if (otherType != null)
            {
                otherKey = otherType.CreateKey();
                if (!_chains.TryGetValue(otherKey, out otherChains))
                {
                    _chains.Add(otherKey, otherChains = new Dictionary <string, VChain>());
                }
            }

            chains.TryGetValue(name, out chain);
            otherChains?.TryGetValue(name, out otherChain);
            if (otherChain == null)
            {
                if (chain == null)
                {
                    chains.Add(name, chain = new VChain(name));
                }
                otherChain = chain;
                otherChains?.Add(name, otherChain);
            }
            else
            {
                if (chain == null)
                {
                    chains.Add(name, chain = otherChain);
                }
                else if (chain != otherChain)
                {
                    CombineChains(chain, otherChain);
                }
            }

            chain.Types.Add(key);
            if (otherType != null)
            {
                chain.Types.Add(otherKey);
            }
            if (!chain.DontRename && DontRename != null)
            {
                chain.DontRename = DontRename(method) || (slot.Parent != null && DontRename(slot.Parent?.MethodDef));
            }
        }