/// <summary>
        /// Applies the rule.
        /// </summary>
        /// <param name="node">The node instance to modify.</param>
        /// <param name="data">Private data from CheckConsistency().</param>
        public override void Apply(IAttachmentInstruction node, object data)
        {
            IExpression AttachmentSource = (IExpression)node.Source;
            IResultType SourceTypeList   = AttachmentSource.ResolvedResult.Item;
            IClass      EmbeddingClass   = node.EmbeddingClass;

            IList <IList <ITypeName> >     FullAttachmentTypeNameList = ((Tuple <IList <IList <ITypeName> >, IList <IList <ICompiledType> > >)data).Item1;
            IList <IList <ICompiledType> > FullAttachmentTypeList     = ((Tuple <IList <IList <ITypeName> >, IList <IList <ICompiledType> > >)data).Item2;

            for (int i = 0; i < node.EntityNameList.Count; i++)
            {
                IExpressionType       Item      = SourceTypeList.At(i);
                IName                 ItemName  = node.EntityNameList[i];
                string                ValidText = ItemName.ValidText.Item;
                IList <ITypeName>     AttachmentTypeNameList = FullAttachmentTypeNameList[i];
                IList <ICompiledType> AttachmentTypeList     = FullAttachmentTypeList[i];

                for (int j = 0; j < node.AttachmentList.Count; j++)
                {
                    IAttachment   Attachment         = node.AttachmentList[j];
                    ITypeName     AttachmentTypeName = AttachmentTypeNameList[j];
                    ICompiledType AttachmentType     = AttachmentTypeList[j];

                    IScopeAttributeFeature TypeFixedEntity = Attachment.FullScope[ValidText];
                    TypeFixedEntity.FixFeatureType(AttachmentTypeName, AttachmentType);

                    Attachment.ResolvedLocalEntitiesList.Add(TypeFixedEntity);
                }
            }

            node.ResolvedInitResult.Item = ResultType.Empty;
        }
