Beispiel #1
0
        /// <summary>
        /// Expand given statements int program point base chain
        /// </summary>
        /// <param name="statements">Statements to expand</param>
        /// <returns>Program points created from statements expanding</returns>
        private List <ProgramPointBase> expandStatements(IEnumerable <LangElement> statements)
        {
            var points = new List <ProgramPointBase>();
            ProgramPointBase lastPoint = null;

            foreach (var statement in statements)
            {
                var expanded = ElementExpander.ExpandStatement(statement, reportCreation);

                if (lastPoint != null)
                {
                    //connect before expanded points
                    lastPoint.AddFlowChild(expanded[0]);
                }

                lastPoint = expanded[expanded.Length - 1];

                points.AddRange(expanded);
            }

            return(points);
        }
Beispiel #2
0
        /// <summary>
        /// Creates points block from given expression
        /// <remarks>It's supposed to be used as parent for assume block</remarks>
        /// </summary>
        /// <param name="expression">Expression which points block will be created</param>
        /// <returns>Created points block</returns>
        internal PointsBlock CreateFromExpression(Expression expression)
        {
            PointsBlock createdBlock;

            if (_creadtedExpressionBlocks.TryGetValue(expression, out createdBlock))
            {
                return(createdBlock);
            }

            var points = ElementExpander.ExpandStatement(expression, reportCreation);

            if (points.Any())
            {
                createdBlock = PointsBlock.ForExpression(points);
                _creadtedExpressionBlocks.Add(expression, createdBlock);

                _createdBlocks.Add(createdBlock);
                return(createdBlock);
            }
            else
            {
                throw new NotSupportedException("Empty expression is not supported");
            }
        }