예제 #1
0
        /// <summary>
        /// Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                InitialValue.SemanticAnalysis(instance, Filter.AllMatches);

                AccumulatorVariable.Type = InitialValue.GetExpressionType();
            }

            return(retVal);
        }
        /// <summary>
        /// Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                InitialValue.SemanticAnalysis(instance, Filter.IsRightSide);
                Expression.SemanticAnalysis(instance, Filter.AllMatches);
                Condition.SemanticAnalysis(instance, Filter.AllMatches);

                LastIteration.Type    = InitialValue.GetExpressionType();
                CurrentIteration.Type = InitialValue.GetExpressionType();
            }

            return(retVal);
        }
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                // InitialValue
                if (InitialValue != null)
                {
                    InitialValue.SemanticAnalysis(instance, IsRightSide.INSTANCE);
                    StaticUsage.AddUsages(InitialValue.StaticUsage, Usage.ModeEnum.Read);

                    LastIteration.Type    = InitialValue.GetExpressionType();
                    CurrentIteration.Type = InitialValue.GetExpressionType();
                    StaticUsage.AddUsage(InitialValue.GetExpressionType(), Root, Usage.ModeEnum.Type);
                }
                else
                {
                    AddError("Initial value not provided", RuleChecksEnum.SemanticAnalysisError);
                }

                // Expression
                if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(Expression.StaticUsage, Usage.ModeEnum.Read);
                }
                else
                {
                    Root.AddError("Accumulator expression value not provided");
                }

                // Condition
                if (Condition != null)
                {
                    Condition.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(Condition.StaticUsage, Usage.ModeEnum.Read);
                }
                else
                {
                    Root.AddError("Stop condition not provided");
                }
            }

            return(retVal);
        }
예제 #4
0
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                if (InitialValue != null)
                {
                    InitialValue.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(InitialValue.StaticUsage, Usage.ModeEnum.Read);

                    AccumulatorVariable.Type = InitialValue.GetExpressionType();
                }
                else
                {
                    AddError("Initial value not provided", RuleChecksEnum.SemanticAnalysisError);
                }
            }

            return(retVal);
        }