public override void visit(Generated.Type obj, bool visitSubNodes)
        {
            Types.Type type = obj as Types.Type;

            if (type != null)
            {
                if (type is Types.StateMachine)
                {
                    // Ignore state machines
                }
                else
                {
                    if (!(type is Types.Structure) && !(type is Functions.Function))
                    {
                        if (Utils.Utils.isEmpty(type.getDefault()))
                        {
                            type.AddError("Types should define their default value");
                        }
                        else
                        {
                            if (type.DefaultValue == null)
                            {
                                type.AddError("Invalid default value");
                            }
                        }
                        if (type is Types.Range)
                        {
                            Types.Range range = type as Types.Range;
                            if (range.getPrecision() == Generated.acceptor.PrecisionEnum.aIntegerPrecision && range.Default.IndexOf('.') > 0 ||
                                range.getPrecision() == Generated.acceptor.PrecisionEnum.aDoublePrecision && range.Default.IndexOf('.') <= 0)
                            {
                                type.AddError("Default value's precision does not correspond to the type's precision");
                            }
                            foreach (Constants.EnumValue specValue in range.SpecialValues)
                            {
                                String value = specValue.getValue();
                                if (range.getPrecision() == Generated.acceptor.PrecisionEnum.aDoublePrecision && value.IndexOf('.') <= 0 ||
                                    range.getPrecision() == Generated.acceptor.PrecisionEnum.aIntegerPrecision && value.IndexOf('.') > 0)
                                {
                                    type.AddError("Precision of the special value + " + specValue.Name + " does not correspond to the type's precision");
                                }
                            }
                        }
                    }

                    if (declaredTypes.ContainsKey(type.FullName))
                    {
                        declaredTypes[type.Name].AddError(TYPE_DECLARED_SEVERAL_TIMES);
                        type.AddError(TYPE_DECLARED_SEVERAL_TIMES);
                    }
                    else
                    {
                        declaredTypes[type.Name] = type;
                    }
                }
            }

            base.visit(obj, visitSubNodes);
        }
Пример #2
0
        /// <summary>
        ///     Indicates that the other type may be placed in this range
        /// </summary>
        /// <param name="otherType"></param>
        /// <returns></returns>
        public override bool Match(Type otherType)
        {
            bool retVal = base.Match(otherType);

            if (!retVal)
            {
                if (otherType is IntegerType && getPrecision() == acceptor.PrecisionEnum.aIntegerPrecision)
                {
                    retVal = true;
                }
                else if (otherType is DoubleType && getPrecision() == acceptor.PrecisionEnum.aDoublePrecision)
                {
                    retVal = true;
                }
                else
                {
                    Range otherRange = otherType as Range;
                    if (otherRange != null && getPrecision() == otherRange.getPrecision())
                    {
                        retVal = true;
                    }
                }
            }

            return(retVal);
        }
Пример #3
0
        /// <summary>
        ///     Indicates that the other type can be placed in variables of this type
        /// </summary>
        /// <param name="otherType"></param>
        /// <returns></returns>
        public override bool Match(Type otherType)
        {
            bool retVal = base.Match(otherType);

            if (!retVal)
            {
                Range range = otherType as Range;
                if (range != null && range.getPrecision() == acceptor.PrecisionEnum.aDoublePrecision)
                {
                    retVal = true;
                }
            }

            return(retVal);
        }
Пример #4
0
        /// <summary>
        ///     Indicates if the type is double
        /// </summary>
        public bool IsDouble()
        {
            bool retVal = false;

            Range range = this as Range;

            if (range != null)
            {
                retVal = range.getPrecision() == acceptor.PrecisionEnum.aDoublePrecision;
            }
            else
            {
                retVal = this == EFSSystem.DoubleType;
            }

            return(retVal);
        }
Пример #5
0
        /// <summary>
        ///     Combines two types to create a new one
        /// </summary>
        /// <param name="right"></param>
        /// <returns></returns>
        public override Type CombineType(Type right, BinaryExpression.Operator Operator)
        {
            Type retVal = null;

            if (Operator == BinaryExpression.Operator.Mult)
            {
                Range range = right as Range;
                if (range != null)
                {
                    if (range.getPrecision() == acceptor.PrecisionEnum.aIntegerPrecision)
                    {
                        retVal = this;
                    }
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Combines two types to create a new one
        /// </summary>
        /// <param name="right"></param>
        /// <returns></returns>
        public override Types.Type CombineType(Type right, DataDictionary.Interpreter.BinaryExpression.OPERATOR Operator)
        {
            Types.Type retVal = null;

            if (Operator == DataDictionary.Interpreter.BinaryExpression.OPERATOR.MULT)
            {
                Range range = right as Range;
                if (range != null)
                {
                    if (range.getPrecision() == Generated.acceptor.PrecisionEnum.aIntegerPrecision)
                    {
                        retVal = this;
                    }
                }
            }

            return(retVal);
        }