Пример #1
0
        /// <summary>
        /// Creates points block directly from basic block. It is checked that
        /// block is not empty, otherwise contractable block will be created
        /// </summary>
        /// <param name="block">Block witch statements fill created block</param>
        /// <returns>Created points block</returns>
        internal PointsBlock CreateFromBlock(BasicBlock block)
        {
            PointsBlock createdBlock;
            var         points = expandStatements(block.Statements);

            if (points.Count > 0)
            {
                createdBlock = PointsBlock.ForBlock(points, block, false);
            }
            else
            {
                var empty = new EmptyProgramPoint();
                reportCreation(empty);
                createdBlock = PointsBlock.ForBlock(new[] { empty }, block, true);
            }

            _createdBlocks.Add(createdBlock);
            _createdBasicBlocks.Add(block, createdBlock);
            return(createdBlock);
        }
Пример #2
0
        public override void VisitBinaryEx(BinaryEx x)
        {
            var        lOperand = CreateRValue(x.LeftExpr);
            ValuePoint rOperand;

            BinaryExPoint expression;

            switch (x.PublicOperation)
            {
            case Operations.And:
            case Operations.Or:

                /* Points are created in current ordering
                 *    1. blockStart,
                 *    2. shortendPath,
                 *    3. nonShortendPath,
                 *    4. rOperand
                 */

                var shortableForm    = x.PublicOperation == Operations.And ? ConditionForm.None : ConditionForm.All;
                var nonShortableForm = shortableForm == ConditionForm.All ? ConditionForm.None : ConditionForm.All;

                var shortableCondition = new AssumptionCondition(shortableForm, x.LeftExpr);
                //shortened evaluation path
                var shortendPath = new AssumePoint(shortableCondition, new[] { lOperand });

                var nonShortableCondition = new AssumptionCondition(nonShortableForm, x.LeftExpr);
                //normal evaluation
                var nonShortendPath = new AssumePoint(nonShortableCondition, new[] { lOperand });

                //block borders
                var blockStart = new EmptyProgramPoint();
                //1.
                AppendToChain(blockStart);
                //2.
                AppendToChain(shortendPath);
                //3.
                AppendToChain(nonShortendPath);
                //4.
                rOperand = CreateRValue(x.RightExpr);

                expression = new BinaryExPoint(x, lOperand, rOperand);

                //shortend path is added via chain
                blockStart.AddFlowChild(nonShortendPath);

                //set explicit edge
                PreventChainEdge(shortendPath);
                shortendPath.AddFlowChild(expression);



                break;

            default:
                rOperand   = CreateRValue(x.RightExpr);
                expression = new BinaryExPoint(x, lOperand, rOperand);
                break;
            }

            Result(expression);
        }
Пример #3
0
 /// <summary>
 /// Creates points block containing just empty program point and returns this point.
 /// <remarks>Created points block is not contractable</remarks>
 /// </summary>
 /// <param name="createdPoint">Created program point</param>
 /// <param name="outgoingBlocks">Blocks used as outcomming edges</param>
 /// <returns>Created points block</returns>
 internal PointsBlock CreateEmptyBlock(out ProgramPointBase createdPoint, params BasicBlock[] outgoingBlocks)
 {
     createdPoint = new EmptyProgramPoint();
     return(CreateBlockFromProgramPoint(createdPoint, outgoingBlocks));
 }