Example #1
0
        /// <summary>
        /// Emits variable declarations, if any
        /// </summary>
        /// <returns>The variables.</returns>
        /// <param name="variables">Variables.</param>
        /// <param name="indentation">Indentation.</param>
        public IEnumerable <string> DeclareVariables(IEnumerable <Variable> variables, int indentation)
        {
            if (variables != null && variables.Any())
            {
                var indent = new string(' ', indentation);

                foreach (var n in variables)
                {
                    yield return($"{indent}{m_typeScope.GetType(n).Name} {n.Name} = {GetInitializer(n)};");
                }

                yield return("");
            }
        }
Example #2
0
 /// <summary>
 /// Lists all members for a given value type
 /// </summary>
 /// <returns>The member VHDL strings.</returns>
 /// <param name="type">The VHDL type.</param>
 public IEnumerable <string> ListMembers(TypeDefinition type)
 {
     if (type.IsEnum)
     {
         foreach (var e in type.Fields.Where(x => x.Name != "value__"))
         {
             yield return(e.Name);
         }
     }
     else if (type.IsValueType && !type.IsPrimitive)
     {
         foreach (var m in type.Fields)
         {
             if (!m.IsStatic)
             {
                 yield return(string.Format("{0} {1}", TypeScope.GetType(m.FieldType), Naming.ToValidName(m.Name)));
             }
         }
     }
 }