예제 #1
0
        internal int?GetOldVariableIndex(int newIndex)
        {
            EnvironmentUpdateMapEntry environmentEntry = FindByNewIndex(this.VariableEntries, newIndex);

            if (environmentEntry != null)
            {
                return(environmentEntry.IsAddition ? (int?)null : environmentEntry.OldOffset);
            }
            return(null);
        }
예제 #2
0
        static IList <EnvironmentUpdateMapEntry> Merge(int finalCount, IList <EnvironmentUpdateMapEntry> first,
                                                       IList <EnvironmentUpdateMapEntry> second)
        {
            List <EnvironmentUpdateMapEntry> result = new List <EnvironmentUpdateMapEntry>();

            for (int i = 0; i < finalCount; i++)
            {
                EnvironmentUpdateMapEntry resultEntry = MergeEntry(i, first, second);
                if (resultEntry != null)
                {
                    result.Add(resultEntry);
                }
            }

            return(result.Count > 0 ? result : null);
        }
예제 #3
0
        static EnvironmentUpdateMapEntry MergeEntry(int finalIndex, IList <EnvironmentUpdateMapEntry> first,
                                                    IList <EnvironmentUpdateMapEntry> second)
        {
            EnvironmentUpdateMapEntry secondEntry = FindByNewIndex(second, finalIndex);
            EnvironmentUpdateMapEntry firstEntry;

            if (secondEntry != null)
            {
                firstEntry = secondEntry.IsAddition ? null : FindByNewIndex(first, secondEntry.OldOffset);
            }
            else
            {
                firstEntry = FindByNewIndex(first, finalIndex);
            }

            return(EnvironmentUpdateMapEntry.Merge(firstEntry, secondEntry));
        }
예제 #4
0
        internal static EnvironmentUpdateMapEntry Merge(EnvironmentUpdateMapEntry first, EnvironmentUpdateMapEntry second)
        {
            if (first == null || second == null)
            {
                return(first ?? second);
            }

            Fx.Assert(first.NewOffset == second.OldOffset && !second.IsAddition, "Merging mismatched entries");
            if (first.OldOffset == second.NewOffset)
            {
                return(null);
            }

            return(new EnvironmentUpdateMapEntry
            {
                OldOffset = first.OldOffset,
                NewOffset = second.NewOffset,
                IsNewHandle = first.IsNewHandle
            });
        }