예제 #2
0
        private bool CheckParameters(IIndexerFeature node, IScopeAttributeFeature resultFeature, IScopeAttributeFeature valueFeature, ISealableDictionary <string, IScopeAttributeFeature> checkedScope)
        {
            bool   Success    = true;
            string NameResult = resultFeature.ValidFeatureName.Item.Name;
            string NameValue  = valueFeature.ValidFeatureName.Item.Name;

            foreach (IEntityDeclaration Item in node.IndexParameterList)
            {
                IName  SourceName = (IName)Item.EntityName;
                string ValidName  = SourceName.ValidText.Item;

                if (checkedScope.ContainsKey(ValidName))
                {
                    AddSourceError(new ErrorDuplicateName(SourceName, ValidName));
                    Success = false;
                }
                else if (ValidName == NameResult)
                {
                    AddSourceError(new ErrorNameResultNotAllowed(SourceName));
                    Success = false;
                }
                else if (ValidName == NameValue)
                {
                    AddSourceError(new ErrorNameValueNotAllowed(SourceName));
                    Success = false;
                }
                else
                {
                    checkedScope.Add(ValidName, Item.ValidEntity.Item);
                }
            }

            return(Success);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IndexerType"/> class.
        /// </summary>
        /// <param name="baseTypeName">The type name of the resolved base type.</param>
        /// <param name="baseType">The type of the resolved base type.</param>
        /// <param name="entityTypeName">The type name of the resolved result type.</param>
        /// <param name="entityType">The type of the resolved result type.</param>
        /// <param name="indexerKind">Type of indexer.</param>
        /// <param name="indexParameterList">The list of parameters.</param>
        /// <param name="parameterEnd">The indexer parameter end type.</param>
        /// <param name="getRequireList">The list of require assertions for the getter.</param>
        /// <param name="getEnsureList">The list of ensure assertions for the getter.</param>
        /// <param name="getExceptionIdentifierList">The list of known exceptions thrown for the getter.</param>
        /// <param name="setRequireList">The list of require assertions for the setter.</param>
        /// <param name="setEnsureList">The list of ensure assertions for the setter.</param>
        /// <param name="setExceptionIdentifierList">The list of known exceptions thrown for the setter.</param>
        public IndexerType(ITypeName baseTypeName, IClassType baseType, ITypeName entityTypeName, ICompiledType entityType, BaseNode.UtilityType indexerKind, IList <IEntityDeclaration> indexParameterList, BaseNode.ParameterEndStatus parameterEnd, IList <IAssertion> getRequireList, IList <IAssertion> getEnsureList, IList <IIdentifier> getExceptionIdentifierList, IList <IAssertion> setRequireList, IList <IAssertion> setEnsureList, IList <IIdentifier> setExceptionIdentifierList)
            : this()
        {
            BaseType     = baseType;
            EntityType   = null;
            ParameterEnd = parameterEnd;
            IndexerKind  = indexerKind;

            ResolvedBaseTypeName.Item   = baseTypeName;
            ResolvedBaseType.Item       = baseType;
            ResolvedEntityTypeName.Item = entityTypeName;
            ResolvedEntityType.Item     = entityType;
            IndexParameterList          = indexParameterList;
            GetRequireList             = getRequireList;
            GetEnsureList              = getEnsureList;
            GetExceptionIdentifierList = getExceptionIdentifierList;
            SetRequireList             = setRequireList;
            SetEnsureList              = setEnsureList;
            SetExceptionIdentifierList = setExceptionIdentifierList;

            foreach (IEntityDeclaration Item in indexParameterList)
            {
                IName  ParameterName = (IName)Item.EntityName;
                string ValidText     = ParameterName.ValidText.Item;
                IScopeAttributeFeature ParameterFeature = Item.ValidEntity.Item;
                ParameterTable.Add(new Parameter(ValidText, ParameterFeature));
            }
            ParameterTable.Seal();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpOverLoopInstruction"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="parentFeature">The parent feature.</param>
        /// <param name="source">The Easly instruction from which the C# instruction is created.</param>
        protected CSharpOverLoopInstruction(ICSharpContext context, ICSharpFeature parentFeature, IOverLoopInstruction source)
            : base(context, parentFeature, source)
        {
            OverList         = CSharpExpression.Create(context, (IExpression)source.OverList);
            LoopInstructions = CSharpScope.Create(context, parentFeature, (IScope)source.LoopInstructions);

            foreach (IName Name in source.IndexerList)
            {
                string IndexerName = Name.ValidText.Item;
                IScopeAttributeFeature IndexerFeature = Source.InnerLoopScope[IndexerName];

                ICSharpScopeAttributeFeature NewIndexer = CSharpScopeAttributeFeature.Create(context, ParentFeature.Owner, IndexerFeature);
                IndexerList.Add(NewIndexer);
            }

            if (source.ExitEntityName.IsAssigned)
            {
                ExitEntityName = ((IIdentifier)source.ExitEntityName.Item).ValidText.Item;
            }

            foreach (IAssertion Item in Source.InvariantList)
            {
                ICSharpAssertion NewAssertion = CSharpAssertion.Create(context, Item);
                InvariantList.Add(NewAssertion);
            }
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IConstantFeature node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            data = null;
            bool Success = true;

            IName       EntityName     = (IName)((IFeatureWithName)node).EntityName;
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;
            IClass      EmbeddingClass = node.EmbeddingClass;

            if (TypeToResolve.ResolvedType.Item is IClassType AsClassType)
            {
                if (AsClassType.BaseClass.Cloneable == BaseNode.CloneableStatus.Single)
                {
                    AddSourceError(new ErrorSingleTypeNotAllowed(node, EntityName.ValidText.Item));
                    Success = false;
                }
            }

            if (Success)
            {
                IScopeAttributeFeature NewEntity = ScopeAttributeFeature.CreateResultFeature(TypeToResolve, EmbeddingClass, node);
                data = NewEntity;
            }

            return(Success);
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(ITupleType node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            ISealableDictionary <string, IScopeAttributeFeature> FieldTable = new SealableDictionary <string, IScopeAttributeFeature>();

            foreach (IEntityDeclaration Item in node.EntityDeclarationList)
            {
                IName FieldName = (IName)Item.EntityName;

                Debug.Assert(FieldName.ValidText.IsAssigned);
                string ValidText = FieldName.ValidText.Item;

                IScopeAttributeFeature FieldAttribute = Item.ValidEntity.Item;

                if (FieldTable.ContainsKey(ValidText))
                {
                    AddSourceError(new ErrorDuplicateName(FieldName, ValidText));
                    Success = false;
                }
                else
                {
                    FieldTable.Add(ValidText, FieldAttribute);
                }
            }

            if (Success)
            {
                data = FieldTable;
            }

            return(Success);
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Parameter"/> class.
        /// </summary>
        /// <param name="name">The parameter name.</param>
        /// <param name="resolvedParameter">The corresponding resolved attribute.</param>
        public Parameter(string name, IScopeAttributeFeature resolvedParameter)
        {
            Name = name;
            ResolvedParameter = resolvedParameter;

#if COVERAGE
            string DebugString = ToString();
#endif
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IForLoopInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            IClass EmbeddingClass = node.EmbeddingClass;
            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = new SealableDictionary <string, IScopeAttributeFeature>();

            foreach (IEntityDeclaration Item in node.EntityDeclarationList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (CheckedScope.ContainsKey(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
                else
                {
                    CheckedScope.Add(ValidFeatureName, LocalEntity);
                }
            }

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedScope, node.InnerScopes, ConflictList);

            foreach (IEntityDeclaration Item in node.EntityDeclarationList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (ConflictList.Contains(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
            }

            IList <IClass> AssignedSingleClassList = new List <IClass>();
            IErrorList     CheckErrorList          = new ErrorList();

            if (ScopeHolder.HasConflictingSingleAttributes(CheckedScope, node.InnerScopes, AssignedSingleClassList, node, CheckErrorList))
            {
                AddSourceErrorList(CheckErrorList);
                Success = false;
            }

            if (Success)
            {
                data = CheckedScope;
            }

            return(Success);
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IQueryOverloadType node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            ISealableList <IParameter> ParameterTable = new SealableList <IParameter>();
            ISealableList <IParameter> ResultTable    = new SealableList <IParameter>();

            foreach (IEntityDeclaration Item in node.ParameterList)
            {
                IName ParameterName = (IName)Item.EntityName;

                Debug.Assert(ParameterName.ValidText.IsAssigned);
                string ValidText = ParameterName.ValidText.Item;

                IScopeAttributeFeature ParameterFeature = Item.ValidEntity.Item;

                if (Parameter.TableContainsName(ParameterTable, ValidText))
                {
                    AddSourceError(new ErrorDuplicateName(ParameterName, ValidText));
                    Success = false;
                }
                else
                {
                    ParameterTable.Add(new Parameter(ValidText, ParameterFeature));
                }
            }

            foreach (IEntityDeclaration Item in node.ResultList)
            {
                IName ResultName = (IName)Item.EntityName;

                Debug.Assert(ResultName.ValidText.IsAssigned);
                string ValidText = ResultName.ValidText.Item;

                IScopeAttributeFeature ResultFeature = Item.ValidEntity.Item;

                if (Parameter.TableContainsName(ResultTable, ValidText) || Parameter.TableContainsName(ParameterTable, ValidText))
                {
                    AddSourceError(new ErrorDuplicateName(ResultName, ValidText));
                    Success = false;
                }
                else
                {
                    ResultTable.Add(new Parameter(ValidText, ResultFeature));
                }
            }

            if (Success)
            {
                data = new Tuple <ISealableList <IParameter>, ISealableList <IParameter> >(ParameterTable, ResultTable);
            }

            return(Success);
        }
예제 #10
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IAttributeFeature node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;
            IClass      EmbeddingClass = node.EmbeddingClass;

            IScopeAttributeFeature ResultFeature = ScopeAttributeFeature.CreateResultFeature(TypeToResolve, EmbeddingClass, node);

            data = ResultFeature;

            return(true);
        }
예제 #11
0
        /// <summary>
        /// Applies the rule.
        /// </summary>
        /// <param name="node">The node instance to modify.</param>
        /// <param name="data">Private data from CheckConsistency().</param>
        public override void Apply(IEntityDeclaration node, object data)
        {
            IScopeAttributeFeature NewEntity = (IScopeAttributeFeature)data;
            IClass EmbeddingClass            = node.EmbeddingClass;

            node.ValidEntity.Item = NewEntity;

            if (node.DefaultValue.IsAssigned)
            {
                EmbeddingClass.NodeWithDefaultList.Add(NewEntity.DefaultValue.Item);
            }
        }
예제 #12
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(ICommandOverload node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = new SealableDictionary <string, IScopeAttributeFeature>();
            ISealableList <IParameter> ParameterTable = new SealableList <IParameter>();

            foreach (EntityDeclaration Item in node.ParameterList)
            {
                IName  SourceName = (IName)Item.EntityName;
                string ValidName  = SourceName.ValidText.Item;

                if (CheckedScope.ContainsKey(ValidName))
                {
                    AddSourceError(new ErrorDuplicateName(SourceName, ValidName));
                    Success = false;
                }
                else
                {
                    CheckedScope.Add(ValidName, Item.ValidEntity.Item);
                    ParameterTable.Add(new Parameter(ValidName, Item.ValidEntity.Item));
                }
            }

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedScope, node.InnerScopes, ConflictList);

            foreach (IEntityDeclaration Item in node.ParameterList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (ConflictList.Contains(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
            }

            if (Success)
            {
                data = new Tuple <ISealableDictionary <string, IScopeAttributeFeature>, ISealableList <IParameter> >(CheckedScope, ParameterTable);
            }

            return(Success);
        }
예제 #13
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IIndexerFeature node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            data = null;
            bool Success = true;

            IClass      EmbeddingClass = node.EmbeddingClass;
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;

            IScopeAttributeFeature ResultFeature = ScopeAttributeFeature.CreateResultFeature(TypeToResolve, EmbeddingClass, node);
            IScopeAttributeFeature ValueFeature  = ScopeAttributeFeature.CreateValueFeature(TypeToResolve, EmbeddingClass, node);

            Success = CheckResultValueConsistency(node, dataList, ResultFeature, ValueFeature, out data);

            return(Success);
        }
예제 #14
0
        private static bool ResolveFeatureAsFunctionType(IQueryExpression node, IErrorList errorList, ICompiledFeature resolvedFinalFeature, List <IExpressionType> mergedArgumentList, TypeArgumentStyles typeArgumentStyle, IFunctionType finalType, ref ResolvedExpression resolvedExpression)
        {
            // IScopeAttributeFeature is the case of an agent.
            IList <IArgument>      ArgumentList            = node.ArgumentList;
            IFunctionFeature       AsFunctionFeature       = resolvedFinalFeature as IFunctionFeature;
            IScopeAttributeFeature AsScopeAttributeFeature = resolvedFinalFeature as IScopeAttributeFeature;

            Debug.Assert(AsFunctionFeature != null || AsScopeAttributeFeature != null);

            IList <ISealableList <IParameter> > ParameterTableList = new List <ISealableList <IParameter> >();

            foreach (IQueryOverloadType Overload in finalType.OverloadList)
            {
                ParameterTableList.Add(Overload.ParameterTable);
            }

            int SelectedIndex;

            if (!Argument.ArgumentsConformToParameters(ParameterTableList, mergedArgumentList, typeArgumentStyle, errorList, node, out SelectedIndex))
            {
                return(false);
            }

            resolvedExpression.SelectedOverloadType = finalType.OverloadList[SelectedIndex];
            resolvedExpression.ResolvedResult       = new ResultType(resolvedExpression.SelectedOverloadType.ResultTypeList);
            resolvedExpression.ResolvedException    = new ResultException(resolvedExpression.SelectedOverloadType.ExceptionIdentifierList);

            if (AsFunctionFeature != null)
            {
                Debug.Assert(AsFunctionFeature.OverloadList.Count == finalType.OverloadList.Count);
                Debug.Assert(AsFunctionFeature.ResolvedAgentType.IsAssigned);
                Debug.Assert(AsFunctionFeature.ResolvedAgentType.Item == finalType);

                resolvedExpression.SelectedOverload = AsFunctionFeature.OverloadList[SelectedIndex];

                resolvedExpression.SelectedResultList = resolvedExpression.SelectedOverload.ResultTable;
                resolvedExpression.FeatureCall        = new FeatureCall(resolvedExpression.SelectedOverload.ParameterTable, resolvedExpression.SelectedOverload.ResultTable, ArgumentList, mergedArgumentList, typeArgumentStyle);
            }
            else
            {
                resolvedExpression.SelectedResultList = resolvedExpression.SelectedOverloadType.ResultTable;
                resolvedExpression.FeatureCall        = new FeatureCall(resolvedExpression.SelectedOverloadType.ParameterTable, resolvedExpression.SelectedOverloadType.ResultTable, ArgumentList, mergedArgumentList, typeArgumentStyle);
            }

            return(true);
        }
예제 #15
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IOverLoopInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = new SealableDictionary <string, IScopeAttributeFeature>();
            IClass EmbeddingClass = node.EmbeddingClass;

            foreach (IName Item in node.IndexerList)
            {
                Debug.Assert(Item.ValidText.IsAssigned);
                string ValidText = Item.ValidText.Item;

                if (CheckedScope.ContainsKey(ValidText))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidText));
                    Success = false;
                }
                else
                {
                    IScopeAttributeFeature NewEntity = ScopeAttributeFeature.Create(Item, ValidText);
                    CheckedScope.Add(ValidText, NewEntity);
                }
            }

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedScope, node.InnerScopes, ConflictList);

            foreach (KeyValuePair <string, IScopeAttributeFeature> Item in CheckedScope)
            {
                if (ConflictList.Contains(Item.Key))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item.Value.Location, Item.Key));
                    Success = false;
                }
            }

            if (Success)
            {
                data = CheckedScope;
            }

            return(Success);
        }
