示例#1
0
        /// <summary>
        /// Creates an instance of a class type, or reuse an existing instance.
        /// </summary>
        /// <param name="instancingClassType">The class type to instanciate.</param>
        /// <param name="resolvedTypeName">The proposed type instance name.</param>
        /// <param name="resolvedType">The proposed type instance.</param>
        public void InstanciateType(ICompiledTypeWithFeature instancingClassType, ref ITypeName resolvedTypeName, ref ICompiledType resolvedType)
        {
            bool IsNewInstance = false;

            ISealableDictionary <string, ICompiledType> InstancedTypeArgumentTable = new SealableDictionary <string, ICompiledType>();

            foreach (KeyValuePair <string, ICompiledType> TypeArgument in TypeArgumentTable)
            {
                ITypeName     InstancedTypeArgumentName = null;
                ICompiledType InstancedTypeArgument     = TypeArgument.Value;
                InstancedTypeArgument.InstanciateType(instancingClassType, ref InstancedTypeArgumentName, ref InstancedTypeArgument);

                InstancedTypeArgumentTable.Add(TypeArgument.Key, InstancedTypeArgument);

                if (InstancedTypeArgument != TypeArgument.Value)
                {
                    IsNewInstance = true;
                }
            }

            if (IsNewInstance)
            {
                ISealableDictionary <ITypeName, ICompiledType> InstancingTypeTable = instancingClassType.GetTypeTable();
                ResolveType(InstancingTypeTable, BaseClass, InstancedTypeArgumentTable, instancingClassType, out resolvedTypeName, out resolvedType);
            }
        }
示例#2
0
        /// <summary>
        /// Creates an instance of a class type, or reuse an existing instance.
        /// </summary>
        /// <param name="instancingClassType">The class type to instanciate.</param>
        /// <param name="resolvedTypeName">The proposed type instance name.</param>
        /// <param name="resolvedType">The proposed type instance.</param>
        public void InstanciateType(ICompiledTypeWithFeature instancingClassType, ref ITypeName resolvedTypeName, ref ICompiledType resolvedType)
        {
            bool IsNewInstance = false;

            ITypeName     InstancedBaseTypeName = ResolvedBaseTypeName.Item;
            ICompiledType InstancedBaseType     = ResolvedBaseType.Item;

            InstancedBaseType.InstanciateType(instancingClassType, ref InstancedBaseTypeName, ref InstancedBaseType);
            IsNewInstance |= InstancedBaseType != ResolvedBaseType.Item;

            IList <ICommandOverloadType> InstancedOverloadList = new List <ICommandOverloadType>();

            foreach (ICommandOverloadType Overload in OverloadList)
            {
                ICommandOverloadType InstancedOverload = Overload;
                CommandOverloadType.InstanciateCommandOverloadType(instancingClassType, ref InstancedOverload);
                IsNewInstance |= InstancedOverload != Overload;

                InstancedOverloadList.Add(InstancedOverload);
            }

            if (IsNewInstance)
            {
                ISealableDictionary <ITypeName, ICompiledType> TypeTable = instancingClassType.GetTypeTable();
                ResolveType(TypeTable, InstancedBaseTypeName, (IObjectType)BaseType, (ICompiledTypeWithFeature)InstancedBaseType, InstancedOverloadList, out resolvedTypeName, out IProcedureType ResolvedProcedureType);
                resolvedType = ResolvedProcedureType;
            }
        }
示例#3
0
        /// <summary>
        /// Creates an instance of a class type, or reuse an existing instance.
        /// </summary>
        /// <param name="instancingClassType">The class type to instanciate.</param>
        /// <param name="resolvedTypeName">The proposed type instance name.</param>
        /// <param name="resolvedType">The proposed type instance.</param>
        public void InstanciateType(ICompiledTypeWithFeature instancingClassType, ref ITypeName resolvedTypeName, ref ICompiledType resolvedType)
        {
            ISealableDictionary <ITypeName, ICompiledType> TypeTable = GetTypeTable();

            Debug.Assert(TypeTable.Count == 0);

            bool IsNewInstance = false;

            IList <IEntityDeclaration> InstancedFieldList = new List <IEntityDeclaration>();

            foreach (IEntityDeclaration Field in EntityDeclarationList)
            {
                Debug.Assert(Field.ValidEntity.IsAssigned);
                Debug.Assert(Field.ValidEntity.Item.ResolvedEffectiveTypeName.IsAssigned);
                Debug.Assert(Field.ValidEntity.Item.ResolvedEffectiveType.IsAssigned);

                ITypeName     InstancedFieldTypeName = Field.ValidEntity.Item.ResolvedEffectiveTypeName.Item;
                ICompiledType InstancedFieldType     = Field.ValidEntity.Item.ResolvedEffectiveType.Item;

                InstancedFieldType.InstanciateType(instancingClassType, ref InstancedFieldTypeName, ref InstancedFieldType);
                IsNewInstance |= InstancedFieldType != Field.ValidEntity.Item.ResolvedEffectiveType.Item;

                IEntityDeclaration InstancedField = new EntityDeclaration(Field, InstancedFieldTypeName, InstancedFieldType);
                InstancedFieldList.Add(InstancedField);
            }

            if (IsNewInstance)
            {
                ISealableDictionary <ITypeName, ICompiledType> InstancingTypeTable = instancingClassType.GetTypeTable();
                ResolveType(InstancingTypeTable, EntityDeclarationList, Sharing, out resolvedTypeName, out resolvedType);
            }
        }
