Ejemplo n.º 1
0
        /// <summary>
        /// Updates the aliases.
        /// </summary>
        private void updateAliases()
        {
            foreach (var item in MemoryAliases)
            {
                MemoryIndex     targetIndex = item.Key;
                MemoryAliasInfo aliasInfo   = item.Value;

                if (!aliasInfo.IsTargetOfMerge)
                {
                    IMemoryAlias currentAliases;
                    if (writeableTargetStructure.TryGetAliases(targetIndex, out currentAliases))
                    {
                        aliasInfo.Aliases.MayAliases.AddAll(currentAliases.MayAliases);
                        aliasInfo.Aliases.MustAliases.AddAll(currentAliases.MustAliases);
                    }
                }
                foreach (MemoryIndex alias in aliasInfo.RemovedAliases)
                {
                    aliasInfo.Aliases.MustAliases.Remove(alias);
                    aliasInfo.Aliases.MayAliases.Remove(alias);
                }

                writeableTargetStructure.SetAlias(targetIndex, aliasInfo.Aliases.Build(writeableTargetStructure));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the alias information.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns></returns>
        internal MemoryAliasInfo getAliasInfo(MemoryIndex index)
        {
            MemoryAliasInfo aliasInfo;

            if (!MemoryAliases.TryGetValue(index, out aliasInfo))
            {
                IMemoryAliasBuilder alias = Factories.StructuralContainersFactories.MemoryAliasFactory.CreateMemoryAlias(writeableTargetStructure, index).Builder(writeableTargetStructure);
                aliasInfo = new MemoryAliasInfo(alias, false);

                MemoryAliases[index] = aliasInfo;
            }
            return(aliasInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes the aliases.
        /// </summary>
        /// <param name="targetIndex">Index of the target.</param>
        /// <param name="targetAliases">The target aliases.</param>
        private void deleteAliases(MemoryIndex targetIndex, IMemoryAlias targetAliases)
        {
            foreach (MemoryIndex aliasIndex in targetAliases.MustAliases)
            {
                MemoryAliasInfo aliasInfo = getAliasInfo(aliasIndex);
                aliasInfo.AddRemovedAlias(targetIndex);
            }

            foreach (MemoryIndex aliasIndex in targetAliases.MayAliases)
            {
                MemoryAliasInfo aliasInfo = getAliasInfo(aliasIndex);
                aliasInfo.AddRemovedAlias(targetIndex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the aliases to given index. Alias entry of the given alias indexes are not changed.
        /// If given memory index contains no aliases new alias entry is created.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="mustAlias">The must alias.</param>
        /// <param name="mayAlias">The may alias.</param>
        public void AddAlias(MemoryIndex index, MemoryIndex mustAlias, MemoryIndex mayAlias)
        {
            MemoryAliasInfo     aliasInfo = getAliasInfo(index);
            IMemoryAliasBuilder alias     = aliasInfo.Aliases;

            if (mustAlias != null)
            {
                alias.MustAliases.Add(mustAlias);

                if (alias.MayAliases.Contains(mustAlias))
                {
                    alias.MayAliases.Remove(mustAlias);
                }
            }

            if (mayAlias != null && !alias.MustAliases.Contains(mayAlias))
            {
                alias.MayAliases.Add(mayAlias);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds the aliases to given index. Alias entry of the given alias indexes are not changed.
        /// If given memory index contains no aliases new alias entry is created.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="mustAliases">The must aliases.</param>
        /// <param name="mayAliases">The may aliases.</param>
        public void AddAliases(MemoryIndex index, IEnumerable <MemoryIndex> mustAliases, IEnumerable <MemoryIndex> mayAliases)
        {
            MemoryAliasInfo     aliasInfo = getAliasInfo(index);
            IMemoryAliasBuilder alias     = aliasInfo.Aliases;

            if (mustAliases != null)
            {
                alias.MustAliases.AddAll(mustAliases);
            }
            if (mayAliases != null)
            {
                alias.MayAliases.AddAll(mayAliases);
            }

            foreach (MemoryIndex mustIndex in alias.MustAliases)
            {
                if (alias.MayAliases.Contains(mustIndex))
                {
                    alias.MayAliases.Remove(mustIndex);
                }
            }
        }
Ejemplo n.º 6
0
            public override void provideCustomDeleteOperation(MemoryIndex targetIndex, IIndexDefinition targetDefinition)
            {
                if (targetDefinition.Array != null)
                {
                    writeableTargetStructure.RemoveArray(targetIndex, targetDefinition.Array);
                }

                if (targetDefinition.Aliases != null)
                {
                    foreach (MemoryIndex aliasIndex in targetDefinition.Aliases.MustAliases)
                    {
                        MemoryAliasInfo aliasInfo = mergeWorker.getAliasInfo(aliasIndex);
                        aliasInfo.AddRemovedAlias(targetIndex);
                    }

                    foreach (MemoryIndex aliasIndex in targetDefinition.Aliases.MayAliases)
                    {
                        MemoryAliasInfo aliasInfo = mergeWorker.getAliasInfo(aliasIndex);
                        aliasInfo.AddRemovedAlias(targetIndex);
                    }
                }

                writeableTargetStructure.RemoveIndex(targetIndex);
            }