예제 #16
0
        private static bool IsResultsMatching(IQueryOverloadType overload1, IQueryOverloadType overload2)
        {
            bool IsMatching = true;

            IsMatching &= overload1.ResultList.Count == overload2.ResultList.Count;

            for (int i = 0; i < overload1.ResultList.Count && i < overload2.ResultList.Count; i++)
            {
                IScopeAttributeFeature OverloadAttribute1 = overload1.ResultList[i].ValidEntity.Item;
                IScopeAttributeFeature OverloadAttribute2 = overload2.ResultList[i].ValidEntity.Item;

                IsMatching &= OverloadAttribute1.ResolvedEffectiveType.Item == OverloadAttribute2.ResolvedEffectiveType.Item;
                IsMatching &= IsResultNameMatching(OverloadAttribute1.EntityName.Text, OverloadAttribute2.EntityName.Text);
                IsMatching &= IsDefaultValueMatching(OverloadAttribute1.DefaultValue, OverloadAttribute2.DefaultValue);
            }

            return(IsMatching);
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IIndexerType node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            IObjectType BaseTypeItem = (IObjectType)node.BaseType;

            Debug.Assert(BaseTypeItem.ResolvedType.IsAssigned);

            IClassType BaseType = BaseTypeItem.ResolvedType.Item as IClassType;

            if (BaseType == null)
            {
                AddSourceError(new ErrorClassTypeRequired(node));
                Success = false;
            }

            ISealableList <IParameter> ParameterTable = new SealableList <IParameter>();

            foreach (IEntityDeclaration Item in node.IndexParameterList)
            {
                IName  ParameterName = (IName)Item.EntityName;
                string ValidText     = ParameterName.ValidText.Item;
                IScopeAttributeFeature ParameterFeature = Item.ValidEntity.Item;

                if (Parameter.TableContainsName(ParameterTable, ValidText))
                {
                    AddSourceError(new ErrorDuplicateName(ParameterName, ValidText));
                    Success = false;
                }
                else
                {
                    ParameterTable.Add(new Parameter(ValidText, ParameterFeature));
                }
            }

            if (Success)
            {
                data = new Tuple <IClassType, ISealableList <IParameter> >(BaseType, ParameterTable);
            }

            return(Success);
        }
