public static List <EnumBaseTypeInfo> FormEnumDictionary(VHDL.type.EnumerationType typeDeclaration)
        {
            List <EnumBaseTypeInfo> dict = new List <EnumBaseTypeInfo>();
            int counter = 0;

            foreach (var literal in typeDeclaration.Literals)
            {
                dict.Add(new EnumBaseTypeInfo()
                {
                    Key = counter, FieldName = GetEnumerationLiteralString(literal), Value = GetEnumerationLiteralValue(literal), Literal = literal
                });
                counter++;
            }

            return(dict);
        }
        public static string GenerateEnumerationType(VHDLCompilerInterface compiler, VHDL.type.EnumerationType typeDeclaration)
        {
            string typeName     = typeDeclaration.Identifier;
            string enumTypeName = string.Format("{0}_Enum", typeDeclaration.Identifier);

            List <EnumBaseTypeInfo> parameters = FormEnumDictionary(typeDeclaration);
            EnumTypeTemplate        template   = new EnumTypeTemplate(typeName, parameters);
            string text = template.TransformText();

            foreach (EnumBaseTypeInfo i in parameters)
            {
                compiler.LiteralDictionary.AddItem(i, string.Format("{0}.{1}", enumTypeName, i.FieldName));
            }
            compiler.TypeRangeDictionary.AddItem(typeDeclaration, string.Format("EnumRange<{0}>", enumTypeName), string.Format("{0}.{1}", enumTypeName, parameters[0].FieldName), string.Format("{0}.{1}", enumTypeName, parameters[parameters.Count - 1].FieldName), "RangeDirection.To");

            return(text);
        }
Пример #3
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            compiler.TypeDictionary.AddItem(type, type.Identifier);

            if (BuiltInTypesDictionary.ContainsBuiltInType(type))
            {
                return;
            }

            if (type is VHDL.type.IntegerType)
            {
                VHDL.type.IntegerType intType = type as VHDL.type.IntegerType;
                ObserveIntegerType(compiler, intType);
                return;
            }

            if (type is VHDL.type.RealType)
            {
                VHDL.type.RealType realType = type as VHDL.type.RealType;
                ObserveFloatingPointType(compiler, realType);
                return;
            }

            if (type is VHDL.type.EnumerationType)
            {
                VHDL.type.EnumerationType enumType = type as VHDL.type.EnumerationType;
                ObserveEnumerationType(compiler, enumType);
                return;
            }

            if (type is VHDL.type.PhysicalType)
            {
                VHDL.type.PhysicalType physType = type as VHDL.type.PhysicalType;
                ObserveEnumerationType(compiler, physType);
                return;
            }
        }
Пример #4
0
        public void ObserveEnumerationType(VHDLCompilerInterface compiler, VHDL.type.EnumerationType enumType)
        {
            string code = EnumTypeGeneratorHelper.GenerateEnumerationType(compiler, enumType);

            compiler.SaveCode(code, enumType.Identifier);
        }
Пример #5
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public EnumerationValue(VHDL.type.EnumerationType type)
     : base(type)
 {
     this.Value = type.Literals[0];
 }
Пример #6
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public EnumerationValue(VHDL.type.EnumerationType type, EnumerationLiteral enumerationLiteral)
     : base(type)
 {
     this.Value = enumerationLiteral;
 }
Пример #7
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 protected STD_ULOGIC_VALUE(VHDL.type.EnumerationType type, EnumerationLiteral enumerationLiteral)
     : base(type, enumerationLiteral)
 {
 }