コード例 #1
0
        private void CheckIfFeatureListed(ISealableDictionary <ICompiledFeature, IList <InstanceNameInfo> > byFeatureTable, AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance)
        {
            bool FeatureAlreadyListed = false;

            foreach (KeyValuePair <ICompiledFeature, IList <InstanceNameInfo> > ImportedEntry in byFeatureTable)
            {
                ICompiledFeature         ImportedKey = ImportedEntry.Key;
                IList <InstanceNameInfo> NameList    = ImportedEntry.Value;

                // Feature already listed
                if (featureInstance.Feature == ImportedKey)
                {
                    UpdateNameList(featureInfo, featureName, featureInstance, NameList);
                    FeatureAlreadyListed = true;
                    break;
                }
            }
            if (!FeatureAlreadyListed)
            {
                IList <InstanceNameInfo> InitList = new List <InstanceNameInfo>();
                InstanceNameInfo         NewInfo  = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                InitList.Add(NewInfo);

                byFeatureTable.Add(featureInstance.Feature, InitList);
            }
        }
コード例 #2
0
        private void CheckIfFeatureNameListed(ISealableDictionary <IFeatureName, InheritedInstanceInfo> byNameTable, AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance)
        {
            bool FeatureAlreadyListed = false;
            bool NameAlreadyListed    = false;

            foreach (KeyValuePair <IFeatureName, InheritedInstanceInfo> ImportedEntry in byNameTable)
            {
                IFeatureName             ImportedKey      = ImportedEntry.Key;
                InheritedInstanceInfo    ImportedInstance = ImportedEntry.Value;
                IList <InstanceNameInfo> InstanceList     = ImportedInstance.PrecursorInstanceList;

                if (featureName.Name == ImportedKey.Name)
                {
                    FeatureAlreadyListed = false;

                    Debug.Assert(featureInstance.Feature != null);

                    foreach (InstanceNameInfo Item in InstanceList)
                    {
                        Debug.Assert(Item.Instance.Feature != null);

                        if (featureInstance.Feature == Item.Instance.Feature)
                        {
                            FeatureAlreadyListed = true;
                            break;
                        }
                    }

                    if (!FeatureAlreadyListed)
                    {
                        InstanceNameInfo NewInfo = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                        InstanceList.Add(NewInfo);
                    }

                    NameAlreadyListed = true;
                    break;
                }
            }
            if (!NameAlreadyListed)
            {
                IList <InstanceNameInfo> InitList = new List <InstanceNameInfo>();
                InstanceNameInfo         NewInfo  = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                InitList.Add(NewInfo);

                InheritedInstanceInfo NewName = new InheritedInstanceInfo();
                NewName.PrecursorInstanceList = InitList;

                byNameTable.Add(featureName, NewName);
            }
        }
