Пример #1
0
        /// <summary>
        ///   Writes the process to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the process 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">No code lines were specified.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            if (CodeLines.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a process ({0}), but the processes doesn't have any code associated with it", Name));
            }

            // Write the header.
            WriteBasicHeader(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("{0}:", Name), indentOffset);
            DocumentationHelper.WriteLine(wr, GetSensitivityListLine(), indentOffset);

            // Write the variable declarations out.
            BaseTypeInfo.WriteBaseTypeInfos(null, wr, Variables.ToArray(), indentOffset + 1, Name, "process");

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

            // Write the code lines.
            foreach (string line in CodeLines)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset + 1);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end process");
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }
Пример #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>
        ///   Writes the procedure to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the procedure 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">No code lines were specified or no parameters were specified.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            if (CodeLines.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any code associated with it", Name));
            }
            if (Parameters.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any parameters", Name));
            }

            // Generate the documentation lookup table.
            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>();

            lookup.Add("Summary", new string[] { Summary });

            if (Parameters.Count > 0)
            {
                List <string> subItems = new List <string>(Parameters.Count);
                foreach (ProcedureParameterInfo info in Parameters)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Parameters", subItems.ToArray());
            }

            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            // Write the header.
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, GetSignature(), indentOffset);

            // Write the variable declarations out.
            BaseTypeInfo.WriteBaseTypeInfos(null, wr, Variables.ToArray(), indentOffset + 1, Name, "procedure");

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

            // Write the code lines.
            foreach (string line in CodeLines)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset + 1);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" procedure");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }
Пример #4
0
        /// <summary>
        ///   Writes the process to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the process 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 override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            if (ConcurrentStatements.Count == 0 && Processes.Count == 0 && SubModules.Count == 0 && Generates.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a generate section ({0}), but the section doesn't have anything to write (processes, sub-modules, etc.).", Name));
            }

            // Validate that there are not duplicate names in the children.
            ValidateChildNames();

            // Validate that there is not an infinite loop.
            List <GenerateInfo> parentList = new List <GenerateInfo>();

            parentList.Add(this);
            ValidateChildGenerates(parentList);

            // Write the header.
            WriteBasicHeader(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("{0}:", Name), indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("{0} generate", GenerateStatement), indentOffset);
            indentOffset++;

            // Write the code lines.
            foreach (string line in ConcurrentStatements)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset);
            }

            if (ConcurrentStatements.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Write the processes.
            BaseTypeInfo.WriteBaseTypeInfos("Processes", wr, Processes.ToArray(), indentOffset, Name, "generate");
            if (Processes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Write the generates.
            BaseTypeInfo.WriteBaseTypeInfos("Generates", wr, Generates.ToArray(), indentOffset, Name, "generate");
            if (Generates.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Write the sub-modules.
            BaseTypeInfo.WriteBaseTypeInfos("Sub-Modules", wr, SubModules.ToArray(), indentOffset, Name, "generate");

            indentOffset--;
            StringBuilder sb = new StringBuilder();

            sb.Append("end generate");
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }