コード例 #1
0
        /// <summary>
        /// Checks the expression and appends errors to the root tree node when inconsistencies are found
        /// </summary>
        /// <param name="context">The interpretation context</param>
        public override void checkExpression()
        {
            base.checkExpression();

            InitialValue.checkExpression();
            Types.Type initialValueType = InitialValue.GetExpressionType();
            if (initialValueType != null)
            {
                Expression.checkExpression();
                Types.Type expressionType = Expression.GetExpressionType();
                if (expressionType != null)
                {
                    if (expressionType != initialValueType)
                    {
                        AddError("Expression " + Expression + " has not the same type (" + expressionType.FullName + " than initial value " + InitialValue + " type " + initialValueType.FullName);
                    }
                }
                else
                {
                    AddError("Cannot determine type of expression " + Expression);
                }

                Types.Type conditionType = Condition.GetExpressionType();
                if (conditionType != null)
                {
                    if (!(conditionType is Types.BoolType))
                    {
                        AddError("Condition " + Condition + " does not evaluate to a boolean");
                    }
                }
                else
                {
                    AddError("Cannot determine type of condition " + Condition);
                }
            }
            else
            {
                AddError("Cannot determine type of the initial value " + InitialValue);
            }
        }