示例#4
0
        /// <summary>
        /// Creates an instance of a class type, or reuse an existing instance.
        /// </summary>
        /// <param name="instancingClassType">The class type to instanciate.</param>
        /// <param name="resolvedTypeName">The proposed type instance name.</param>
        /// <param name="resolvedType">The proposed type instance.</param>
        public void InstanciateType(ICompiledTypeWithFeature instancingClassType, ref ITypeName resolvedTypeName, ref ICompiledType resolvedType)
        {
            bool IsNewInstance = false;

            ITypeName InstancedBaseTypeName = ResolvedBaseTypeName.Item;

            ICompiledType InstancedBaseType = ResolvedBaseType.Item;

            InstancedBaseType.InstanciateType(instancingClassType, ref InstancedBaseTypeName, ref InstancedBaseType);
            IsNewInstance |= InstancedBaseType != ResolvedBaseType.Item;

            ITypeName     InstancedEntityTypeName = ResolvedEntityTypeName.Item;
            ICompiledType InstancedEntityType     = ResolvedEntityType.Item;

            InstancedEntityType.InstanciateType(instancingClassType, ref InstancedEntityTypeName, ref InstancedEntityType);
            IsNewInstance |= InstancedEntityType != ResolvedEntityType.Item;

            IList <IEntityDeclaration> InstancedIndexParameterList = new List <IEntityDeclaration>();

            foreach (IEntityDeclaration Parameter in IndexParameterList)
            {
                ITypeName     InstancedParameterTypeName = Parameter.ValidEntity.Item.ResolvedEffectiveTypeName.Item;
                ICompiledType InstancedParameterType     = Parameter.ValidEntity.Item.ResolvedEffectiveType.Item;
                InstancedParameterType.InstanciateType(instancingClassType, ref InstancedParameterTypeName, ref InstancedParameterType);

                IEntityDeclaration InstancedParameter = new EntityDeclaration(Parameter, InstancedParameterTypeName, InstancedParameterType);
                IName ParameterName = (Name)Parameter.EntityName;

                IScopeAttributeFeature NewEntity;
                if (Parameter.DefaultValue.IsAssigned)
                {
                    // The default value has already been checked and validated.
                    bool IsCreated = ScopeAttributeFeature.Create(Parameter, ParameterName.ValidText.Item, InstancedParameterTypeName, InstancedParameterType, (IExpression)Parameter.DefaultValue.Item, ErrorList.Ignored, out NewEntity);
                    Debug.Assert(IsCreated);
                }
                else
                {
                    NewEntity = ScopeAttributeFeature.Create(Parameter, ParameterName.ValidText.Item, InstancedParameterTypeName, InstancedParameterType);
                }

                IsNewInstance |= InstancedParameterType != Parameter.ValidEntity.Item.ResolvedEffectiveType.Item;

                InstancedParameter.ValidEntity.Item = NewEntity;
                InstancedIndexParameterList.Add(InstancedParameter);
            }

            if (IsNewInstance)
            {
                ISealableDictionary <ITypeName, ICompiledType> TypeTable = instancingClassType.GetTypeTable();
                ResolveType(TypeTable, InstancedBaseTypeName, (IClassType)InstancedBaseType, InstancedEntityTypeName, InstancedEntityType, IndexerKind, InstancedIndexParameterList, ParameterEnd, GetRequireList, GetEnsureList, GetExceptionIdentifierList, SetRequireList, SetEnsureList, SetExceptionIdentifierList, out resolvedTypeName, out resolvedType);
            }
        }
示例#5
0
        /// <summary>
        /// Creates an instance of a class type, or reuse an existing instance.
        /// </summary>
        /// <param name="instancingClassType">The class type to instanciate.</param>
        /// <param name="resolvedTypeName">The proposed type instance name.</param>
        /// <param name="resolvedType">The proposed type instance.</param>
        public void InstanciateType(ICompiledTypeWithFeature instancingClassType, ref ITypeName resolvedTypeName, ref ICompiledType resolvedType)
        {
            bool IsNewInstance = false;

            ITypeName     InstancedBaseTypeName = ResolvedBaseTypeName.Item;
            ICompiledType InstancedBaseType     = ResolvedBaseType.Item;

            InstancedBaseType.InstanciateType(instancingClassType, ref InstancedBaseTypeName, ref InstancedBaseType);
            Debug.Assert(InstancedBaseType is ICompiledTypeWithFeature);

            IsNewInstance |= InstancedBaseType != ResolvedBaseType.Item;

            ITypeName     InstancedEntityTypeName = ResolvedEntityTypeName.Item;
            ICompiledType InstancedEntityType     = ResolvedEntityType.Item;

            InstancedEntityType.InstanciateType(instancingClassType, ref InstancedEntityTypeName, ref InstancedEntityType);
            IsNewInstance |= InstancedEntityType != ResolvedEntityType.Item;

            if (IsNewInstance)
            {
                ISealableDictionary <ITypeName, ICompiledType> TypeTable = instancingClassType.GetTypeTable();
                ResolveType(TypeTable, InstancedBaseTypeName, (IObjectType)BaseType, (ICompiledTypeWithFeature)InstancedBaseType, InstancedEntityTypeName, InstancedEntityType, PropertyKind, GetEnsureList, GetExceptionIdentifierList, SetRequireList, SetExceptionIdentifierList, out resolvedTypeName, out resolvedType);
            }
        }