예제 #18
0
        /// <summary>
        /// Checks that all overloads in a list have parameters that allow them to be distinguished in a caller.
        /// </summary>
        /// <param name="overloadList">The list of overloads.</param>
        /// <param name="errorList">The list of errors found.</param>
        public static bool DisjoinedParameterCheck(IList <ICommandOverloadType> overloadList, IErrorList errorList)
        {
            ISealableDictionary <int, IList <ICommandOverloadType> > UnmixedOverloadsTable = new SealableDictionary <int, IList <ICommandOverloadType> >();

            foreach (ICommandOverloadType Overload in overloadList)
            {
                int LastParameterIndex;

                for (LastParameterIndex = Overload.ParameterTable.Count; LastParameterIndex > 0; LastParameterIndex--)
                {
                    IParameter             p         = Overload.ParameterTable[LastParameterIndex - 1];
                    IScopeAttributeFeature Attribute = p.ResolvedParameter;

                    if (!Attribute.DefaultValue.IsAssigned)
                    {
                        break;
                    }
                }

                if (!UnmixedOverloadsTable.ContainsKey(LastParameterIndex))
                {
                    UnmixedOverloadsTable.Add(LastParameterIndex, new List <ICommandOverloadType>());
                }

                IList <ICommandOverloadType> ThisOverloadMix = UnmixedOverloadsTable[LastParameterIndex];
                ThisOverloadMix.Add(Overload);
            }

            bool Success = true;

            foreach (KeyValuePair <int, IList <ICommandOverloadType> > Entry in UnmixedOverloadsTable)
            {
                IList <ICommandOverloadType> ThisOverloadMix = Entry.Value;

                for (int i = 0; i < Entry.Key; i++)
                {
                    Success &= DisjoinedParameterCheck(ThisOverloadMix, i, errorList);
                }
            }

            return(Success);
        }
