예제 #1
0
        /// <summary>
        ///   Validates that all the child names are unique.
        /// </summary>
        /// <exception cref="InvalidOperationException">Two child objects were found with the same name.</exception>
        private void ValidateChildNames()
        {
            List <BaseTypeInfo> childList = new List <BaseTypeInfo>();

            childList.AddRange(DeclaredTypes);
            childList.AddRange(Functions);
            childList.AddRange(Procedures);
            childList.AddRange(SubModule.GetUniqueComponents(SubModules, true));
            childList.AddRange(Signals);
            childList.AddRange(Aliases);
            childList.AddRange(AttributeDeclarationInfo.GetUniqueAttributeDeclarations(Attributes));
            childList.AddRange(Processes);
            childList.AddRange(Generates);
            childList.AddRange(SubModules);

            BaseTypeInfo.ValidateNoDuplicates(childList.ToArray(), Entity.Name, "module");
        }
예제 #2
0
        /// <summary>
        ///   Writes the module to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the entity to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="InvalidOperationException">Unable to write the object out in its current state.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            ValidateChildNames();

            // Write the entity.
            Entity.Write(wr, indentOffset);

            DocumentationHelper.WriteLine(wr);
            DocumentationHelper.WriteLine(wr, string.Format("architecture {0} of {1} is", Enum.GetName(typeof(ArchitecturalType), Type), Entity.Name), indentOffset);
            DocumentationHelper.WriteLine(wr);

            // Functions
            BaseTypeInfo.WriteBaseTypeInfos("Functions", wr, Functions.ToArray(), indentOffset, Entity.Name, "module");
            if (Functions.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Types and Constants
            DeclarationInfo.WriteDeclarations(wr, DeclaredTypes.ToArray(), indentOffset, Entity.Name, "module");
            if (DeclaredTypes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Procedures
            BaseTypeInfo.WriteBaseTypeInfos("Procedures", wr, Procedures.ToArray(), indentOffset, Entity.Name, "module");
            if (Procedures.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Components
            ComponentInfo[] components = SubModule.GetUniqueComponents(SubModule.GetAllSubModules(this), true);
            BaseTypeInfo.WriteBaseTypeInfos("Components", wr, components, indentOffset, Entity.Name, "module");
            if (components.Length > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Signals
            BaseTypeInfo.WriteBaseTypeInfos("Signals", wr, Signals.ToArray(), indentOffset, Entity.Name, "module");
            if (Signals.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Aliases
            BaseTypeInfo.WriteBaseTypeInfos("Aliases", wr, Aliases.ToArray(), indentOffset, Entity.Name, "module");
            if (Aliases.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Attributes
            AttributeSpecificationInfo.WriteAttributes(wr, Attributes.ToArray(), indentOffset, Entity.Name, "module");
            if (Attributes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            DocumentationHelper.WriteLine(wr, "begin", indentOffset);
            DocumentationHelper.WriteLine(wr);

            // Concurrent Statements
            foreach (string line in ConcurrentStatements)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset);
            }
            if (ConcurrentStatements.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Processes
            BaseTypeInfo.WriteBaseTypeInfos("Processes", wr, Processes.ToArray(), indentOffset, Entity.Name, "module");
            if (Processes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Generates
            BaseTypeInfo.WriteBaseTypeInfos("Generates", wr, Generates.ToArray(), indentOffset, Entity.Name, "module");
            if (Generates.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            BaseTypeInfo.WriteBaseTypeInfos("Sub-Modules", wr, SubModules.ToArray(), indentOffset, Entity.Name, "module");
            if (SubModules.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" architecture");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Enum.GetName(typeof(ArchitecturalType), Type));
            }
            sb.Append(";");
            DocumentationHelper.Write(wr, sb.ToString(), indentOffset);
        }
예제 #3
0
        /// <summary>
        ///   Generates the module sub-information.
        /// </summary>
        /// <param name="info"><see cref="ModuleInfo"/> object to generate the sub-information on.</param>
        /// <returns>Lookup table of the sub-information.</returns>
        private Dictionary <string, List <string> > GenerateModuleSubInfo(ModuleInfo info)
        {
            Dictionary <string, List <string> > lookup = new Dictionary <string, List <string> >();

            // Add Functions.
            if (info.Functions.Count > 0)
            {
                info.Functions.Sort();
                lookup.Add("Functions:", GenerateNamesFromBaseTypeInfo(info.Functions.ToArray()));
            }

            // Add Declarations.
            if (info.DeclaredTypes.Count > 0)
            {
                info.DeclaredTypes.Sort();
                lookup.Add("Constants & Types:", GenerateNamesFromBaseTypeInfo(info.DeclaredTypes.ToArray()));
            }

            // Add Procedures.
            if (info.Procedures.Count > 0)
            {
                info.Procedures.Sort();
                lookup.Add("Procedures:", GenerateNamesFromBaseTypeInfo(info.Procedures.ToArray()));
            }

            if (info.SubModules.Count > 0)
            {
                info.SubModules.Sort();
            }

            // Add Components.
            ComponentInfo[] components = SubModule.GetUniqueComponents(info.SubModules, true);
            if (components.Length > 0)
            {
                lookup.Add("Components:", GenerateNamesFromBaseTypeInfo(components));
            }

            // Add Signals.
            if (info.Signals.Count > 0)
            {
                info.Signals.Sort();
                lookup.Add("Signals:", GenerateNamesFromBaseTypeInfo(info.Signals.ToArray()));
            }

            // Add Aliases.
            if (info.Aliases.Count > 0)
            {
                info.Aliases.Sort();
                lookup.Add("Aliases:", GenerateNamesFromBaseTypeInfo(info.Aliases.ToArray()));
            }

            if (info.Attributes.Count > 0)
            {
                info.Attributes.Sort();
            }

            // Add Attributes.
            AttributeDeclarationInfo[] declarations = AttributeDeclarationInfo.GetUniqueAttributeDeclarations(info.Attributes);
            if (declarations.Length > 0)
            {
                lookup.Add("Attributes:", GenerateNamesFromBaseTypeInfo(declarations));
            }

            // Add Processes.
            if (info.Processes.Count > 0)
            {
                info.Processes.Sort();
                lookup.Add("Processes:", GenerateNamesFromBaseTypeInfo(info.Processes.ToArray()));
            }

            // Add Generates.
            if (info.Generates.Count > 0)
            {
                info.Generates.Sort();
                lookup.Add("Generates:", GenerateNamesFromBaseTypeInfo(info.Generates.ToArray()));
            }

            // Add Sub-Modules.
            if (info.SubModules.Count > 0)
            {
                lookup.Add("Sub-Modules:", GenerateNamesFromBaseTypeInfo(info.SubModules.ToArray()));
            }

            return(lookup);
        }