コード例 #3
0
        private bool CheckPrecursorBodiesHaveAncestor(ISealableDictionary <IFeatureName, InheritedInstanceInfo> byNameTable, IErrorList errorList)
        {
            foreach (KeyValuePair <IFeatureName, InheritedInstanceInfo> ImportedEntry in byNameTable)
            {
                IFeatureName          ImportedKey      = ImportedEntry.Key;
                InheritedInstanceInfo ImportedInstance = ImportedEntry.Value;
                if (ImportedInstance.EffectiveInstance.IsAssigned)
                {
                    InstanceNameInfo Item             = ImportedInstance.EffectiveInstance.Item;
                    ICompiledFeature EffectiveFeature = Item.Instance.Feature;

                    if (EffectiveFeature.HasPrecursorBody)
                    {
                        bool HasEffectiveAncestor = false;

                        foreach (InstanceNameInfo AncestorItem in ImportedInstance.PrecursorInstanceList)
                        {
                            if (AncestorItem == Item)
                            {
                                continue;
                            }

                            ICompiledFeature AncestorEffectiveFeature = AncestorItem.Instance.Feature;
                            if (AncestorEffectiveFeature.IsDeferredFeature)
                            {
                                continue;
                            }

                            HasEffectiveAncestor = true;
                        }

                        if (!HasEffectiveAncestor)
                        {
                            IFeature AsFeature = EffectiveFeature as IFeature;
                            Debug.Assert(AsFeature != null);

                            errorList.AddError(new ErrorMissingAncestor(AsFeature, Item.Name.Name));
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
コード例 #4
0
        private bool CompareNonEffectiveFlags(InheritedInstanceInfo importedInstance, IErrorList errorList)
        {
            bool Result = true;

            IList <InstanceNameInfo> InstanceList = importedInstance.PrecursorInstanceList;

            importedInstance.IsKept         = InstanceList[0].Instance.IsKept;
            importedInstance.IsDiscontinued = InstanceList[0].Instance.IsDiscontinued;

            if (InstanceList.Count > 1)
            {
                ICompiledType FeatureType = InstanceList[0].Instance.Feature.ResolvedAgentType.Item;

                for (int i = 1; i < InstanceList.Count && Result; i++)
                {
                    InstanceNameInfo ThisInstance = InstanceList[i];

                    Result &= importedInstance.IsKept == ThisInstance.Instance.IsKept;
                    Result &= importedInstance.IsDiscontinued == ThisInstance.Instance.IsDiscontinued;
                    Result &= ObjectType.TypesHaveIdenticalSignature(FeatureType, ThisInstance.Instance.Feature.ResolvedAgentType.Item);

                    if (!Result)
                    {
                        if (FeatureType is IIndexerType)
                        {
                            errorList.AddError(new ErrorIndexerInheritanceConflict(ThisInstance.Location));
                        }
                        else
                        {
                            errorList.AddError(new ErrorInheritanceConflict(ThisInstance.Location, ThisInstance.Name.Name));
                        }
                    }
                }
            }

            return(Result);
        }
コード例 #5
0
        private void UpdateNameList(AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance, IList <InstanceNameInfo> nameList)
        {
            OnceReference <InstanceNameInfo> PreviousInstance = new OnceReference <InstanceNameInfo>();

            int i;

            for (i = 0; i < nameList.Count; i++)
            {
                InstanceNameInfo Item = nameList[i];
                if (featureName.Name == Item.Name.Name)
                {
                    PreviousInstance.Item = Item;
                    break;
                }
            }

            // C inherit f from A and B, effectively or not, but keep or discontinue flags don't match.
            if (PreviousInstance.IsAssigned && (PreviousInstance.Item.Instance.IsForgotten == featureInstance.IsForgotten))
            {
                PreviousInstance.Item.SameIsKept         = PreviousInstance.Item.Instance.IsKept == featureInstance.IsKept;
                PreviousInstance.Item.SameIsDiscontinued = PreviousInstance.Item.Instance.IsDiscontinued == featureInstance.IsDiscontinued;
            }

            if (!PreviousInstance.IsAssigned || (PreviousInstance.Item.Instance.IsForgotten && !featureInstance.IsForgotten))
            {
                InstanceNameInfo NewInfo = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                if (i < nameList.Count)
                {
                    nameList[i] = NewInfo;
                }
                else
                {
                    nameList.Add(NewInfo);
                }
            }
        }
コード例 #6
0
        private IFeatureInstance MergeCreateNewInstance(IClass item, IFeatureName importedKey, InheritedInstanceInfo importedInstance, out InstanceNameInfo selectedInstanceInfo)
        {
            IFeatureInstance NewInstance;

            if (importedInstance.EffectiveInstance.IsAssigned)
            {
                selectedInstanceInfo = importedInstance.EffectiveInstance.Item;
            }
            else
            {
                IList <InstanceNameInfo> InstancePrecursorList = importedInstance.PrecursorInstanceList;

                selectedInstanceInfo = null;
                foreach (InstanceNameInfo Item in InstancePrecursorList)
                {
                    if (Item.Instance.Owner == item)
                    {
                        selectedInstanceInfo = Item;
                        break;
                    }
                }

                if (selectedInstanceInfo == null)
                {
                    selectedInstanceInfo = InstancePrecursorList[0];
                }
            }

            NewInstance = new FeatureInstance(selectedInstanceInfo.Instance.Owner, selectedInstanceInfo.Instance.Feature, importedInstance.IsKept, importedInstance.IsDiscontinued);
            return(NewInstance);
        }