예제 #19
0
        /// <summary>
        /// Applies the rule.
        /// </summary>
        /// <param name="node">The node instance to modify.</param>
        /// <param name="data">Private data from CheckConsistency().</param>
        public override void Apply(IOverLoopInstruction node, object data)
        {
            IExpression           OverList          = (IExpression)node.OverList;
            IList <ITypeName>     IndexTypeNameList = ((Tuple <IList <ITypeName>, IList <ICompiledType> >)data).Item1;
            IList <ICompiledType> IndexTypeList     = ((Tuple <IList <ITypeName>, IList <ICompiledType> >)data).Item2;

            for (int i = 0; i < node.IndexerList.Count; i++)
            {
                ITypeName     ItemTypeName = IndexTypeNameList[i];
                ICompiledType ItemType     = IndexTypeList[i];
                IName         ItemName     = node.IndexerList[i];
                string        ValidText    = ItemName.ValidText.Item;

                IScopeAttributeFeature TypeFixedEntity = node.InnerLoopScope[ValidText];
                TypeFixedEntity.FixFeatureType(ItemTypeName, ItemType);
            }

            node.ResolvedInitResult.Item = ResultType.Empty;

            node.AdditionalScope.Merge(node.InnerLoopScope);
            node.AdditionalScope.Seal();
        }
        private bool GetCreatedEntity(ICreateInstruction node, out ITypeName attributeTypeName, out ICompiledType attributeType)
        {
            attributeTypeName = null;
            attributeType     = null;
            bool Success = false;

            IIdentifier EntityIdentifier = (IIdentifier)node.EntityIdentifier;
            string      ValidText        = EntityIdentifier.ValidText.Item;
            IClass      EmbeddingClass   = node.EmbeddingClass;
            IClassType  BaseType         = EmbeddingClass.ResolvedClassType.Item;
            ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node);

            if (LocalScope.ContainsKey(ValidText))
            {
                IScopeAttributeFeature CreatedFeature = LocalScope[ValidText];
                attributeTypeName = CreatedFeature.ResolvedEffectiveTypeName.Item;
                attributeType     = CreatedFeature.ResolvedEffectiveType.Item;
                Success           = true;
            }
            else if (FeatureName.TableContain(EmbeddingClass.FeatureTable, ValidText, out IFeatureName Key, out IFeatureInstance Instance))
            {
                if (Instance.Feature is IAttributeFeature AsAttributeFeature)
                {
                    attributeTypeName = AsAttributeFeature.ResolvedEntityTypeName.Item;
                    attributeType     = AsAttributeFeature.ResolvedEntityType.Item;
                    Success           = true;
                }
                else if (Instance.Feature is IPropertyFeature AsPropertyFeature)
                {
                    attributeTypeName = AsPropertyFeature.ResolvedEntityTypeName.Item;
                    attributeType     = AsPropertyFeature.ResolvedEntityType.Item;
                    Success           = true;
                }
                else
                {
                    AddSourceError(new ErrorCreatedFeatureNotAttributeOrProperty(EntityIdentifier, ValidText));
                }
            }
예제 #21
0
        /// <summary>
        /// Applies the rule.
        /// </summary>
        /// <param name="node">The node instance to modify.</param>
        /// <param name="data">Private data from CheckConsistency().</param>
        public override void Apply(IAttributeFeature node, object data)
        {
            IScopeAttributeFeature NewEntity = (IScopeAttributeFeature)data;

            IObjectType TypeToResolve  = (IObjectType)node.EntityType;
            IClass      EmbeddingClass = node.EmbeddingClass;

            ITypeName     BaseTypeName   = EmbeddingClass.ResolvedClassTypeName.Item;
            IClassType    BaseType       = EmbeddingClass.ResolvedClassType.Item;
            ITypeName     EntityTypeName = TypeToResolve.ResolvedTypeName.Item;
            ICompiledType EntityType     = TypeToResolve.ResolvedType.Item;

            PropertyType.ResolveType(EmbeddingClass.TypeTable, BaseTypeName, BaseType.SourceType, BaseType, EntityTypeName, EntityType, BaseNode.UtilityType.ReadOnly, new List <IAssertion>(), new List <IIdentifier>(), new List <IAssertion>(), new List <IIdentifier>(), out ITypeName ResolvedAgentTypeName, out ICompiledType ResolvedAgentType);

            node.ResolvedEntityTypeName.Item    = EntityTypeName;
            node.ResolvedEntityType.Item        = EntityType;
            node.ResolvedAgentTypeName.Item     = ResolvedAgentTypeName;
            node.ResolvedAgentType.Item         = ResolvedAgentType;
            node.ResolvedEffectiveTypeName.Item = EntityTypeName;
            node.ResolvedEffectiveType.Item     = EntityType;

            node.ResolvedFeature.Item = node;
        }
