/// <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(IIndexerType node, object data)
        {
            IClassType BaseType = ((Tuple <IClassType, ISealableList <IParameter> >)data).Item1;
            ISealableList <IParameter> ParameterTable = ((Tuple <IClassType, ISealableList <IParameter> >)data).Item2;

            IClass      EmbeddingClass = node.EmbeddingClass;
            IObjectType BaseTypeItem   = (IObjectType)node.BaseType;
            IObjectType EntityTypeItem = (IObjectType)node.EntityType;

            Debug.Assert(node.ParameterTable.Count == 0);
            node.ParameterTable.AddRange(ParameterTable);
            node.ParameterTable.Seal();

            ITypeName BaseTypeName = BaseTypeItem.ResolvedTypeName.Item;

            ITypeName     EntityTypeName = EntityTypeItem.ResolvedTypeName.Item;
            ICompiledType EntityType     = EntityTypeItem.ResolvedType.Item;

#if COVERAGE
            string TypeString = node.ToString();
            Debug.Assert(!node.IsReference);
            Debug.Assert(node.IsValue);
#endif

            IndexerType.ResolveType(EmbeddingClass.TypeTable, BaseTypeName, BaseType, EntityTypeName, EntityType, node.IndexerKind, node.IndexParameterList, node.ParameterEnd, node.GetRequireList, node.GetEnsureList, node.GetExceptionIdentifierList, node.SetRequireList, node.SetEnsureList, node.SetExceptionIdentifierList, out ITypeName ResolvedTypeName, out ICompiledType ResolvedType);

            node.ResolvedTypeName.Item = ResolvedTypeName;
            node.ResolvedType.Item     = ResolvedType;
        }
Esempio n. 2
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(IIndexerFeature node, object data)
        {
            IClass      EmbeddingClass = node.EmbeddingClass;
            IObjectType TypeToResolve  = (IObjectType)node.EntityType;

            BaseNode.UtilityType IndexerKind = ((Tuple <BaseNode.UtilityType, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature> >)data).Item1;
            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope    = ((Tuple <BaseNode.UtilityType, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature> >)data).Item2;
            ISealableDictionary <string, IScopeAttributeFeature> CheckedGetScope = ((Tuple <BaseNode.UtilityType, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature> >)data).Item3;
            ISealableDictionary <string, IScopeAttributeFeature> CheckedSetScope = ((Tuple <BaseNode.UtilityType, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature>, ISealableDictionary <string, IScopeAttributeFeature> >)data).Item4;

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

            List <IEntityDeclaration> IndexParameterList = new List <IEntityDeclaration>();

            foreach (IEntityDeclaration Item in node.IndexParameterList)
            {
                IndexParameterList.Add(Item);
            }

            BaseNode.ParameterEndStatus ParameterEnd = node.ParameterEnd;

            IList <IAssertion>  GetRequireList             = new List <IAssertion>();
            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.RequireList)
                {
                    GetRequireList.Add(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 <IAssertion>  SetEnsureList              = 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 (IAssertion Item in SetterBody.EnsureList)
                {
                    SetEnsureList.Add(Item);
                }
                foreach (IIdentifier Item in SetterBody.ExceptionIdentifierList)
                {
                    SetExceptionIdentifierList.Add(Item);
                }
            }

            IndexerType.ResolveType(EmbeddingClass.TypeTable, BaseTypeName, BaseType, EntityTypeName, EntityType, IndexerKind, IndexParameterList, ParameterEnd, GetRequireList, GetEnsureList, GetExceptionIdentifierList, SetRequireList, SetEnsureList, SetExceptionIdentifierList, out ITypeName ResolvedIndexerTypeName, out ICompiledType ResolvedIndexerType);

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

            foreach (KeyValuePair <string, IScopeAttributeFeature> Entry in CheckedScope)
            {
                node.ParameterTable.Add(new Parameter(Entry.Key, Entry.Value));
            }
            node.ParameterTable.Seal();

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

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

            node.LocalGetScope.Merge(CheckedGetScope);
            node.LocalGetScope.Seal();
            node.FullGetScope.Merge(node.LocalGetScope);

            node.LocalSetScope.Merge(CheckedSetScope);
            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 = ResolvedIndexerType.ToString();
#endif
        }