public override double GetValue(AbstractValue value)
 {
     return((value as RealValue).Value);
 }
 public override PhysicalLiteral GetValue(AbstractValue value)
 {
     return((value as PhysicalValue).Value);
 }
 public override int GetValue(AbstractValue value)
 {
     return((value as IntegerValue).Value);
 }
 public abstract T GetValue(AbstractValue value);
 public override EnumerationLiteral GetValue(AbstractValue value)
 {
     return((value as EnumerationValue).Value);
 }
示例#6
0
        /// <summary>
        /// Создание контейнера по заданному типу
        /// </summary>
        /// <param name="si"></param>
        /// <returns></returns>
        public static AbstractValue CreateValue(ISubtypeIndication si)
        {
            if (si == VHDL.builtin.Standard.TIME)
            {
                return(new TIME_VALUE(0));
            }
            if (si is ResolvedSubtypeIndication)
            {
                AbstractValue res = CreateValue((si as ResolvedSubtypeIndication).BaseType);
                res.Type.Constraints.Add(new ResolvedTypeConstraint(si as ResolvedSubtypeIndication));
                return(res);
            }

            if (si is RangeSubtypeIndication)
            {
                AbstractValue res = CreateValue((si as RangeSubtypeIndication).BaseType);
                res.Type.Constraints.Add(new RangeTypeConstraint(si as RangeSubtypeIndication));
                return(res);
            }

            if (si is IndexSubtypeIndication)
            {
                ArrayValue res = CreateValue((si as IndexSubtypeIndication).BaseType) as ArrayValue;
                res.Type.Constraints.Add(new IndexTypeConstraint(si as IndexSubtypeIndication));
                return(res);
            }

            if (si is Subtype)
            {
                return(CreateValue((si as Subtype).SubtypeIndication));
            }
            if (si is IntegerType)
            {
                return(new IntegerValue(si as IntegerType));
            }
            if (si is RealType)
            {
                return(new RealValue(si as RealType));
            }
            if (si is EnumerationType)
            {
                EnumerationType en = si as EnumerationType;
                switch (en.Identifier.ToLower())
                {
                case "std_logic": return(new STD_LOGIC_VALUE());

                case "std_ulogic": return(new STD_LOGIC_VALUE());

                case "bit": return(new BIT_VALUE());

                case "character": return(new CHARACTER_VALUE());

                default: return(new EnumerationValue(si as EnumerationType));
                }
            }
            if (si is PhysicalType)
            {
                return(new PhysicalValue(si as PhysicalType));
            }
            if (si is UnconstrainedArray)
            {
                throw new Exception("Undefined bounds of array");
            }
            if (si is ConstrainedArray)
            {
                //ArrayValue val = new ArrayValue(si as ConstrainedArray, );
                //return val;
            }
            if (si is RecordType)
            {
                return(new RecordValue(si as RecordType));
            }
            return(null);
        }