예제 #22
0
        /// <summary>
        /// Creates a tuple type with resolved arguments.
        /// </summary>
        /// <param name="entityDeclarationList">The resolved list of fields.</param>
        /// <param name="sharing">The type sharing.</param>
        /// <param name="resolvedTypeName">The type name upon return.</param>
        /// <param name="resolvedType">The type upon return.</param>
        public static void BuildType(IList <IEntityDeclaration> entityDeclarationList, BaseNode.SharingType sharing, out ITypeName resolvedTypeName, out ICompiledType resolvedType)
        {
            ISealableDictionary <IFeatureName, IFeatureInstance> FeatureTable = new SealableDictionary <IFeatureName, IFeatureInstance>();

            foreach (IEntityDeclaration Item in entityDeclarationList)
            {
                Debug.Assert(Item.ValidEntity.IsAssigned);
                IScopeAttributeFeature ValidEntity = Item.ValidEntity.Item;

                Debug.Assert(ValidEntity.ValidFeatureName.IsAssigned);
                IFeatureName FeatureName = ValidEntity.ValidFeatureName.Item;

                IClass           EmbeddingClass  = Item.EmbeddingClass;
                IFeatureInstance FeatureInstance = new FeatureInstance(EmbeddingClass, ValidEntity);

                FeatureTable.Add(FeatureName, FeatureInstance);
            }

            ITupleType ResolvedTupleType = new TupleType(entityDeclarationList, sharing, FeatureTable);

            resolvedTypeName = new TypeName(ResolvedTupleType.TypeFriendlyName);
            resolvedType     = ResolvedTupleType;
        }
예제 #23
0
        private bool CheckResultValueConsistency(IIndexerFeature node, IDictionary <ISourceTemplate, object> dataList, IScopeAttributeFeature resultFeature, IScopeAttributeFeature valueFeature, out object data)
        {
            data = null;
            bool Success = true;

            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope    = new SealableDictionary <string, IScopeAttributeFeature>();
            ISealableDictionary <string, IScopeAttributeFeature> CheckedGetScope = new SealableDictionary <string, IScopeAttributeFeature>();
            ISealableDictionary <string, IScopeAttributeFeature> CheckedSetScope = new SealableDictionary <string, IScopeAttributeFeature>();

            string NameResult = resultFeature.ValidFeatureName.Item.Name;
            string NameValue  = valueFeature.ValidFeatureName.Item.Name;

            Success &= CheckParameters(node, resultFeature, valueFeature, CheckedScope);

            CheckedGetScope.Merge(CheckedScope);
            CheckedGetScope.Add(NameResult, resultFeature);

            CheckedSetScope.Merge(CheckedScope);
            CheckedSetScope.Add(NameValue, valueFeature);

            List <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedGetScope, node.InnerScopes, ConflictList);
            ScopeHolder.RecursiveCheck(CheckedSetScope, node.InnerScopes, ConflictList);

            Debug.Assert(node.InnerScopes.Count == 0);

            // This has been checked in another rule.
            Debug.Assert(!ConflictList.Contains(NameResult));
            Debug.Assert(!ConflictList.Contains(NameValue));

            Success &= CheckIndexerKind(node, out BaseNode.UtilityType IndexerKind);

            if (Success)
            {
                data = new Tuple <BaseNode.UtilityType, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature> >(IndexerKind, CheckedScope, CheckedGetScope, CheckedSetScope);
            }

            return(Success);
        }
예제 #24
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IAttachmentInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            IClass EmbeddingClass = node.EmbeddingClass;

            IList <ISealableDictionary <string, IScopeAttributeFeature> > CheckedScopeList = new List <ISealableDictionary <string, IScopeAttributeFeature> >();

            for (int i = 0; i < node.AttachmentList.Count; i++)
            {
                CheckedScopeList.Add(new SealableDictionary <string, IScopeAttributeFeature>());
            }

            for (int Index = 0; Index < node.EntityNameList.Count; Index++)
            {
                IName Item = node.EntityNameList[Index];

                Debug.Assert(Item.ValidText.IsAssigned);
                string ValidText = Item.ValidText.Item;

                if (CheckedScopeList[0].ContainsKey(ValidText))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidText));
                    Success = false;
                    continue;
                }

                for (int i = 0; i < node.AttachmentList.Count; i++)
                {
                    Attachment AttachmentItem = (Attachment)node.AttachmentList[i];
                    ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = CheckedScopeList[i];

                    Debug.Assert(Index < AttachmentItem.AttachTypeList.Count);
                    IObjectType AttachedType = AttachmentItem.AttachTypeList[Index];

                    Debug.Assert(AttachedType.ResolvedTypeName.IsAssigned);
                    Debug.Assert(AttachedType.ResolvedType.IsAssigned);

                    IScopeAttributeFeature NewEntity = ScopeAttributeFeature.Create(Item, ValidText, AttachedType.ResolvedTypeName.Item, AttachedType.ResolvedType.Item);
                    CheckedScope.Add(ValidText, NewEntity);
                }
            }

            IList <string> ConflictList = new List <string>();

            for (int i = 0; i < node.AttachmentList.Count; i++)
            {
                IAttachment AttachmentItem = (Attachment)node.AttachmentList[i];
                ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = CheckedScopeList[i];
                ScopeHolder.RecursiveCheck(CheckedScope, AttachmentItem.InnerScopes, ConflictList);
            }

            foreach (IName Item in node.EntityNameList)
            {
                Debug.Assert(Item.ValidText.IsAssigned);
                string ValidText = Item.ValidText.Item;

                if (ConflictList.Contains(ValidText))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidText));
                    Success = false;
                }
            }

            if (Success)
            {
                data = CheckedScopeList;
            }

            return(Success);
        }
예제 #25
0
        /// <summary>
        /// Applies the rule.
        /// </summary>
        /// <param name="node">The node instance to modify.</param>
        /// <param name="data">Private data from CheckConsistency().</param>
        public override void Apply(IPropertyFeature node, object data)
        {
            IClass      EmbeddingClass = node.EmbeddingClass;
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;

            ITypeName     BaseTypeName   = EmbeddingClass.ResolvedClassTypeName.Item;
            IClassType    BaseType       = EmbeddingClass.ResolvedClassType.Item;
            ITypeName     EntityTypeName = TypeToResolve.ResolvedTypeName.Item;
            ICompiledType EntityType     = TypeToResolve.ResolvedType.Item;

            IList <IAssertion>  GetEnsureList = new List <IAssertion>();
            IList <IIdentifier> GetExceptionIdentifierList = new List <IIdentifier>();

            if (node.GetterBody.IsAssigned)
            {
                IBody GetterBody = (IBody)node.GetterBody.Item;
                foreach (IAssertion Item in GetterBody.EnsureList)
                {
                    GetEnsureList.Add(Item);
                }
                foreach (IIdentifier Item in GetterBody.ExceptionIdentifierList)
                {
                    GetExceptionIdentifierList.Add(Item);
                }
            }

            IList <IAssertion>  SetRequireList             = new List <IAssertion>();
            IList <IIdentifier> SetExceptionIdentifierList = new List <IIdentifier>();

            if (node.SetterBody.IsAssigned)
            {
                IBody SetterBody = (IBody)node.SetterBody.Item;
                foreach (IAssertion Item in SetterBody.RequireList)
                {
                    SetRequireList.Add(Item);
                }
                foreach (IIdentifier Item in SetterBody.ExceptionIdentifierList)
                {
                    SetExceptionIdentifierList.Add(Item);
                }
            }

            PropertyType.ResolveType(EmbeddingClass.TypeTable, BaseTypeName, BaseType.SourceType, BaseType, EntityTypeName, EntityType, node.PropertyKind, GetEnsureList, GetExceptionIdentifierList, SetRequireList, SetExceptionIdentifierList, out ITypeName ResolvedPropertyTypeName, out ICompiledType ResolvedPropertyType);

#if COVERAGE
            Debug.Assert(!ResolvedPropertyType.IsReference);
            Debug.Assert(ResolvedPropertyType.IsValue);
#endif

            node.ResolvedEntityTypeName.Item    = EntityTypeName;
            node.ResolvedEntityType.Item        = EntityType;
            node.ResolvedAgentTypeName.Item     = ResolvedPropertyTypeName;
            node.ResolvedAgentType.Item         = ResolvedPropertyType;
            node.ResolvedEffectiveTypeName.Item = EntityTypeName;
            node.ResolvedEffectiveType.Item     = EntityType;

            if (node.GetterBody.IsAssigned)
            {
                EmbeddingClass.BodyList.Add((IBody)node.GetterBody.Item);
            }

            if (node.SetterBody.IsAssigned)
            {
                EmbeddingClass.BodyList.Add((IBody)node.SetterBody.Item);
            }

            IScopeAttributeFeature Result = ((Tuple <IScopeAttributeFeature, IScopeAttributeFeature>)data).Item1;
            IScopeAttributeFeature Value  = ((Tuple <IScopeAttributeFeature, IScopeAttributeFeature>)data).Item2;

            node.LocalGetScope.Add(Result.ValidFeatureName.Item.Name, Result);
            node.LocalGetScope.Seal();
            node.FullGetScope.Merge(node.LocalGetScope);

            node.LocalSetScope.Add(Value.ValidFeatureName.Item.Name, Value);
            node.LocalSetScope.Seal();
            node.FullSetScope.Merge(node.LocalSetScope);

            node.LocalScope.Seal();
            node.FullScope.Merge(node.LocalScope);

            ScopeHolder.RecursiveAdd(node.FullGetScope, node.InnerGetScopes);
            ScopeHolder.RecursiveAdd(node.FullSetScope, node.InnerSetScopes);

            node.ResolvedFeature.Item = node;

#if COVERAGE
            string TypeString = ResolvedPropertyType.ToString();
#endif
        }
예제 #26
0
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IPropertyFeature node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            data = null;
            bool Success = true;

            IClass      EmbeddingClass = node.EmbeddingClass;
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;

            IScopeAttributeFeature Result = ScopeAttributeFeature.CreateResultFeature(TypeToResolve, EmbeddingClass, node);
            IScopeAttributeFeature Value  = ScopeAttributeFeature.CreateValueFeature(TypeToResolve, EmbeddingClass, node);

            string NameResult = Result.ValidFeatureName.Item.Name;
            string NameValue  = Value.ValidFeatureName.Item.Name;

            ISealableDictionary <string, IScopeAttributeFeature> CheckedGetScope = new SealableDictionary <string, IScopeAttributeFeature>();

            CheckedGetScope.Add(NameResult, Result);
            ISealableDictionary <string, IScopeAttributeFeature> CheckedSetScope = new SealableDictionary <string, IScopeAttributeFeature>();

            CheckedSetScope.Add(NameValue, Value);

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedGetScope, node.InnerScopes, ConflictList);
            ScopeHolder.RecursiveCheck(CheckedSetScope, node.InnerScopes, ConflictList);

            // This has been checked in another rule.
            Debug.Assert(!ConflictList.Contains(NameResult));
            Debug.Assert(!ConflictList.Contains(NameValue));

            IName PropertyName = (IName)((IFeatureWithName)node).EntityName;

            if (node.GetterBody.IsAssigned && node.SetterBody.IsAssigned)
            {
                ICompiledBody AsCompiledGetter = (ICompiledBody)node.GetterBody.Item;
                ICompiledBody AsCompiledSetter = (ICompiledBody)node.SetterBody.Item;

                if (AsCompiledGetter.IsDeferredBody != AsCompiledSetter.IsDeferredBody)
                {
                    AddSourceError(new ErrorBodyTypeMismatch(node, PropertyName.ValidText.Item));
                    Success = false;
                }

                if (node.PropertyKind != BaseNode.UtilityType.ReadWrite)
                {
                    AddSourceError(new ErrorBodyTypeMismatch(node, PropertyName.ValidText.Item));
                    Success = false;
                }
            }
            else if (node.GetterBody.IsAssigned)
            {
                if (node.PropertyKind == BaseNode.UtilityType.WriteOnly)
                {
                    AddSourceError(new ErrorBodyTypeMismatch(node, PropertyName.ValidText.Item));
                    Success = false;
                }
            }
            else if (node.SetterBody.IsAssigned)
            {
                if (node.PropertyKind == BaseNode.UtilityType.ReadOnly)
                {
                    AddSourceError(new ErrorBodyTypeMismatch(node, PropertyName.ValidText.Item));
                    Success = false;
                }
            }

            if (Success)
            {
                data = new Tuple <IScopeAttributeFeature, IScopeAttributeFeature>(Result, Value);
            }

            return(Success);
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IQueryOverload node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = new SealableDictionary <string, IScopeAttributeFeature>();

            Debug.Assert(node.ParameterTable.Count == node.ParameterList.Count);
            for (int i = 0; i < node.ParameterTable.Count; i++)
            {
                IParameter         Parameter         = node.ParameterTable[i];
                IEntityDeclaration EntityDeclaration = node.ParameterList[i];

                if (CheckedScope.ContainsKey(Parameter.Name))
                {
                    AddSourceError(new ErrorDuplicateName(EntityDeclaration, Parameter.Name));
                    Success = false;
                }
                else
                {
                    CheckedScope.Add(Parameter.Name, EntityDeclaration.ValidEntity.Item);
                }
            }

            Debug.Assert(node.ResultTable.Count == node.ResultList.Count);
            for (int i = 0; i < node.ResultTable.Count; i++)
            {
                IParameter         Result            = node.ResultTable[i];
                IEntityDeclaration EntityDeclaration = node.ResultList[i];

                if (CheckedScope.ContainsKey(Result.Name))
                {
                    AddSourceError(new ErrorDuplicateName(EntityDeclaration, Result.Name));
                    Success = false;
                }
                else
                {
                    CheckedScope.Add(Result.Name, EntityDeclaration.ValidEntity.Item);
                }
            }

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedScope, node.InnerScopes, ConflictList);

            foreach (IEntityDeclaration Item in node.ParameterList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (ConflictList.Contains(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
            }

            foreach (IEntityDeclaration Item in node.ResultList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (ConflictList.Contains(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
            }

            if (Success)
            {
                data = CheckedScope;
            }

            return(Success);
        }
        /// <summary>
        /// Creates a <see cref="IScopeAttributeFeature"/>.
        /// </summary>
        /// <param name="location">The location associated to this attribute.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <param name="attributeTypeName">Resolved type name of the attribute.</param>
        /// <param name="attributeType">Resolved type of the attribute.</param>
        /// <param name="initialDefaultValue">Default value, if any.</param>
        /// <param name="errorList">List of errors found.</param>
        /// <param name="feature">The created feature if successful.</param>
        public static bool Create(ISource location, string attributeName, ITypeName attributeTypeName, ICompiledType attributeType, IExpression initialDefaultValue, IErrorList errorList, out IScopeAttributeFeature feature)
        {
            Debug.Assert(initialDefaultValue != null);

            feature = null;
            bool Result = false;

            if (attributeType is IClassType AsClassType && AsClassType.BaseClass.Cloneable == BaseNode.CloneableStatus.Single)
            {
                errorList.AddError(new ErrorSingleTypeNotAllowed(location, attributeName));
            }